mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Separate connect and listdatabases call for publish (#16391)
* Separate connect and listdatabases call for publish * add return value
This commit is contained in:
@@ -9,6 +9,7 @@ import { Project } from '../models/project';
|
||||
import { PublishProfile, readPublishProfile } from '../models/publishProfile/publishProfile';
|
||||
import { promptForPublishProfile } from './publishDatabaseDialog';
|
||||
import { getVscodeMssqlApi } from '../common/utils';
|
||||
import { IConnectionInfo } from 'vscode-mssql';
|
||||
|
||||
/**
|
||||
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
|
||||
@@ -72,15 +73,19 @@ export async function launchPublishDatabaseQuickpick(project: Project): Promise<
|
||||
|
||||
// 2. Select connection
|
||||
const vscodeMssqlApi = await getVscodeMssqlApi();
|
||||
let connectionProfile: IConnectionInfo | undefined = undefined;
|
||||
let connectionUri: string = '';
|
||||
let dbs: string[] | undefined = undefined;
|
||||
while (!dbs) {
|
||||
const connectionProfile = await vscodeMssqlApi.promptForConnection(true);
|
||||
connectionProfile = await vscodeMssqlApi.promptForConnection(true);
|
||||
if (!connectionProfile) {
|
||||
// User cancelled
|
||||
return;
|
||||
}
|
||||
// Get the list of databases now to validate that the connection is valid and re-prompt them if it isn't
|
||||
try {
|
||||
dbs = await vscodeMssqlApi.listDatabases(connectionProfile);
|
||||
connectionUri = await vscodeMssqlApi.connect(connectionProfile);
|
||||
dbs = await vscodeMssqlApi.listDatabases(connectionUri);
|
||||
} catch (err) {
|
||||
// no-op, the mssql extension handles showing the error to the user. We'll just go
|
||||
// back and prompt the user for a connection again
|
||||
|
||||
@@ -26,6 +26,11 @@ declare module 'vscode-mssql' {
|
||||
*/
|
||||
readonly dacFx: IDacFxService;
|
||||
|
||||
/**
|
||||
* Service for accessing SchemaCompare functionality
|
||||
*/
|
||||
readonly schemaCompare: ISchemaCompareService;
|
||||
|
||||
/**
|
||||
* Prompts the user to select an existing connection or create a new one, and then returns the result
|
||||
* @param ignoreFocusOut Whether the quickpick prompt ignores focus out (default false)
|
||||
@@ -33,11 +38,19 @@ declare module 'vscode-mssql' {
|
||||
promptForConnection(ignoreFocusOut?: boolean): Promise<IConnectionInfo | undefined>;
|
||||
|
||||
/**
|
||||
* Lists the databases for a given connection. An error is thrown and displayed to the user if an
|
||||
* error occurs while connecting
|
||||
* @param connection The connection to list the databases for
|
||||
* Attempts to create a new connection for the given connection info. An error is thrown and displayed
|
||||
* to the user if an error occurs while connecting.
|
||||
* @param connectionInfo The connection info
|
||||
* @returns The URI associated with this connection
|
||||
*/
|
||||
listDatabases(connection: IConnectionInfo): Promise<string[]>;
|
||||
connect(connectionInfo: IConnectionInfo): Promise<string>;
|
||||
|
||||
/**
|
||||
* Lists the databases for a given connection. Must be given an already-opened connection to succeed.
|
||||
* @param connectionUri The URI of the connection to list the databases for.
|
||||
* @returns The list of database names
|
||||
*/
|
||||
listDatabases(connectionUri: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,6 +225,10 @@ declare module 'vscode-mssql' {
|
||||
schemaObjectType = 5
|
||||
}
|
||||
|
||||
export interface ISchemaCompareService {
|
||||
schemaCompareGetDefaultOptions(): Thenable<SchemaCompareOptionsResult>;
|
||||
}
|
||||
|
||||
export interface IDacFxService {
|
||||
exportBacpac(databaseName: string, packageFilePath: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
|
||||
importBacpac(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
|
||||
@@ -467,4 +484,10 @@ declare module 'vscode-mssql' {
|
||||
createStreamingJobTsql: string;
|
||||
}
|
||||
|
||||
export interface SchemaCompareGetOptionsParams { }
|
||||
|
||||
export interface SchemaCompareOptionsResult extends ResultStatus {
|
||||
defaultDeploymentOptions: DeploymentOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user