Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
"category": "DVC",
"icon": "$(star-full)"
},
{
"title": "%command.addStarredExperimentsTableSort%",
"command": "dvc.addStarredExperimentsTableSort",
"category": "DVC",
"icon": "$(star-full)"
},
{
"title": "%command.addTarget%",
"command": "dvc.addTarget",
Expand Down Expand Up @@ -557,6 +563,10 @@
"command": "dvc.addStarredExperimentsTableFilter",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.addStarredExperimentsTableSort",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.addTarget",
"when": "false"
Expand Down Expand Up @@ -1009,6 +1019,11 @@
"group": "inline",
"when": "view == dvc.views.experimentsSortByTree && dvc.commands.available && viewItem == dvcRoot"
},
{
"command": "dvc.addStarredExperimentsTableSort",
"group": "inline",
"when": "view == dvc.views.experimentsSortByTree && dvc.commands.available && viewItem == dvcRoot"
},
{
"command": "dvc.views.experimentsSortByTree.removeSort",
"group": "inline",
Expand Down Expand Up @@ -1226,10 +1241,15 @@
"when": "view == dvc.views.experimentsSortByTree",
"group": "navigation@1"
},
{
"command": "dvc.addStarredExperimentsTableSort",
"when": "view == dvc.views.experimentsSortByTree",
"group": "navigation@2"
},
{
"command": "dvc.views.experimentsSortByTree.removeAllSorts",
"when": "view == dvc.views.experimentsSortByTree && dvc.experiments.sorted",
"group": "navigation@2"
"group": "navigation@3"
},
{
"command": "dvc.addExperimentsTableFilter",
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"command.addExperimentsTableFilter": "Add Filter To Experiments Table",
"command.addExperimentsTableSort": "Add Or Update Sort On Experiments Table",
"command.addStarredExperimentsTableFilter": "Filter Experiments Table to Starred",
"command.addStarredExperimentsTableSort": "Sort Experiments Table by Starred",
"command.addTarget": "Add Target",
"command.applyExperiment": "Apply Experiment To Workspace",
"command.branchExperiment": "Create New Branch From Experiment",
Expand Down
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export enum RegisteredCommands {
EXPERIMENT_SELECT = 'dvc.views.experimentsTree.selectExperiments',
EXPERIMENT_SHOW = 'dvc.showExperiments',
EXPERIMENT_SORT_ADD = 'dvc.addExperimentsTableSort',
EXPERIMENT_SORT_ADD_STARRED = 'dvc.addStarredExperimentsTableSort',
EXPERIMENT_SORT_REMOVE = 'dvc.views.experimentsSortByTree.removeSort',
EXPERIMENT_SORTS_REMOVE = 'dvc.removeExperimentsTableSorts',
EXPERIMENT_SORTS_REMOVE_ALL = 'dvc.views.experimentsSortByTree.removeAllSorts',
Expand Down
5 changes: 5 additions & 0 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ const registerExperimentQuickPickCommands = (
(dvcRoot?: string) => experiments.addSort(dvcRoot)
)

internalCommands.registerExternalCommand(
RegisteredCommands.EXPERIMENT_SORT_ADD_STARRED,
(dvcRoot?: string) => experiments.addStarredSort(dvcRoot)
)

internalCommands.registerExternalCommand(
RegisteredCommands.EXPERIMENT_SORTS_REMOVE,
() => experiments.removeSorts()
Expand Down
6 changes: 6 additions & 0 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
pickFiltersToRemove
} from './model/filterBy/quickPick'
import { tooManySelected } from './model/status'
import { starredSort } from './model/sortBy/constants'
import { pickSortsToRemove, pickSortToAdd } from './model/sortBy/quickPick'
import { ColumnsModel } from './columns/model'
import { CheckpointsModel } from './checkpoints/model'
Expand Down Expand Up @@ -202,6 +203,11 @@ export class Experiments extends BaseRepository<TableData> {
return this.notifyChanged()
}

public addStarredSort() {
this.experiments.addSort(starredSort)
return this.notifyChanged()
}

public removeSort(pathToRemove: string) {
this.experiments.removeSort(pathToRemove)
return this.notifyChanged()
Expand Down
1 change: 1 addition & 0 deletions extension/src/experiments/model/sortBy/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const starredSort = { descending: true, path: 'starred' }
8 changes: 8 additions & 0 deletions extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
return this.getRepository(dvcRoot).addSort()
}

public async addStarredSort(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).addStarredSort()
}

public async removeSorts() {
const dvcRoot = await this.getFocusedOrOnlyOrPickProject()
if (!dvcRoot) {
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_SELECT]: undefined
[EventName.EXPERIMENT_SHOW]: undefined
[EventName.EXPERIMENT_SORT_ADD]: undefined
[EventName.EXPERIMENT_SORT_ADD_STARRED]: undefined
[EventName.EXPERIMENT_SORT_REMOVE]: undefined
[EventName.EXPERIMENT_SORTS_REMOVE]: undefined
[EventName.EXPERIMENT_SORTS_REMOVE_ALL]: undefined
Expand Down
22 changes: 22 additions & 0 deletions extension/src/test/suite/experiments/model/sortBy/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { buildMetricOrParamPath } from '../../../../../experiments/columns/paths
import { RegisteredCommands } from '../../../../../commands/external'
import { ExperimentsOutput } from '../../../../../cli/reader'
import { WEBVIEW_TEST_TIMEOUT } from '../../../timeouts'
import { starredSort } from '../../../../../experiments/model/sortBy/constants'

suite('Experiments Sort By Tree Test Suite', () => {
const testData = {
Expand Down Expand Up @@ -287,5 +288,26 @@ suite('Experiments Sort By Tree Test Suite', () => {
'should not call get repository in removeSorts without a root'
).not.to.be.called
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should provide a shortcut to sort by starred experiments', async () => {
const { experiments, experimentsModel } = buildExperiments(disposable)

await experiments.isReady()

stub(WorkspaceExperiments.prototype, 'getRepository').returns(experiments)
stub(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(WorkspaceExperiments as any).prototype,
'getFocusedOrOnlyOrPickProject'
).returns(dvcDemoPath)

const mockAddSort = stub(experimentsModel, 'addSort')

await commands.executeCommand(
RegisteredCommands.EXPERIMENT_SORT_ADD_STARRED
)

expect(mockAddSort).to.be.calledWith(starredSort)
})
})
})