diff --git a/extensions/data-workspace/src/common/constants.ts b/extensions/data-workspace/src/common/constants.ts index 13941b4879..a7829a2bad 100644 --- a/extensions/data-workspace/src/common/constants.ts +++ b/extensions/data-workspace/src/common/constants.ts @@ -54,6 +54,8 @@ 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"); +export const Default = localize('dataworkspace.default', "Default"); +export const SelectTargetPlatform = localize('dataworkspace.selectTargetPlatform', "Select Target Platform"); //Open Existing Dialog export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open Existing Project"); diff --git a/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts b/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts index 221a963293..dea55d29b9 100644 --- a/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts +++ b/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts @@ -20,9 +20,11 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS label: projType.displayName, description: projType.description, id: projType.id, + targetPlatforms: projType.targetPlatforms, + defaultTargetPlatform: projType.defaultTargetPlatform, sdkOption: projType.sdkStyleOption, sdkLearnMoreUrl: projType.sdkStyleLearnMoreUrl - } as vscode.QuickPickItem & { id: string, sdkOption?: boolean, sdkLearnMoreUrl?: string }; + } as vscode.QuickPickItem & { id: string, sdkOption?: boolean, targetPlatforms?: string[], defaultTargetPlatform?: string, sdkLearnMoreUrl?: string }; }); // 1. Prompt for project type @@ -89,9 +91,34 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS continue; } + let targetPlatform; + if (projectType.targetPlatforms) { + // 4. Target platform of the project + let targetPlatforms: vscode.QuickPickItem[] = projectType.targetPlatforms.map(targetPlatform => { return { label: targetPlatform }; }); + + if (projectType.defaultTargetPlatform) { + // move the default target platform to be the first one in the list + const defaultIndex = targetPlatforms.findIndex(i => i.label === projectType.defaultTargetPlatform); + if (defaultIndex > -1) { + targetPlatforms.splice(defaultIndex, 1); + } + + // add default next to the default target platform + targetPlatforms.unshift({ label: projectType.defaultTargetPlatform, description: constants.Default }); + } + + const selectedTargetPlatform = await vscode.window.showQuickPick(targetPlatforms, { title: constants.SelectTargetPlatform, ignoreFocusOut: true }); + if (!selectedTargetPlatform) { + // User cancelled + return; + } + + targetPlatform = selectedTargetPlatform.label; + } + let sdkStyle; if (projectType.sdkOption) { - // 4. SDK-style project or not + // 5. SDK-style project or not const sdkLearnMoreButton: vscode.QuickInputButton = { iconPath: new vscode.ThemeIcon('link-external'), tooltip: constants.LearnMore @@ -138,5 +165,5 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS } } - await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, undefined, sdkStyle); + await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, targetPlatform, sdkStyle); }