33* Licensed under the MIT License. See License.md in the project root for license information.
44*--------------------------------------------------------------------------------------------*/
55
6- import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils' ;
6+ import { AzureWizardPromptStep , type IAzureQuickPickItem } from '@microsoft/vscode-azext-utils' ;
77import * as path from 'path' ;
88import { browseItem } from '../../../../constants' ;
99import { localize } from '../../../../utils/localize' ;
1010import { type BuildImageInAzureImageSourceContext } from './BuildImageInAzureImageSourceContext' ;
1111
1212export class SourcePathStep extends AzureWizardPromptStep < BuildImageInAzureImageSourceContext > {
1313 public async prompt ( context : BuildImageInAzureImageSourceContext ) : Promise < void > {
14- await context . ui . showQuickPick ( [ browseItem ] , {
15- placeHolder : localize ( 'sourceDirectoryPick' , 'Choose your source code directory' )
16- } ) ;
14+ const srcPath : string | undefined = ( await context . ui . showQuickPick ( await this . getPicks ( context ) , {
15+ placeHolder : localize ( 'sourceDirectoryPick' , 'Choose your source code directory' ) ,
16+ suppressPersistence : true
17+ } ) ) . data ;
1718
18- context . srcPath = ( await context . ui . showOpenDialog ( {
19+ context . srcPath = srcPath ?? ( await context . ui . showOpenDialog ( {
1920 defaultUri : context . rootFolder ?. uri ,
2021 canSelectFiles : false ,
2122 canSelectFolders : true
@@ -32,6 +33,22 @@ export class SourcePathStep extends AzureWizardPromptStep<BuildImageInAzureImage
3233 return ! context . srcPath ;
3334 }
3435
36+ private async getPicks ( context : BuildImageInAzureImageSourceContext ) : Promise < IAzureQuickPickItem < string | undefined > [ ] > {
37+ const rootPath : string = context . rootFolder . uri . fsPath ;
38+ const relativePathArgs : string [ ] = path . relative ( rootPath , path . dirname ( context . dockerfilePath ) ) . split ( path . sep ) ;
39+ const picks : IAzureQuickPickItem < string | undefined > [ ] = [ { label : './' , description : 'root' , data : rootPath } ] ;
40+
41+ let p : string = '' ;
42+ for ( const pathArg of relativePathArgs ) {
43+ p += path . sep + pathArg ;
44+ picks . push ( { label : '.' + p , data : rootPath + p } ) ;
45+ }
46+
47+ ( picks . at ( - 1 ) as IAzureQuickPickItem ) . description = 'dockerfile' ;
48+ picks . push ( browseItem ) ;
49+ return picks ;
50+ }
51+
3552 private hasRootDockerfile ( context : BuildImageInAzureImageSourceContext ) : boolean {
3653 if ( ! context . rootFolder || ! context . dockerfilePath ) {
3754 return false ;
0 commit comments