diff --git a/extension/package.json b/extension/package.json index 0322bf105c..d4a13831a5 100644 --- a/extension/package.json +++ b/extension/package.json @@ -577,7 +577,7 @@ }, { "title": "Refresh Plots for Selected Experiments", - "command": "dvc.views.plotsPathsTree.refreshPlots", + "command": "dvc.views.plots.refreshPlots", "category": "DVC", "icon": "$(refresh)" }, @@ -989,7 +989,7 @@ "when": "dvc.commands.available && dvc.project.available" }, { - "command": "dvc.views.plotsPathsTree.refreshPlots", + "command": "dvc.views.plots.refreshPlots", "when": "dvc.commands.available && dvc.project.available" }, { @@ -1383,7 +1383,7 @@ "group": "navigation@2" }, { - "command": "dvc.views.plotsPathsTree.refreshPlots", + "command": "dvc.views.plots.refreshPlots", "when": "view == dvc.views.plotsPathsTree", "group": "navigation@3" } diff --git a/extension/src/commands/external.ts b/extension/src/commands/external.ts index d95170eb6c..f501d0a413 100644 --- a/extension/src/commands/external.ts +++ b/extension/src/commands/external.ts @@ -72,7 +72,7 @@ export enum RegisteredCommands { PLOTS_PATH_TOGGLE = 'dvc.views.plotsPathsTree.toggleStatus', PLOTS_SHOW = 'dvc.showPlots', PLOTS_SELECT = 'dvc.views.plotsPathsTree.selectPlots', - PLOTS_REFRESH = 'dvc.views.plotsPathsTree.refreshPlots', + PLOTS_REFRESH = 'dvc.views.plots.refreshPlots', PLOTS_CUSTOM_ADD = 'dvc.views.plots.addCustomPlot', PLOTS_CUSTOM_REMOVE = 'dvc.views.plots.removeCustomPlots', diff --git a/extension/src/plots/index.ts b/extension/src/plots/index.ts index acc0531287..c09ac53bb2 100644 --- a/extension/src/plots/index.ts +++ b/extension/src/plots/index.ts @@ -198,13 +198,13 @@ export class Plots extends BaseRepository { experiments: Experiments ) { const webviewMessages = new WebviewMessages( + this.dvcRoot, paths, plots, errors, experiments, () => this.getWebview(), - () => this.selectPlots(), - () => this.data.update() + () => this.selectPlots() ) this.dispose.track( this.onDidReceivedWebviewMessage(message => diff --git a/extension/src/plots/webview/messages.ts b/extension/src/plots/webview/messages.ts index 06b08c9e20..d6c1a2b5c8 100644 --- a/extension/src/plots/webview/messages.ts +++ b/extension/src/plots/webview/messages.ts @@ -13,7 +13,6 @@ import { Logger } from '../../common/logger' import { Experiments } from '../../experiments' import { sendTelemetryEvent } from '../../telemetry' import { EventName } from '../../telemetry/constants' -import { Toast } from '../../vscode/toast' import { MessageFromWebview, MessageFromWebviewType, @@ -30,6 +29,7 @@ import { RegisteredCommands } from '../../commands/external' import { ErrorsModel } from '../errors/model' export class WebviewMessages { + private readonly dvcRoot: string private readonly paths: PathsModel private readonly plots: PlotsModel private readonly errors: ErrorsModel @@ -37,24 +37,23 @@ export class WebviewMessages { private readonly getWebview: () => BaseWebview | undefined private readonly selectPlots: () => Promise - private readonly updateData: () => Promise constructor( + dvcRoot: string, paths: PathsModel, plots: PlotsModel, errors: ErrorsModel, experiments: Experiments, getWebview: () => BaseWebview | undefined, - selectPlots: () => Promise, - updateData: () => Promise + selectPlots: () => Promise ) { + this.dvcRoot = dvcRoot this.paths = paths this.plots = plots this.errors = errors this.experiments = experiments this.getWebview = getWebview this.selectPlots = selectPlots - this.updateData = updateData } public async sendWebviewMessage() { @@ -79,7 +78,10 @@ export class WebviewMessages { public handleMessageFromWebview(message: MessageFromWebview) { switch (message.type) { case MessageFromWebviewType.ADD_CUSTOM_PLOT: - return commands.executeCommand(RegisteredCommands.PLOTS_CUSTOM_ADD) + return commands.executeCommand( + RegisteredCommands.PLOTS_CUSTOM_ADD, + this.dvcRoot + ) case MessageFromWebviewType.RESIZE_PLOTS: return this.setPlotSize( message.payload.section, @@ -101,9 +103,15 @@ export class WebviewMessages { case MessageFromWebviewType.SELECT_EXPERIMENTS: return this.selectExperimentsFromWebview() case MessageFromWebviewType.REMOVE_CUSTOM_PLOTS: - return commands.executeCommand(RegisteredCommands.PLOTS_CUSTOM_REMOVE) + return commands.executeCommand( + RegisteredCommands.PLOTS_CUSTOM_REMOVE, + this.dvcRoot + ) case MessageFromWebviewType.REFRESH_REVISIONS: - return this.refreshData() + return commands.executeCommand( + RegisteredCommands.PLOTS_REFRESH, + this.dvcRoot + ) case MessageFromWebviewType.TOGGLE_EXPERIMENT: return this.setExperimentStatus(message.payload) case MessageFromWebviewType.ZOOM_PLOT: @@ -237,16 +245,6 @@ export class WebviewMessages { ) } - private refreshData() { - void Toast.infoWithOptions('Attempting to refresh visible plots data.') - void this.updateData() - sendTelemetryEvent( - EventName.VIEWS_PLOTS_MANUAL_REFRESH, - undefined, - undefined - ) - } - private sendSectionCollapsed() { void this.getWebview()?.show({ sectionCollapsed: this.plots.getSectionCollapsed() diff --git a/extension/src/telemetry/constants.ts b/extension/src/telemetry/constants.ts index 063c207c0f..099ffbefe3 100644 --- a/extension/src/telemetry/constants.ts +++ b/extension/src/telemetry/constants.ts @@ -71,7 +71,6 @@ export const EventName = Object.assign( VIEWS_PLOTS_CREATED: 'views.plots.created', VIEWS_PLOTS_EXPERIMENT_TOGGLE: 'views.plots.toggleExperimentStatus', VIEWS_PLOTS_FOCUS_CHANGED: 'views.plots.focusChanged', - VIEWS_PLOTS_MANUAL_REFRESH: 'views.plots.manualRefresh', VIEWS_PLOTS_REVISIONS_REORDERED: 'views.plots.revisionsReordered', VIEWS_PLOTS_SECTION_RESIZED: 'views.plots.sectionResized', VIEWS_PLOTS_SECTION_TOGGLE: 'views.plots.toggleSection', @@ -252,7 +251,6 @@ export interface IEventNamePropertyMapping { [EventName.VIEWS_PLOTS_CLOSED]: undefined [EventName.VIEWS_PLOTS_CREATED]: undefined [EventName.VIEWS_PLOTS_FOCUS_CHANGED]: WebviewFocusChangedProperties - [EventName.VIEWS_PLOTS_MANUAL_REFRESH]: undefined [EventName.VIEWS_PLOTS_REVISIONS_REORDERED]: undefined [EventName.VIEWS_PLOTS_COMPARISON_ROWS_REORDERED]: undefined [EventName.VIEWS_PLOTS_SECTION_RESIZED]: { diff --git a/extension/src/test/suite/plots/index.test.ts b/extension/src/test/suite/plots/index.test.ts index 8550536834..f2c18a0f26 100644 --- a/extension/src/test/suite/plots/index.test.ts +++ b/extension/src/test/suite/plots/index.test.ts @@ -568,6 +568,7 @@ suite('Plots Test Suite', () => { const webview = await plots.showWebview() mockPlotsDiff.resetHistory() const instanceMessageSpy = spy(webview, 'show') + await webview.isReady() const mockSendTelemetryEvent = stub(Telemetry, 'sendTelemetryEvent') const mockMessageReceived = getMessageReceivedEmitter(webview) @@ -583,11 +584,7 @@ suite('Plots Test Suite', () => { await dataUpdateEvent expect(mockSendTelemetryEvent).to.be.calledOnce - expect(mockSendTelemetryEvent).to.be.calledWithExactly( - EventName.VIEWS_PLOTS_MANUAL_REFRESH, - undefined, - undefined - ) + expect(mockSendTelemetryEvent).to.be.calledWith(EventName.PLOTS_REFRESH) expect(mockPlotsDiff).to.be.called expect(mockPlotsDiff).to.be.calledWithExactly( dvcDemoPath, @@ -841,7 +838,8 @@ suite('Plots Test Suite', () => { }) expect(executeCommandSpy).to.be.calledWithExactly( - RegisteredCommands.PLOTS_CUSTOM_ADD + RegisteredCommands.PLOTS_CUSTOM_ADD, + dvcDemoPath ) }) @@ -857,7 +855,8 @@ suite('Plots Test Suite', () => { }) expect(executeCommandSpy).to.be.calledWithExactly( - RegisteredCommands.PLOTS_CUSTOM_REMOVE + RegisteredCommands.PLOTS_CUSTOM_REMOVE, + dvcDemoPath ) }) diff --git a/extension/src/test/suite/plots/paths/tree.test.ts b/extension/src/test/suite/plots/paths/tree.test.ts index f9cc61d0be..b42606e70d 100644 --- a/extension/src/test/suite/plots/paths/tree.test.ts +++ b/extension/src/test/suite/plots/paths/tree.test.ts @@ -130,7 +130,7 @@ suite('Plots Paths Tree Test Suite', () => { }) }).timeout(WEBVIEW_TEST_TIMEOUT) - it('should be able to refresh revision data for all plots using dvc.views.plotsPathsTree.refreshPlots', async () => { + it('should be able to refresh revision data for all plots using dvc.views.plots.refreshPlots', async () => { const { data, mockPlotsDiff, plots } = await buildPlots( disposable, plotsDiffFixture