From 00da5fdcb3b89a812dc2c49002dab38ff45689ad Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 30 Aug 2021 15:32:20 -0700 Subject: [PATCH] Add icons for some quickpick items (#16939) --- extensions/data-workspace/.vscode/launch.json | 24 +++++++ .../src/dialogs/newProjectQuickpick.ts | 65 ++++++++++--------- .../sql-database-projects/.vscode/launch.json | 24 +++++++ .../src/common/constants.ts | 1 + .../src/dialogs/addDatabaseReferenceDialog.ts | 3 +- .../src/dialogs/publishDatabaseQuickpick.ts | 6 +- 6 files changed, 90 insertions(+), 33 deletions(-) create mode 100644 extensions/data-workspace/.vscode/launch.json create mode 100644 extensions/sql-database-projects/.vscode/launch.json diff --git a/extensions/data-workspace/.vscode/launch.json b/extensions/data-workspace/.vscode/launch.json new file mode 100644 index 0000000000..a9dfe70099 --- /dev/null +++ b/extensions/data-workspace/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + // Note for debugging the VS Code version of the extension, currently you will need to modify + // the package.json and manually copy over the values from package.vscode.json into package.json + // (otherwise you'll get errors since other extensions depend on an extension with the name + // data-workspace-vscode, not data-workspace) + { + "type": "extensionHost", + "request": "launch", + "name": "Launch Extension", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/out/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts b/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts index 651ca5fe3e..37a80e87d8 100644 --- a/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts +++ b/extensions/data-workspace/src/dialogs/newProjectQuickpick.ts @@ -42,42 +42,49 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS return; } - // 3. Prompt for Project location - // Show quick pick with just browse option to give user context about what the file dialog is for (since that doesn't always have a title) - const browseProjectLocation = await vscode.window.showQuickPick( - [constants.BrowseEllipsisWithIcon], - { title: constants.SelectProjectLocation, ignoreFocusOut: true }); - if (!browseProjectLocation) { - return; + const defaultProjectSaveLoc = defaultProjectSaveLocation(); + const browseProjectLocationOptions = [constants.BrowseEllipsisWithIcon]; + if (defaultProjectSaveLoc) { + browseProjectLocationOptions.unshift(defaultProjectSaveLoc.fsPath); } + // 3. Prompt for Project location // We validate that the folder doesn't already exist, and if it does keep prompting them to pick a new one - let valid = false; let projectLocation = ''; - while (!valid) { - const locations = await vscode.window.showOpenDialog({ - canSelectFiles: false, - canSelectFolders: true, - canSelectMany: false, - openLabel: constants.Select, - title: constants.SelectProjectLocation, - defaultUri: defaultProjectSaveLocation() - }); - if (!locations) { - return; + let browseProjectLocationTitle = constants.SelectProjectLocation; + while (true) { + const browseProjectLocation = await vscode.window.showQuickPick( + browseProjectLocationOptions, + { title: browseProjectLocationTitle, ignoreFocusOut: true }); + if (!browseProjectLocation) { + // User cancelled + return undefined; } - projectLocation = locations[0].fsPath; - const exists = await directoryExist(path.join(projectLocation, projectName)); - if (exists) { - // Show the browse quick pick again with the title updated with the error - const browseProjectLocation = await vscode.window.showQuickPick( - [constants.BrowseEllipsisWithIcon], - { title: constants.ProjectDirectoryAlreadyExistErrorShort(projectName), ignoreFocusOut: true }); - if (!browseProjectLocation) { - return; + if (browseProjectLocation === constants.BrowseEllipsisWithIcon) { + const locations = await vscode.window.showOpenDialog({ + canSelectFiles: false, + canSelectFolders: true, + canSelectMany: false, + openLabel: constants.Select, + title: constants.SelectProjectLocation, + defaultUri: defaultProjectSaveLoc + }); + if (!locations) { + // User cancelled out of open dialog - let them choose location again + browseProjectLocationTitle = constants.SelectProjectLocation; + continue; } + projectLocation = locations[0].fsPath; } else { - valid = true; + projectLocation = browseProjectLocation; } + const locationExists = await directoryExist(path.join(projectLocation, projectName)); + if (!locationExists) { + // Have a valid location so exit out now + break; + } + // Otherwise show the browse quick pick again with the title updated with the error + browseProjectLocationTitle = constants.ProjectDirectoryAlreadyExistErrorShort(projectName); + continue; } await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, undefined); diff --git a/extensions/sql-database-projects/.vscode/launch.json b/extensions/sql-database-projects/.vscode/launch.json new file mode 100644 index 0000000000..a9dfe70099 --- /dev/null +++ b/extensions/sql-database-projects/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + // Note for debugging the VS Code version of the extension, currently you will need to modify + // the package.json and manually copy over the values from package.vscode.json into package.json + // (otherwise you'll get errors since other extensions depend on an extension with the name + // data-workspace-vscode, not data-workspace) + { + "type": "extensionHost", + "request": "launch", + "name": "Launch Extension", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/out/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/extensions/sql-database-projects/src/common/constants.ts b/extensions/sql-database-projects/src/common/constants.ts index 39ae35b3de..aab3bf0114 100644 --- a/extensions/sql-database-projects/src/common/constants.ts +++ b/extensions/sql-database-projects/src/common/constants.ts @@ -115,6 +115,7 @@ export const selectProfileToUse = localize('selectProfileToUse', "Select publish export const selectProfile = localize('selectProfile', "Select Profile"); export const dontUseProfile = localize('dontUseProfile', "Don't use profile"); export const browseForProfile = localize('browseForProfile', "Browse for profile"); +export const browseForProfileWithIcon = `$(folder) ${browseForProfile}`; export const chooseAction = localize('chooseAction', "Choose action"); export const chooseSqlcmdVarsToModify = localize('chooseSqlcmdVarsToModify', "Choose SQLCMD variables to modify"); export const enterNewValueForVar = (varName: string) => localize('enterNewValueForVar', "Enter new value for variable '{0}'", varName); diff --git a/extensions/sql-database-projects/src/dialogs/addDatabaseReferenceDialog.ts b/extensions/sql-database-projects/src/dialogs/addDatabaseReferenceDialog.ts index a2c1758918..a6f22b31f1 100644 --- a/extensions/sql-database-projects/src/dialogs/addDatabaseReferenceDialog.ts +++ b/extensions/sql-database-projects/src/dialogs/addDatabaseReferenceDialog.ts @@ -616,8 +616,9 @@ export class AddDatabaseReferenceDialog { } export function getSystemDbOptions(project: Project): string[] { + const projectTargetVersion = project.getProjectTargetVersion().toLowerCase(); // only master is a valid system db reference for projects targeting Azure and DW - if (project.getProjectTargetVersion().toLowerCase().includes('azure') || project.getProjectTargetVersion().toLowerCase().includes('dw')) { + if (projectTargetVersion.includes('azure') || projectTargetVersion.includes('dw')) { return [constants.master]; } return [constants.master, constants.msdb]; diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts index ba395c79c8..ffbda39252 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts @@ -21,7 +21,7 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn // 1. Select publish settings file (optional) // Create custom quickpick so we can control stuff like displaying the loading indicator const quickPick = vscode.window.createQuickPick(); - quickPick.items = [{ label: constants.dontUseProfile }, { label: constants.browseForProfile }]; + quickPick.items = [{ label: constants.dontUseProfile }, { label: constants.browseForProfileWithIcon }]; quickPick.ignoreFocusOut = true; quickPick.title = constants.selectProfileToUse; const profilePicked = new Promise((resolve, reject) => { @@ -160,8 +160,8 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn key: key } as vscode.QuickPickItem & { key?: string, isResetAllVars?: boolean, isDone?: boolean }; }); - quickPickItems.push({ label: constants.resetAllVars, isResetAllVars: true }); - quickPickItems.unshift({ label: constants.done, isDone: true }); + quickPickItems.push({ label: `$(refresh) ${constants.resetAllVars}`, isResetAllVars: true }); + quickPickItems.unshift({ label: `$(check) ${constants.done}`, isDone: true }); const sqlCmd = await vscode.window.showQuickPick( quickPickItems, { title: constants.chooseSqlcmdVarsToModify, ignoreFocusOut: true }