diff --git a/extension/src/experiments/model/filterBy/tree.ts b/extension/src/experiments/model/filterBy/tree.ts index 8f17fd712b..68e521070a 100644 --- a/extension/src/experiments/model/filterBy/tree.ts +++ b/extension/src/experiments/model/filterBy/tree.ts @@ -6,12 +6,12 @@ import { TreeDataProvider, TreeItem, TreeItemCollapsibleState, - Uri, - window + Uri } from 'vscode' import { getFilterId } from '.' import { Experiments } from '../..' import { definedAndNonEmpty, flatten } from '../../../util/array' +import { createTreeView } from '../../../vscode/tree' type FilterItem = { description: string @@ -33,14 +33,7 @@ export class ExperimentsFilterByTree this.onDidChangeTreeData = experiments.experimentsChanged.event this.dispose.track( - window.createTreeView( - 'dvc.views.experimentsFilterByTree', - { - canSelectMany: true, - showCollapseAll: true, - treeDataProvider: this - } - ) + createTreeView('dvc.views.experimentsFilterByTree', this) ) this.experiments = experiments diff --git a/extension/src/experiments/paramsAndMetrics/tree.ts b/extension/src/experiments/paramsAndMetrics/tree.ts index 4e45ea4060..46fd42bee5 100644 --- a/extension/src/experiments/paramsAndMetrics/tree.ts +++ b/extension/src/experiments/paramsAndMetrics/tree.ts @@ -7,13 +7,13 @@ import { TreeItem, TreeItemCollapsibleState, TreeView, - Uri, - window + Uri } from 'vscode' import { Status } from './model' import { Experiments } from '..' import { Resource, ResourceLocator } from '../../resourceLocator' import { definedAndNonEmpty, flatten } from '../../util/array' +import { createTreeView } from '../../vscode/tree' type ParamsAndMetricsItem = { description: string | undefined @@ -41,13 +41,9 @@ export class ExperimentsParamsAndMetricsTree this.onDidChangeTreeData = experiments.paramsOrMetricsChanged.event this.view = this.dispose.track( - window.createTreeView( + createTreeView( 'dvc.views.experimentsParamsAndMetricsTree', - { - canSelectMany: true, - showCollapseAll: true, - treeDataProvider: this - } + this ) ) diff --git a/extension/src/vscode/tree.ts b/extension/src/vscode/tree.ts new file mode 100644 index 0000000000..ac2c056a34 --- /dev/null +++ b/extension/src/vscode/tree.ts @@ -0,0 +1,11 @@ +import { TreeDataProvider, TreeView, window } from 'vscode' + +export const createTreeView = ( + name: string, + treeDataProvider: TreeDataProvider +): TreeView => + window.createTreeView(name, { + canSelectMany: true, + showCollapseAll: true, + treeDataProvider + })