@@ -26,13 +26,15 @@ import { collectColumnsWithChangedValues } from '../columns/collect'
2626import { ColumnLike } from '../columns/like'
2727import { getFilterId } from '../model/filterBy'
2828import { writeToClipboard } from '../../vscode/clipboard'
29+ import { Studio } from '../studio'
2930
3031export class WebviewMessages {
3132 private readonly dvcRoot : string
3233
3334 private readonly experiments : ExperimentsModel
3435 private readonly columns : ColumnsModel
3536 private readonly pipeline : Pipeline
37+ private readonly studio : Studio
3638
3739 private readonly getWebview : ( ) => BaseWebview < TableData > | undefined
3840 private readonly notifyChanged : ( ) => void
@@ -50,6 +52,7 @@ export class WebviewMessages {
5052 experiments : ExperimentsModel ,
5153 columns : ColumnsModel ,
5254 pipeline : Pipeline ,
55+ studio : Studio ,
5356 getWebview : ( ) => BaseWebview < TableData > | undefined ,
5457 notifyChanged : ( ) => void ,
5558 selectColumns : ( ) => Promise < void > ,
@@ -64,6 +67,7 @@ export class WebviewMessages {
6467 this . experiments = experiments
6568 this . columns = columns
6669 this . pipeline = pipeline
70+ this . studio = studio
6771 this . getWebview = getWebview
6872 this . notifyChanged = notifyChanged
6973 this . selectColumns = selectColumns
@@ -231,6 +235,9 @@ export class WebviewMessages {
231235 case MessageFromWebviewType . COPY_TO_CLIPBOARD :
232236 return this . copyToClipboard ( message . payload )
233237
238+ case MessageFromWebviewType . COPY_STUDIO_LINK :
239+ return this . copyStudioLink ( message . payload )
240+
234241 default :
235242 Logger . error ( `Unexpected message: ${ JSON . stringify ( message ) } ` )
236243 }
@@ -314,6 +321,7 @@ export class WebviewMessages {
314321 hasMoreCommits ,
315322 hasRunningWorkspaceExperiment ,
316323 isShowingMoreCommits ,
324+ isStudioConnected ,
317325 rows ,
318326 selectedBranches ,
319327 selectedForPlotsCount ,
@@ -332,6 +340,7 @@ export class WebviewMessages {
332340 this . experiments . getHasMoreCommits ( ) ,
333341 this . experiments . hasRunningWorkspaceExperiment ( ) ,
334342 this . experiments . getIsShowingMoreCommits ( ) ,
343+ this . studio . isConnected ( ) ,
335344 this . experiments . getRowData ( ) ,
336345 this . experiments . getSelectedBranches ( ) ,
337346 this . experiments . getSelectedRevisions ( ) . length ,
@@ -356,6 +365,7 @@ export class WebviewMessages {
356365 hasMoreCommits,
357366 hasRunningWorkspaceExperiment,
358367 isShowingMoreCommits,
368+ isStudioConnected,
359369 rows,
360370 selectedBranches,
361371 selectedForPlotsCount,
@@ -584,4 +594,23 @@ export class WebviewMessages {
584594 undefined
585595 )
586596 }
597+
598+ private async copyStudioLink ( id : string ) {
599+ const sha = this . experiments . getExperiments ( ) . find ( exp => exp . id === id )
600+ ?. sha
601+
602+ if ( ! sha ) {
603+ return
604+ }
605+
606+ const link = this . studio . getLink ( sha )
607+
608+ await writeToClipboard ( link , `[Studio link](${ link } )` )
609+
610+ void sendTelemetryEvent (
611+ EventName . VIEWS_EXPERIMENTS_TABLE_COPY_STUDIO_LINK ,
612+ undefined ,
613+ undefined
614+ )
615+ }
587616}
0 commit comments