From 5771786b14be30ceb05aa506c1c6fc8a7a341451 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 21 Sep 2023 08:10:49 -0500 Subject: [PATCH] Remove `addCustomPlot` util from plots webview --- extension/src/plots/index.ts | 3 +-- extension/src/plots/webview/messages.ts | 12 +---------- extension/src/telemetry/constants.ts | 2 -- extension/src/test/suite/plots/index.test.ts | 21 ------------------- extension/src/webview/contract.ts | 4 ---- webview/src/plots/components/App.test.tsx | 4 ++-- .../components/customPlots/NoPlotsAdded.tsx | 4 ++-- .../components/emptyState/ErrorState.tsx | 8 ++----- webview/src/plots/util/messages.ts | 5 ----- 9 files changed, 8 insertions(+), 55 deletions(-) diff --git a/extension/src/plots/index.ts b/extension/src/plots/index.ts index ae7ac0ddc7..41c31ff5a6 100644 --- a/extension/src/plots/index.ts +++ b/extension/src/plots/index.ts @@ -223,8 +223,7 @@ export class Plots extends BaseRepository { errors, experiments, () => this.getWebview(), - () => this.selectPlots(), - () => this.addCustomPlot() + () => 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 dddc510cc2..30c729e322 100644 --- a/extension/src/plots/webview/messages.ts +++ b/extension/src/plots/webview/messages.ts @@ -41,7 +41,6 @@ export class WebviewMessages { private readonly getWebview: () => BaseWebview | undefined private readonly selectPlots: () => Promise - private readonly addCustomPlot: () => Promise constructor( dvcRoot: string, @@ -50,8 +49,7 @@ export class WebviewMessages { errors: ErrorsModel, experiments: Experiments, getWebview: () => BaseWebview | undefined, - selectPlots: () => Promise, - addCustomPlot: () => Promise + selectPlots: () => Promise ) { this.dvcRoot = dvcRoot this.paths = paths @@ -60,7 +58,6 @@ export class WebviewMessages { this.experiments = experiments this.getWebview = getWebview this.selectPlots = selectPlots - this.addCustomPlot = addCustomPlot } public async sendWebviewMessage() { @@ -79,8 +76,6 @@ export class WebviewMessages { RegisteredCommands.ADD_PLOT, this.dvcRoot ) - case MessageFromWebviewType.ADD_CUSTOM_PLOT: - return this.addCustomPlotFromWebview() case MessageFromWebviewType.EXPORT_PLOT_DATA_AS_CSV: return this.exportPlotDataAsCsv(message.payload) case MessageFromWebviewType.EXPORT_PLOT_DATA_AS_TSV: @@ -309,11 +304,6 @@ export class WebviewMessages { ) } - private addCustomPlotFromWebview() { - void this.addCustomPlot() - sendTelemetryEvent(EventName.VIEWS_PLOTS_CUSTOM_ADD, undefined, undefined) - } - private setExperimentStatus(id: string) { this.experiments.toggleExperimentStatus(id) sendTelemetryEvent( diff --git a/extension/src/telemetry/constants.ts b/extension/src/telemetry/constants.ts index ff5bcff127..4410753285 100644 --- a/extension/src/telemetry/constants.ts +++ b/extension/src/telemetry/constants.ts @@ -86,7 +86,6 @@ export const EventName = Object.assign( VIEWS_PLOTS_COMPARISON_ROWS_REORDERED: 'views.plots.comparisonRowsReordered', VIEWS_PLOTS_CREATED: 'views.plots.created', - VIEWS_PLOTS_CUSTOM_ADD: 'views.plots.addCustomPlot', VIEWS_PLOTS_EXPERIMENT_TOGGLE: 'views.plots.toggleExperimentStatus', VIEWS_PLOTS_EXPORT_PLOT_DATA_AS_CSV: 'views.plots.exportPlotDataAsCsv', VIEWS_PLOTS_EXPORT_PLOT_DATA_AS_JSON: 'views.plots.exportPlotDataAsJson', @@ -288,7 +287,6 @@ export interface IEventNamePropertyMapping { [EventName.VIEWS_PLOTS_CLOSED]: undefined [EventName.VIEWS_PLOTS_CREATED]: undefined - [EventName.VIEWS_PLOTS_CUSTOM_ADD]: undefined [EventName.VIEWS_PLOTS_FOCUS_CHANGED]: WebviewFocusChangedProperties [EventName.VIEWS_PLOTS_REVISIONS_REORDERED]: undefined [EventName.VIEWS_PLOTS_COMPARISON_ROWS_REORDERED]: undefined diff --git a/extension/src/test/suite/plots/index.test.ts b/extension/src/test/suite/plots/index.test.ts index a8e8f11fdf..ac04903455 100644 --- a/extension/src/test/suite/plots/index.test.ts +++ b/extension/src/test/suite/plots/index.test.ts @@ -1106,27 +1106,6 @@ suite('Plots Test Suite', () => { ) }).timeout(WEBVIEW_TEST_TIMEOUT) - it('should handle an add custom plot message from the webview', async () => { - const { mockMessageReceived, plots } = await buildPlotsWebview({ - disposer: disposable, - plotsDiff: plotsDiffFixture - }) - - const mockAddCustomPlot = stub(plots, 'addCustomPlot') - const mockSendTelemetryEvent = stub(Telemetry, 'sendTelemetryEvent') - - mockMessageReceived.fire({ - type: MessageFromWebviewType.ADD_CUSTOM_PLOT - }) - - expect(mockAddCustomPlot).to.be.calledOnce - expect(mockSendTelemetryEvent).to.be.calledWithExactly( - EventName.VIEWS_PLOTS_CUSTOM_ADD, - undefined, - undefined - ) - }) - it('should handle a remove custom plot message from the webview', async () => { const { mockMessageReceived } = await buildPlotsWebview({ disposer: disposable, diff --git a/extension/src/webview/contract.ts b/extension/src/webview/contract.ts index 5138717d3b..1a1510b6cc 100644 --- a/extension/src/webview/contract.ts +++ b/extension/src/webview/contract.ts @@ -17,7 +17,6 @@ export enum MessageFromWebviewType { APPLY_EXPERIMENT_TO_WORKSPACE = 'apply-experiment-to-workspace', ADD_STARRED_EXPERIMENT_FILTER = 'add-starred-experiment-filter', ADD_PLOT = 'add-plot', - ADD_CUSTOM_PLOT = 'add-custom-plot', CREATE_BRANCH_FROM_EXPERIMENT = 'create-branch-from-experiment', COPY_TO_CLIPBOARD = 'copy-to-clipboard', COPY_STUDIO_LINK = 'copy-studio-link', @@ -108,9 +107,6 @@ export type PlotsTemplatesReordered = { }[] export type MessageFromWebview = - | { - type: MessageFromWebviewType.ADD_CUSTOM_PLOT - } | { type: MessageFromWebviewType.ADD_PLOT } diff --git a/webview/src/plots/components/App.test.tsx b/webview/src/plots/components/App.test.tsx index f7fb9e4c21..39795f19e7 100644 --- a/webview/src/plots/components/App.test.tsx +++ b/webview/src/plots/components/App.test.tsx @@ -415,7 +415,7 @@ describe('App', () => { fireEvent.click(addCustomPlotsButton) expect(mockPostMessage).toHaveBeenCalledWith({ - type: MessageFromWebviewType.ADD_CUSTOM_PLOT + type: MessageFromWebviewType.ADD_PLOT }) mockPostMessage.mockReset() @@ -560,7 +560,7 @@ describe('App', () => { fireEvent.click(addPlotButton) expect(mockPostMessage).toHaveBeenCalledWith({ - type: MessageFromWebviewType.ADD_CUSTOM_PLOT + type: MessageFromWebviewType.ADD_PLOT }) }) diff --git a/webview/src/plots/components/customPlots/NoPlotsAdded.tsx b/webview/src/plots/components/customPlots/NoPlotsAdded.tsx index 3018c9fee3..b831260025 100644 --- a/webview/src/plots/components/customPlots/NoPlotsAdded.tsx +++ b/webview/src/plots/components/customPlots/NoPlotsAdded.tsx @@ -1,13 +1,13 @@ import React from 'react' import { StartButton } from '../../../shared/components/button/StartButton' import { EmptyState } from '../../../shared/components/emptyState/EmptyState' -import { addCustomPlot } from '../../util/messages' +import { addPlot } from '../../util/messages' export const NoPlotsAdded: React.FC = () => { return (

No Plots Added

- +
) } diff --git a/webview/src/plots/components/emptyState/ErrorState.tsx b/webview/src/plots/components/emptyState/ErrorState.tsx index e15b6af673..fed4b17bca 100644 --- a/webview/src/plots/components/emptyState/ErrorState.tsx +++ b/webview/src/plots/components/emptyState/ErrorState.tsx @@ -1,10 +1,6 @@ import React from 'react' import { EmptyState } from './EmptyState' -import { - addCustomPlot, - refreshRevisions, - selectRevisions -} from '../../util/messages' +import { addPlot, refreshRevisions, selectRevisions } from '../../util/messages' import { RefreshButton } from '../../../shared/components/button/RefreshButton' import { StartButton } from '../../../shared/components/button/StartButton' import { ErrorIcon } from '../../../shared/components/errorIcon/ErrorIcon' @@ -23,7 +19,7 @@ export const ErrorState: React.FC<{ )} diff --git a/webview/src/plots/util/messages.ts b/webview/src/plots/util/messages.ts index 0b5ac4ba31..11bfdb1d50 100644 --- a/webview/src/plots/util/messages.ts +++ b/webview/src/plots/util/messages.ts @@ -8,11 +8,6 @@ export const addPlot = () => type: MessageFromWebviewType.ADD_PLOT }) -export const addCustomPlot = () => - sendMessage({ - type: MessageFromWebviewType.ADD_CUSTOM_PLOT - }) - export const exportPlotDataAsCsv = (id: string) => { sendMessage({ payload: id,