1+ import { commands } from 'vscode'
12import isEmpty from 'lodash.isempty'
23import {
34 ComparisonPlot ,
@@ -21,12 +22,11 @@ import {
2122import { PlotsModel } from '../model'
2223import { PathsModel } from '../paths/model'
2324import { BaseWebview } from '../../webview'
24- import { pickCustomPlots , pickMetricAndParam } from '../model/quickPick'
2525import { getModifiedTime , openImageFileInEditor } from '../../fileSystem'
26- import { Title } from '../../vscode/title'
2726import { reorderObjectList } from '../../util/array'
2827import { CustomPlotsOrderValue } from '../model/custom'
2928import { getCustomPlotId } from '../model/collect'
29+ import { RegisteredCommands } from '../../commands/external'
3030import { ErrorsModel } from '../errors/model'
3131
3232export class WebviewMessages {
@@ -74,7 +74,7 @@ export class WebviewMessages {
7474 public handleMessageFromWebview ( message : MessageFromWebview ) {
7575 switch ( message . type ) {
7676 case MessageFromWebviewType . ADD_CUSTOM_PLOT :
77- return this . addCustomPlot ( )
77+ return commands . executeCommand ( RegisteredCommands . PLOTS_CUSTOM_ADD )
7878 case MessageFromWebviewType . RESIZE_PLOTS :
7979 return this . setPlotSize (
8080 message . payload . section ,
@@ -96,7 +96,7 @@ export class WebviewMessages {
9696 case MessageFromWebviewType . SELECT_EXPERIMENTS :
9797 return this . selectExperimentsFromWebview ( )
9898 case MessageFromWebviewType . REMOVE_CUSTOM_PLOTS :
99- return this . removeCustomPlots ( )
99+ return commands . executeCommand ( RegisteredCommands . PLOTS_CUSTOM_REMOVE )
100100 case MessageFromWebviewType . REFRESH_REVISIONS :
101101 return this . refreshData ( )
102102 case MessageFromWebviewType . TOGGLE_EXPERIMENT :
@@ -183,37 +183,6 @@ export class WebviewMessages {
183183 )
184184 }
185185
186- private async addCustomPlot ( ) {
187- const metricAndParam = await pickMetricAndParam (
188- this . experiments . getColumnTerminalNodes ( ) ,
189- this . plots . getCustomPlotsOrder ( )
190- )
191-
192- if ( ! metricAndParam ) {
193- return
194- }
195-
196- this . plots . addCustomPlot ( metricAndParam )
197- this . sendCustomPlotsAndEvent ( EventName . VIEWS_PLOTS_CUSTOM_PLOT_ADDED )
198- }
199-
200- private async removeCustomPlots ( ) {
201- const selectedPlotsIds = await pickCustomPlots (
202- this . plots . getCustomPlotsOrder ( ) ,
203- 'There are no plots to remove.' ,
204- {
205- title : Title . SELECT_CUSTOM_PLOTS_TO_REMOVE
206- }
207- )
208-
209- if ( ! selectedPlotsIds ) {
210- return
211- }
212-
213- this . plots . removeCustomPlots ( selectedPlotsIds )
214- this . sendCustomPlotsAndEvent ( EventName . VIEWS_PLOTS_CUSTOM_PLOT_REMOVED )
215- }
216-
217186 private setCustomPlotsOrder ( plotIds : string [ ] ) {
218187 const customPlotsOrderWithId = this . plots
219188 . getCustomPlotsOrder ( )
@@ -232,17 +201,12 @@ export class WebviewMessages {
232201 } ) )
233202
234203 this . plots . setCustomPlotsOrder ( newOrder )
235- this . sendCustomPlotsAndEvent ( EventName . VIEWS_REORDER_PLOTS_CUSTOM )
236- }
237-
238- private sendCustomPlotsAndEvent (
239- event :
240- | typeof EventName . VIEWS_PLOTS_CUSTOM_PLOT_ADDED
241- | typeof EventName . VIEWS_PLOTS_CUSTOM_PLOT_REMOVED
242- | typeof EventName . VIEWS_REORDER_PLOTS_CUSTOM
243- ) {
244204 this . sendCustomPlots ( )
245- sendTelemetryEvent ( event , undefined , undefined )
205+ sendTelemetryEvent (
206+ EventName . VIEWS_REORDER_PLOTS_CUSTOM ,
207+ undefined ,
208+ undefined
209+ )
246210 }
247211
248212 private selectPlotsFromWebview ( ) {
0 commit comments