11import { commands , Uri , ViewColumn , window } from 'vscode'
2+ import { TableData } from './contract'
23import {
34 RegisteredCliCommands ,
45 RegisteredCommands
@@ -7,6 +8,7 @@ import { Logger } from '../../common/logger'
78import { sendTelemetryEvent } from '../../telemetry'
89import { EventName } from '../../telemetry/constants'
910import { join } from '../../test/util/path'
11+ import { BaseWebview } from '../../webview'
1012import {
1113 MessageFromWebview ,
1214 MessageFromWebviewType
@@ -15,30 +17,42 @@ import { ColumnsModel } from '../columns/model'
1517import { splitColumnPath } from '../columns/paths'
1618import { ExperimentsModel } from '../model'
1719import { SortDefinition } from '../model/sortBy'
20+ import { CheckpointsModel } from '../checkpoints/model'
1821
1922export class WebviewMessages {
2023 private readonly dvcRoot : string
2124
2225 private readonly experiments : ExperimentsModel
2326 private readonly columns : ColumnsModel
27+ private readonly checkpoints : CheckpointsModel
2428
29+ private readonly getWebview : ( ) => BaseWebview < TableData > | undefined
2530 private readonly notifyChanged : ( ) => void
2631 private readonly selectColumns : ( ) => void
2732
2833 constructor (
2934 dvcRoot : string ,
3035 experiments : ExperimentsModel ,
3136 columns : ColumnsModel ,
37+ checkpoints : CheckpointsModel ,
38+ getWebview : ( ) => BaseWebview < TableData > | undefined ,
3239 notifyChanged : ( ) => void ,
3340 selectColumns : ( ) => void
3441 ) {
3542 this . dvcRoot = dvcRoot
3643 this . experiments = experiments
3744 this . columns = columns
45+ this . checkpoints = checkpoints
46+ this . getWebview = getWebview
3847 this . notifyChanged = notifyChanged
3948 this . selectColumns = selectColumns
4049 }
4150
51+ public sendWebviewMessage ( ) {
52+ const webview = this . getWebview ( )
53+ webview ?. show ( this . getWebviewData ( ) )
54+ }
55+
4256 public handleMessageFromWebview ( message : MessageFromWebview ) {
4357 switch ( message . type ) {
4458 case MessageFromWebviewType . REORDER_COLUMNS :
@@ -104,6 +118,24 @@ export class WebviewMessages {
104118 }
105119 }
106120
121+ private getWebviewData ( ) {
122+ return {
123+ changes : this . columns . getChanges ( ) ,
124+ columnOrder : this . columns . getColumnOrder ( ) ,
125+ columnWidths : this . columns . getColumnWidths ( ) ,
126+ columns : this . columns . getSelected ( ) ,
127+ filteredCounts : this . experiments . getFilteredCounts (
128+ this . checkpoints . hasCheckpoints ( )
129+ ) ,
130+ filters : this . experiments . getFilterPaths ( ) ,
131+ hasCheckpoints : this . checkpoints . hasCheckpoints ( ) ,
132+ hasColumns : this . columns . hasColumns ( ) ,
133+ hasRunningExperiment : this . experiments . hasRunningExperiment ( ) ,
134+ rows : this . experiments . getRowData ( ) ,
135+ sorts : this . experiments . getSorts ( )
136+ }
137+ }
138+
107139 private setColumnOrder ( order : string [ ] ) {
108140 this . columns . setColumnOrder ( order )
109141 sendTelemetryEvent (
0 commit comments