mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add validation for checking for dacpac being on the same drive (#21434)
* add extra validation for add dacpac reference quickpick * Add placeholder with message
This commit is contained in:
@@ -282,6 +282,7 @@ export const databaseNameServerNameVariableRequired = localize('databaseNameServ
|
|||||||
export const otherServer = 'OtherServer';
|
export const otherServer = 'OtherServer';
|
||||||
export const otherSeverVariable = 'OtherServer';
|
export const otherSeverVariable = 'OtherServer';
|
||||||
export const databaseProject = localize('databaseProject', "Database project");
|
export const databaseProject = localize('databaseProject', "Database project");
|
||||||
|
export const dacpacMustBeOnSameDrive = localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file.");
|
||||||
export const dacpacNotOnSameDrive = (projectLocation: string): string => { return localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file. The project file is located at {0}", projectLocation); };
|
export const dacpacNotOnSameDrive = (projectLocation: string): string => { return localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file. The project file is located at {0}", projectLocation); };
|
||||||
export const referenceType = localize('referenceType', "Reference type");
|
export const referenceType = localize('referenceType', "Reference type");
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export async function addDatabaseReferenceQuickpick(project: Project): Promise<A
|
|||||||
case constants.systemDatabase:
|
case constants.systemDatabase:
|
||||||
return addSystemDatabaseReference(project);
|
return addSystemDatabaseReference(project);
|
||||||
case constants.dacpacText:
|
case constants.dacpacText:
|
||||||
return addDacpacReference();
|
return addDacpacReference(project);
|
||||||
default:
|
default:
|
||||||
console.log(`Unknown reference type ${referenceType}`);
|
console.log(`Unknown reference type ${referenceType}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -130,7 +130,7 @@ async function addSystemDatabaseReference(project: Project): Promise<ISystemData
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addDacpacReference(): Promise<IDacpacReferenceSettings | undefined> {
|
async function addDacpacReference(project: Project): Promise<IDacpacReferenceSettings | undefined> {
|
||||||
// (steps continued from addDatabaseReferenceQuickpick)
|
// (steps continued from addDatabaseReferenceQuickpick)
|
||||||
// 2. Prompt for location
|
// 2. Prompt for location
|
||||||
const location = await promptLocation();
|
const location = await promptLocation();
|
||||||
@@ -141,17 +141,34 @@ 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(
|
let dacPacLocation;
|
||||||
[constants.browseEllipsisWithIcon],
|
while (!dacPacLocation) {
|
||||||
{ title: constants.selectDacpac, ignoreFocusOut: true });
|
const browseSelected = await vscode.window.showQuickPick(
|
||||||
if (!browseSelected) {
|
[constants.browseEllipsisWithIcon],
|
||||||
return undefined;
|
{
|
||||||
}
|
title: constants.selectDacpac,
|
||||||
|
ignoreFocusOut: true,
|
||||||
|
placeHolder: constants.dacpacMustBeOnSameDrive
|
||||||
|
});
|
||||||
|
if (!browseSelected) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const dacPacLocation = (await promptDacpacLocation())?.[0];
|
dacPacLocation = (await promptDacpacLocation())?.[0];
|
||||||
if (!dacPacLocation) {
|
if (!dacPacLocation) {
|
||||||
// User cancelled
|
// User cancelled
|
||||||
return undefined;
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only support adding dacpacs that are on the same drive as the sqlproj
|
||||||
|
const projectDrive = path.parse(project.projectFilePath).root;
|
||||||
|
const dacpacDrive = path.parse(dacPacLocation.fsPath).root;
|
||||||
|
if (projectDrive !== dacpacDrive) {
|
||||||
|
void vscode.window.showErrorMessage(constants.dacpacNotOnSameDrive(project.projectFilePath));
|
||||||
|
|
||||||
|
// set dacPacLocation to undefined so that the browse quickpick will show again
|
||||||
|
dacPacLocation = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Prompt for db/server values
|
// 4. Prompt for db/server values
|
||||||
|
|||||||
Reference in New Issue
Block a user