mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -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:
@@ -369,7 +369,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/xml-formatter": "^1.1.0",
|
"@types/xml-formatter": "^1.1.0",
|
||||||
"@microsoft/ads-extension-telemetry": "^1.1.3",
|
"@microsoft/ads-extension-telemetry": "^1.1.5",
|
||||||
"fast-glob": "^3.1.0",
|
"fast-glob": "^3.1.0",
|
||||||
"promisify-child-process": "^3.1.1",
|
"promisify-child-process": "^3.1.1",
|
||||||
"vscode-languageclient": "^5.3.0-next.1",
|
"vscode-languageclient": "^5.3.0-next.1",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as azdata from 'azdata';
|
import type * as azdataType from 'azdata';
|
||||||
|
|
||||||
export interface IconPath {
|
export interface IconPath {
|
||||||
dark: string;
|
dark: string;
|
||||||
@@ -40,7 +40,7 @@ export class IconPathHelper {
|
|||||||
public static error: IconPath;
|
public static error: IconPath;
|
||||||
public static inProgress: IconPath;
|
public static inProgress: IconPath;
|
||||||
|
|
||||||
public static dashboardSqlProj: azdata.ThemedIconPath;
|
public static dashboardSqlProj: azdataType.ThemedIconPath;
|
||||||
|
|
||||||
public static setExtensionContext(extensionContext: vscode.ExtensionContext) {
|
public static setExtensionContext(extensionContext: vscode.ExtensionContext) {
|
||||||
IconPathHelper.extensionContext = extensionContext;
|
IconPathHelper.extensionContext = extensionContext;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import type * as azdataType from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as constants from './constants';
|
import * as constants from './constants';
|
||||||
@@ -324,3 +325,20 @@ export function timeConversion(duration: number): string {
|
|||||||
|
|
||||||
return portions.join(', ');
|
return portions.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to load the azdata API - but gracefully handle the failure in case we're running
|
||||||
|
// in a context where the API doesn't exist (such as VS Code)
|
||||||
|
let azdataApi: typeof azdataType | undefined = undefined;
|
||||||
|
try {
|
||||||
|
azdataApi = require('azdata');
|
||||||
|
} catch {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the azdata API if it's available in the context this extension is running in.
|
||||||
|
* @returns The azdata API if it's available
|
||||||
|
*/
|
||||||
|
export function getAzdataApi(): typeof azdataType | undefined {
|
||||||
|
return azdataApi;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* 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 vscode from 'vscode';
|
||||||
import * as templates from '../templates/templates';
|
import * as templates from '../templates/templates';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@@ -49,7 +49,7 @@ export default class MainController implements vscode.Disposable {
|
|||||||
vscode.commands.registerCommand('sqlDatabaseProjects.build', async (node: WorkspaceTreeItem) => { await this.projectsController.buildProject(node); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.build', async (node: WorkspaceTreeItem) => { await this.projectsController.buildProject(node); });
|
||||||
vscode.commands.registerCommand('sqlDatabaseProjects.publish', async (node: WorkspaceTreeItem) => { await this.projectsController.publishProject(node); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.publish', async (node: WorkspaceTreeItem) => { await this.projectsController.publishProject(node); });
|
||||||
vscode.commands.registerCommand('sqlDatabaseProjects.schemaCompare', async (node: WorkspaceTreeItem) => { await this.projectsController.schemaCompare(node); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.schemaCompare', async (node: WorkspaceTreeItem) => { await this.projectsController.schemaCompare(node); });
|
||||||
vscode.commands.registerCommand('sqlDatabaseProjects.createProjectFromDatabase', async (profile: azdata.IConnectionProfile) => { await this.projectsController.createProjectFromDatabase(profile); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.createProjectFromDatabase', async (profile: azdataType.IConnectionProfile) => { await this.projectsController.createProjectFromDatabase(profile); });
|
||||||
|
|
||||||
vscode.commands.registerCommand('sqlDatabaseProjects.newScript', async (node: WorkspaceTreeItem) => { await this.projectsController.addItemPromptFromNode(node, templates.script); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.newScript', async (node: WorkspaceTreeItem) => { await this.projectsController.addItemPromptFromNode(node, templates.script); });
|
||||||
vscode.commands.registerCommand('sqlDatabaseProjects.newPreDeploymentScript', async (node: WorkspaceTreeItem) => { await this.projectsController.addItemPromptFromNode(node, templates.preDeployScript); });
|
vscode.commands.registerCommand('sqlDatabaseProjects.newPreDeploymentScript', async (node: WorkspaceTreeItem) => { await this.projectsController.addItemPromptFromNode(node, templates.preDeployScript); });
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import * as utils from '../common/utils';
|
|||||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||||
import * as templates from '../templates/templates';
|
import * as templates from '../templates/templates';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as azdata from 'azdata';
|
import type * as azdataType from 'azdata';
|
||||||
import * as dataworkspace from 'dataworkspace';
|
import * as dataworkspace from 'dataworkspace';
|
||||||
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
@@ -57,7 +57,7 @@ export class ProjectsController {
|
|||||||
|
|
||||||
for (let i = this.publishInfo.length - 1; i >= 0; i--) {
|
for (let i = this.publishInfo.length - 1; i >= 0; i--) {
|
||||||
if (this.publishInfo[i].projectFile === projectFile) {
|
if (this.publishInfo[i].projectFile === projectFile) {
|
||||||
let icon: azdata.IconPath;
|
let icon: azdataType.IconPath;
|
||||||
let text: string;
|
let text: string;
|
||||||
if (this.publishInfo[i].status === Status.success) {
|
if (this.publishInfo[i].status === Status.success) {
|
||||||
icon = IconPathHelper.success;
|
icon = IconPathHelper.success;
|
||||||
@@ -88,7 +88,7 @@ export class ProjectsController {
|
|||||||
|
|
||||||
for (let i = this.buildInfo.length - 1; i >= 0; i--) {
|
for (let i = this.buildInfo.length - 1; i >= 0; i--) {
|
||||||
if (this.buildInfo[i].projectFile === projectFile) {
|
if (this.buildInfo[i].projectFile === projectFile) {
|
||||||
let icon: azdata.IconPath;
|
let icon: azdataType.IconPath;
|
||||||
let text: string;
|
let text: string;
|
||||||
if (this.buildInfo[i].status === Status.success) {
|
if (this.buildInfo[i].status === Status.success) {
|
||||||
icon = IconPathHelper.success;
|
icon = IconPathHelper.success;
|
||||||
@@ -286,11 +286,11 @@ export class ProjectsController {
|
|||||||
try {
|
try {
|
||||||
if ((<IPublishSettings>settings).upgradeExisting) {
|
if ((<IPublishSettings>settings).upgradeExisting) {
|
||||||
telemetryProps.publishAction = 'deploy';
|
telemetryProps.publishAction = 'deploy';
|
||||||
result = await dacFxService.deployDacpac(tempPath, settings.databaseName, (<IPublishSettings>settings).upgradeExisting, settings.connectionUri, azdata.TaskExecutionMode.execute, settings.sqlCmdVariables, settings.deploymentOptions);
|
result = await dacFxService.deployDacpac(tempPath, settings.databaseName, (<IPublishSettings>settings).upgradeExisting, settings.connectionUri, utils.getAzdataApi()!.TaskExecutionMode.execute, settings.sqlCmdVariables, settings.deploymentOptions);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
telemetryProps.publishAction = 'generateScript';
|
telemetryProps.publishAction = 'generateScript';
|
||||||
result = await dacFxService.generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, azdata.TaskExecutionMode.script, settings.sqlCmdVariables, settings.deploymentOptions);
|
result = await dacFxService.generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, utils.getAzdataApi()!.TaskExecutionMode.script, settings.sqlCmdVariables, settings.deploymentOptions);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const actionEndTime = new Date().getTime();
|
const actionEndTime = new Date().getTime();
|
||||||
@@ -842,7 +842,7 @@ export class ProjectsController {
|
|||||||
* Creates a new SQL database project from the existing database,
|
* Creates a new SQL database project from the existing database,
|
||||||
* prompting the user for a name, file path location and extract target
|
* prompting the user for a name, file path location and extract target
|
||||||
*/
|
*/
|
||||||
public async createProjectFromDatabase(context: azdata.IConnectionProfile | any): Promise<CreateProjectFromDatabaseDialog> {
|
public async createProjectFromDatabase(context: azdataType.IConnectionProfile | any): Promise<CreateProjectFromDatabaseDialog> {
|
||||||
const profile = this.getConnectionProfileFromContext(context);
|
const profile = this.getConnectionProfileFromContext(context);
|
||||||
let createProjectFromDatabaseDialog = this.getCreateProjectFromDatabaseDialog(profile);
|
let createProjectFromDatabaseDialog = this.getCreateProjectFromDatabaseDialog(profile);
|
||||||
|
|
||||||
@@ -853,7 +853,7 @@ export class ProjectsController {
|
|||||||
return createProjectFromDatabaseDialog;
|
return createProjectFromDatabaseDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCreateProjectFromDatabaseDialog(profile: azdata.IConnectionProfile | undefined): CreateProjectFromDatabaseDialog {
|
public getCreateProjectFromDatabaseDialog(profile: azdataType.IConnectionProfile | undefined): CreateProjectFromDatabaseDialog {
|
||||||
return new CreateProjectFromDatabaseDialog(profile);
|
return new CreateProjectFromDatabaseDialog(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -895,7 +895,7 @@ export class ProjectsController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getConnectionProfileFromContext(context: azdata.IConnectionProfile | any): azdata.IConnectionProfile | undefined {
|
private getConnectionProfileFromContext(context: azdataType.IConnectionProfile | any): azdataType.IConnectionProfile | undefined {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -909,9 +909,9 @@ export class ProjectsController {
|
|||||||
let ext = vscode.extensions.getExtension(mssql.extension.name)!;
|
let ext = vscode.extensions.getExtension(mssql.extension.name)!;
|
||||||
|
|
||||||
const service = (await ext.activate() as mssql.IExtension).dacFx;
|
const service = (await ext.activate() as mssql.IExtension).dacFx;
|
||||||
const ownerUri = await azdata.connection.getUriForConnection(model.serverId);
|
const ownerUri = await utils.getAzdataApi()!.connection.getUriForConnection(model.serverId);
|
||||||
|
|
||||||
await service.createProjectFromDatabase(model.database, model.filePath, model.projName, model.version, ownerUri, model.extractTarget, azdata.TaskExecutionMode.execute);
|
await service.createProjectFromDatabase(model.database, model.filePath, model.projName, model.version, ownerUri, model.extractTarget, utils.getAzdataApi()!.TaskExecutionMode.execute);
|
||||||
|
|
||||||
// TODO: Check for success; throw error
|
// TODO: Check for success; throw error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* 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 vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as constants from '../common/constants';
|
import * as constants from '../common/constants';
|
||||||
@@ -23,25 +23,25 @@ export enum ReferenceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class AddDatabaseReferenceDialog {
|
export class AddDatabaseReferenceDialog {
|
||||||
public dialog: azdata.window.Dialog;
|
public dialog: azdataType.window.Dialog;
|
||||||
public addDatabaseReferenceTab: azdata.window.DialogTab;
|
public addDatabaseReferenceTab: azdataType.window.DialogTab;
|
||||||
private view: azdata.ModelView | undefined;
|
private view: azdataType.ModelView | undefined;
|
||||||
private formBuilder: azdata.FormBuilder | undefined;
|
private formBuilder: azdataType.FormBuilder | undefined;
|
||||||
private projectDropdown: azdata.DropDownComponent | undefined;
|
private projectDropdown: azdataType.DropDownComponent | undefined;
|
||||||
private projectFormComponent: azdata.FormComponent | undefined;
|
private projectFormComponent: azdataType.FormComponent | undefined;
|
||||||
private systemDatabaseDropdown: azdata.DropDownComponent | undefined;
|
private systemDatabaseDropdown: azdataType.DropDownComponent | undefined;
|
||||||
private systemDatabaseFormComponent: azdata.FormComponent | undefined;
|
private systemDatabaseFormComponent: azdataType.FormComponent | undefined;
|
||||||
public dacpacTextbox: azdata.InputBoxComponent | undefined;
|
public dacpacTextbox: azdataType.InputBoxComponent | undefined;
|
||||||
private dacpacFormComponent: azdata.FormComponent | undefined;
|
private dacpacFormComponent: azdataType.FormComponent | undefined;
|
||||||
public locationDropdown: azdata.DropDownComponent | undefined;
|
public locationDropdown: azdataType.DropDownComponent | undefined;
|
||||||
public databaseNameTextbox: azdata.InputBoxComponent | undefined;
|
public databaseNameTextbox: azdataType.InputBoxComponent | undefined;
|
||||||
public databaseVariableTextbox: azdata.InputBoxComponent | undefined;
|
public databaseVariableTextbox: azdataType.InputBoxComponent | undefined;
|
||||||
public serverNameTextbox: azdata.InputBoxComponent | undefined;
|
public serverNameTextbox: azdataType.InputBoxComponent | undefined;
|
||||||
public serverVariableTextbox: azdata.InputBoxComponent | undefined;
|
public serverVariableTextbox: azdataType.InputBoxComponent | undefined;
|
||||||
public suppressMissingDependenciesErrorsCheckbox: azdata.CheckBoxComponent | undefined;
|
public suppressMissingDependenciesErrorsCheckbox: azdataType.CheckBoxComponent | undefined;
|
||||||
public exampleUsage: azdata.TextComponent | undefined;
|
public exampleUsage: azdataType.TextComponent | undefined;
|
||||||
private projectRadioButton: azdata.RadioButtonComponent | undefined;
|
private projectRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
private systemDatabaseRadioButton: azdata.RadioButtonComponent | undefined;
|
private systemDatabaseRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
|
|
||||||
public currentReferenceType: ReferenceType | undefined;
|
public currentReferenceType: ReferenceType | undefined;
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ export class AddDatabaseReferenceDialog {
|
|||||||
public addReference: ((proj: Project, settings: ISystemDatabaseReferenceSettings | IDacpacReferenceSettings | IProjectReferenceSettings) => any) | undefined;
|
public addReference: ((proj: Project, settings: ISystemDatabaseReferenceSettings | IDacpacReferenceSettings | IProjectReferenceSettings) => any) | undefined;
|
||||||
|
|
||||||
constructor(private project: Project) {
|
constructor(private project: Project) {
|
||||||
this.dialog = azdata.window.createModelViewDialog(constants.addDatabaseReferenceDialogName, 'addDatabaseReferencesDialog');
|
this.dialog = utils.getAzdataApi()!.window.createModelViewDialog(constants.addDatabaseReferenceDialogName, 'addDatabaseReferencesDialog');
|
||||||
this.addDatabaseReferenceTab = azdata.window.createTab(constants.addDatabaseReferenceDialogName);
|
this.addDatabaseReferenceTab = utils.getAzdataApi()!.window.createTab(constants.addDatabaseReferenceDialogName);
|
||||||
this.dialog.registerCloseValidator(async () => {
|
this.dialog.registerCloseValidator(async () => {
|
||||||
return this.validate();
|
return this.validate();
|
||||||
});
|
});
|
||||||
@@ -68,7 +68,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
if (projectDrive !== dacpacDrive) {
|
if (projectDrive !== dacpacDrive) {
|
||||||
this.dialog.message = {
|
this.dialog.message = {
|
||||||
text: constants.dacpacNotOnSameDrive(this.project.projectFilePath),
|
text: constants.dacpacNotOnSameDrive(this.project.projectFilePath),
|
||||||
level: azdata.window.MessageLevel.Error
|
level: utils.getAzdataApi()!.window.MessageLevel.Error
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
this.dialog.cancelButton.label = constants.cancelButtonText;
|
||||||
|
|
||||||
azdata.window.openDialog(this.dialog);
|
utils.getAzdataApi()!.window.openDialog(this.dialog);
|
||||||
await this.initDialogPromise;
|
await this.initDialogPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}).component();
|
}).component();
|
||||||
const exampleUsage = this.createExampleUsage();
|
const exampleUsage = this.createExampleUsage();
|
||||||
|
|
||||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||||
.withFormItems([
|
.withFormItems([
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
@@ -188,7 +188,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private createRadioButtons(): azdata.FormComponent {
|
private createRadioButtons(): azdataType.FormComponent {
|
||||||
this.projectRadioButton = this.view!.modelBuilder.radioButton()
|
this.projectRadioButton = this.view!.modelBuilder.radioButton()
|
||||||
.withProperties({
|
.withProperties({
|
||||||
name: 'referenceType',
|
name: 'referenceType',
|
||||||
@@ -230,7 +230,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
this.projectRadioButton.enabled = false;
|
this.projectRadioButton.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let flexRadioButtonsModel: azdata.FlexContainer = this.view!.modelBuilder.flexContainer()
|
let flexRadioButtonsModel: azdataType.FlexContainer = this.view!.modelBuilder.flexContainer()
|
||||||
.withLayout({ flexFlow: 'column' })
|
.withLayout({ flexFlow: 'column' })
|
||||||
.withItems([this.projectRadioButton, this.systemDatabaseRadioButton, dacpacRadioButton])
|
.withItems([this.projectRadioButton, this.systemDatabaseRadioButton, dacpacRadioButton])
|
||||||
.withProperties({ ariaRole: 'radiogroup' })
|
.withProperties({ ariaRole: 'radiogroup' })
|
||||||
@@ -243,9 +243,9 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public projectRadioButtonClick(): void {
|
public projectRadioButtonClick(): void {
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.dacpacFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.dacpacFormComponent);
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.systemDatabaseFormComponent);
|
||||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.projectFormComponent, 2);
|
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.projectFormComponent, 2);
|
||||||
|
|
||||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||||
|
|
||||||
@@ -256,9 +256,9 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public systemDbRadioButtonClick(): void {
|
public systemDbRadioButtonClick(): void {
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.dacpacFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.dacpacFormComponent);
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.projectFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.projectFormComponent);
|
||||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent, 2);
|
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
|
// update dropdown values because only different database, same server is a valid location for system db references
|
||||||
this.locationDropdown!.values = constants.systemDbLocationDropdownValues;
|
this.locationDropdown!.values = constants.systemDbLocationDropdownValues;
|
||||||
@@ -271,9 +271,9 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public dacpacRadioButtonClick(): void {
|
public dacpacRadioButtonClick(): void {
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.systemDatabaseFormComponent);
|
||||||
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.projectFormComponent);
|
this.formBuilder!.removeFormItem(<azdataType.FormComponent>this.projectFormComponent);
|
||||||
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.dacpacFormComponent, 2);
|
this.formBuilder!.insertFormItem(<azdataType.FormComponent>this.dacpacFormComponent, 2);
|
||||||
|
|
||||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
this.updateExampleUsage();
|
this.updateExampleUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createProjectDropdown(): Promise<azdata.FormComponent> {
|
private async createProjectDropdown(): Promise<azdataType.FormComponent> {
|
||||||
this.projectDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
this.projectDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||||
ariaLabel: constants.databaseProject
|
ariaLabel: constants.databaseProject
|
||||||
}).component();
|
}).component();
|
||||||
@@ -305,7 +305,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSystemDatabaseDropdown(): azdata.FormComponent {
|
private createSystemDatabaseDropdown(): azdataType.FormComponent {
|
||||||
this.systemDatabaseDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
this.systemDatabaseDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||||
values: [constants.master, constants.msdb],
|
values: [constants.master, constants.msdb],
|
||||||
ariaLabel: constants.databaseNameLabel
|
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({
|
this.dacpacTextbox = this.view!.modelBuilder.inputBox().withProperties({
|
||||||
ariaLabel: constants.dacpacText,
|
ariaLabel: constants.dacpacText,
|
||||||
placeHolder: constants.dacpacPlaceholder,
|
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({
|
const loadDacpacButton = this.view!.modelBuilder.button().withProperties({
|
||||||
ariaLabel: constants.loadDacpacButton,
|
ariaLabel: constants.loadDacpacButton,
|
||||||
iconPath: IconPathHelper.folder_blue,
|
iconPath: IconPathHelper.folder_blue,
|
||||||
@@ -381,7 +381,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
return loadDacpacButton;
|
return loadDacpacButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createLocationDropdown(): azdata.FormComponent {
|
private createLocationDropdown(): azdataType.FormComponent {
|
||||||
this.locationDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
this.locationDropdown = this.view!.modelBuilder.dropDown().withProperties({
|
||||||
ariaLabel: constants.locationDropdown,
|
ariaLabel: constants.locationDropdown,
|
||||||
values: this.currentReferenceType === ReferenceType.systemDb ? constants.systemDbLocationDropdownValues : constants.locationDropdownValues
|
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
|
// database name row
|
||||||
this.databaseNameTextbox = this.createInputBox(constants.databaseName, true, true);
|
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();
|
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 {
|
private createLabel(value: string, required: boolean = false): azdataType.TextComponent {
|
||||||
const label = this.view!.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const label = this.view!.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: value,
|
value: value,
|
||||||
width: cssStyles.addDatabaseReferenceDialogLabelWidth,
|
width: cssStyles.addDatabaseReferenceDialogLabelWidth,
|
||||||
requiredIndicator: required
|
requiredIndicator: required
|
||||||
@@ -505,7 +505,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
return label;
|
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({
|
const inputBox = this.view!.modelBuilder.inputBox().withProperties({
|
||||||
ariaLabel: ariaLabel,
|
ariaLabel: ariaLabel,
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
@@ -521,7 +521,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
return inputBox;
|
return inputBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createExampleUsage(): azdata.FormComponent {
|
private createExampleUsage(): azdataType.FormComponent {
|
||||||
this.exampleUsage = this.view!.modelBuilder.text().withProperties({
|
this.exampleUsage = this.view!.modelBuilder.text().withProperties({
|
||||||
value: this.currentReferenceType === ReferenceType.project ? constants.databaseNameRequiredVariableOptional : constants.systemDatabaseReferenceRequired,
|
value: this.currentReferenceType === ReferenceType.project ? constants.databaseNameRequiredVariableOptional : constants.systemDatabaseReferenceRequired,
|
||||||
CSSStyles: { 'user-select': 'text' }
|
CSSStyles: { 'user-select': 'text' }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* 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 vscode from 'vscode';
|
||||||
import * as constants from '../common/constants';
|
import * as constants from '../common/constants';
|
||||||
import * as newProjectTool from '../tools/newProjectTool';
|
import * as newProjectTool from '../tools/newProjectTool';
|
||||||
@@ -15,19 +15,19 @@ import { cssStyles } from '../common/uiConstants';
|
|||||||
import { ImportDataModel } from '../models/api/import';
|
import { ImportDataModel } from '../models/api/import';
|
||||||
import { Deferred } from '../common/promise';
|
import { Deferred } from '../common/promise';
|
||||||
import { getConnectionName } from './utils';
|
import { getConnectionName } from './utils';
|
||||||
import { exists, isCurrentWorkspaceUntitled } from '../common/utils';
|
import { exists, getAzdataApi, isCurrentWorkspaceUntitled } from '../common/utils';
|
||||||
|
|
||||||
export class CreateProjectFromDatabaseDialog {
|
export class CreateProjectFromDatabaseDialog {
|
||||||
public dialog: azdata.window.Dialog;
|
public dialog: azdataType.window.Dialog;
|
||||||
public createProjectFromDatabaseTab: azdata.window.DialogTab;
|
public createProjectFromDatabaseTab: azdataType.window.DialogTab;
|
||||||
public sourceConnectionTextBox: azdata.InputBoxComponent | undefined;
|
public sourceConnectionTextBox: azdataType.InputBoxComponent | undefined;
|
||||||
private selectConnectionButton: azdata.ButtonComponent | undefined;
|
private selectConnectionButton: azdataType.ButtonComponent | undefined;
|
||||||
public sourceDatabaseDropDown: azdata.DropDownComponent | undefined;
|
public sourceDatabaseDropDown: azdataType.DropDownComponent | undefined;
|
||||||
public projectNameTextBox: azdata.InputBoxComponent | undefined;
|
public projectNameTextBox: azdataType.InputBoxComponent | undefined;
|
||||||
public projectLocationTextBox: azdata.InputBoxComponent | undefined;
|
public projectLocationTextBox: azdataType.InputBoxComponent | undefined;
|
||||||
public folderStructureDropDown: azdata.DropDownComponent | undefined;
|
public folderStructureDropDown: azdataType.DropDownComponent | undefined;
|
||||||
public workspaceInputBox: azdata.InputBoxComponent | undefined;
|
public workspaceInputBox: azdataType.InputBoxComponent | undefined;
|
||||||
private formBuilder: azdata.FormBuilder | undefined;
|
private formBuilder: azdataType.FormBuilder | undefined;
|
||||||
private connectionId: string | undefined;
|
private connectionId: string | undefined;
|
||||||
private toDispose: vscode.Disposable[] = [];
|
private toDispose: vscode.Disposable[] = [];
|
||||||
private initDialogComplete!: Deferred<void>;
|
private initDialogComplete!: Deferred<void>;
|
||||||
@@ -35,9 +35,9 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
|
|
||||||
public createProjectFromDatabaseCallback: ((model: ImportDataModel) => any) | undefined;
|
public createProjectFromDatabaseCallback: ((model: ImportDataModel) => any) | undefined;
|
||||||
|
|
||||||
constructor(private profile: azdata.IConnectionProfile | undefined) {
|
constructor(private profile: azdataType.IConnectionProfile | undefined) {
|
||||||
this.dialog = azdata.window.createModelViewDialog(constants.createProjectFromDatabaseDialogName, 'createProjectFromDatabaseDialog');
|
this.dialog = getAzdataApi()!.window.createModelViewDialog(constants.createProjectFromDatabaseDialogName, 'createProjectFromDatabaseDialog');
|
||||||
this.createProjectFromDatabaseTab = azdata.window.createTab(constants.createProjectFromDatabaseDialogName);
|
this.createProjectFromDatabaseTab = getAzdataApi()!.window.createTab(constants.createProjectFromDatabaseDialogName);
|
||||||
this.dialog.registerCloseValidator(async () => {
|
this.dialog.registerCloseValidator(async () => {
|
||||||
return this.validate();
|
return this.validate();
|
||||||
});
|
});
|
||||||
@@ -51,7 +51,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
|
|
||||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
this.dialog.cancelButton.label = constants.cancelButtonText;
|
||||||
|
|
||||||
azdata.window.openDialog(this.dialog);
|
getAzdataApi()!.window.openDialog(this.dialog);
|
||||||
await this.initDialogPromise;
|
await this.initDialogPromise;
|
||||||
|
|
||||||
if (this.profile) {
|
if (this.profile) {
|
||||||
@@ -91,7 +91,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
const createworkspaceContainerFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
|
const createworkspaceContainerFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
|
||||||
createworkspaceContainerFormSection.addItems([workspaceContainerRow]);
|
createworkspaceContainerFormSection.addItems([workspaceContainerRow]);
|
||||||
|
|
||||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||||
.withFormItems([
|
.withFormItems([
|
||||||
{
|
{
|
||||||
title: constants.sourceDatabase,
|
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 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,
|
value: constants.server,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||||
@@ -157,7 +157,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
return connectionRow;
|
return connectionRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDatabaseRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createDatabaseRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
this.sourceDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
this.sourceDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
||||||
ariaLabel: constants.databaseNameLabel,
|
ariaLabel: constants.databaseNameLabel,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -170,13 +170,13 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.tryEnableCreateButton();
|
this.tryEnableCreateButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
const databaseLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const databaseLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.databaseNameLabel,
|
value: constants.databaseNameLabel,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||||
}).component();
|
}).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;
|
return databaseRow;
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.projectNameTextBox!.value = newProjectTool.defaultProjectNameFromDb(<string>this.sourceDatabaseDropDown!.value);
|
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({
|
this.sourceConnectionTextBox = view.modelBuilder.inputBox().withProperties({
|
||||||
value: '',
|
value: '',
|
||||||
placeHolder: constants.selectConnection,
|
placeHolder: constants.selectConnection,
|
||||||
@@ -200,7 +200,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
return this.sourceConnectionTextBox;
|
return this.sourceConnectionTextBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSelectConnectionButton(view: azdata.ModelView): azdata.Component {
|
private createSelectConnectionButton(view: azdataType.ModelView): azdataType.Component {
|
||||||
this.selectConnectionButton = view.modelBuilder.button().withProperties({
|
this.selectConnectionButton = view.modelBuilder.button().withProperties({
|
||||||
ariaLabel: constants.selectConnection,
|
ariaLabel: constants.selectConnection,
|
||||||
iconPath: IconPathHelper.selectConnection,
|
iconPath: IconPathHelper.selectConnection,
|
||||||
@@ -209,7 +209,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.selectConnectionButton.onDidClick(async () => {
|
this.selectConnectionButton.onDidClick(async () => {
|
||||||
let connection = await azdata.connection.openConnectionDialog();
|
let connection = await getAzdataApi()!.connection.openConnectionDialog();
|
||||||
this.connectionId = connection.connectionId;
|
this.connectionId = connection.connectionId;
|
||||||
|
|
||||||
let connectionTextboxValue: string;
|
let connectionTextboxValue: string;
|
||||||
@@ -230,7 +230,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.sourceDatabaseDropDown!.loading = true;
|
this.sourceDatabaseDropDown!.loading = true;
|
||||||
let databaseValues;
|
let databaseValues;
|
||||||
try {
|
try {
|
||||||
databaseValues = (await azdata.connection.listDatabases(connectionId))
|
databaseValues = (await getAzdataApi()!.connection.listDatabases(connectionId))
|
||||||
// filter out system dbs
|
// filter out system dbs
|
||||||
.filter(db => !constants.systemDbs.includes(db));
|
.filter(db => !constants.systemDbs.includes(db));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -253,8 +253,8 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.selectConnectionButton!.iconPath = IconPathHelper.connect;
|
this.selectConnectionButton!.iconPath = IconPathHelper.connect;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createProjectNameRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createProjectNameRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
this.projectNameTextBox = view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
this.projectNameTextBox = view.modelBuilder.inputBox().withProperties<azdataType.InputBoxProperties>({
|
||||||
ariaLabel: constants.projectNamePlaceholderText,
|
ariaLabel: constants.projectNamePlaceholderText,
|
||||||
placeHolder: constants.projectNamePlaceholderText,
|
placeHolder: constants.projectNamePlaceholderText,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -268,7 +268,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.tryEnableCreateButton();
|
this.tryEnableCreateButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectNameLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const projectNameLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.projectNameLabel,
|
value: constants.projectNameLabel,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||||
@@ -279,8 +279,8 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
return projectNameRow;
|
return projectNameRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createProjectLocationRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createProjectLocationRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
const browseFolderButton: azdata.Component = this.createBrowseFolderButton(view);
|
const browseFolderButton: azdataType.Component = this.createBrowseFolderButton(view);
|
||||||
|
|
||||||
this.projectLocationTextBox = view.modelBuilder.inputBox().withProperties({
|
this.projectLocationTextBox = view.modelBuilder.inputBox().withProperties({
|
||||||
value: '',
|
value: '',
|
||||||
@@ -295,7 +295,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.tryEnableCreateButton();
|
this.tryEnableCreateButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectLocationLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const projectLocationLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.projectLocationLabel,
|
value: constants.projectLocationLabel,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||||
@@ -307,8 +307,8 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
return projectLocationRow;
|
return projectLocationRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createBrowseFolderButton(view: azdata.ModelView): azdata.ButtonComponent {
|
private createBrowseFolderButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
const browseFolderButton = view.modelBuilder.button().withProperties<azdataType.ButtonProperties>({
|
||||||
ariaLabel: constants.browseButtonText,
|
ariaLabel: constants.browseButtonText,
|
||||||
iconPath: IconPathHelper.folder_blue,
|
iconPath: IconPathHelper.folder_blue,
|
||||||
height: '18px',
|
height: '18px',
|
||||||
@@ -335,7 +335,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
return browseFolderButton;
|
return browseFolderButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createFolderStructureRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createFolderStructureRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
this.folderStructureDropDown = view.modelBuilder.dropDown().withProperties({
|
this.folderStructureDropDown = view.modelBuilder.dropDown().withProperties({
|
||||||
values: [constants.file, constants.flat, constants.objectType, constants.schema, constants.schemaObjectType],
|
values: [constants.file, constants.flat, constants.objectType, constants.schema, constants.schemaObjectType],
|
||||||
value: constants.schemaObjectType,
|
value: constants.schemaObjectType,
|
||||||
@@ -348,13 +348,13 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.tryEnableCreateButton();
|
this.tryEnableCreateButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
const folderStructureLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const folderStructureLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.folderStructureLabel,
|
value: constants.folderStructureLabel,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.createProjectFromDatabaseLabelWidth
|
width: cssStyles.createProjectFromDatabaseLabelWidth
|
||||||
}).component();
|
}).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;
|
return folderStructureRow;
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
* created if no workspace is currently open
|
* created if no workspace is currently open
|
||||||
* @param view
|
* @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 : '';
|
const initialWorkspaceInputBoxValue = !!vscode.workspace.workspaceFile && !isCurrentWorkspaceUntitled() ? vscode.workspace.workspaceFile.fsPath : '';
|
||||||
|
|
||||||
this.workspaceInputBox = view.modelBuilder.inputBox().withProperties({
|
this.workspaceInputBox = view.modelBuilder.inputBox().withProperties({
|
||||||
@@ -375,7 +375,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
width: '100%'
|
width: '100%'
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
const browseFolderButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
|
const browseFolderButton = view.modelBuilder.button().withProperties<azdataType.ButtonProperties>({
|
||||||
ariaLabel: constants.browseButtonText,
|
ariaLabel: constants.browseButtonText,
|
||||||
iconPath: IconPathHelper.folder_blue,
|
iconPath: IconPathHelper.folder_blue,
|
||||||
height: '16px',
|
height: '16px',
|
||||||
@@ -402,7 +402,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
this.workspaceInputBox!.title = selectedFile;
|
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,
|
value: vscode.workspace.workspaceFile ? constants.addProjectToCurrentWorkspace : constants.newWorkspaceWillBeCreated,
|
||||||
CSSStyles: { 'margin-top': '-10px', 'margin-bottom': '5px' }
|
CSSStyles: { 'margin-top': '-10px', 'margin-bottom': '5px' }
|
||||||
}).component();
|
}).component();
|
||||||
@@ -454,7 +454,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
newWorkspaceFilePath: this.workspaceInputBox!.enabled ? vscode.Uri.file(this.workspaceInputBox!.value!) : undefined
|
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);
|
await this.createProjectFromDatabaseCallback!(model);
|
||||||
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
@@ -529,7 +529,7 @@ export class CreateProjectFromDatabaseDialog {
|
|||||||
protected showErrorMessage(message: string): void {
|
protected showErrorMessage(message: string): void {
|
||||||
this.dialog.message = {
|
this.dialog.message = {
|
||||||
text: 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.
|
* 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 vscode from 'vscode';
|
||||||
import * as constants from '../common/constants';
|
import * as constants from '../common/constants';
|
||||||
import * as utils from '../common/utils';
|
import * as utils from '../common/utils';
|
||||||
@@ -17,25 +17,25 @@ import { cssStyles } from '../common/uiConstants';
|
|||||||
import { getConnectionName } from './utils';
|
import { getConnectionName } from './utils';
|
||||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||||
|
|
||||||
interface DataSourceDropdownValue extends azdata.CategoryValue {
|
interface DataSourceDropdownValue extends azdataType.CategoryValue {
|
||||||
dataSource: SqlConnectionDataSource;
|
dataSource: SqlConnectionDataSource;
|
||||||
database: string;
|
database: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PublishDatabaseDialog {
|
export class PublishDatabaseDialog {
|
||||||
public dialog: azdata.window.Dialog;
|
public dialog: azdataType.window.Dialog;
|
||||||
public publishTab: azdata.window.DialogTab;
|
public publishTab: azdataType.window.DialogTab;
|
||||||
private targetConnectionTextBox: azdata.InputBoxComponent | undefined;
|
private targetConnectionTextBox: azdataType.InputBoxComponent | undefined;
|
||||||
private dataSourcesFormComponent: azdata.FormComponent | undefined;
|
private dataSourcesFormComponent: azdataType.FormComponent | undefined;
|
||||||
private dataSourcesDropDown: azdata.DropDownComponent | undefined;
|
private dataSourcesDropDown: azdataType.DropDownComponent | undefined;
|
||||||
private targetDatabaseDropDown: azdata.DropDownComponent | undefined;
|
private targetDatabaseDropDown: azdataType.DropDownComponent | undefined;
|
||||||
private connectionsRadioButton: azdata.RadioButtonComponent | undefined;
|
private connectionsRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
private dataSourcesRadioButton: azdata.RadioButtonComponent | undefined;
|
private dataSourcesRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
private sqlCmdVariablesTable: azdata.DeclarativeTableComponent | undefined;
|
private sqlCmdVariablesTable: azdataType.DeclarativeTableComponent | undefined;
|
||||||
private sqlCmdVariablesFormComponentGroup: azdata.FormComponentGroup | undefined;
|
private sqlCmdVariablesFormComponentGroup: azdataType.FormComponentGroup | undefined;
|
||||||
private loadSqlCmdVarsButton: azdata.ButtonComponent | undefined;
|
private loadSqlCmdVarsButton: azdataType.ButtonComponent | undefined;
|
||||||
private loadProfileTextBox: azdata.InputBoxComponent | undefined;
|
private loadProfileTextBox: azdataType.InputBoxComponent | undefined;
|
||||||
private formBuilder: azdata.FormBuilder | undefined;
|
private formBuilder: azdataType.FormBuilder | undefined;
|
||||||
|
|
||||||
private connectionId: string | undefined;
|
private connectionId: string | undefined;
|
||||||
private connectionIsDataSource: boolean | undefined;
|
private connectionIsDataSource: boolean | undefined;
|
||||||
@@ -51,8 +51,8 @@ export class PublishDatabaseDialog {
|
|||||||
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
||||||
|
|
||||||
constructor(private project: Project) {
|
constructor(private project: Project) {
|
||||||
this.dialog = azdata.window.createModelViewDialog(constants.publishDialogName, 'sqlProjectPublishDialog');
|
this.dialog = utils.getAzdataApi()!.window.createModelViewDialog(constants.publishDialogName, 'sqlProjectPublishDialog');
|
||||||
this.publishTab = azdata.window.createTab(constants.publishDialogName);
|
this.publishTab = utils.getAzdataApi()!.window.createTab(constants.publishDialogName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openDialog(): void {
|
public openDialog(): void {
|
||||||
@@ -63,14 +63,14 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
this.dialog.cancelButton.label = constants.cancelButtonText;
|
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()));
|
this.toDispose.push(generateScriptButton.onClick(async () => await this.generateScriptClick()));
|
||||||
generateScriptButton.enabled = false;
|
generateScriptButton.enabled = false;
|
||||||
|
|
||||||
this.dialog.customButtons = [];
|
this.dialog.customButtons = [];
|
||||||
this.dialog.customButtons.push(generateScriptButton);
|
this.dialog.customButtons.push(generateScriptButton);
|
||||||
|
|
||||||
azdata.window.openDialog(this.dialog);
|
utils.getAzdataApi()!.window.openDialog(this.dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private dispose(): void {
|
private dispose(): void {
|
||||||
@@ -100,7 +100,7 @@ export class PublishDatabaseDialog {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
component: <azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable
|
component: <azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
title: constants.sqlCmdTableLabel
|
title: constants.sqlCmdTableLabel
|
||||||
@@ -114,7 +114,7 @@ export class PublishDatabaseDialog {
|
|||||||
horizontalFormSection.addItems([profileRow, connectionRow, databaseRow]);
|
horizontalFormSection.addItems([profileRow, connectionRow, databaseRow]);
|
||||||
|
|
||||||
|
|
||||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||||
.withFormItems([
|
.withFormItems([
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
@@ -157,13 +157,13 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
if (this.connectionIsDataSource) {
|
if (this.connectionIsDataSource) {
|
||||||
const dataSource = (this.dataSourcesDropDown!.value! as DataSourceDropdownValue).dataSource;
|
const dataSource = (this.dataSourcesDropDown!.value! as DataSourceDropdownValue).dataSource;
|
||||||
const connProfile: azdata.IConnectionProfile = dataSource.getConnectionProfile();
|
const connProfile: azdataType.IConnectionProfile = dataSource.getConnectionProfile();
|
||||||
|
|
||||||
if (dataSource.integratedSecurity) {
|
if (dataSource.integratedSecurity) {
|
||||||
connId = (await azdata.connection.connect(connProfile, false, false)).connectionId;
|
connId = (await utils.getAzdataApi()!.connection.connect(connProfile, false, false)).connectionId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
connId = (await azdata.connection.openConnectionDialog(undefined, connProfile)).connectionId;
|
connId = (await utils.getAzdataApi()!.connection.openConnectionDialog(undefined, connProfile)).connectionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -174,7 +174,7 @@ export class PublishDatabaseDialog {
|
|||||||
connId = this.connectionId;
|
connId = this.connectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await azdata.connection.getUriForConnection(connId);
|
return await utils.getAzdataApi()!.connection.getUriForConnection(connId);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw new Error(constants.unableToCreatePublishConnection + ': ' + utils.getErrorMessage(err));
|
throw new Error(constants.unableToCreatePublishConnection + ': ' + utils.getErrorMessage(err));
|
||||||
@@ -192,7 +192,7 @@ export class PublishDatabaseDialog {
|
|||||||
profileUsed: this.profileUsed
|
profileUsed: this.profileUsed
|
||||||
};
|
};
|
||||||
|
|
||||||
azdata.window.closeDialog(this.dialog);
|
utils.getAzdataApi()!.window.closeDialog(this.dialog);
|
||||||
await this.publish!(this.project, settings);
|
await this.publish!(this.project, settings);
|
||||||
|
|
||||||
this.dispose();
|
this.dispose();
|
||||||
@@ -211,7 +211,7 @@ export class PublishDatabaseDialog {
|
|||||||
profileUsed: this.profileUsed
|
profileUsed: this.profileUsed
|
||||||
};
|
};
|
||||||
|
|
||||||
azdata.window.closeDialog(this.dialog);
|
utils.getAzdataApi()!.window.closeDialog(this.dialog);
|
||||||
|
|
||||||
if (this.generateScript) {
|
if (this.generateScript) {
|
||||||
await this.generateScript!(this.project, settings);
|
await this.generateScript!(this.project, settings);
|
||||||
@@ -256,7 +256,7 @@ export class PublishDatabaseDialog {
|
|||||||
return this.serverName!;
|
return this.serverName!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createRadioButtons(view: azdata.ModelView): azdata.Component {
|
private createRadioButtons(view: azdataType.ModelView): azdataType.Component {
|
||||||
this.connectionsRadioButton = view.modelBuilder.radioButton()
|
this.connectionsRadioButton = view.modelBuilder.radioButton()
|
||||||
.withProperties({
|
.withProperties({
|
||||||
name: 'connection',
|
name: 'connection',
|
||||||
@@ -265,7 +265,7 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
this.connectionsRadioButton.checked = true;
|
this.connectionsRadioButton.checked = true;
|
||||||
this.connectionsRadioButton.onDidClick(() => {
|
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
|
// TODO: fix this when data sources are enabled again
|
||||||
// this.formBuilder!.insertFormItem(<azdata.FormComponent>this.targetConnectionTextBox, 2);
|
// this.formBuilder!.insertFormItem(<azdata.FormComponent>this.targetConnectionTextBox, 2);
|
||||||
this.connectionIsDataSource = false;
|
this.connectionIsDataSource = false;
|
||||||
@@ -281,13 +281,13 @@ export class PublishDatabaseDialog {
|
|||||||
this.dataSourcesRadioButton.onDidClick(() => {
|
this.dataSourcesRadioButton.onDidClick(() => {
|
||||||
// TODO: fix this when data sources are enabled again
|
// TODO: fix this when data sources are enabled again
|
||||||
// this.formBuilder!.removeFormItem(<azdata.FormComponent>this.targetConnectionTextBox);
|
// 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.connectionIsDataSource = true;
|
||||||
|
|
||||||
this.setDatabaseToSelectedDataSourceDatabase();
|
this.setDatabaseToSelectedDataSourceDatabase();
|
||||||
});
|
});
|
||||||
|
|
||||||
let flexRadioButtonsModel: azdata.FlexContainer = view.modelBuilder.flexContainer()
|
let flexRadioButtonsModel: azdataType.FlexContainer = view.modelBuilder.flexContainer()
|
||||||
.withLayout({ flexFlow: 'column' })
|
.withLayout({ flexFlow: 'column' })
|
||||||
.withItems([this.connectionsRadioButton, this.dataSourcesRadioButton])
|
.withItems([this.connectionsRadioButton, this.dataSourcesRadioButton])
|
||||||
.withProperties({ ariaRole: 'radiogroup' })
|
.withProperties({ ariaRole: 'radiogroup' })
|
||||||
@@ -296,7 +296,7 @@ export class PublishDatabaseDialog {
|
|||||||
return flexRadioButtonsModel;
|
return flexRadioButtonsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createTargetConnectionComponent(view: azdata.ModelView): azdata.InputBoxComponent {
|
private createTargetConnectionComponent(view: azdataType.ModelView): azdataType.InputBoxComponent {
|
||||||
this.targetConnectionTextBox = view.modelBuilder.inputBox().withProperties({
|
this.targetConnectionTextBox = view.modelBuilder.inputBox().withProperties({
|
||||||
value: '',
|
value: '',
|
||||||
ariaLabel: constants.targetConnectionLabel,
|
ariaLabel: constants.targetConnectionLabel,
|
||||||
@@ -312,7 +312,7 @@ export class PublishDatabaseDialog {
|
|||||||
return this.targetConnectionTextBox;
|
return this.targetConnectionTextBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDataSourcesFormComponent(view: azdata.ModelView): azdata.FormComponent {
|
private createDataSourcesFormComponent(view: azdataType.ModelView): azdataType.FormComponent {
|
||||||
if (this.project.dataSources.length > 0) {
|
if (this.project.dataSources.length > 0) {
|
||||||
return this.createDataSourcesDropdown(view);
|
return this.createDataSourcesDropdown(view);
|
||||||
} else {
|
} 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[] = [];
|
let dataSourcesValues: DataSourceDropdownValue[] = [];
|
||||||
|
|
||||||
this.project.dataSources.filter(d => d instanceof SqlConnectionDataSource).forEach(dataSource => {
|
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);
|
const loadProfileButton = this.createLoadProfileButton(view);
|
||||||
this.loadProfileTextBox = view.modelBuilder.inputBox().withProperties({
|
this.loadProfileTextBox = view.modelBuilder.inputBox().withProperties({
|
||||||
placeHolder: constants.loadProfilePlaceholderText,
|
placeHolder: constants.loadProfilePlaceholderText,
|
||||||
@@ -368,7 +368,7 @@ export class PublishDatabaseDialog {
|
|||||||
width: cssStyles.publishDialogTextboxWidth
|
width: cssStyles.publishDialogTextboxWidth
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
const profileLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const profileLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.profile,
|
value: constants.profile,
|
||||||
width: cssStyles.publishDialogLabelWidth
|
width: cssStyles.publishDialogLabelWidth
|
||||||
}).component();
|
}).component();
|
||||||
@@ -379,11 +379,11 @@ export class PublishDatabaseDialog {
|
|||||||
return profileRow;
|
return profileRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createConnectionRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createConnectionRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
this.targetConnectionTextBox = this.createTargetConnectionComponent(view);
|
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,
|
value: constants.server,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.publishDialogLabelWidth
|
width: cssStyles.publishDialogLabelWidth
|
||||||
@@ -395,7 +395,7 @@ export class PublishDatabaseDialog {
|
|||||||
return connectionRow;
|
return connectionRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDatabaseRow(view: azdata.ModelView): azdata.FlexContainer {
|
private createDatabaseRow(view: azdataType.ModelView): azdataType.FlexContainer {
|
||||||
this.targetDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
this.targetDatabaseDropDown = view.modelBuilder.dropDown().withProperties({
|
||||||
values: [this.getDefaultDatabaseName()],
|
values: [this.getDefaultDatabaseName()],
|
||||||
value: this.getDefaultDatabaseName(),
|
value: this.getDefaultDatabaseName(),
|
||||||
@@ -410,27 +410,27 @@ export class PublishDatabaseDialog {
|
|||||||
this.tryEnableGenerateScriptAndOkButtons();
|
this.tryEnableGenerateScriptAndOkButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
const databaseLabel = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
const databaseLabel = view.modelBuilder.text().withProperties<azdataType.TextComponentProperties>({
|
||||||
value: constants.databaseNameLabel,
|
value: constants.databaseNameLabel,
|
||||||
requiredIndicator: true,
|
requiredIndicator: true,
|
||||||
width: cssStyles.publishDialogLabelWidth
|
width: cssStyles.publishDialogLabelWidth
|
||||||
}).component();
|
}).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;
|
return databaseRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSqlCmdTable(view: azdata.ModelView): azdata.DeclarativeTableComponent {
|
private createSqlCmdTable(view: azdataType.ModelView): azdataType.DeclarativeTableComponent {
|
||||||
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
||||||
|
|
||||||
const table = view.modelBuilder.declarativeTable().withProperties<azdata.DeclarativeTableProperties>({
|
const table = view.modelBuilder.declarativeTable().withProperties<azdataType.DeclarativeTableProperties>({
|
||||||
ariaLabel: constants.sqlCmdTableLabel,
|
ariaLabel: constants.sqlCmdTableLabel,
|
||||||
dataValues: this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars),
|
dataValues: this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars),
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
displayName: constants.sqlCmdVariableColumn,
|
displayName: constants.sqlCmdVariableColumn,
|
||||||
valueType: azdata.DeclarativeDataType.string,
|
valueType: utils.getAzdataApi()!.DeclarativeDataType.string,
|
||||||
width: '50%',
|
width: '50%',
|
||||||
isReadOnly: true,
|
isReadOnly: true,
|
||||||
headerCssStyles: cssStyles.tableHeader,
|
headerCssStyles: cssStyles.tableHeader,
|
||||||
@@ -438,7 +438,7 @@ export class PublishDatabaseDialog {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: constants.sqlCmdValueColumn,
|
displayName: constants.sqlCmdValueColumn,
|
||||||
valueType: azdata.DeclarativeDataType.string,
|
valueType: utils.getAzdataApi()!.DeclarativeDataType.string,
|
||||||
width: '50%',
|
width: '50%',
|
||||||
isReadOnly: false,
|
isReadOnly: false,
|
||||||
headerCssStyles: cssStyles.tableHeader,
|
headerCssStyles: cssStyles.tableHeader,
|
||||||
@@ -459,8 +459,8 @@ export class PublishDatabaseDialog {
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createLoadSqlCmdVarsButton(view: azdata.ModelView): azdata.ButtonComponent {
|
private createLoadSqlCmdVarsButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||||
let loadSqlCmdVarsButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
let loadSqlCmdVarsButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||||
label: constants.loadSqlCmdVarsButtonTitle,
|
label: constants.loadSqlCmdVarsButtonTitle,
|
||||||
title: constants.loadSqlCmdVarsButtonTitle,
|
title: constants.loadSqlCmdVarsButtonTitle,
|
||||||
ariaLabel: constants.loadSqlCmdVarsButtonTitle,
|
ariaLabel: constants.loadSqlCmdVarsButtonTitle,
|
||||||
@@ -474,7 +474,7 @@ export class PublishDatabaseDialog {
|
|||||||
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
|
||||||
|
|
||||||
const data = this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars!);
|
const data = this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars!);
|
||||||
(<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable)!.updateProperties({
|
(<azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable)!.updateProperties({
|
||||||
dataValues: data
|
dataValues: data
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -484,8 +484,8 @@ export class PublishDatabaseDialog {
|
|||||||
return loadSqlCmdVarsButton;
|
return loadSqlCmdVarsButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSelectConnectionButton(view: azdata.ModelView): azdata.Component {
|
private createSelectConnectionButton(view: azdataType.ModelView): azdataType.Component {
|
||||||
let selectConnectionButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
let selectConnectionButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||||
ariaLabel: constants.selectConnection,
|
ariaLabel: constants.selectConnection,
|
||||||
iconPath: IconPathHelper.selectConnection,
|
iconPath: IconPathHelper.selectConnection,
|
||||||
height: '16px',
|
height: '16px',
|
||||||
@@ -493,7 +493,7 @@ export class PublishDatabaseDialog {
|
|||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
selectConnectionButton.onDidClick(async () => {
|
selectConnectionButton.onDidClick(async () => {
|
||||||
let connection = await azdata.connection.openConnectionDialog();
|
let connection = await utils.getAzdataApi()!.connection.openConnectionDialog();
|
||||||
this.connectionId = connection.connectionId;
|
this.connectionId = connection.connectionId;
|
||||||
this.serverName = connection.options['server'];
|
this.serverName = connection.options['server'];
|
||||||
|
|
||||||
@@ -519,7 +519,7 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
// populate database dropdown with the databases for this connection
|
// populate database dropdown with the databases for this connection
|
||||||
if (connectionId) {
|
if (connectionId) {
|
||||||
const databaseValues = (await azdata.connection.listDatabases(connectionId))
|
const databaseValues = (await utils.getAzdataApi()!.connection.listDatabases(connectionId))
|
||||||
// filter out system dbs
|
// filter out system dbs
|
||||||
.filter(db => !constants.systemDbs.includes(db));
|
.filter(db => !constants.systemDbs.includes(db));
|
||||||
|
|
||||||
@@ -527,8 +527,8 @@ export class PublishDatabaseDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private createLoadProfileButton(view: azdata.ModelView): azdata.ButtonComponent {
|
private createLoadProfileButton(view: azdataType.ModelView): azdataType.ButtonComponent {
|
||||||
let loadProfileButton: azdata.ButtonComponent = view.modelBuilder.button().withProperties({
|
let loadProfileButton: azdataType.ButtonComponent = view.modelBuilder.button().withProperties({
|
||||||
ariaLabel: constants.loadProfilePlaceholderText,
|
ariaLabel: constants.loadProfilePlaceholderText,
|
||||||
iconPath: IconPathHelper.folder_blue,
|
iconPath: IconPathHelper.folder_blue,
|
||||||
height: '18px',
|
height: '18px',
|
||||||
@@ -555,7 +555,7 @@ export class PublishDatabaseDialog {
|
|||||||
if (this.readPublishProfile) {
|
if (this.readPublishProfile) {
|
||||||
const result = await this.readPublishProfile(fileUris[0]);
|
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
|
// 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.connectionId = result.connectionId;
|
||||||
this.serverName = result.serverName;
|
this.serverName = result.serverName;
|
||||||
@@ -573,18 +573,18 @@ export class PublishDatabaseDialog {
|
|||||||
this.deploymentOptions = result.options;
|
this.deploymentOptions = result.options;
|
||||||
|
|
||||||
const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForPublish());
|
const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForPublish());
|
||||||
await (<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable).updateProperties({
|
await (<azdataType.DeclarativeTableComponent>this.sqlCmdVariablesTable).updateProperties({
|
||||||
dataValues: data
|
dataValues: data
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Object.keys(result.sqlCmdVariables).length) {
|
if (Object.keys(result.sqlCmdVariables).length) {
|
||||||
// add SQLCMD Variables table if it wasn't there before
|
// add SQLCMD Variables table if it wasn't there before
|
||||||
if (Object.keys(this.project.sqlCmdVariables).length === 0) {
|
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) {
|
} else if (Object.keys(this.project.sqlCmdVariables).length === 0) {
|
||||||
// remove the table if there are no SQLCMD variables in the project and loaded profile
|
// 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
|
// show file path in text box and hover text
|
||||||
@@ -596,7 +596,7 @@ export class PublishDatabaseDialog {
|
|||||||
return loadProfileButton;
|
return loadProfileButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdata.DeclarativeTableCellValue[][] {
|
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdataType.DeclarativeTableCellValue[][] {
|
||||||
let data = [];
|
let data = [];
|
||||||
for (let key in sqlCmdVars) {
|
for (let key in sqlCmdVars) {
|
||||||
data.push([{ value: key }, { value: sqlCmdVars[key] }]);
|
data.push([{ value: key }, { value: sqlCmdVars[key] }]);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* 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 { DataSource } from './dataSources';
|
import { DataSource } from './dataSources';
|
||||||
import * as constants from '../../common/constants';
|
import * as constants from '../../common/constants';
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ export class SqlConnectionDataSource extends DataSource {
|
|||||||
return new SqlConnectionDataSource(json.name, (json.data as unknown as SqlConnectionDataSourceJson).connectionString);
|
return new SqlConnectionDataSource(json.name, (json.data as unknown as SqlConnectionDataSourceJson).connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getConnectionProfile(): azdata.IConnectionProfile {
|
public getConnectionProfile(): azdataType.IConnectionProfile {
|
||||||
const connProfile: azdata.IConnectionProfile = {
|
const connProfile: azdataType.IConnectionProfile = {
|
||||||
serverName: this.server,
|
serverName: this.server,
|
||||||
databaseName: this.database,
|
databaseName: this.database,
|
||||||
connectionName: this.name,
|
connectionName: this.name,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
|
||||||
import * as xmldom from 'xmldom';
|
import * as xmldom from 'xmldom';
|
||||||
import * as constants from '../../common/constants';
|
import * as constants from '../../common/constants';
|
||||||
import * as utils from '../../common/utils';
|
import * as utils from '../../common/utils';
|
||||||
@@ -67,13 +66,13 @@ async function readConnectionString(xmlDoc: any): Promise<{ connectionId: string
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (dataSource.integratedSecurity) {
|
if (dataSource.integratedSecurity) {
|
||||||
const connection = await azdata.connection.connect(connectionProfile, false, false);
|
const connection = await utils.getAzdataApi()!.connection.connect(connectionProfile, false, false);
|
||||||
connId = connection.connectionId;
|
connId = connection.connectionId;
|
||||||
server = dataSource.server;
|
server = dataSource.server;
|
||||||
username = constants.defaultUser;
|
username = constants.defaultUser;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const connection = await azdata.connection.openConnectionDialog(undefined, connectionProfile);
|
const connection = await utils.getAzdataApi()!.connection.openConnectionDialog(undefined, connectionProfile);
|
||||||
connId = connection.connectionId;
|
connId = connection.connectionId;
|
||||||
server = connection.options['server'];
|
server = connection.options['server'];
|
||||||
username = connection.options['user'];
|
username = connection.options['user'];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { ThemedIconPath } from 'azdata';
|
import type { ThemedIconPath } from 'azdata';
|
||||||
import * as dataworkspace from 'dataworkspace';
|
import * as dataworkspace from 'dataworkspace';
|
||||||
import * as sqldbproj from 'sqldbproj';
|
import * as sqldbproj from 'sqldbproj';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|||||||
@@ -205,10 +205,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
|
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
|
||||||
integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==
|
integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==
|
||||||
|
|
||||||
"@microsoft/ads-extension-telemetry@^1.1.3":
|
"@microsoft/ads-extension-telemetry@^1.1.5":
|
||||||
version "1.1.3"
|
version "1.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/@microsoft/ads-extension-telemetry/-/ads-extension-telemetry-1.1.3.tgz#54160eefa21f2a536622b0617f3c3f2018cf9c87"
|
resolved "https://registry.yarnpkg.com/@microsoft/ads-extension-telemetry/-/ads-extension-telemetry-1.1.5.tgz#4f2ec72a7730131fdd939ace307a1ff5feef16b6"
|
||||||
integrity sha512-+h6hM9oOA6Zj/N0nCGPzRgydR0YHiHpNJoNlv6a/ziWXO3RYSbQX+3U/PpT3gEA6+8RwByf6RVICo7uIGBy1LQ==
|
integrity sha512-Xq8qQi8CHxXPTCO5cRvJABgtVdFO42kQgVoHkBc7ByBhN4VMdw/kakbWgVtHbMl4oRARtpncE2xYCiVeZHK6XA==
|
||||||
dependencies:
|
dependencies:
|
||||||
vscode-extension-telemetry "^0.1.6"
|
vscode-extension-telemetry "^0.1.6"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user