Skip to content

Commit 3a29ab7

Browse files
authored
Improve web app selection step (#1104)
1 parent 45978c7 commit 3a29ab7

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

docs/assets/images/ss-pick-webapp.png

-602 Bytes
Loading

src/commands/addServerNamespaceToWorkspace.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
206206
}
207207

208208
let newParams = "";
209-
let newPath = "/";
209+
let newPath = uri.path;
210210
if (filterType == "csp") {
211211
// Prompt for a specific web app
212212
let cspApps = cspAppsForUri(uri);
@@ -237,11 +237,36 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
237237
return;
238238
}
239239
}
240-
newPath =
241-
(await vscode.window.showQuickPick(cspApps, {
242-
placeHolder: "Pick a specific web application to show, or press 'Escape' to show all",
243-
ignoreFocusOut: true,
244-
})) ?? "/";
240+
newPath = await new Promise<string | undefined>((resolve) => {
241+
let result: string;
242+
const allItem: vscode.QuickPickItem = { label: "All" };
243+
const quickPick = vscode.window.createQuickPick();
244+
quickPick.placeholder = "Pick a specific web application to show, or show all";
245+
quickPick.ignoreFocusOut = true;
246+
quickPick.items = [
247+
allItem,
248+
...cspApps.map((label) => {
249+
return { label };
250+
}),
251+
];
252+
const activeIdx = quickPick.items.findIndex((i) => i.label == uri.path);
253+
quickPick.activeItems = [quickPick.items[activeIdx == -1 ? 0 : activeIdx]];
254+
255+
quickPick.onDidChangeSelection((items) => {
256+
result = items[0].label == allItem.label ? "/" : items[0].label;
257+
});
258+
quickPick.onDidAccept(() => {
259+
quickPick.hide();
260+
});
261+
quickPick.onDidHide(() => {
262+
resolve(result);
263+
quickPick.dispose();
264+
});
265+
quickPick.show();
266+
});
267+
if (!newPath) {
268+
return;
269+
}
245270
newParams = "csp";
246271
} else if (filterType == "project") {
247272
// Prompt for project

0 commit comments

Comments
 (0)