Skip to content

Commit

Permalink
add create tree view wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Aug 3, 2021
1 parent acffc32 commit 1376336
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
13 changes: 3 additions & 10 deletions extension/src/experiments/model/filterBy/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,14 +33,7 @@ export class ExperimentsFilterByTree
this.onDidChangeTreeData = experiments.experimentsChanged.event

this.dispose.track(
window.createTreeView<string | FilterItem>(
'dvc.views.experimentsFilterByTree',
{
canSelectMany: true,
showCollapseAll: true,
treeDataProvider: this
}
)
createTreeView<FilterItem>('dvc.views.experimentsFilterByTree', this)
)

this.experiments = experiments
Expand Down
12 changes: 4 additions & 8 deletions extension/src/experiments/paramsAndMetrics/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,13 +41,9 @@ export class ExperimentsParamsAndMetricsTree
this.onDidChangeTreeData = experiments.paramsOrMetricsChanged.event

this.view = this.dispose.track(
window.createTreeView<string | ParamsAndMetricsItem>(
createTreeView<ParamsAndMetricsItem>(
'dvc.views.experimentsParamsAndMetricsTree',
{
canSelectMany: true,
showCollapseAll: true,
treeDataProvider: this
}
this
)
)

Expand Down
11 changes: 11 additions & 0 deletions extension/src/vscode/tree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TreeDataProvider, TreeView, window } from 'vscode'

export const createTreeView = <T>(
name: string,
treeDataProvider: TreeDataProvider<string | T>
): TreeView<string | T> =>
window.createTreeView<string | T>(name, {
canSelectMany: true,
showCollapseAll: true,
treeDataProvider
})

0 comments on commit 1376336

Please sign in to comment.