mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
* fix schema compare default connection when there are multiple connections
This commit is contained in:
@@ -26,6 +26,7 @@ const SchemaCompareLabel: string = localize('schemaCompare.dialogTitle', 'Schema
|
|||||||
|
|
||||||
export class SchemaCompareDialog {
|
export class SchemaCompareDialog {
|
||||||
public dialog: azdata.window.Dialog;
|
public dialog: azdata.window.Dialog;
|
||||||
|
public dialogName: string;
|
||||||
private schemaCompareTab: azdata.window.DialogTab;
|
private schemaCompareTab: azdata.window.DialogTab;
|
||||||
private sourceDacpacComponent: azdata.FormComponent;
|
private sourceDacpacComponent: azdata.FormComponent;
|
||||||
private sourceTextBox: azdata.InputBoxComponent;
|
private sourceTextBox: azdata.InputBoxComponent;
|
||||||
@@ -47,7 +48,7 @@ export class SchemaCompareDialog {
|
|||||||
private sourceIsDacpac: boolean;
|
private sourceIsDacpac: boolean;
|
||||||
private targetIsDacpac: boolean;
|
private targetIsDacpac: boolean;
|
||||||
private database: string;
|
private database: string;
|
||||||
public dialogName: string;
|
private connectionId: string;
|
||||||
|
|
||||||
protected initializeDialog(): void {
|
protected initializeDialog(): void {
|
||||||
this.schemaCompareTab = azdata.window.createTab(SchemaCompareLabel);
|
this.schemaCompareTab = azdata.window.createTab(SchemaCompareLabel);
|
||||||
@@ -55,10 +56,17 @@ export class SchemaCompareDialog {
|
|||||||
this.dialog.content = [this.schemaCompareTab];
|
this.dialog.content = [this.schemaCompareTab];
|
||||||
}
|
}
|
||||||
|
|
||||||
public openDialog(p: any, dialogName?: string): void {
|
public async openDialog(context: any, dialogName?: string): Promise<void> {
|
||||||
let profile = p ? <azdata.IConnectionProfile>p.connectionProfile : undefined;
|
let profile = context ? <azdata.IConnectionProfile>context.connectionProfile : undefined;
|
||||||
if (profile) {
|
if (profile) {
|
||||||
this.database = profile.databaseName;
|
this.database = profile.databaseName;
|
||||||
|
this.connectionId = profile.id;
|
||||||
|
} else {
|
||||||
|
let connection = await azdata.connection.getCurrentConnection();
|
||||||
|
if (connection) {
|
||||||
|
this.connectionId = connection.connectionId;
|
||||||
|
this.database = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let event = dialogName ? dialogName : null;
|
let event = dialogName ? dialogName : null;
|
||||||
@@ -396,7 +404,16 @@ export class SchemaCompareDialog {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let count = -1;
|
||||||
|
let idx = -1;
|
||||||
let values = cons.map(c => {
|
let values = cons.map(c => {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if (c.connectionId === this.connectionId) {
|
||||||
|
idx = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
let db = c.options.databaseDisplayName;
|
||||||
let usr = c.options.user;
|
let usr = c.options.user;
|
||||||
let srv = c.options.server;
|
let srv = c.options.server;
|
||||||
|
|
||||||
@@ -412,6 +429,13 @@ export class SchemaCompareDialog {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// move server of current connection to the top of the list so it is the default
|
||||||
|
if (idx >= 1) {
|
||||||
|
let tmp = values[0];
|
||||||
|
values[0] = values[idx];
|
||||||
|
values[idx] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user