Add icons for some quickpick items (#16939)

This commit is contained in:
Charles Gagnon
2021-08-30 15:32:20 -07:00
committed by GitHub
parent 05d8ad4811
commit 00da5fdcb3
6 changed files with 90 additions and 33 deletions

View File

@@ -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"
]
}
]
}

View File

@@ -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);

View File

@@ -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"
]
}
]
}

View File

@@ -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);

View File

@@ -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];

View File

@@ -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<PublishProfile | undefined>((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 }