Skip to content

Commit

Permalink
Merge branch 'main' into switch-jest-to-swc
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Sep 6, 2022
2 parents 384e620 + 4b53203 commit 8977134
Show file tree
Hide file tree
Showing 26 changed files with 2,718 additions and 3,970 deletions.
4 changes: 2 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@
"@types/chai-as-promised": "7.1.5",
"@types/copy-webpack-plugin": "10.1.0",
"@types/fs-extra": "9.0.13",
"@types/jest": "28.1.8",
"@types/jest": "29.0.0",
"@types/js-yaml": "4.0.5",
"@types/lodash.clonedeep": "4.5.7",
"@types/lodash.get": "4.4.7",
Expand Down Expand Up @@ -1649,7 +1649,7 @@
"ts-loader": "9.3.1",
"vsce": "2.10.2",
"vscode-uri": "3.0.3",
"wdio-vscode-service": "4.0.5",
"wdio-vscode-service": "4.0.6",
"webdriverio": "7.23.0",
"webpack": "5.74.0",
"webpack-cli": "4.10.0"
Expand Down
69 changes: 0 additions & 69 deletions extension/src/experiments/decorationProvider.ts

This file was deleted.

4 changes: 2 additions & 2 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ExperimentsData } from './data'
import { askToDisableAutoApplyFilters } from './toast'
import { Experiment, ColumnType, TableData } from './webview/contract'
import { WebviewMessages } from './webview/messages'
import { ExperimentsDecorationProvider } from './decorationProvider'
import { DecorationProvider } from './model/decorationProvider'
import { starredFilter } from './model/filterBy/constants'
import { ResourceLocator } from '../resourceLocator'
import { AvailableCommands, InternalCommands } from '../commands/internal'
Expand Down Expand Up @@ -72,7 +72,7 @@ export class Experiments extends BaseRepository<TableData> {

private readonly columnsChanged = this.dispose.track(new EventEmitter<void>())
private readonly decorationProvider = this.dispose.track(
new ExperimentsDecorationProvider()
new DecorationProvider()
)

private readonly internalCommands: InternalCommands
Expand Down
44 changes: 44 additions & 0 deletions extension/src/experiments/model/decorationProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { EventEmitter, FileDecoration, ThemeColor, Uri } from 'vscode'
import { DecoratableTreeItemScheme, getDecoratableUri } from '../../tree'
import { ErrorDecorationProvider } from '../../tree/errorDecorationProvider'

export class DecorationProvider extends ErrorDecorationProvider {
private static DecorationFiltered: FileDecoration = {
color: new ThemeColor('gitDecoration.ignoredResourceForeground'),
tooltip: 'Filtered'
}

private errors = new Set<string>()
private filtered = new Set<string>()

constructor(decorationsChanged?: EventEmitter<Uri[]>) {
super(DecoratableTreeItemScheme.EXPERIMENTS, decorationsChanged)
}

public provideFileDecoration(uri: Uri): FileDecoration | undefined {
if (this.errors.has(uri.fsPath)) {
return DecorationProvider.DecorationError
}
if (this.filtered.has(uri.fsPath)) {
return DecorationProvider.DecorationFiltered
}
}

public setState(
labels: string[],
filtered: Set<string>,
errors: Set<string>
) {
const urisToUpdate: Uri[] = []

for (const label of labels) {
urisToUpdate.push(
getDecoratableUri(label, DecoratableTreeItemScheme.EXPERIMENTS)
)
}

this.filtered = filtered
this.errors = errors
this.decorationsChanged.fire(urisToUpdate)
}
}
2 changes: 1 addition & 1 deletion extension/src/experiments/model/filterBy/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { InternalCommands } from '../../../commands/internal'
import { sendViewOpenedTelemetryEvent } from '../../../telemetry'
import { EventName } from '../../../telemetry/constants'
import { definedAndNonEmpty, joinTruthyItems } from '../../../util/array'
import { createTreeView, getRootItem } from '../../../vscode/tree'
import { createTreeView, getRootItem } from '../../../tree'
import { Disposable } from '../../../class/dispose'

export type FilterItem = {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/model/sortBy/tree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Event, ThemeIcon, TreeDataProvider, TreeItem } from 'vscode'
import { SortDefinition } from './'
import { WorkspaceExperiments } from '../../workspace'
import { createTreeView, getRootItem } from '../../../vscode/tree'
import { createTreeView, getRootItem } from '../../../tree'
import { RegisteredCommands } from '../../../commands/external'
import { sendViewOpenedTelemetryEvent } from '../../../telemetry'
import { EventName } from '../../../telemetry/constants'
Expand Down
6 changes: 4 additions & 2 deletions extension/src/experiments/model/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
} from 'vscode'
import { ExperimentType } from '.'
import { ExperimentsTree } from './tree'
import { getDecoratableUri } from '../decorationProvider'
import { buildMockedExperiments } from '../../test/util/jest'
import { ResourceLocator } from '../../resourceLocator'
import { RegisteredCommands } from '../../commands/external'
import { getMarkdownString } from '../../vscode/markdownString'
import { DecoratableTreeItemScheme, getDecoratableUri } from '../../tree'

const mockedCommands = jest.mocked(commands)
mockedCommands.registerCommand = jest.fn()
Expand Down Expand Up @@ -392,7 +392,9 @@ describe('ExperimentsTree', () => {
collapsibleState
) {
expect(collapsibleState).toStrictEqual(0)
expect(resourceUri).toStrictEqual(getDecoratableUri('workspace'))
expect(resourceUri).toStrictEqual(
getDecoratableUri('workspace', DecoratableTreeItemScheme.EXPERIMENTS)
)
mockedItem = { collapsibleState, resourceUri }
return mockedItem
})
Expand Down
18 changes: 13 additions & 5 deletions extension/src/experiments/model/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ import {
import { ExperimentType } from '.'
import { collectDeletable, ExperimentItem } from './collect'
import { MAX_SELECTED_EXPERIMENTS } from './status'
import { getDecoratableUri } from '../decorationProvider'
import { WorkspaceExperiments } from '../workspace'
import { sendViewOpenedTelemetryEvent } from '../../telemetry'
import { EventName } from '../../telemetry/constants'
import { definedAndNonEmpty } from '../../util/array'
import { createTreeView, getRootItem } from '../../vscode/tree'
import {
createTreeView,
DecoratableTreeItemScheme,
getDecoratableTreeItem,
getErrorTooltip,
getRootItem
} from '../../tree'
import { IconName, Resource, ResourceLocator } from '../../resourceLocator'
import {
RegisteredCliCommands,
RegisteredCommands
} from '../../commands/external'
import { sum } from '../../util/math'
import { Disposable } from '../../class/dispose'
import { getMarkdownString } from '../../vscode/markdownString'

export class ExperimentsTree
extends Disposable
Expand Down Expand Up @@ -86,7 +90,11 @@ export class ExperimentsTree
type,
tooltip
} = element
const item = new TreeItem(getDecoratableUri(label), collapsibleState)
const item = getDecoratableTreeItem(
label,
DecoratableTreeItemScheme.EXPERIMENTS,
collapsibleState
)
if (iconPath) {
item.iconPath = iconPath
}
Expand Down Expand Up @@ -302,6 +310,6 @@ export class ExperimentsTree
return
}

return getMarkdownString(`$(error) ${error}`)
return getErrorTooltip(error)
}
}
12 changes: 6 additions & 6 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WorkspaceExperiments } from './experiments/workspace'
import { registerExperimentCommands } from './experiments/commands/register'
import { registerPlotsCommands } from './plots/commands/register'
import { findAbsoluteDvcRootPath, findDvcRootPaths } from './fileSystem'
import { TrackedExplorerTree } from './fileSystem/tree'
import { RepositoriesTree } from './repository/model/tree'
import { IExtension } from './interfaces'
import { registerRepositoryCommands } from './repository/commands/register'
import { ResourceLocator } from './resourceLocator'
Expand Down Expand Up @@ -61,7 +61,7 @@ export class Extension extends Disposable implements IExtension {
private readonly repositories: WorkspaceRepositories
private readonly experiments: WorkspaceExperiments
private readonly plots: WorkspacePlots
private readonly trackedExplorerTree: TrackedExplorerTree
private readonly repositoriesTree: RepositoriesTree
private readonly dvcExecutor: DvcExecutor
private readonly dvcReader: DvcReader
private readonly dvcRunner: DvcRunner
Expand Down Expand Up @@ -177,8 +177,8 @@ export class Extension extends Disposable implements IExtension {
)
)

this.trackedExplorerTree = this.dispose.track(
new TrackedExplorerTree(this.internalCommands, this.repositories)
this.repositoriesTree = this.dispose.track(
new RepositoriesTree(this.internalCommands, this.repositories)
)

setup(this)
Expand Down Expand Up @@ -355,7 +355,7 @@ export class Extension extends Disposable implements IExtension {

await Promise.all([
this.repositories.create(this.dvcRoots, this.updatesPaused),
this.trackedExplorerTree.initialize(this.dvcRoots),
this.repositoriesTree.initialize(this.dvcRoots),
this.experiments.create(
this.dvcRoots,
this.updatesPaused,
Expand All @@ -379,7 +379,7 @@ export class Extension extends Disposable implements IExtension {

public resetMembers() {
this.repositories.reset()
this.trackedExplorerTree.initialize([])
this.repositoriesTree.initialize([])
this.experiments.reset()
this.plots.reset()
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/path/selection/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { WorkspaceExperiments } from '../../experiments/workspace'
import { WorkspacePlots } from '../../plots/workspace'
import { Resource, ResourceLocator } from '../../resourceLocator'
import { RegisteredCommands } from '../../commands/external'
import { createTreeView } from '../../vscode/tree'
import { createTreeView } from '../../tree'
import { definedAndNonEmpty } from '../../util/array'
import { sendViewOpenedTelemetryEvent } from '../../telemetry'
import { ViewOpenedEventName } from '../../telemetry/constants'
Expand Down
54 changes: 0 additions & 54 deletions extension/src/repository/errorDecorationProvider.ts

This file was deleted.

6 changes: 3 additions & 3 deletions extension/src/repository/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EventEmitter } from 'vscode'
import { ErrorDecorationProvider } from './errorDecorationProvider'
import { DecorationProvider as ErrorDecorationProvider } from './model/decorationProvider'
import {
ScmDecorationProvider,
DecorationProvider as ScmDecorationProvider,
ScmDecorationState
} from './scmDecorationProvider'
} from './sourceControlManagement/decorationProvider'
import { RepositoryData } from './data'
import { RepositoryModel } from './model'
import { SourceControlManagement, SCMState } from './sourceControlManagement'
Expand Down
2 changes: 1 addition & 1 deletion extension/src/repository/model/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Uri } from 'vscode'
import { Resource } from '../commands'
import { addToMapSet } from '../../util/map'
import { Changes, DataStatusOutput } from '../../cli/dvc/reader'
import { DecorationDataStatus } from '../scmDecorationProvider'
import { DecorationDataStatus } from '../sourceControlManagement/decorationProvider'
import { relativeWithUri } from '../../fileSystem'
import {
getDirectChild,
Expand Down
Loading

0 comments on commit 8977134

Please sign in to comment.