mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
Handle no azdata API in sql db proj extension gracefully (#15873)
* Update db proj ext to handle not having azdata API available * Fixes * Fix compile
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import type * as azdataType from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as constants from '../common/constants';
|
||||
@@ -23,25 +23,25 @@ export enum ReferenceType {
|
||||
}
|
||||
|
||||
export class AddDatabaseReferenceDialog {
|
||||
public dialog: azdata.window.Dialog;
|
||||
public addDatabaseReferenceTab: azdata.window.DialogTab;
|
||||
private view: azdata.ModelView | undefined;
|
||||
private formBuilder: azdata.FormBuilder | undefined;
|
||||
private projectDropdown: azdata.DropDownComponent | undefined;
|
||||
private projectFormComponent: azdata.FormComponent | undefined;
|
||||
private systemDatabaseDropdown: azdata.DropDownComponent | undefined;
|
||||
private systemDatabaseFormComponent: azdata.FormComponent | undefined;
|
||||
public dacpacTextbox: azdata.InputBoxComponent | undefined;
|
||||
private dacpacFormComponent: azdata.FormComponent | undefined;
|
||||
public locationDropdown: azdata.DropDownComponent | undefined;
|
||||
public databaseNameTextbox: azdata.InputBoxComponent | undefined;
|
||||
public databaseVariableTextbox: azdata.InputBoxComponent | undefined;
|
||||
public serverNameTextbox: azdata.InputBoxComponent | undefined;
|
||||
public serverVariableTextbox: azdata.InputBoxComponent | undefined;
|
||||
public suppressMissingDependenciesErrorsCheckbox: azdata.CheckBoxComponent | undefined;
|
||||
public exampleUsage: azdata.TextComponent | undefined;
|
||||
private projectRadioButton: azdata.RadioButtonComponent | undefined;
|
||||
private systemDatabaseRadioButton: azdata.RadioButtonComponent | undefined;
|
||||
public dialog: azdataType.window.Dialog;
|
||||
public addDatabaseReferenceTab: azdataType.window.DialogTab;
|
||||
private view: azdataType.ModelView | undefined;
|
||||
private formBuilder: azdataType.FormBuilder | undefined;
|
||||
private projectDropdown: azdataType.DropDownComponent | undefined;
|
||||
private projectFormComponent: azdataType.FormComponent | undefined;
|
||||
private systemDatabaseDropdown: azdataType.DropDownComponent | undefined;
|
||||
private systemDatabaseFormComponent: azdataType.FormComponent | undefined;
|
||||
public dacpacTextbox: azdataType.InputBoxComponent | undefined;
|
||||
private dacpacFormComponent: azdataType.FormComponent | undefined;
|
||||
public locationDropdown: azdataType.DropDownComponent | undefined;
|
||||
public databaseNameTextbox: azdataType.InputBoxComponent | undefined;
|
||||
public databaseVariableTextbox: azdataType.InputBoxComponent | undefined;
|
||||
public serverNameTextbox: azdataType.InputBoxComponent | undefined;
|
||||
public serverVariableTextbox: azdataType.InputBoxComponent | undefined;
|
||||
public suppressMissingDependenciesErrorsCheckbox: azdataType.CheckBoxComponent | undefined;
|
||||
public exampleUsage: azdataType.TextComponent | undefined;
|
||||
private projectRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||
private systemDatabaseRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||
|
||||
public currentReferenceType: ReferenceType | undefined;
|
||||
|
||||
@@ -52,8 +52,8 @@ export class AddDatabaseReferenceDialog {
|
||||
public addReference: ((proj: Project, settings: ISystemDatabaseReferenceSettings | IDacpacReferenceSettings | IProjectReferenceSettings) => any) | undefined;
|
||||
|
||||
constructor(private project: Project) {
|
||||
this.dialog = azdata.window.createModelViewDialog(constants.addDatabaseReferenceDialogName, 'addDatabaseReferencesDialog');
|
||||
this.addDatabaseReferenceTab = azdata.window.createTab(constants.addDatabaseReferenceDialogName);
|
||||
this.dialog = utils.getAzdataApi()!.window.createModelViewDialog(constants.addDatabaseReferenceDialogName, 'addDatabaseReferencesDialog');
|
||||
this.addDatabaseReferenceTab = utils.getAzdataApi()!.window.createTab(constants.addDatabaseReferenceDialogName);
|
||||
this.dialog.registerCloseValidator(async () => {
|
||||
return this.validate();
|
||||
});
|
||||
@@ -68,7 +68,7 @@ export class AddDatabaseReferenceDialog {
|
||||
if (projectDrive !== dacpacDrive) {
|
||||
this.dialog.message = {
|
||||
text: constants.dacpacNotOnSameDrive(this.project.projectFilePath),
|
||||
level: azdata.window.MessageLevel.Error
|
||||
level: utils.getAzdataApi()!.window.MessageLevel.Error
|
||||
};
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class AddDatabaseReferenceDialog {
|
||||
|
||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
||||
|
||||
azdata.window.openDialog(this.dialog);
|
||||
utils.getAzdataApi()!.window.openDialog(this.dialog);
|
||||
await this.initDialogPromise;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ export class AddDatabaseReferenceDialog {
|
||||
}).component();
|
||||
const exampleUsage = this.createExampleUsage();
|
||||
|
||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
||||
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
{
|
||||
title: '',
|
||||
@@ -188,7 +188,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private createRadioButtons(): azdata.FormComponent {
|
||||
private createRadioButtons(): azdataType.FormComponent {
|
||||
this.projectRadioButton = this.view!.modelBuilder.radioButton()
|
||||
.withProperties({
|
||||
name: 'referenceType',
|
||||
@@ -230,7 +230,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.projectRadioButton.enabled = false;
|
||||
}
|
||||
|
||||
let flexRadioButtonsModel: azdata.FlexContainer = this.view!.modelBuilder.flexContainer()
|
||||
let flexRadioButtonsModel: azdataType.FlexContainer = this.view!.modelBuilder.flexContainer()
|
||||
.withLayout({ flexFlow: 'column' })
|
||||
.withItems([this.projectRadioButton, this.systemDatabaseRadioButton, dacpacRadioButton])
|
||||
.withProperties({ ariaRole: 'radiogroup' })
|
||||
@@ -243,9 +243,9 @@ export class AddDatabaseReferenceDialog {
|
||||
}
|
||||
|
||||
public projectRadioButtonClick(): void {
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.dacpacFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.projectFormComponent, 2);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.dacpacFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.systemDatabaseFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.projectFormComponent, 2);
|
||||
|
||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||
|
||||
@@ -256,9 +256,9 @@ export class AddDatabaseReferenceDialog {
|
||||
}
|
||||
|
||||
public systemDbRadioButtonClick(): void {
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.dacpacFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.projectFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent, 2);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.dacpacFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.projectFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.systemDatabaseFormComponent, 2);
|
||||
|
||||
// update dropdown values because only different database, same server is a valid location for system db references
|
||||
this.locationDropdown!.values = constants.systemDbLocationDropdownValues;
|
||||
@@ -271,9 +271,9 @@ export class AddDatabaseReferenceDialog {
|
||||
}
|
||||
|
||||
public dacpacRadioButtonClick(): void {
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.projectFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.dacpacFormComponent, 2);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.systemDatabaseFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.projectFormComponent);
|
||||
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.dacpacFormComponent, 2);
|
||||
|
||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||
|
||||
@@ -283,7 +283,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.updateExampleUsage();
|
||||
}
|
||||
|
||||
private async createProjectDropdown(): Promise<azdata.FormComponent> {
|
||||
private async createProjectDropdown(): Promise<azdataType.FormComponent> {
|
||||
this.projectDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||
ariaLabel: constants.databaseProject
|
||||
}).component();
|
||||
@@ -305,7 +305,7 @@ export class AddDatabaseReferenceDialog {
|
||||
};
|
||||
}
|
||||
|
||||
private createSystemDatabaseDropdown(): azdata.FormComponent {
|
||||
private createSystemDatabaseDropdown(): azdataType.FormComponent {
|
||||
this.systemDatabaseDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||
values: [constants.master, constants.msdb],
|
||||
ariaLabel: constants.databaseNameLabel
|
||||
@@ -326,7 +326,7 @@ export class AddDatabaseReferenceDialog {
|
||||
};
|
||||
}
|
||||
|
||||
private createDacpacTextbox(): azdata.FormComponent {
|
||||
private createDacpacTextbox(): azdataType.FormComponent {
|
||||
this.dacpacTextbox = this.view!.modelBuilder.inputBox().withProperties({
|
||||
ariaLabel: constants.dacpacText,
|
||||
placeHolder: constants.dacpacPlaceholder,
|
||||
@@ -349,7 +349,7 @@ export class AddDatabaseReferenceDialog {
|
||||
};
|
||||
}
|
||||
|
||||
private createLoadDacpacButton(): azdata.ButtonComponent {
|
||||
private createLoadDacpacButton(): azdataType.ButtonComponent {
|
||||
const loadDacpacButton = this.view!.modelBuilder.button().withProperties({
|
||||
ariaLabel: constants.loadDacpacButton,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
@@ -381,7 +381,7 @@ export class AddDatabaseReferenceDialog {
|
||||
return loadDacpacButton;
|
||||
}
|
||||
|
||||
private createLocationDropdown(): azdata.FormComponent {
|
||||
private createLocationDropdown(): azdataType.FormComponent {
|
||||
this.locationDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||
ariaLabel: constants.locationDropdown,
|
||||
values: this.currentReferenceType === ReferenceType.systemDb ? constants.systemDbLocationDropdownValues : constants.locationDropdownValues
|
||||
@@ -469,7 +469,7 @@ export class AddDatabaseReferenceDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private createVariableSection(): azdata.FormComponent {
|
||||
private createVariableSection(): azdataType.FormComponent {
|
||||
// database name row
|
||||
this.databaseNameTextbox = this.createInputBox(constants.databaseName, true, true);
|
||||
const databaseNameRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.databaseName, true), this.databaseNameTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
@@ -495,8 +495,8 @@ export class AddDatabaseReferenceDialog {
|
||||
};
|
||||
}
|
||||
|
||||
private createLabel(value: string, required: boolean = false): azdata.TextComponent {
|
||||
const label = this.view!.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
private createLabel(value: string, required: boolean = false): azdataType.TextComponent {
|
||||
const label = this.view!.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: value,
|
||||
width: cssStyles.addDatabaseReferenceDialogLabelWidth,
|
||||
requiredIndicator: required
|
||||
@@ -505,7 +505,7 @@ export class AddDatabaseReferenceDialog {
|
||||
return label;
|
||||
}
|
||||
|
||||
private createInputBox(ariaLabel: string, enabled: boolean, required: boolean): azdata.InputBoxComponent {
|
||||
private createInputBox(ariaLabel: string, enabled: boolean, required: boolean): azdataType.InputBoxComponent {
|
||||
const inputBox = this.view!.modelBuilder.inputBox().withProperties({
|
||||
ariaLabel: ariaLabel,
|
||||
enabled: enabled,
|
||||
@@ -521,7 +521,7 @@ export class AddDatabaseReferenceDialog {
|
||||
return inputBox;
|
||||
}
|
||||
|
||||
private createExampleUsage(): azdata.FormComponent {
|
||||
private createExampleUsage(): azdataType.FormComponent {
|
||||
this.exampleUsage = this.view!.modelBuilder.text().withProperties({
|
||||
value: this.currentReferenceType === ReferenceType.project ? constants.databaseNameRequiredVariableOptional : constants.systemDatabaseReferenceRequired,
|
||||
CSSStyles: { 'user-select': 'text' }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import type * as azdataType from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as constants from '../common/constants';
|
||||
import * as newProjectTool from '../tools/newProjectTool';
|
||||
@@ -15,19 +15,19 @@ import { cssStyles } from '../common/uiConstants';
|
||||
import { ImportDataModel } from '../models/api/import';
|
||||
import { Deferred } from '../common/promise';
|
||||
import { getConnectionName } from './utils';
|
||||
import { exists, isCurrentWorkspaceUntitled } from '../common/utils';
|
||||
import { exists, getAzdataApi, isCurrentWorkspaceUntitled } from '../common/utils';
|
||||
|
||||
export class CreateProjectFromDatabaseDialog {
|
||||
public dialog: azdata.window.Dialog;
|
||||
public createProjectFromDatabaseTab: azdata.window.DialogTab;
|
||||
public sourceConnectionTextBox: azdata.InputBoxComponent | undefined;
|
||||
private selectConnectionButton: azdata.ButtonComponent | undefined;
|
||||
public sourceDatabaseDropDown: azdata.DropDownComponent | undefined;
|
||||
public projectNameTextBox: azdata.InputBoxComponent | undefined;
|
||||
public projectLocationTextBox: azdata.InputBoxComponent | undefined;
|
||||
public folderStructureDropDown: azdata.DropDownComponent | undefined;
|
||||
public workspaceInputBox: azdata.InputBoxComponent | undefined;
|
||||
private formBuilder: azdata.FormBuilder | undefined;
|
||||
public dialog: azdataType.window.Dialog;
|
||||
public createProjectFromDatabaseTab: azdataType.window.DialogTab;
|
||||
public sourceConnectionTextBox: azdataType.InputBoxComponent | undefined;
|
||||
private selectConnectionButton: azdataType.ButtonComponent | undefined;
|
||||
public sourceDatabaseDropDown: azdataType.DropDownComponent | undefined;
|
||||
public projectNameTextBox: azdataType.InputBoxComponent | undefined;
|
||||
public projectLocationTextBox: azdataType.InputBoxComponent | undefined;
|
||||
public folderStructureDropDown: azdataType.DropDownComponent | undefined;
|
||||
public workspaceInputBox: azdataType.InputBoxComponent | undefined;
|
||||
private formBuilder: azdataType.FormBuilder | undefined;
|
||||
private connectionId: string | undefined;
|
||||
private toDispose: vscode.Disposable[] = [];
|
||||
private initDialogComplete!: Deferred<void>;
|
||||
@@ -35,9 +35,9 @@ export class CreateProjectFromDatabaseDialog {
|
||||
|
||||
public createProjectFromDatabaseCallback: ((model: ImportDataModel) => any) | undefined;
|
||||
|
||||
constructor(private profile: azdata.IConnectionProfile | undefined) {
|
||||
this.dialog = azdata.window.createModelViewDialog(constants.createProjectFromDatabaseDialogName, 'createProjectFromDatabaseDialog');
|
||||
this.createProjectFromDatabaseTab = azdata.window.createTab(constants.createProjectFromDatabaseDialogName);
|
||||
constructor(private profile: azdataType.IConnectionProfile | undefined) {
|
||||
this.dialog = getAzdataApi()!.window.createModelViewDialog(constants.createProjectFromDatabaseDialogName, 'createProjectFromDatabaseDialog');
|
||||
this.createProjectFromDatabaseTab = getAzdataApi()!.window.createTab(constants.createProjectFromDatabaseDialogName);
|
||||
this.dialog.registerCloseValidator(async () => {
|
||||
return this.validate();
|
||||
});
|
||||
@@ -51,7 +51,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
|
||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
||||
|
||||
azdata.window.openDialog(this.dialog);
|
||||
getAzdataApi()!.window.openDialog(this.dialog);
|
||||
await this.initDialogPromise;
|
||||
|
||||
if (this.profile) {
|
||||
@@ -91,7 +91,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
const createworkspaceContainerFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
|
||||
createworkspaceContainerFormSection.addItems([workspaceContainerRow]);
|
||||
|
||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
||||
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
{
|
||||
title: constants.sourceDatabase,
|
||||
@@ -141,11 +141,11 @@ export class CreateProjectFromDatabaseDialog {
|
||||
});
|
||||
}
|
||||
|
||||
private createConnectionRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createConnectionRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
const sourceConnectionTextBox = this.createSourceConnectionComponent(view);
|
||||
const selectConnectionButton: azdata.Component = this.createSelectConnectionButton(view);
|
||||
const selectConnectionButton: azdataType.Component = this.createSelectConnectionButton(view);
|
||||
|
||||
const serverLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const serverLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.server,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||
@@ -157,7 +157,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
return connectionRow;
|
||||
}
|
||||
|
||||
private createDatabaseRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createDatabaseRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
this.sourceDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
||||
ariaLabel: constants.databaseNameLabel,
|
||||
required: true,
|
||||
@@ -170,13 +170,13 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.tryEnableCreateButton();
|
||||
});
|
||||
|
||||
const databaseLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const databaseLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.databaseNameLabel,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||
}).component();
|
||||
|
||||
const databaseRow = view.modelBuilder.flexContainer().withItems([databaseLabel, <azdata.DropDownComponent>this.sourceDatabaseDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px', 'margin-bottom': '-10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
const databaseRow = view.modelBuilder.flexContainer().withItems([databaseLabel, <azdataType.DropDownComponent>this.sourceDatabaseDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px', 'margin-bottom': '-10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
|
||||
return databaseRow;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.projectNameTextBox!.value = newProjectTool.defaultProjectNameFromDb(<string>this.sourceDatabaseDropDown!.value);
|
||||
}
|
||||
|
||||
private createSourceConnectionComponent(view: azdata.ModelView): azdata.InputBoxComponent {
|
||||
private createSourceConnectionComponent(view: azdataType.ModelView): azdataType.InputBoxComponent {
|
||||
this.sourceConnectionTextBox = view.modelBuilder.inputBox().withProperties({
|
||||
value: '',
|
||||
placeHolder: constants.selectConnection,
|
||||
@@ -200,7 +200,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
return this.sourceConnectionTextBox;
|
||||
}
|
||||
|
||||
private createSelectConnectionButton(view: azdata.ModelView): azdata.Component {
|
||||
private createSelectConnectionButton(view: azdataType.ModelView): azdataType.Component {
|
||||
this.selectConnectionButton = view.modelBuilder.button().withProperties({
|
||||
ariaLabel: constants.selectConnection,
|
||||
iconPath: IconPathHelper.selectConnection,
|
||||
@@ -209,7 +209,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
}).component();
|
||||
|
||||
this.selectConnectionButton.onDidClick(async () => {
|
||||
let connection = await azdata.connection.openConnectionDialog();
|
||||
let connection = await getAzdataApi()!.connection.openConnectionDialog();
|
||||
this.connectionId = connection.connectionId;
|
||||
|
||||
let connectionTextboxValue: string;
|
||||
@@ -230,7 +230,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.sourceDatabaseDropDown!.loading = true;
|
||||
let databaseValues;
|
||||
try {
|
||||
databaseValues = (await azdata.connection.listDatabases(connectionId))
|
||||
databaseValues = (await getAzdataApi()!.connection.listDatabases(connectionId))
|
||||
// filter out system dbs
|
||||
.filter(db => !constants.systemDbs.includes(db));
|
||||
} catch (e) {
|
||||
@@ -253,8 +253,8 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.selectConnectionButton!.iconPath = IconPathHelper.connect;
|
||||
}
|
||||
|
||||
private createProjectNameRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
this.projectNameTextBox = view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
||||
private createProjectNameRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
this.projectNameTextBox = view.modelBuilder.inputBox().withProperties<azdataType.InputBoxProperties>({
|
||||
ariaLabel: constants.projectNamePlaceholderText,
|
||||
placeHolder: constants.projectNamePlaceholderText,
|
||||
required: true,
|
||||
@@ -268,7 +268,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.tryEnableCreateButton();
|
||||
});
|
||||
|
||||
const projectNameLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const projectNameLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.projectNameLabel,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||
@@ -279,8 +279,8 @@ export class CreateProjectFromDatabaseDialog {
|
||||
return projectNameRow;
|
||||
}
|
||||
|
||||
private createProjectLocationRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
const browseFolderButton: azdata.Component = this.createBrowseFolderButton(view);
|
||||
private createProjectLocationRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
const browseFolderButton: azdataType.Component = this.createBrowseFolderButton(view);
|
||||
|
||||
this.projectLocationTextBox = view.modelBuilder.inputBox().withProperties({
|
||||
value: '',
|
||||
@@ -295,7 +295,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.tryEnableCreateButton();
|
||||
});
|
||||
|
||||
const projectLocationLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const projectLocationLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.projectLocationLabel,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||
@@ -307,8 +307,8 @@ export class CreateProjectFromDatabaseDialog {
|
||||
return projectLocationRow;
|
||||
}
|
||||
|
||||
private createBrowseFolderButton(view: azdata.ModelView): azdata.ButtonComponent {
|
||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
private createBrowseFolderButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdataType.ButtonProperties>({
|
||||
ariaLabel: constants.browseButtonText,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
height: '18px',
|
||||
@@ -335,7 +335,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
return browseFolderButton;
|
||||
}
|
||||
|
||||
private createFolderStructureRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createFolderStructureRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
this.folderStructureDropDown = view.modelBuilder.dropDown().withProperties({
|
||||
values: [constants.file, constants.flat, constants.objectType, constants.schema, constants.schemaObjectType],
|
||||
value: constants.schemaObjectType,
|
||||
@@ -348,13 +348,13 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.tryEnableCreateButton();
|
||||
});
|
||||
|
||||
const folderStructureLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const folderStructureLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.folderStructureLabel,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||
}).component();
|
||||
|
||||
const folderStructureRow = view.modelBuilder.flexContainer().withItems([folderStructureLabel, <azdata.DropDownComponent>this.folderStructureDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px', 'margin-top': '-10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
const folderStructureRow = view.modelBuilder.flexContainer().withItems([folderStructureLabel, <azdataType.DropDownComponent>this.folderStructureDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px', 'margin-top': '-10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
|
||||
return folderStructureRow;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
* created if no workspace is currently open
|
||||
* @param view
|
||||
*/
|
||||
private createWorkspaceContainerRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createWorkspaceContainerRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
const initialWorkspaceInputBoxValue = !!vscode.workspace.workspaceFile && !isCurrentWorkspaceUntitled() ? vscode.workspace.workspaceFile.fsPath : '';
|
||||
|
||||
this.workspaceInputBox = view.modelBuilder.inputBox().withProperties({
|
||||
@@ -375,7 +375,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
width: '100%'
|
||||
}).component();
|
||||
|
||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdataType.ButtonProperties>({
|
||||
ariaLabel: constants.browseButtonText,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
height: '16px',
|
||||
@@ -402,7 +402,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
this.workspaceInputBox!.title = selectedFile;
|
||||
}));
|
||||
|
||||
const workspaceLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const workspaceLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: vscode.workspace.workspaceFile ? constants.addProjectToCurrentWorkspace : constants.newWorkspaceWillBeCreated,
|
||||
CSSStyles: { 'margin-top': '-10px', 'margin-bottom': '5px' }
|
||||
}).component();
|
||||
@@ -454,7 +454,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
newWorkspaceFilePath: this.workspaceInputBox!.enabled ? vscode.Uri.file(this.workspaceInputBox!.value!) : undefined
|
||||
};
|
||||
|
||||
azdata.window.closeDialog(this.dialog);
|
||||
getAzdataApi()!.window.closeDialog(this.dialog);
|
||||
await this.createProjectFromDatabaseCallback!(model);
|
||||
|
||||
this.dispose();
|
||||
@@ -529,7 +529,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
protected showErrorMessage(message: string): void {
|
||||
this.dialog.message = {
|
||||
text: message,
|
||||
level: azdata.window.MessageLevel.Error
|
||||
level: getAzdataApi()!.window.MessageLevel.Error
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import type * as azdataType from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as constants from '../common/constants';
|
||||
import * as utils from '../common/utils';
|
||||
@@ -17,25 +17,25 @@ import { cssStyles } from '../common/uiConstants';
|
||||
import { getConnectionName } from './utils';
|
||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||
|
||||
interface DataSourceDropdownValue extends azdata.CategoryValue {
|
||||
interface DataSourceDropdownValue extends azdataType.CategoryValue {
|
||||
dataSource: SqlConnectionDataSource;
|
||||
database: string;
|
||||
}
|
||||
|
||||
export class PublishDatabaseDialog {
|
||||
public dialog: azdata.window.Dialog;
|
||||
public publishTab: azdata.window.DialogTab;
|
||||
private targetConnectionTextBox: azdata.InputBoxComponent | undefined;
|
||||
private dataSourcesFormComponent: azdata.FormComponent | undefined;
|
||||
private dataSourcesDropDown: azdata.DropDownComponent | undefined;
|
||||
private targetDatabaseDropDown: azdata.DropDownComponent | undefined;
|
||||
private connectionsRadioButton: azdata.RadioButtonComponent | undefined;
|
||||
private dataSourcesRadioButton: azdata.RadioButtonComponent | undefined;
|
||||
private sqlCmdVariablesTable: azdata.DeclarativeTableComponent | undefined;
|
||||
private sqlCmdVariablesFormComponentGroup: azdata.FormComponentGroup | undefined;
|
||||
private loadSqlCmdVarsButton: azdata.ButtonComponent | undefined;
|
||||
private loadProfileTextBox: azdata.InputBoxComponent | undefined;
|
||||
private formBuilder: azdata.FormBuilder | undefined;
|
||||
public dialog: azdataType.window.Dialog;
|
||||
public publishTab: azdataType.window.DialogTab;
|
||||
private targetConnectionTextBox: azdataType.InputBoxComponent | undefined;
|
||||
private dataSourcesFormComponent: azdataType.FormComponent | undefined;
|
||||
private dataSourcesDropDown: azdataType.DropDownComponent | undefined;
|
||||
private targetDatabaseDropDown: azdataType.DropDownComponent | undefined;
|
||||
private connectionsRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||
private dataSourcesRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||
private sqlCmdVariablesTable: azdataType.DeclarativeTableComponent | undefined;
|
||||
private sqlCmdVariablesFormComponentGroup: azdataType.FormComponentGroup | undefined;
|
||||
private loadSqlCmdVarsButton: azdataType.ButtonComponent | undefined;
|
||||
private loadProfileTextBox: azdataType.InputBoxComponent | undefined;
|
||||
private formBuilder: azdataType.FormBuilder | undefined;
|
||||
|
||||
private connectionId: string | undefined;
|
||||
private connectionIsDataSource: boolean | undefined;
|
||||
@@ -51,8 +51,8 @@ export class PublishDatabaseDialog {
|
||||
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
||||
|
||||
constructor(private project: Project) {
|
||||
this.dialog = azdata.window.createModelViewDialog(constants.publishDialogName, 'sqlProjectPublishDialog');
|
||||
this.publishTab = azdata.window.createTab(constants.publishDialogName);
|
||||
this.dialog = utils.getAzdataApi()!.window.createModelViewDialog(constants.publishDialogName, 'sqlProjectPublishDialog');
|
||||
this.publishTab = utils.getAzdataApi()!.window.createTab(constants.publishDialogName);
|
||||
}
|
||||
|
||||
public openDialog(): void {
|
||||
@@ -63,14 +63,14 @@ export class PublishDatabaseDialog {
|
||||
|
||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
||||
|
||||
let generateScriptButton: azdata.window.Button = azdata.window.createButton(constants.generateScriptButtonText);
|
||||
let generateScriptButton: azdataType.window.Button = utils.getAzdataApi()!.window.createButton(constants.generateScriptButtonText);
|
||||
this.toDispose.push(generateScriptButton.onClick(async () => await this.generateScriptClick()));
|
||||
generateScriptButton.enabled = false;
|
||||
|
||||
this.dialog.customButtons = [];
|
||||
this.dialog.customButtons.push(generateScriptButton);
|
||||
|
||||
azdata.window.openDialog(this.dialog);
|
||||
utils.getAzdataApi()!.window.openDialog(this.dialog);
|
||||
}
|
||||
|
||||
private dispose(): void {
|
||||
@@ -100,7 +100,7 @@ export class PublishDatabaseDialog {
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
component: <azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable
|
||||
component: <azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable
|
||||
}
|
||||
],
|
||||
title: constants.sqlCmdTableLabel
|
||||
@@ -114,7 +114,7 @@ export class PublishDatabaseDialog {
|
||||
horizontalFormSection.addItems([profileRow, connectionRow, databaseRow]);
|
||||
|
||||
|
||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
||||
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
{
|
||||
title: '',
|
||||
@@ -157,13 +157,13 @@ export class PublishDatabaseDialog {
|
||||
|
||||
if (this.connectionIsDataSource) {
|
||||
const dataSource = (this.dataSourcesDropDown!.value! as DataSourceDropdownValue).dataSource;
|
||||
const connProfile: azdata.IConnectionProfile = dataSource.getConnectionProfile();
|
||||
const connProfile: azdataType.IConnectionProfile = dataSource.getConnectionProfile();
|
||||
|
||||
if (dataSource.integratedSecurity) {
|
||||
connId = (await azdata.connection.connect(connProfile, false, false)).connectionId;
|
||||
connId = (await utils.getAzdataApi()!.connection.connect(connProfile, false, false)).connectionId;
|
||||
}
|
||||
else {
|
||||
connId = (await azdata.connection.openConnectionDialog(undefined, connProfile)).connectionId;
|
||||
connId = (await utils.getAzdataApi()!.connection.openConnectionDialog(undefined, connProfile)).connectionId;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -174,7 +174,7 @@ export class PublishDatabaseDialog {
|
||||
connId = this.connectionId;
|
||||
}
|
||||
|
||||
return await azdata.connection.getUriForConnection(connId);
|
||||
return await utils.getAzdataApi()!.connection.getUriForConnection(connId);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(constants.unableToCreatePublishConnection + ': ' + utils.getErrorMessage(err));
|
||||
@@ -192,7 +192,7 @@ export class PublishDatabaseDialog {
|
||||
profileUsed: this.profileUsed
|
||||
};
|
||||
|
||||
azdata.window.closeDialog(this.dialog);
|
||||
utils.getAzdataApi()!.window.closeDialog(this.dialog);
|
||||
await this.publish!(this.project, settings);
|
||||
|
||||
this.dispose();
|
||||
@@ -211,7 +211,7 @@ export class PublishDatabaseDialog {
|
||||
profileUsed: this.profileUsed
|
||||
};
|
||||
|
||||
azdata.window.closeDialog(this.dialog);
|
||||
utils.getAzdataApi()!.window.closeDialog(this.dialog);
|
||||
|
||||
if (this.generateScript) {
|
||||
await this.generateScript!(this.project, settings);
|
||||
@@ -256,7 +256,7 @@ export class PublishDatabaseDialog {
|
||||
return this.serverName!;
|
||||
}
|
||||
|
||||
private createRadioButtons(view: azdata.ModelView): azdata.Component {
|
||||
private createRadioButtons(view: azdataType.ModelView): azdataType.Component {
|
||||
this.connectionsRadioButton = view.modelBuilder.radioButton()
|
||||
.withProperties({
|
||||
name: 'connection',
|
||||
@@ -265,7 +265,7 @@ export class PublishDatabaseDialog {
|
||||
|
||||
this.connectionsRadioButton.checked = true;
|
||||
this.connectionsRadioButton.onDidClick(() => {
|
||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.dataSourcesFormComponent);
|
||||
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.dataSourcesFormComponent);
|
||||
// TODO: fix this when data sources are enabled again
|
||||
// this.formBuilder!.insertFormItem(<azdata.FormComponent>this.targetConnectionTextBox, 2);
|
||||
this.connectionIsDataSource = false;
|
||||
@@ -281,13 +281,13 @@ export class PublishDatabaseDialog {
|
||||
this.dataSourcesRadioButton.onDidClick(() => {
|
||||
// TODO: fix this when data sources are enabled again
|
||||
// this.formBuilder!.removeFormItem(<azdata.FormComponent>this.targetConnectionTextBox);
|
||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.dataSourcesFormComponent, 2);
|
||||
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.dataSourcesFormComponent, 2);
|
||||
this.connectionIsDataSource = true;
|
||||
|
||||
this.setDatabaseToSelectedDataSourceDatabase();
|
||||
});
|
||||
|
||||
let flexRadioButtonsModel: azdata.FlexContainer = view.modelBuilder.flexContainer()
|
||||
let flexRadioButtonsModel: azdataType.FlexContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ flexFlow: 'column' })
|
||||
.withItems([this.connectionsRadioButton, this.dataSourcesRadioButton])
|
||||
.withProperties({ ariaRole: 'radiogroup' })
|
||||
@@ -296,7 +296,7 @@ export class PublishDatabaseDialog {
|
||||
return flexRadioButtonsModel;
|
||||
}
|
||||
|
||||
private createTargetConnectionComponent(view: azdata.ModelView): azdata.InputBoxComponent {
|
||||
private createTargetConnectionComponent(view: azdataType.ModelView): azdataType.InputBoxComponent {
|
||||
this.targetConnectionTextBox = view.modelBuilder.inputBox().withProperties({
|
||||
value: '',
|
||||
ariaLabel: constants.targetConnectionLabel,
|
||||
@@ -312,7 +312,7 @@ export class PublishDatabaseDialog {
|
||||
return this.targetConnectionTextBox;
|
||||
}
|
||||
|
||||
private createDataSourcesFormComponent(view: azdata.ModelView): azdata.FormComponent {
|
||||
private createDataSourcesFormComponent(view: azdataType.ModelView): azdataType.FormComponent {
|
||||
if (this.project.dataSources.length > 0) {
|
||||
return this.createDataSourcesDropdown(view);
|
||||
} else {
|
||||
@@ -324,7 +324,7 @@ export class PublishDatabaseDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private createDataSourcesDropdown(view: azdata.ModelView): azdata.FormComponent {
|
||||
private createDataSourcesDropdown(view: azdataType.ModelView): azdataType.FormComponent {
|
||||
let dataSourcesValues: DataSourceDropdownValue[] = [];
|
||||
|
||||
this.project.dataSources.filter(d => d instanceof SqlConnectionDataSource).forEach(dataSource => {
|
||||
@@ -360,7 +360,7 @@ export class PublishDatabaseDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private createProfileRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createProfileRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
const loadProfileButton = this.createLoadProfileButton(view);
|
||||
this.loadProfileTextBox = view.modelBuilder.inputBox().withProperties({
|
||||
placeHolder: constants.loadProfilePlaceholderText,
|
||||
@@ -368,7 +368,7 @@ export class PublishDatabaseDialog {
|
||||
width: cssStyles.publishDialogTextboxWidth
|
||||
}).component();
|
||||
|
||||
const profileLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const profileLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.profile,
|
||||
width: cssStyles.publishDialogLabelWidth
|
||||
}).component();
|
||||
@@ -379,11 +379,11 @@ export class PublishDatabaseDialog {
|
||||
return profileRow;
|
||||
}
|
||||
|
||||
private createConnectionRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createConnectionRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
this.targetConnectionTextBox = this.createTargetConnectionComponent(view);
|
||||
const selectConnectionButton: azdata.Component = this.createSelectConnectionButton(view);
|
||||
const selectConnectionButton: azdataType.Component = this.createSelectConnectionButton(view);
|
||||
|
||||
const serverLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const serverLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.server,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.publishDialogLabelWidth
|
||||
@@ -395,7 +395,7 @@ export class PublishDatabaseDialog {
|
||||
return connectionRow;
|
||||
}
|
||||
|
||||
private createDatabaseRow(view: azdata.ModelView): azdata.FlexContainer {
|
||||
private createDatabaseRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||
this.targetDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
||||
values: [this.getDefaultDatabaseName()],
|
||||
value: this.getDefaultDatabaseName(),
|
||||
@@ -410,27 +410,27 @@ export class PublishDatabaseDialog {
|
||||
this.tryEnableGenerateScriptAndOkButtons();
|
||||
});
|
||||
|
||||
const databaseLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
const databaseLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||
value: constants.databaseNameLabel,
|
||||
requiredIndicator: true,
|
||||
width: cssStyles.publishDialogLabelWidth
|
||||
}).component();
|
||||
|
||||
const databaseRow = view.modelBuilder.flexContainer().withItems([databaseLabel, <azdata.DropDownComponent>this.targetDatabaseDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
const databaseRow = view.modelBuilder.flexContainer().withItems([databaseLabel, <azdataType.DropDownComponent>this.targetDatabaseDropDown], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
|
||||
return databaseRow;
|
||||
}
|
||||
|
||||
private createSqlCmdTable(view: azdata.ModelView): azdata.DeclarativeTableComponent {
|
||||
private createSqlCmdTable(view: azdataType.ModelView): azdataType.DeclarativeTableComponent {
|
||||
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
||||
|
||||
const table = view.modelBuilder.declarativeTable().withProperties<azdata.DeclarativeTableProperties>({
|
||||
const table = view.modelBuilder.declarativeTable().withProperties<azdataType.DeclarativeTableProperties>({
|
||||
ariaLabel: constants.sqlCmdTableLabel,
|
||||
dataValues: this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars),
|
||||
columns: [
|
||||
{
|
||||
displayName: constants.sqlCmdVariableColumn,
|
||||
valueType: azdata.DeclarativeDataType.string,
|
||||
valueType: utils.getAzdataApi()!.DeclarativeDataType.string,
|
||||
width: '50%',
|
||||
isReadOnly: true,
|
||||
headerCssStyles: cssStyles.tableHeader,
|
||||
@@ -438,7 +438,7 @@ export class PublishDatabaseDialog {
|
||||
},
|
||||
{
|
||||
displayName: constants.sqlCmdValueColumn,
|
||||
valueType: azdata.DeclarativeDataType.string,
|
||||
valueType: utils.getAzdataApi()!.DeclarativeDataType.string,
|
||||
width: '50%',
|
||||
isReadOnly: false,
|
||||
headerCssStyles: cssStyles.tableHeader,
|
||||
@@ -459,8 +459,8 @@ export class PublishDatabaseDialog {
|
||||
return table;
|
||||
}
|
||||
|
||||
private createLoadSqlCmdVarsButton(view: azdata.ModelView): azdata.ButtonComponent {
|
||||
let loadSqlCmdVarsButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
private createLoadSqlCmdVarsButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||
let loadSqlCmdVarsButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
label: constants.loadSqlCmdVarsButtonTitle,
|
||||
title: constants.loadSqlCmdVarsButtonTitle,
|
||||
ariaLabel: constants.loadSqlCmdVarsButtonTitle,
|
||||
@@ -474,7 +474,7 @@ export class PublishDatabaseDialog {
|
||||
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
||||
|
||||
const data = this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars!);
|
||||
(<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable)!.updateProperties({
|
||||
(<azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable)!.updateProperties({
|
||||
dataValues: data
|
||||
});
|
||||
|
||||
@@ -484,8 +484,8 @@ export class PublishDatabaseDialog {
|
||||
return loadSqlCmdVarsButton;
|
||||
}
|
||||
|
||||
private createSelectConnectionButton(view: azdata.ModelView): azdata.Component {
|
||||
let selectConnectionButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
private createSelectConnectionButton(view: azdataType.ModelView): azdataType.Component {
|
||||
let selectConnectionButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
ariaLabel: constants.selectConnection,
|
||||
iconPath: IconPathHelper.selectConnection,
|
||||
height: '16px',
|
||||
@@ -493,7 +493,7 @@ export class PublishDatabaseDialog {
|
||||
}).component();
|
||||
|
||||
selectConnectionButton.onDidClick(async () => {
|
||||
let connection = await azdata.connection.openConnectionDialog();
|
||||
let connection = await utils.getAzdataApi()!.connection.openConnectionDialog();
|
||||
this.connectionId = connection.connectionId;
|
||||
this.serverName = connection.options['server'];
|
||||
|
||||
@@ -519,7 +519,7 @@ export class PublishDatabaseDialog {
|
||||
|
||||
// populate database dropdown with the databases for this connection
|
||||
if (connectionId) {
|
||||
const databaseValues = (await azdata.connection.listDatabases(connectionId))
|
||||
const databaseValues = (await utils.getAzdataApi()!.connection.listDatabases(connectionId))
|
||||
// filter out system dbs
|
||||
.filter(db => !constants.systemDbs.includes(db));
|
||||
|
||||
@@ -527,8 +527,8 @@ export class PublishDatabaseDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private createLoadProfileButton(view: azdata.ModelView): azdata.ButtonComponent {
|
||||
let loadProfileButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
private createLoadProfileButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||
let loadProfileButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||
ariaLabel: constants.loadProfilePlaceholderText,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
height: '18px',
|
||||
@@ -555,7 +555,7 @@ export class PublishDatabaseDialog {
|
||||
if (this.readPublishProfile) {
|
||||
const result = await this.readPublishProfile(fileUris[0]);
|
||||
// clear out old database dropdown values. They'll get populated later if there was a connection specified in the profile
|
||||
(<azdata.DropDownComponent>this.targetDatabaseDropDown).values = [];
|
||||
(<azdataType.DropDownComponent>this.targetDatabaseDropDown).values = [];
|
||||
|
||||
this.connectionId = result.connectionId;
|
||||
this.serverName = result.serverName;
|
||||
@@ -573,18 +573,18 @@ export class PublishDatabaseDialog {
|
||||
this.deploymentOptions = result.options;
|
||||
|
||||
const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForPublish());
|
||||
await (<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable).updateProperties({
|
||||
await (<azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable).updateProperties({
|
||||
dataValues: data
|
||||
});
|
||||
|
||||
if (Object.keys(result.sqlCmdVariables).length) {
|
||||
// add SQLCMD Variables table if it wasn't there before
|
||||
if (Object.keys(this.project.sqlCmdVariables).length === 0) {
|
||||
this.formBuilder?.addFormItem(<azdata.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
|
||||
this.formBuilder?.addFormItem(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
|
||||
}
|
||||
} else if (Object.keys(this.project.sqlCmdVariables).length === 0) {
|
||||
// remove the table if there are no SQLCMD variables in the project and loaded profile
|
||||
this.formBuilder?.removeFormItem(<azdata.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
|
||||
this.formBuilder?.removeFormItem(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
|
||||
}
|
||||
|
||||
// show file path in text box and hover text
|
||||
@@ -596,7 +596,7 @@ export class PublishDatabaseDialog {
|
||||
return loadProfileButton;
|
||||
}
|
||||
|
||||
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdata.DeclarativeTableCellValue[][] {
|
||||
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdataType.DeclarativeTableCellValue[][] {
|
||||
let data = [];
|
||||
for (let key in sqlCmdVars) {
|
||||
data.push([{ value: key }, { value: sqlCmdVars[key] }]);
|
||||
|
||||
Reference in New Issue
Block a user