Skip to content

Commit

Permalink
Remove addCustomPlot util from plots webview
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Sep 21, 2023
1 parent 80c2495 commit 5771786
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 55 deletions.
3 changes: 1 addition & 2 deletions extension/src/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ export class Plots extends BaseRepository<TPlotsData> {
errors,
experiments,
() => this.getWebview(),
() => this.selectPlots(),
() => this.addCustomPlot()
() => this.selectPlots()
)
this.dispose.track(
this.onDidReceivedWebviewMessage(message =>
Expand Down
12 changes: 1 addition & 11 deletions extension/src/plots/webview/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class WebviewMessages {

private readonly getWebview: () => BaseWebview<TPlotsData> | undefined
private readonly selectPlots: () => Promise<void>
private readonly addCustomPlot: () => Promise<void>

constructor(
dvcRoot: string,
Expand All @@ -50,8 +49,7 @@ export class WebviewMessages {
errors: ErrorsModel,
experiments: Experiments,
getWebview: () => BaseWebview<TPlotsData> | undefined,
selectPlots: () => Promise<void>,
addCustomPlot: () => Promise<void>
selectPlots: () => Promise<void>
) {
this.dvcRoot = dvcRoot
this.paths = paths
Expand All @@ -60,7 +58,6 @@ export class WebviewMessages {
this.experiments = experiments
this.getWebview = getWebview
this.selectPlots = selectPlots
this.addCustomPlot = addCustomPlot
}

public async sendWebviewMessage() {
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions extension/src/test/suite/plots/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions extension/src/webview/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -108,9 +107,6 @@ export type PlotsTemplatesReordered = {
}[]

export type MessageFromWebview =
| {
type: MessageFromWebviewType.ADD_CUSTOM_PLOT
}
| {
type: MessageFromWebviewType.ADD_PLOT
}
Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ describe('App', () => {
fireEvent.click(addCustomPlotsButton)

expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.ADD_CUSTOM_PLOT
type: MessageFromWebviewType.ADD_PLOT
})
mockPostMessage.mockReset()

Expand Down Expand Up @@ -560,7 +560,7 @@ describe('App', () => {

fireEvent.click(addPlotButton)
expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.ADD_CUSTOM_PLOT
type: MessageFromWebviewType.ADD_PLOT
})
})

Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/components/customPlots/NoPlotsAdded.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<EmptyState isFullScreen={false}>
<p>No Plots Added</p>
<StartButton onClick={addCustomPlot} text="Add Plot" />
<StartButton onClick={addPlot} text="Add Plot" />
</EmptyState>
)
}
8 changes: 2 additions & 6 deletions webview/src/plots/components/emptyState/ErrorState.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -23,7 +19,7 @@ export const ErrorState: React.FC<{
<StartButton
isNested={true}
appearance="secondary"
onClick={addCustomPlot}
onClick={addPlot}
text="Add Custom Plot"
/>
)}
Expand Down
5 changes: 0 additions & 5 deletions webview/src/plots/util/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5771786

Please sign in to comment.