in src/views/connectionUI.ts [209:252]
public showDatabasesOnCurrentServer(currentCredentials: Interfaces.IConnectionCredentials,
databaseNames: Array<string>): Promise<Interfaces.IConnectionCredentials> {
const self = this;
return new Promise<Interfaces.IConnectionCredentials>((resolve, reject) => {
const pickListItems: vscode.QuickPickItem[] = databaseNames.map(name => {
let newCredentials: Interfaces.IConnectionCredentials = <any>{};
Object.assign<Interfaces.IConnectionCredentials, Interfaces.IConnectionCredentials>(newCredentials, currentCredentials);
if (newCredentials['profileName']) {
delete newCredentials['profileName'];
}
newCredentials.dbname = name;
return <Interfaces.IConnectionCredentialsQuickPickItem> {
label: name,
description: '',
detail: '',
connectionCreds: newCredentials,
quickPickItemType: CredentialsQuickPickItemType.Mru
};
});
// Add an option to disconnect from the current server
const disconnectItem: vscode.QuickPickItem = {
label: LocalizedConstants.disconnectOptionLabel,
description: LocalizedConstants.disconnectOptionDescription
};
pickListItems.push(disconnectItem);
const pickListOptions: vscode.QuickPickOptions = {
placeHolder: LocalizedConstants.msgChooseDatabasePlaceholder
};
// show database picklist, and modify the current connection to switch the active database
self.vscodeWrapper.showQuickPick<vscode.QuickPickItem>(pickListItems, pickListOptions).then( selection => {
if (selection === disconnectItem) {
self.handleDisconnectChoice().then(() => resolve(undefined), err => reject(err));
} else if (typeof selection !== 'undefined') {
resolve((selection as Interfaces.IConnectionCredentialsQuickPickItem).connectionCreds);
} else {
resolve(undefined);
}
});
});
}