Have create proj from database show default save location as option (#16909)

* Default create proj location to setting

* update icons

* undo
This commit is contained in:
Charles Gagnon
2021-08-26 18:59:05 -07:00
committed by GitHub
parent 159cd7f895
commit a95d90ce5c
5 changed files with 38 additions and 30 deletions

View File

@@ -217,6 +217,7 @@ export const selectFolderStructure = localize('selectFolderStructure', "Select f
export const folderStructureLabel = localize('folderStructureLabel', "Folder structure");
export const WorkspaceFileExtension = '.code-workspace';
export const browseEllipsis = localize('browseEllipsis', "Browse...");
export const browseEllipsisWithIcon = `$(folder) ${browseEllipsis}`;
export const selectProjectLocation = localize('selectProjectLocation', "Select project location");
export const ProjectParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.projectParentDirectoryNotExistError', "The selected project location '{0}' does not exist or is not a directory.", location); };
export const ProjectDirectoryAlreadyExistError = (projectName: string, location: string): string => { return localize('dataworkspace.projectDirectoryAlreadyExistError', "There is already a directory named '{0}' in the selected location: '{1}'.", projectName, location); };

View File

@@ -143,7 +143,7 @@ async function addDacpacReference(): Promise<IDacpacReferenceSettings | undefine
// 3. Prompt for dacpac 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 browseSelected = await vscode.window.showQuickPick(
[constants.browseEllipsis],
[constants.browseEllipsisWithIcon],
{ title: constants.selectDacpac, ignoreFocusOut: true });
if (!browseSelected) {
return undefined;

View File

@@ -80,42 +80,48 @@ export async function createNewProjectFromDatabaseWithQuickpick(connectionInfo?:
}
// 4. 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.browseEllipsis],
{ title: constants.projectLocationPlaceholderText, ignoreFocusOut: true });
if (!browseProjectLocation) {
return undefined;
const defaultProjectSaveLoc = defaultProjectSaveLocation();
const browseProjectLocationOptions: string[] = [constants.browseEllipsisWithIcon];
if (defaultProjectSaveLoc) {
browseProjectLocationOptions.push(defaultProjectSaveLoc.fsPath);
}
// 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.selectString,
title: constants.selectProjectLocation,
defaultUri: defaultProjectSaveLocation()
});
if (!locations) {
let browseProjectLocationTitle = constants.projectLocationPlaceholderText;
while (true) {
const browseProjectLocation = await vscode.window.showQuickPick(
browseProjectLocationOptions,
{ title: browseProjectLocationTitle, ignoreFocusOut: true });
if (!browseProjectLocation) {
// User cancelled
return undefined;
}
projectLocation = locations[0].fsPath;
const locationExists = await exists(path.join(projectLocation, projectName));
if (locationExists) {
// Show the browse quick pick again with the title updated with the error
const browseProjectLocation = await vscode.window.showQuickPick(
[constants.browseEllipsis],
{ title: constants.folderAlreadyExistsChooseNewLocation(projectName), ignoreFocusOut: true });
if (!browseProjectLocation) {
return undefined;
if (browseProjectLocation === constants.browseEllipsisWithIcon) {
const locations = await vscode.window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
openLabel: constants.selectString,
title: constants.selectProjectLocation,
defaultUri: defaultProjectSaveLoc
});
if (!locations) {
// User cancelled out of open dialog - let them choose location again
browseProjectLocationTitle = constants.projectLocationPlaceholderText;
continue;
}
projectLocation = locations[0].fsPath;
} else {
valid = true;
projectLocation = browseProjectLocation;
}
const locationExists = await exists(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.folderAlreadyExistsChooseNewLocation(projectName);
continue;
}
// 5: Prompt for folder structure