mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 09:35:38 -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:
@@ -51,6 +51,9 @@ export const NameCannotBeEmpty = localize('dataworkspace.nameCannotBeEmpty', "Na
|
||||
export const TargetPlatform = localize('dataworkspace.targetPlatform', "Target Platform");
|
||||
export const SdkStyleProject = localize('dataworkspace.sdkStyleProject', "SDK-style project (Preview)");
|
||||
export const LearnMore = localize('dataworkspace.learnMore', "Learn More");
|
||||
export const YesRecommended = localize('dataworkspace.yesRecommended', "Yes (Recommended)");
|
||||
export const No = localize('dataworkspace.no', "No");
|
||||
export const SdkLearnMorePlaceholder = localize('dataworkspace.sdkLearnMorePlaceholder', "Click \"Learn More\" button for more information about SDK-style projects");
|
||||
|
||||
//Open Existing Dialog
|
||||
export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open Existing Project");
|
||||
|
||||
@@ -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