Skip to content

Commit 0035539

Browse files
authored
Improve UX for bundle init folder selection (#1026)
Tried using showOpenDialog directly to select parent folder, but at least on macOS we can't provide a context for that window (e.g. a title explaining what are you selecting a folder for). Instead we are using quick pick where you can write a path to a folder manually or chose to click on a button that opens system's folder-selection dialog.
1 parent ba2327d commit 0035539

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

packages/databricks-vscode/src/bundle/BundleProjectManager.ts

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,52 @@ export class BundleProjectManager {
410410
}
411411

412412
private async promptForParentFolder(): Promise<Uri | undefined> {
413-
const parentPath = await window.showInputBox({
414-
title: "Provide a path to a folder where you would want your new project to be",
415-
value: this.workspaceUri.fsPath,
416-
});
417-
if (!parentPath) {
418-
return undefined;
413+
const quickPick = window.createQuickPick();
414+
const openFolderLabel = "Open folder selection dialog";
415+
quickPick.value = this.workspaceUri.fsPath;
416+
quickPick.title =
417+
"Provide a path to a folder where you would want your new project to be";
418+
quickPick.items = [
419+
{label: quickPick.value, alwaysShow: true},
420+
{label: "", kind: QuickPickItemKind.Separator, alwaysShow: true},
421+
{label: openFolderLabel, alwaysShow: true},
422+
];
423+
quickPick.show();
424+
const disposables = [
425+
quickPick.onDidChangeValue(() => {
426+
quickPick.items = [
427+
{label: quickPick.value, alwaysShow: true},
428+
...quickPick.items.slice(1),
429+
];
430+
}),
431+
];
432+
const choice = await new Promise<QuickPickItem | undefined>(
433+
(resolve) => {
434+
disposables.push(
435+
quickPick.onDidAccept(() =>
436+
resolve(quickPick.selectedItems[0])
437+
),
438+
quickPick.onDidHide(() => resolve(undefined))
439+
);
440+
}
441+
);
442+
disposables.forEach((d) => d.dispose());
443+
quickPick.hide();
444+
if (!choice) {
445+
return;
419446
}
420-
return Uri.file(parentPath);
447+
if (choice.label !== openFolderLabel) {
448+
return Uri.file(choice.label);
449+
}
450+
const choices = await window.showOpenDialog({
451+
title: "Chose a folder where you would want your new project to be",
452+
openLabel: "Select folder",
453+
defaultUri: this.workspaceUri,
454+
canSelectFolders: true,
455+
canSelectFiles: false,
456+
canSelectMany: false,
457+
});
458+
return choices ? choices[0] : undefined;
421459
}
422460

423461
dispose() {

0 commit comments

Comments
 (0)