mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
add SDK style option to new project quickpick (#18724)
* add SDK style option to new project quickpick * addressing comments
This commit is contained in:
@@ -19,8 +19,10 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
|
||||
return {
|
||||
label: projType.displayName,
|
||||
description: projType.description,
|
||||
id: projType.id
|
||||
} as vscode.QuickPickItem & { id: string };
|
||||
id: projType.id,
|
||||
sdkOption: projType.sdkStyleOption,
|
||||
sdkLearnMoreUrl: projType.sdkStyleLearnMoreUrl
|
||||
} as vscode.QuickPickItem & { id: string, sdkOption?: boolean, sdkLearnMoreUrl?: string };
|
||||
});
|
||||
|
||||
// 1. Prompt for project type
|
||||
@@ -87,5 +89,54 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
|
||||
continue;
|
||||
}
|
||||
|
||||
await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, undefined);
|
||||
let sdkStyle;
|
||||
if (projectType.sdkOption) {
|
||||
// 4. SDK-style project or not
|
||||
const sdkLearnMoreButton: vscode.QuickInputButton = {
|
||||
iconPath: new vscode.ThemeIcon('link-external'),
|
||||
tooltip: constants.LearnMore
|
||||
};
|
||||
const quickPick = vscode.window.createQuickPick();
|
||||
quickPick.items = [{ label: constants.YesRecommended }, { label: constants.No }];
|
||||
quickPick.title = constants.SdkStyleProject;
|
||||
quickPick.ignoreFocusOut = true;
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
|
||||
try {
|
||||
if (projectType.sdkLearnMoreUrl) {
|
||||
// add button to open sdkLearnMoreUrl if it was provided
|
||||
quickPick.buttons = [sdkLearnMoreButton];
|
||||
quickPick.placeholder = constants.SdkLearnMorePlaceholder;
|
||||
}
|
||||
|
||||
let sdkStylePromise = new Promise<boolean | undefined>((resolve) => {
|
||||
disposables.push(
|
||||
quickPick.onDidHide(() => {
|
||||
resolve(undefined);
|
||||
}),
|
||||
quickPick.onDidChangeSelection((item) => {
|
||||
resolve(item[0].label === constants.YesRecommended);
|
||||
}));
|
||||
|
||||
if (projectType.sdkLearnMoreUrl) {
|
||||
disposables.push(quickPick.onDidTriggerButton(async () => {
|
||||
await vscode.env.openExternal(vscode.Uri.parse(projectType.sdkLearnMoreUrl!));
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
quickPick.show();
|
||||
sdkStyle = await sdkStylePromise;
|
||||
quickPick.hide();
|
||||
} finally {
|
||||
disposables.forEach(d => d.dispose());
|
||||
}
|
||||
|
||||
if (sdkStyle === undefined) {
|
||||
// User cancelled
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, undefined, sdkStyle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user