mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Add Create Proj from DB to VS Code context menus (#16584)
* Add Create Proj from DB to VS Code context menus * Fix error * add comment * use constant
This commit is contained in:
@@ -863,10 +863,10 @@ export class ProjectsController {
|
||||
* Creates a new SQL database project from the existing database,
|
||||
* prompting the user for a name, file path location and extract target
|
||||
*/
|
||||
public async createProjectFromDatabase(context: azdataType.IConnectionProfile | any): Promise<CreateProjectFromDatabaseDialog | undefined> {
|
||||
public async createProjectFromDatabase(context: azdataType.IConnectionProfile | mssqlVscode.ITreeNodeInfo | undefined): Promise<CreateProjectFromDatabaseDialog | undefined> {
|
||||
const profile = this.getConnectionProfileFromContext(context);
|
||||
if (utils.getAzdataApi()) {
|
||||
let createProjectFromDatabaseDialog = this.getCreateProjectFromDatabaseDialog(profile);
|
||||
let createProjectFromDatabaseDialog = this.getCreateProjectFromDatabaseDialog(profile as azdataType.IConnectionProfile);
|
||||
|
||||
createProjectFromDatabaseDialog.createProjectFromDatabaseCallback = async (model) => await this.createProjectFromDatabaseCallback(model);
|
||||
|
||||
@@ -874,7 +874,15 @@ export class ProjectsController {
|
||||
|
||||
return createProjectFromDatabaseDialog;
|
||||
} else {
|
||||
const model = await createNewProjectFromDatabaseWithQuickpick();
|
||||
if (context) {
|
||||
// The profile we get from VS Code is for the overall server connection and isn't updated based on the database node
|
||||
// the command was launched from like it is in ADS. So get the actual database name from the MSSQL extension and
|
||||
// update the connection info here.
|
||||
const treeNodeContext = context as mssqlVscode.ITreeNodeInfo;
|
||||
const databaseName = (await utils.getVscodeMssqlApi()).getDatabaseNameFromTreeNode(treeNodeContext);
|
||||
(profile as mssqlVscode.IConnectionInfo).database = databaseName;
|
||||
}
|
||||
const model = await createNewProjectFromDatabaseWithQuickpick(profile as mssqlVscode.IConnectionInfo);
|
||||
if (model) {
|
||||
await this.createProjectFromDatabaseCallback(model);
|
||||
}
|
||||
@@ -925,14 +933,14 @@ export class ProjectsController {
|
||||
}
|
||||
}
|
||||
|
||||
private getConnectionProfileFromContext(context: azdataType.IConnectionProfile | any): azdataType.IConnectionProfile | undefined {
|
||||
private getConnectionProfileFromContext(context: azdataType.IConnectionProfile | mssqlVscode.ITreeNodeInfo | undefined): azdataType.IConnectionProfile | mssqlVscode.IConnectionInfo | undefined {
|
||||
if (!context) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// depending on where import new project is launched from, the connection profile could be passed as just
|
||||
// the profile or it could be wrapped in another object
|
||||
return (<any>context).connectionProfile ? (<any>context).connectionProfile : context;
|
||||
return (<any>context)?.connectionProfile ?? (context as mssqlVscode.ITreeNodeInfo).connectionInfo ?? context;
|
||||
}
|
||||
|
||||
public async createProjectFromDatabaseApiCall(model: ImportDataModel): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user