mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 09:35:37 -05:00
Move create new option for publish to top and filter out system dbs (#16908)
* Move create new option for publish to top * Move New tag to description * fix
This commit is contained in:
@@ -119,9 +119,9 @@ 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);
|
||||
export const resetAllVars = localize('resetAllVars', "Reset all variables");
|
||||
export const createNew = localize('createNew', "<Create New>");
|
||||
export const createNew = localize('createNew', "Create New");
|
||||
export const enterNewDatabaseName = localize('enterNewDatabaseName', "Enter new database name");
|
||||
export const newDatabaseTitle = (name: string) => localize({ key: 'newDatabaseTitle', comment: ['Name is the name of a new database being created'] }, "{0} (new)", name);
|
||||
export const newText = localize('new', "New");
|
||||
export const selectDatabase = localize('selectDatabase', "Select database");
|
||||
export const done = localize('done', "Done");
|
||||
export const nameMustNotBeEmpty = localize('nameMustNotBeEmpty', "Name must not be empty");
|
||||
|
||||
@@ -100,23 +100,25 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn
|
||||
}
|
||||
|
||||
// 3. Select database
|
||||
const dbQuickpicks = dbs.map(db => {
|
||||
return {
|
||||
label: db,
|
||||
dbName: db
|
||||
} as vscode.QuickPickItem & { dbName: string, isCreateNew?: boolean };
|
||||
});
|
||||
const dbQuickpicks = dbs
|
||||
.filter(db => !constants.systemDbs.includes(db))
|
||||
.map(db => {
|
||||
return {
|
||||
label: db
|
||||
} as vscode.QuickPickItem & { isCreateNew?: boolean };
|
||||
});
|
||||
// Add Create New at the top now so it'll show second to top below the suggested name of the current project
|
||||
dbQuickpicks.unshift({ label: `$(add) ${constants.createNew}`, isCreateNew: true });
|
||||
|
||||
// Ensure the project name is an option, either adding it if it doesn't already exist or moving it to the top if it does
|
||||
const projectNameIndex = dbs.findIndex(db => db === project.projectFileName);
|
||||
if (projectNameIndex === -1) {
|
||||
dbQuickpicks.unshift({ label: constants.newDatabaseTitle(project.projectFileName), dbName: project.projectFileName });
|
||||
dbQuickpicks.unshift({ label: project.projectFileName, description: constants.newText });
|
||||
} else {
|
||||
dbQuickpicks.splice(projectNameIndex, 1);
|
||||
dbQuickpicks.unshift({ label: project.projectFileName, dbName: project.projectFileName });
|
||||
dbQuickpicks.unshift({ label: project.projectFileName });
|
||||
}
|
||||
|
||||
dbQuickpicks.push({ label: constants.createNew, dbName: '', isCreateNew: true });
|
||||
|
||||
let databaseName: string | undefined = undefined;
|
||||
while (!databaseName) {
|
||||
const selectedDatabase = await vscode.window.showQuickPick(
|
||||
@@ -126,7 +128,7 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn
|
||||
// User cancelled
|
||||
return;
|
||||
}
|
||||
databaseName = selectedDatabase.dbName;
|
||||
databaseName = selectedDatabase.label;
|
||||
if (selectedDatabase.isCreateNew) {
|
||||
databaseName = await vscode.window.showInputBox(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user