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:
Charles Gagnon
2021-08-26 15:52:08 -07:00
committed by GitHub
parent 3dd212c90d
commit 6a0a185cbd
2 changed files with 15 additions and 13 deletions

View File

@@ -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(
{