Skip to content

Commit 827b864

Browse files
committed
Feedback
1 parent 251a8e4 commit 827b864

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/commands/image/imageSource/buildImageInAzure/SourcePathStep.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
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';
77
import * as path from 'path';
88
import { browseItem } from '../../../../constants';
99
import { localize } from '../../../../utils/localize';
1010
import { type BuildImageInAzureImageSourceContext } from './BuildImageInAzureImageSourceContext';
1111

1212
export 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

Comments
 (0)