11import { SetupData as TSetupData } from './webview/contract'
22import { WebviewMessages } from './webview/messages'
3+ import { findPythonBinForInstall } from './autoInstall'
34import { BaseWebview } from '../webview'
45import { ViewKey } from '../webview/constants'
56import { BaseRepository } from '../webview/repository'
67import { Resource } from '../resourceLocator'
8+ import { isPythonExtensionInstalled } from '../extensions/python'
9+ import { getBinDisplayText } from '../fileSystem'
710
811export type SetupWebviewWebview = BaseWebview < TSetupData >
912
1013export class Setup extends BaseRepository < TSetupData > {
1114 public readonly viewKey = ViewKey . SETUP
1215
1316 private webviewMessages : WebviewMessages
14- private initProject : ( ) => void
1517 private showExperiments : ( ) => void
1618 private getCliAccessible : ( ) => boolean
1719 private getHasRoots : ( ) => boolean
18- private getHasData : ( ) => boolean
20+ private getHasData : ( ) => boolean | undefined
1921
2022 constructor (
2123 dvcRoot : string ,
@@ -24,27 +26,26 @@ export class Setup extends BaseRepository<TSetupData> {
2426 showExperiments : ( ) => void ,
2527 getCliAccessible : ( ) => boolean ,
2628 getHasRoots : ( ) => boolean ,
27- getHasData : ( ) => boolean
29+ getHasData : ( ) => boolean | undefined
2830 ) {
2931 super ( dvcRoot , webviewIcon )
3032
31- this . webviewMessages = this . createWebviewMessageHandler ( )
33+ this . webviewMessages = this . createWebviewMessageHandler ( initProject )
3234
3335 if ( this . webview ) {
3436 this . sendDataToWebview ( )
3537 }
38+ this . showExperiments = showExperiments
3639 this . getCliAccessible = getCliAccessible
3740 this . getHasRoots = getHasRoots
38- this . initProject = initProject
39- this . showExperiments = showExperiments
4041 this . getHasData = getHasData
4142 }
4243
4344 public sendInitialWebviewData ( ) {
4445 return this . sendDataToWebview ( )
4546 }
4647
47- public sendDataToWebview ( ) {
48+ public async sendDataToWebview ( ) {
4849 const cliAccessible = this . getCliAccessible ( )
4950 const projectInitialized = this . getHasRoots ( )
5051 const hasData = this . getHasData ( )
@@ -60,17 +61,21 @@ export class Setup extends BaseRepository<TSetupData> {
6061 return
6162 }
6263
64+ const pythonBinPath = await findPythonBinForInstall ( )
65+
6366 this . webviewMessages . sendWebviewMessage (
6467 cliAccessible ,
6568 projectInitialized ,
69+ isPythonExtensionInstalled ( ) ,
70+ getBinDisplayText ( pythonBinPath ) ,
6671 hasData
6772 )
6873 }
6974
70- private createWebviewMessageHandler ( ) {
75+ private createWebviewMessageHandler ( initProject : ( ) => void ) {
7176 const webviewMessages = new WebviewMessages (
7277 ( ) => this . getWebview ( ) ,
73- ( ) => this . initProject ( )
78+ initProject
7479 )
7580 this . dispose . track (
7681 this . onDidReceivedWebviewMessage ( message =>
0 commit comments