From 90d6defa05237770a06599d7cecfed17094e1400 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Tue, 15 Mar 2022 18:07:41 -0700 Subject: [PATCH] Add select target platform to new project quickpick (#18731) * add step to choose target platform in new project quickpick * add comment * only splice if the default target platform index isn't -1 * change 3 to 5 in comment --- .../data-workspace/src/common/constants.ts | 2 ++ .../src/dialogs/newProjectQuickpick.ts | 33 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) 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); }