Skip to content

Commit

Permalink
Remove unused parameters in the mutations/mutators tree view interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Jan 16, 2024
1 parent c96338d commit a0cdd58
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 52 deletions.
31 changes: 11 additions & 20 deletions vscode/src/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class MutationsTreeDataProvider implements vscode.TreeDataProvider<Mutati
root.insertNode(new Mutation(m));
}
root.updateDescriptions();
items = await root.children(this.apiClient, this.workspaceState);
items = root.children();
} else {
items = mutations.map((m) => new NamedMutationTreeItemData(new Mutation(m)));
}
Expand All @@ -120,7 +120,7 @@ export class MutationsTreeDataProvider implements vscode.TreeDataProvider<Mutati
this.data = items.sort((a, b) => compare(a.mutatorName, b.mutatorName));
return this.data;
} else {
return await element.children(this.apiClient, this.workspaceState);
return element.children();
}
}

Expand Down Expand Up @@ -213,7 +213,7 @@ abstract class MutationsTreeItemData {

treeItem(workspaceData: MutationsTreeMemento): vscode.TreeItem {
let state = vscode.TreeItemCollapsibleState.Collapsed;
if (!this.canHaveChildren(workspaceData)) {
if (!this.canHaveChildren()) {
state = vscode.TreeItemCollapsibleState.None;
}

Expand All @@ -236,11 +236,11 @@ abstract class MutationsTreeItemData {
return item;
}

canHaveChildren(_workspaceData: MutationsTreeMemento): boolean {
canHaveChildren(): boolean {
return false;
}

async children(_apiClient: api.Client, _workspaceState: MutationsTreeMemento): Promise<MutationsTreeItemData[]> {
children(): MutationsTreeItemData[] {
return [];
}
}
Expand All @@ -254,14 +254,11 @@ export class MutationsGroupByNameTreeItemData extends MutationsTreeItemData {
this.tooltip = new vscode.MarkdownString(tooltip);
}

override canHaveChildren(_workspaceData: MutationsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutationsTreeMemento
): Promise<MutationsTreeItemData[]> {
override children(): MutationsTreeItemData[] {
return this.childItems;
}

Expand Down Expand Up @@ -315,15 +312,12 @@ export class NamedMutationTreeItemData extends MutationsTreeItemData {
super.iconPath = new vscode.ThemeIcon("zap");
}

override canHaveChildren(_workspaceData: MutationsTreeMemento): boolean {
override canHaveChildren(): boolean {
// TODO - always true once created-at/etc is added
return this.mutation.experimentName != null || this.mutation.params.size != 0;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutationsTreeMemento
): Promise<MutationsTreeItemData[]> {
override children(): MutationsTreeItemData[] {
const children = [];
if (this.mutation.experimentName) {
children.push(new MutationDetailLeafTreeItemData(`Experiment: ${this.mutation.experimentName}`));
Expand All @@ -341,14 +335,11 @@ export class MutationParametersTreeItemData extends MutationsTreeItemData {
super("Parameters");
}

override canHaveChildren(_workspaceData: MutationsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutationsTreeMemento
): Promise<MutationsTreeItemData[]> {
override children(): MutationsTreeItemData[] {
const children = [];
for (const [paramName, paramValue] of this.mutation.params) {
children.push(new MutationDetailLeafTreeItemData(`${paramName}: ${paramValue}`));
Expand Down
49 changes: 17 additions & 32 deletions vscode/src/mutators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class MutatorsTreeDataProvider implements vscode.TreeDataProvider<Mutator
}

getTreeItem(element: MutatorsTreeItemData): vscode.TreeItem {
return element.treeItem(this.workspaceState);
return element.treeItem();
}

async getChildren(element?: MutatorsTreeItemData): Promise<MutatorsTreeItemData[]> {
Expand All @@ -99,15 +99,15 @@ export class MutatorsTreeDataProvider implements vscode.TreeDataProvider<Mutator
root.insertNode(new Mutator(m));
}
root.updateDescriptions();
items = await root.children(this.apiClient, this.workspaceState);
items = root.children();
} else {
items = mutators.map((m) => new NamedMutatorTreeItemData(new Mutator(m)));
}
const { compare } = Intl.Collator("en-US");
this.data = items.sort((a, b) => compare(a.name, b.name));
return this.data;
} else {
return await element.children(this.apiClient, this.workspaceState);
return element.children();
}
}

Expand Down Expand Up @@ -181,9 +181,9 @@ abstract class MutatorsTreeItemData {

constructor(public name: string) {}

treeItem(workspaceData: MutatorsTreeMemento): vscode.TreeItem {
treeItem(): vscode.TreeItem {
let state = vscode.TreeItemCollapsibleState.Collapsed;
if (!this.canHaveChildren(workspaceData)) {
if (!this.canHaveChildren()) {
state = vscode.TreeItemCollapsibleState.None;
}

Expand All @@ -206,11 +206,11 @@ abstract class MutatorsTreeItemData {
return item;
}

canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
canHaveChildren(): boolean {
return false;
}

async children(_apiClient: api.Client, _workspaceState: MutatorsTreeMemento): Promise<MutatorsTreeItemData[]> {
children(): MutatorsTreeItemData[] {
return [];
}
}
Expand All @@ -224,14 +224,11 @@ export class MutatorsGroupByNameTreeItemData extends MutatorsTreeItemData {
this.tooltip = new vscode.MarkdownString(tooltip);
}

override canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutatorsTreeMemento
): Promise<MutatorsTreeItemData[]> {
override children(): MutatorsTreeItemData[] {
return this.childItems;
}

Expand Down Expand Up @@ -275,14 +272,11 @@ export class NamedMutatorTreeItemData extends MutatorsTreeItemData {
this.iconPath = new vscode.ThemeIcon("outline-view-icon");
}

override canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutatorsTreeMemento
): Promise<MutatorsTreeItemData[]> {
override children(): MutatorsTreeItemData[] {
const children = [];
if (this.mutator.description) {
children.push(new MutatorDetailLeafTreeItemData(`${this.mutator.description}`));
Expand Down Expand Up @@ -314,14 +308,11 @@ export class MutatorOrgMetadataTreeItemData extends MutatorsTreeItemData {
super.iconPath = new vscode.ThemeIcon("organization");
}

override canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutatorsTreeMemento
): Promise<MutatorsTreeItemData[]> {
override children(): MutatorsTreeItemData[] {
const children = [];
for (const [k, v] of this.orgMetadataAttrs) {
children.push(new MutatorDetailLeafTreeItemData(`${k}: ${v}`));
Expand All @@ -337,14 +328,11 @@ export class MutatorParametersTreeItemData extends MutatorsTreeItemData {
super.iconPath = new vscode.ThemeIcon("output");
}

override canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutatorsTreeMemento
): Promise<MutatorsTreeItemData[]> {
override children(): MutatorsTreeItemData[] {
const children = [];
for (const p of this.params) {
children.push(new MutatorParameterTreeItemData(p));
Expand All @@ -359,14 +347,11 @@ export class MutatorParameterTreeItemData extends MutatorsTreeItemData {
super(param.name);
}

override canHaveChildren(_workspaceData: MutatorsTreeMemento): boolean {
override canHaveChildren(): boolean {
return true;
}

override async children(
_apiClient: api.Client,
_workspaceState: MutatorsTreeMemento
): Promise<MutatorsTreeItemData[]> {
override children(): MutatorsTreeItemData[] {
const children = [];
if (this.param.description) {
children.push(new MutatorDetailLeafTreeItemData(`${this.param.description}`));
Expand Down

0 comments on commit a0cdd58

Please sign in to comment.