Add confirmation before converting to SDK-style project (#18893)

* Add confirmation before updating to SDK-style project

* update string

* update string

* update other learn more url
This commit is contained in:
Kim Santiago
2022-04-07 15:48:05 -07:00
committed by GitHub
parent d8b3db2ee3
commit 379b24d78c
2 changed files with 19 additions and 11 deletions

View File

@@ -98,7 +98,7 @@ export const defaultProjectNameStarter = localize('defaultProjectNameStarter', "
export const location = localize('location', "Location");
export const reloadProject = localize('reloadProject', "Would you like to reload your database project?");
export const learnMore = localize('learnMore', "Learn More");
export const sdkLearnMoreUrl = 'https://github.com/microsoft/DacFx/tree/main/src/Microsoft.Build.Sql';
export const sdkLearnMoreUrl = 'https://aka.ms/sqlprojsdk';
export function newObjectNamePrompt(objectType: string) { return localize('newObjectNamePrompt', 'New {0} name:', objectType); }
export function deleteConfirmation(toDelete: string) { return localize('deleteConfirmation', "Are you sure you want to delete {0}?", toDelete); }
export function deleteConfirmationContents(toDelete: string) { return localize('deleteConfirmationContents', "Are you sure you want to delete {0} and all of its contents?", toDelete); }
@@ -106,6 +106,7 @@ export function deleteReferenceConfirmation(toDelete: string) { return localize(
export function selectTargetPlatform(currentTargetPlatform: string) { return localize('selectTargetPlatform', "Current target platform: {0}. Select new target platform", currentTargetPlatform); }
export function currentTargetPlatform(projectName: string, currentTargetPlatform: string) { return localize('currentTargetPlatform', "Target platform of the project {0} is now {1}", projectName, currentTargetPlatform); }
export function projectUpdatedToSdkStyle(projectName: string) { return localize('projectUpdatedToSdkStyle', "The project {0} has been updated to be an SDK-style project. Click 'Learn More' for details on the Microsoft.Build.Sql SDK and ways to simplify the project file.", projectName); }
export function convertToSdkStyleConfirmation(projectName: string) { return localize('convertToSdkStyleConfirmation', "The project '{0}' will not be fully compatible with SSDT after conversion. A backup copy of the project file will be created in the project folder prior to conversion. More information is available at https://aka.ms/sqlprojsdk. Continue with converting to SDK-style project?", projectName); }
export function updatedToSdkStyleError(projectName: string) { return localize('updatedToSdkStyleError', "Converting the project {0} to SDK-style was unsuccessful. Changes to the .sqlproj have been rolled back.", projectName); }
// Publish dialog strings

View File

@@ -887,20 +887,27 @@ export class ProjectsController {
*/
public async convertToSdkStyleProject(context: dataworkspace.WorkspaceTreeItem): Promise<void> {
const project = this.getProjectFromContext(context);
const updateResult = await project.convertProjectToSdkStyle();
if (!updateResult) {
void vscode.window.showErrorMessage(constants.updatedToSdkStyleError(project.projectFileName));
} else {
void this.reloadProject(context);
// confirm that user wants to update the project and knows the SSDT doesn't have support for displaying glob files yet
await vscode.window.showWarningMessage(constants.convertToSdkStyleConfirmation(project.projectFileName), { modal: true }, constants.yesString).then(async (result) => {
if (result === constants.yesString) {
const updateResult = await project.convertProjectToSdkStyle();
void this.reloadProject(context);
// show message that project file can be simplified
const result = await vscode.window.showInformationMessage(constants.projectUpdatedToSdkStyle(project.projectFileName), constants.learnMore);
if (!updateResult) {
void vscode.window.showErrorMessage(constants.updatedToSdkStyleError(project.projectFileName));
} else {
void this.reloadProject(context);
if (result === constants.learnMore) {
void vscode.env.openExternal(vscode.Uri.parse(constants.sdkLearnMoreUrl!));
// show message that project file can be simplified
const result = await vscode.window.showInformationMessage(constants.projectUpdatedToSdkStyle(project.projectFileName), constants.learnMore);
if (result === constants.learnMore) {
void vscode.env.openExternal(vscode.Uri.parse(constants.sdkLearnMoreUrl!));
}
}
}
}
});
}
/**