Untitled diff

Created Diff never expires
9 removals
45 lines
9 additions
46 lines
import { inject as service } from "@ember-decorators/service";
import { inject as service } from "@ember-decorators/service";
import Component from '@ember/component';
import Component from '@glimmer/component';
import { action, wrapComputed, computed } from "@ember/object";
import { action, computed } from "@ember/object";
import { isEmpty } from '@ember/utils';
import { isEmpty } from '@ember/utils';
import { task } from 'ember-concurrency';
import { task } from 'ember-concurrency';
import { filterByFilePath } from '../utils';
import { filterByFilePath } from '../utils';


export default class AddonSourceUsagesComponent extends Component {
export default class AddonSourceUsagesComponent extends Component {
@tracked visibleUsageCount = 25;
@tracked visibleUsageCount = 25;
@tracked showUsages = false;
@tracked showUsages = false;
@tracked usages = null;
@tracked usages = null;


regex = false;
fileFilter = null;

@service codeSearch;
@service codeSearch;


get visibleUsages() {
get visibleUsages() {
return this.usages.slice(0, this.visibleUsageCount);
return this.usages.slice(0, this.visibleUsageCount);
}
}


get moreUsages() {
get moreUsages() {
return this.visibleUsageCount < this.usages.length;
return this.visibleUsageCount < this.usages.length;
}
}


@(task(function* () {
@(task(function* () {
let usages = yield this.codeSearch.usages.perform(this.addon.id, this.query, this.regex);
let usages = yield this.codeSearch.usages.perform(
this.usages = filterByFilePath(usages, this.fileFilter);
this.args.addon.id,
this.args.query,
this.args.regex
);
this.usages = filterByFilePath(usages, this.args.fileFilter);
}).drop())
}).drop())
fetchUsages;
fetchUsages;


@action
@action
toggleUsages() {
toggleUsages() {
this.showUsages = !this.showUsages;
this.showUsages = !this.showUsages;


if (this.showUsages && this.usages === null) {
if (this.showUsages && this.usages === null) {
this.fetchUsages.perform();
this.fetchUsages.perform();
}
}
}
}


@action
@action
viewMore() {
viewMore() {
this.visibleUsageCount += 25;
this.visibleUsageCount += 25;
}
}
}
}