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

@@ -26,6 +26,7 @@ export const openedProjectsUndefinedAfterRefresh = localize('openedProjectsUndef
export const OkButtonText = localize('dataworkspace.ok', "OK"); export const OkButtonText = localize('dataworkspace.ok', "OK");
export const BrowseButtonText = localize('dataworkspace.browse', "Browse"); export const BrowseButtonText = localize('dataworkspace.browse', "Browse");
export const BrowseEllipsis = localize('dataworkspace.browseEllipsis', "Browse..."); export const BrowseEllipsis = localize('dataworkspace.browseEllipsis', "Browse...");
export const BrowseEllipsisWithIcon = `$(folder) ${BrowseEllipsis}`;
export const OpenButtonText = localize('dataworkspace.open', "Open"); export const OpenButtonText = localize('dataworkspace.open', "Open");
export const CreateButtonText = localize('dataworkspace.create', "Create"); export const CreateButtonText = localize('dataworkspace.create', "Create");
export const Select = localize('dataworkspace.select', "Select"); export const Select = localize('dataworkspace.select', "Select");

View File

@@ -45,7 +45,7 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
// 3. Prompt for Project location // 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) // 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( const browseProjectLocation = await vscode.window.showQuickPick(
[constants.BrowseEllipsis], [constants.BrowseEllipsisWithIcon],
{ title: constants.SelectProjectLocation, ignoreFocusOut: true }); { title: constants.SelectProjectLocation, ignoreFocusOut: true });
if (!browseProjectLocation) { if (!browseProjectLocation) {
return; return;
@@ -70,7 +70,7 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
if (exists) { if (exists) {
// Show the browse quick pick again with the title updated with the error // Show the browse quick pick again with the title updated with the error
const browseProjectLocation = await vscode.window.showQuickPick( const browseProjectLocation = await vscode.window.showQuickPick(
[constants.BrowseEllipsis], [constants.BrowseEllipsisWithIcon],
{ title: constants.ProjectDirectoryAlreadyExistErrorShort(projectName), ignoreFocusOut: true }); { title: constants.ProjectDirectoryAlreadyExistErrorShort(projectName), ignoreFocusOut: true });
if (!browseProjectLocation) { if (!browseProjectLocation) {
return; return;

View File

@@ -217,6 +217,7 @@ export const selectFolderStructure = localize('selectFolderStructure', "Select f
export const folderStructureLabel = localize('folderStructureLabel', "Folder structure"); export const folderStructureLabel = localize('folderStructureLabel', "Folder structure");
export const WorkspaceFileExtension = '.code-workspace'; export const WorkspaceFileExtension = '.code-workspace';
export const browseEllipsis = localize('browseEllipsis', "Browse..."); export const browseEllipsis = localize('browseEllipsis', "Browse...");
export const browseEllipsisWithIcon = `$(folder) ${browseEllipsis}`;
export const selectProjectLocation = localize('selectProjectLocation', "Select project location"); 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 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); }; 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 // 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) // 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( const browseSelected = await vscode.window.showQuickPick(
[constants.browseEllipsis], [constants.browseEllipsisWithIcon],
{ title: constants.selectDacpac, ignoreFocusOut: true }); { title: constants.selectDacpac, ignoreFocusOut: true });
if (!browseSelected) { if (!browseSelected) {
return undefined; return undefined;

View File

@@ -80,42 +80,48 @@ export async function createNewProjectFromDatabaseWithQuickpick(connectionInfo?:
} }
// 4. Prompt for Project location // 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 defaultProjectSaveLoc = defaultProjectSaveLocation();
const browseProjectLocation = await vscode.window.showQuickPick( const browseProjectLocationOptions: string[] = [constants.browseEllipsisWithIcon];
[constants.browseEllipsis], if (defaultProjectSaveLoc) {
{ title: constants.projectLocationPlaceholderText, ignoreFocusOut: true }); browseProjectLocationOptions.push(defaultProjectSaveLoc.fsPath);
if (!browseProjectLocation) {
return undefined;
} }
// We validate that the folder doesn't already exist, and if it does keep prompting them to pick a new one // 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 = ''; let projectLocation = '';
while (!valid) { let browseProjectLocationTitle = constants.projectLocationPlaceholderText;
while (true) {
const browseProjectLocation = await vscode.window.showQuickPick(
browseProjectLocationOptions,
{ title: browseProjectLocationTitle, ignoreFocusOut: true });
if (!browseProjectLocation) {
// User cancelled
return undefined;
}
if (browseProjectLocation === constants.browseEllipsisWithIcon) {
const locations = await vscode.window.showOpenDialog({ const locations = await vscode.window.showOpenDialog({
canSelectFiles: false, canSelectFiles: false,
canSelectFolders: true, canSelectFolders: true,
canSelectMany: false, canSelectMany: false,
openLabel: constants.selectString, openLabel: constants.selectString,
title: constants.selectProjectLocation, title: constants.selectProjectLocation,
defaultUri: defaultProjectSaveLocation() defaultUri: defaultProjectSaveLoc
}); });
if (!locations) { if (!locations) {
// User cancelled // User cancelled out of open dialog - let them choose location again
return undefined; browseProjectLocationTitle = constants.projectLocationPlaceholderText;
continue;
} }
projectLocation = locations[0].fsPath; 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;
}
} else { } 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 // 5: Prompt for folder structure