From ca43adeee8a99568fae5a7a23155198dd5e1c37e Mon Sep 17 00:00:00 2001 From: ssreerama Date: Mon, 5 Jun 2023 08:26:20 -0700 Subject: [PATCH 01/16] Initial commit for adding a basic general tab for the database properties --- extensions/admin-tool-ext-win/package.json | 4 +- extensions/mssql/package.json | 2 +- extensions/mssql/src/mssql.d.ts | 18 +++ .../mssql/src/objectManagement/commands.ts | 17 +- .../objectManagement/localizedConstants.ts | 22 +++ .../objectManagementService.ts | 36 +++++ .../ui/databasePropertiesDialog.ts | 151 ++++++++++++++++++ extensions/mssql/src/ui/dialogBase.ts | 17 ++ 8 files changed, 259 insertions(+), 8 deletions(-) create mode 100644 extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts diff --git a/extensions/admin-tool-ext-win/package.json b/extensions/admin-tool-ext-win/package.json index f460695e3a17..2bbf3ade9222 100644 --- a/extensions/admin-tool-ext-win/package.json +++ b/extensions/admin-tool-ext-win/package.json @@ -70,7 +70,7 @@ }, { "command": "adminToolExtWin.launchSsmsMinPropertiesDialog", - "when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", + "when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", "group": "z-AdminToolExt@2" }, { @@ -92,7 +92,7 @@ }, { "command": "adminToolExtWin.launchSsmsMinPropertiesDialog", - "when": "isWindows && connectionProvider == MSSQL && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", + "when": "isWindows && connectionProvider == MSSQL && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", "group": "z-AdminToolExt@2" }, { diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index bcf648708739..ba5d17054629 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -509,7 +509,7 @@ }, { "command": "mssql.objectProperties", - "when": "connectionProvider == MSSQL && nodeType =~ /^(ServerLevelLogin|User|ServerLevelServerRole|ApplicationRole|DatabaseRole)$/ && config.workbench.enablePreviewFeatures", + "when": "connectionProvider == MSSQL && nodeType =~ /^(ServerLevelLogin|User|ServerLevelServerRole|ApplicationRole|DatabaseRole|Database)$/ && config.workbench.enablePreviewFeatures", "group": "0_query@1", "isDefault": true }, diff --git a/extensions/mssql/src/mssql.d.ts b/extensions/mssql/src/mssql.d.ts index 4bedc2d7155c..4fe127a1e562 100644 --- a/extensions/mssql/src/mssql.d.ts +++ b/extensions/mssql/src/mssql.d.ts @@ -899,6 +899,7 @@ declare module 'mssql' { Column = "Column", Database = "Database", DatabaseRole = "DatabaseRole", + DatabaseProperties = "DatabaseProperties", ServerLevelLogin = "ServerLevelLogin", ServerLevelServerRole = "ServerLevelServerRole", Table = "Table", @@ -1379,6 +1380,23 @@ declare module 'mssql' { containmentTypes: string[]; recoveryModels: string[]; } + + export interface DatabasePropertiesInfo extends SqlObject { + collationName: string; + dateCreated: string; + lastDatabaseBackup: string; + lastDatabaseLogBackup: string; + memoryAllocatedToMemoryOptimizedObjects: string; + memoryUsedByMemoryOptimizedObjects: string; + numberOfUsers: string; + owner: string; + size: string; + spaceAvailable: string; + status: string; + } + + export interface DatabasePropertiesViewInfo extends ObjectViewInfo { + } } export interface IObjectManagementService { diff --git a/extensions/mssql/src/objectManagement/commands.ts b/extensions/mssql/src/objectManagement/commands.ts index a795429c388b..fab7f71e9c11 100644 --- a/extensions/mssql/src/objectManagement/commands.ts +++ b/extensions/mssql/src/objectManagement/commands.ts @@ -22,10 +22,11 @@ import { ServerRoleDialog } from './ui/serverRoleDialog'; import { DatabaseRoleDialog } from './ui/databaseRoleDialog'; import { ApplicationRoleDialog } from './ui/applicationRoleDialog'; import { DatabaseDialog } from './ui/databaseDialog'; +import { DatabasePropertiesDialog } from './ui/databasePropertiesDialog'; export function registerObjectManagementCommands(appContext: AppContext) { // Notes: Change the second parameter to false to use the actual object management service. - const service = getObjectManagementService(appContext, false); + const service = getObjectManagementService(appContext, true); appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newObject', async (context: azdata.ObjectExplorerContext) => { await handleNewObjectDialogCommand(context, service); })); @@ -106,15 +107,19 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore return; } try { - const parentUrn = await getParentUrn(context); + const parentUrn = context.nodeInfo ? await getParentUrn(context) : undefined; + const objectType = context.nodeInfo && context.nodeInfo.nodeType === 'Database' ? ObjectManagement.NodeType.DatabaseProperties : context.nodeInfo.nodeType as ObjectManagement.NodeType; + const objectName = context.nodeInfo ? context.nodeInfo.label : objectManagementLoc.PropertiesHeader; + const objectUrn = context.nodeInfo ? context.nodeInfo!.metadata!.urn : undefined; + const options: ObjectManagementDialogOptions = { connectionUri: connectionUri, isNewObject: false, database: context.connectionProfile!.databaseName!, - objectType: context.nodeInfo.nodeType as ObjectManagement.NodeType, - objectName: context.nodeInfo.label, + objectType: objectType, + objectName: objectName, parentUrn: parentUrn, - objectUrn: context.nodeInfo!.metadata!.urn, + objectUrn: objectUrn, objectExplorerContext: context }; const dialog = getDialog(service, options); @@ -246,6 +251,8 @@ function getDialog(service: IObjectManagementService, dialogOptions: ObjectManag return new UserDialog(service, dialogOptions); case ObjectManagement.NodeType.Database: return new DatabaseDialog(service, dialogOptions); + case ObjectManagement.NodeType.DatabaseProperties: + return new DatabasePropertiesDialog(service, dialogOptions); default: throw new Error(`Unsupported object type: ${dialogOptions.objectType}`); } diff --git a/extensions/mssql/src/objectManagement/localizedConstants.ts b/extensions/mssql/src/objectManagement/localizedConstants.ts index 1a7e551577a4..373a79e0328e 100644 --- a/extensions/mssql/src/objectManagement/localizedConstants.ts +++ b/extensions/mssql/src/objectManagement/localizedConstants.ts @@ -216,6 +216,26 @@ export const ObjectSelectionMethodDialog_AllObjectsOfTypes = localize('objectMan export const ObjectSelectionMethodDialog_AllObjectsOfSchema = localize('objectManagement.ObjectSelectionMethodDialog_AllObjectsOfSchema', "All objects belonging to a schema"); export const ObjectSelectionMethodDialog_SelectSchemaDropdownLabel = localize('objectManagement.ObjectSelectionMethodDialog_SelectSchemaDropdownLabel', "Schema"); +// Object Properties Dialog +export const PropertiesHeader = localize('objectManagement.properties', "Properties"); +export const FilesHeaderText = localize('objectManagement.filesHeaderText', "Files"); + +//Database properties Dialog +export const LastDatabaseBackupText = localize('objectManagement.lastDatabaseBackup', "Last Database Backup"); +export const LastDatabaseLogBackupText = localize('objectManagement.lastDatabaseLogBackup', "Last Database Log Backup"); +export const BackupSectionHeader = localize('objectManagement.databaseProperties.backupSectionHeader', "Backup"); +export const DatabaseSectionHeader = localize('objectManagement.databaseProperties.databaseSectionHeader', "Database"); +export const MaintenanceSectionHeader = localize('objectManagement.databaseProperties.maintenanceSectionHeader', "Maintenance"); +export const NamePropertyText = localize('objectManagement.databaseProperties.name', "Name"); +export const StatusText = localize('objectManagement.databaseProperties.status', "Status"); +export const OwnerPropertyText = localize('objectManagement.databaseProperties.owner', "Owner"); +export const DateCreatedText = localize('objectManagement.databaseProperties.dateCreated', "Date Created"); +export const SizeText = localize('objectManagement.databaseProperties.size', "Size"); +export const SpaceAvailableText = localize('objectManagement.databaseProperties.spaceAvailable', "Space Available"); +export const NumberOfUsersText = localize('objectManagement.databaseProperties.numberOfUsers', "Number of Users"); +export const MemoryAllocatedText = localize('objectManagement.databaseProperties.memoryAllocated', "Memory Allocated To Memory Optimized Objects"); +export const MemoryUsedText = localize('objectManagement.databaseProperties.memoryUsed', "Memory Used By Memory Optimized Objects"); + // Util functions export function getNodeTypeDisplayName(type: string, inTitle: boolean = false): string { switch (type) { @@ -237,6 +257,8 @@ export function getNodeTypeDisplayName(type: string, inTitle: boolean = false): return ColumnTypeDisplayName; case ObjectManagement.NodeType.Database: return inTitle ? DatabaseTypeDisplayNameInTitle : DatabaseTypeDisplayName; + case ObjectManagement.NodeType.DatabaseProperties: + return inTitle ? DatabaseTypeDisplayNameInTitle : DatabaseTypeDisplayName; default: throw new Error(`Unknown node type: ${type}`); } diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index 989567a60532..d13cf1006204 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -194,6 +194,8 @@ export class TestObjectManagementService implements IObjectManagementService { obj = this.getApplicationRoleView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.DatabaseRole) { obj = this.getDatabaseRoleView(isNewObject, objectUrn); + } else if (objectType === ObjectManagement.NodeType.DatabaseProperties) { + obj = this.getDatabasePropertiesView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelLogin) { obj = this.getLoginView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelServerRole) { @@ -432,6 +434,40 @@ export class TestObjectManagementService implements IObjectManagementService { }; } + private getDatabasePropertiesView(isNewObject: boolean, name: string): ObjectManagement.DatabasePropertiesViewInfo { + return isNewObject ? { + objectInfo: { + name: '', + collationName: '', + dateCreated: '', + lastDatabaseBackup: '', + lastDatabaseLogBackup: '', + memoryAllocatedToMemoryOptimizedObjects: '', + memoryUsedByMemoryOptimizedObjects: '', + numberOfUsers: '', + owner: '', + size: '', + spaceAvailable: '', + status: '' + } + } : { + objectInfo: { + name: 'Database Properties1', + collationName: 'Latin1_General_100_CI_AS_KS_WS', + dateCreated: '5/31/2023 8:05:55 AM', + lastDatabaseBackup: 'None', + lastDatabaseLogBackup: 'None', + memoryAllocatedToMemoryOptimizedObjects: '0.00 MB', + memoryUsedByMemoryOptimizedObjects: '0.00 MB', + numberOfUsers: '5', + owner: 'databaseProperties 1', + size: '16.00 MB', + spaceAvailable: '1.15 MB', + status: 'Normal' + } + }; + } + private delayAndResolve(obj?: any): Promise { return new Promise((resolve, reject) => { setTimeout(() => { diff --git a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts new file mode 100644 index 000000000000..12b9d44651aa --- /dev/null +++ b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts @@ -0,0 +1,151 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import * as azdata from 'azdata'; +import * as localizedConstants from '../localizedConstants'; +import { IObjectManagementService, ObjectManagement } from 'mssql'; +import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase'; +import { AlterUserDocUrl, CreateUserDocUrl } from '../constants'; + +export class DatabasePropertiesDialog extends ObjectManagementDialogBase { + + // Tabs + private generalTab: azdata.window.DialogTab; + private filesTab: azdata.window.DialogTab; + + // Backup section and its inputs + private backupSection: azdata.GroupContainer; + private lastDatabaseBackupInput: azdata.InputBoxComponent; + private lastDatabaseLogBackupInput: azdata.InputBoxComponent; + + // Database section and its inputs + private databaseSection: azdata.GroupContainer; + private nameInput: azdata.InputBoxComponent; + private statusInput: azdata.InputBoxComponent; + private ownerInput: azdata.InputBoxComponent; + private dateCreatedInput: azdata.InputBoxComponent; + private sizeInput: azdata.InputBoxComponent; + private spaceAvailabeInput: azdata.InputBoxComponent; + private numberOfUsersInput: azdata.InputBoxComponent; + private memoryAllocatedInput: azdata.InputBoxComponent; + private memoryUsedInput: azdata.InputBoxComponent; + + // Maintenance section and its inputs + private maintenanceSection: azdata.GroupContainer; + private collationInput: azdata.InputBoxComponent; + + constructor(objectManagementService: IObjectManagementService, options: ObjectManagementDialogOptions) { + super(objectManagementService, options); + this.generalTab = azdata.window.createTab(localizedConstants.GeneralSectionHeader); + this.filesTab = azdata.window.createTab(localizedConstants.FilesHeaderText); + } + + protected async initializeUI(): Promise { + const sections: azdata.Component[] = []; + + this.initializeBackupSection(); + sections.push(this.backupSection); + + this.initializeDatabaseSection(); + sections.push(this.databaseSection); + + this.initializeMaintenanceSection(); + sections.push(this.maintenanceSection); + + this.formContainer.addItems(sections, this.getSectionItemLayout()); + this.registerTab(this.generalTab, [this.formContainer]); + + this.dialogObject.content = [this.generalTab, this.filesTab]; + azdata.window.openDialog(this.dialogObject); + } + + protected override get helpUrl(): string { + return this.options.isNewObject ? CreateUserDocUrl : AlterUserDocUrl; + } + + private initializeBackupSection(): void { + this.lastDatabaseBackupInput = this.createInputBox(localizedConstants.LastDatabaseBackupText, async (newValue) => { + this.objectInfo.lastDatabaseBackup = newValue; + }, this.objectInfo.lastDatabaseBackup, this.options.isNewObject); + const lastDatabaseBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseBackupText, this.lastDatabaseBackupInput); + + this.lastDatabaseLogBackupInput = this.createInputBox(localizedConstants.LastDatabaseLogBackupText, async (newValue) => { + this.objectInfo.lastDatabaseLogBackup = newValue; + }, this.objectInfo.lastDatabaseLogBackup, this.options.isNewObject); + const lastDatabaseLogBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseLogBackupText, this.lastDatabaseLogBackupInput); + + this.backupSection = this.createGroup(localizedConstants.BackupSectionHeader, [ + lastDatabaseBackupContainer, + lastDatabaseLogBackupContainer + ], false); + } + + private initializeDatabaseSection(): void { + this.nameInput = this.createInputBox(localizedConstants.NamePropertyText, async (newValue) => { + this.objectInfo.name = newValue; + }, this.objectInfo.name, this.options.isNewObject); + const nameContainer = this.createLabelInputContainer(localizedConstants.NamePropertyText, this.nameInput); + + this.statusInput = this.createInputBox(localizedConstants.StatusText, async (newValue) => { + this.objectInfo.status = newValue; + }, this.objectInfo.status, this.options.isNewObject); + const statusContainer = this.createLabelInputContainer(localizedConstants.StatusText, this.statusInput); + + this.ownerInput = this.createInputBox(localizedConstants.OwnerPropertyText, async (newValue) => { + this.objectInfo.owner = newValue; + }, this.objectInfo.owner, this.options.isNewObject); + const ownerContainer = this.createLabelInputContainer(localizedConstants.OwnerPropertyText, this.ownerInput); + + this.dateCreatedInput = this.createInputBox(localizedConstants.DateCreatedText, async (newValue) => { + this.objectInfo.dateCreated = newValue; + }, this.objectInfo.dateCreated, this.options.isNewObject); + const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); + + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async (newValue) => { + this.objectInfo.size = newValue; + }, this.objectInfo.size, this.options.isNewObject); + const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); + + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async (newValue) => { + this.objectInfo.spaceAvailable = newValue; + }, this.objectInfo.spaceAvailable, this.options.isNewObject); + const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); + + this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async (newValue) => { + this.objectInfo.numberOfUsers = newValue; + }, this.objectInfo.numberOfUsers, this.options.isNewObject); + const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); + + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async (newValue) => { + this.objectInfo.memoryAllocatedToMemoryOptimizedObjects = newValue; + }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjects, this.options.isNewObject); + const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); + + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async (newValue) => { + this.objectInfo.memoryUsedByMemoryOptimizedObjects = newValue; + }, this.objectInfo.memoryUsedByMemoryOptimizedObjects, this.options.isNewObject); + const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); + + this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ + nameContainer, + statusContainer, + ownerContainer, + dateCreatedContainer, + sizeContainer, + spaceAvailabeContainer, + numberOfUsersContainer, + memoryAllocatedContainer, + memoryUsedContainer + ], false); + } + + private initializeMaintenanceSection(): void { + this.collationInput = this.createInputBox(localizedConstants.CollationText, async (newValue) => { + this.objectInfo.collationName = newValue; + }, this.objectInfo.collationName, this.options.isNewObject); + const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); + + this.maintenanceSection = this.createGroup(localizedConstants.MaintenanceSectionHeader, [collationContainer], false); + } +} diff --git a/extensions/mssql/src/ui/dialogBase.ts b/extensions/mssql/src/ui/dialogBase.ts index a347723d86d5..261b8ed88683 100644 --- a/extensions/mssql/src/ui/dialogBase.ts +++ b/extensions/mssql/src/ui/dialogBase.ts @@ -165,6 +165,23 @@ export abstract class DialogBase { }).withItems(items).component(); } + protected registerTab(tab: azdata.window.DialogTab, items: azdata.Component[]): void { + tab.registerContent(async view => { + let formModel = this.modelView.modelBuilder.formContainer().withFormItems( + [ + { + component: this.modelView.modelBuilder.flexContainer().withLayout({ flexFlow: 'row' }).withItems(items).component(), + title: '' + } + ], + { + horizontal: false + } + ).component(); + await view.initializeModel(formModel); + }); + } + protected createTableList(ariaLabel: string, columnNames: string[], allItems: T[], From ca0ad70bd10fcf4732ef358a5a1bea1f3eed8d0d Mon Sep 17 00:00:00 2001 From: ssreerama Date: Mon, 5 Jun 2023 11:04:40 -0700 Subject: [PATCH 02/16] Refactoring for dialog inputs --- .../ui/databasePropertiesDialog.ts | 70 ++++++------------- extensions/mssql/src/ui/dialogBase.ts | 4 +- 2 files changed, 23 insertions(+), 51 deletions(-) diff --git a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts index 12b9d44651aa..68abef800c3a 100644 --- a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts @@ -10,16 +10,16 @@ import { AlterUserDocUrl, CreateUserDocUrl } from '../constants'; export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - // Tabs + // Horizontal Tabs private generalTab: azdata.window.DialogTab; private filesTab: azdata.window.DialogTab; - // Backup section and its inputs + // GeneralTab: Backup section and its inputs private backupSection: azdata.GroupContainer; private lastDatabaseBackupInput: azdata.InputBoxComponent; private lastDatabaseLogBackupInput: azdata.InputBoxComponent; - // Database section and its inputs + // GeneralTab: Database section and its inputs private databaseSection: azdata.GroupContainer; private nameInput: azdata.InputBoxComponent; private statusInput: azdata.InputBoxComponent; @@ -31,7 +31,7 @@ export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - const sections: azdata.Component[] = []; - this.initializeBackupSection(); - sections.push(this.backupSection); - this.initializeDatabaseSection(); - sections.push(this.databaseSection); - this.initializeMaintenanceSection(); - sections.push(this.maintenanceSection); - this.formContainer.addItems(sections, this.getSectionItemLayout()); - this.registerTab(this.generalTab, [this.formContainer]); + this.registerTab(this.generalTab, [this.backupSection, this.databaseSection, this.maintenanceSection]); this.dialogObject.content = [this.generalTab, this.filesTab]; + + // We need to close the already opened dialog during handleObjectPropertiesDialogCommand, + // which is required for the horizontal dialog tabs, as we cannot refresh the exising dialog + azdata.window.closeDialog(this.dialogObject); azdata.window.openDialog(this.dialogObject); } @@ -65,14 +61,10 @@ export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - this.objectInfo.lastDatabaseBackup = newValue; - }, this.objectInfo.lastDatabaseBackup, this.options.isNewObject); + this.lastDatabaseBackupInput = this.createInputBox(localizedConstants.LastDatabaseBackupText, async () => { }, this.objectInfo.lastDatabaseBackup, this.options.isNewObject); const lastDatabaseBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseBackupText, this.lastDatabaseBackupInput); - this.lastDatabaseLogBackupInput = this.createInputBox(localizedConstants.LastDatabaseLogBackupText, async (newValue) => { - this.objectInfo.lastDatabaseLogBackup = newValue; - }, this.objectInfo.lastDatabaseLogBackup, this.options.isNewObject); + this.lastDatabaseLogBackupInput = this.createInputBox(localizedConstants.LastDatabaseLogBackupText, async () => { }, this.objectInfo.lastDatabaseLogBackup, this.options.isNewObject); const lastDatabaseLogBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseLogBackupText, this.lastDatabaseLogBackupInput); this.backupSection = this.createGroup(localizedConstants.BackupSectionHeader, [ @@ -82,49 +74,31 @@ export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - this.objectInfo.name = newValue; - }, this.objectInfo.name, this.options.isNewObject); + this.nameInput = this.createInputBox(localizedConstants.NamePropertyText, async () => { }, this.objectInfo.name, this.options.isNewObject); const nameContainer = this.createLabelInputContainer(localizedConstants.NamePropertyText, this.nameInput); - this.statusInput = this.createInputBox(localizedConstants.StatusText, async (newValue) => { - this.objectInfo.status = newValue; - }, this.objectInfo.status, this.options.isNewObject); + this.statusInput = this.createInputBox(localizedConstants.StatusText, async () => { }, this.objectInfo.status, this.options.isNewObject); const statusContainer = this.createLabelInputContainer(localizedConstants.StatusText, this.statusInput); - this.ownerInput = this.createInputBox(localizedConstants.OwnerPropertyText, async (newValue) => { - this.objectInfo.owner = newValue; - }, this.objectInfo.owner, this.options.isNewObject); + this.ownerInput = this.createInputBox(localizedConstants.OwnerPropertyText, async () => { }, this.objectInfo.owner, this.options.isNewObject); const ownerContainer = this.createLabelInputContainer(localizedConstants.OwnerPropertyText, this.ownerInput); - this.dateCreatedInput = this.createInputBox(localizedConstants.DateCreatedText, async (newValue) => { - this.objectInfo.dateCreated = newValue; - }, this.objectInfo.dateCreated, this.options.isNewObject); + this.dateCreatedInput = this.createInputBox(localizedConstants.DateCreatedText, async () => { }, this.objectInfo.dateCreated, this.options.isNewObject); const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); - this.sizeInput = this.createInputBox(localizedConstants.SizeText, async (newValue) => { - this.objectInfo.size = newValue; - }, this.objectInfo.size, this.options.isNewObject); + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.size, this.options.isNewObject); const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); - this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async (newValue) => { - this.objectInfo.spaceAvailable = newValue; - }, this.objectInfo.spaceAvailable, this.options.isNewObject); + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailable, this.options.isNewObject); const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); - this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async (newValue) => { - this.objectInfo.numberOfUsers = newValue; - }, this.objectInfo.numberOfUsers, this.options.isNewObject); + this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers, this.options.isNewObject); const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); - this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async (newValue) => { - this.objectInfo.memoryAllocatedToMemoryOptimizedObjects = newValue; - }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjects, this.options.isNewObject); + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjects, this.options.isNewObject); const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); - this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async (newValue) => { - this.objectInfo.memoryUsedByMemoryOptimizedObjects = newValue; - }, this.objectInfo.memoryUsedByMemoryOptimizedObjects, this.options.isNewObject); + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjects, this.options.isNewObject); const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ @@ -141,9 +115,7 @@ export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - this.objectInfo.collationName = newValue; - }, this.objectInfo.collationName, this.options.isNewObject); + this.collationInput = this.createInputBox(localizedConstants.CollationText, async () => { }, this.objectInfo.collationName, this.options.isNewObject); const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); this.maintenanceSection = this.createGroup(localizedConstants.MaintenanceSectionHeader, [collationContainer], false); diff --git a/extensions/mssql/src/ui/dialogBase.ts b/extensions/mssql/src/ui/dialogBase.ts index 261b8ed88683..30a1445ac604 100644 --- a/extensions/mssql/src/ui/dialogBase.ts +++ b/extensions/mssql/src/ui/dialogBase.ts @@ -170,12 +170,12 @@ export abstract class DialogBase { let formModel = this.modelView.modelBuilder.formContainer().withFormItems( [ { - component: this.modelView.modelBuilder.flexContainer().withLayout({ flexFlow: 'row' }).withItems(items).component(), + component: this.modelView.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).withItems(items).component(), title: '' } ], { - horizontal: false + horizontal: true } ).component(); await view.initializeModel(formModel); From 1a9094a0f7bb91050c3913821cb5f2120a40b4ee Mon Sep 17 00:00:00 2001 From: ssreerama Date: Tue, 6 Jun 2023 09:48:42 -0700 Subject: [PATCH 03/16] removed properties nodeType and using database node and additional cleanup, diabling the functionality. --- extensions/admin-tool-ext-win/package.json | 4 ++-- extensions/mssql/package.json | 2 +- extensions/mssql/src/mssql.d.ts | 1 - .../mssql/src/objectManagement/commands.ts | 18 +++++++----------- .../objectManagement/localizedConstants.ts | 4 +--- .../objectManagementService.ts | 19 ++----------------- .../ui/objectManagementDialogBase.ts | 1 + 7 files changed, 14 insertions(+), 35 deletions(-) diff --git a/extensions/admin-tool-ext-win/package.json b/extensions/admin-tool-ext-win/package.json index 2bbf3ade9222..f460695e3a17 100644 --- a/extensions/admin-tool-ext-win/package.json +++ b/extensions/admin-tool-ext-win/package.json @@ -70,7 +70,7 @@ }, { "command": "adminToolExtWin.launchSsmsMinPropertiesDialog", - "when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", + "when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", "group": "z-AdminToolExt@2" }, { @@ -92,7 +92,7 @@ }, { "command": "adminToolExtWin.launchSsmsMinPropertiesDialog", - "when": "isWindows && connectionProvider == MSSQL && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", + "when": "isWindows && connectionProvider == MSSQL && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|ServerLevelLinkedServer)$/", "group": "z-AdminToolExt@2" }, { diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index ba5d17054629..bcf648708739 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -509,7 +509,7 @@ }, { "command": "mssql.objectProperties", - "when": "connectionProvider == MSSQL && nodeType =~ /^(ServerLevelLogin|User|ServerLevelServerRole|ApplicationRole|DatabaseRole|Database)$/ && config.workbench.enablePreviewFeatures", + "when": "connectionProvider == MSSQL && nodeType =~ /^(ServerLevelLogin|User|ServerLevelServerRole|ApplicationRole|DatabaseRole)$/ && config.workbench.enablePreviewFeatures", "group": "0_query@1", "isDefault": true }, diff --git a/extensions/mssql/src/mssql.d.ts b/extensions/mssql/src/mssql.d.ts index 4fe127a1e562..e671e28f9f3e 100644 --- a/extensions/mssql/src/mssql.d.ts +++ b/extensions/mssql/src/mssql.d.ts @@ -899,7 +899,6 @@ declare module 'mssql' { Column = "Column", Database = "Database", DatabaseRole = "DatabaseRole", - DatabaseProperties = "DatabaseProperties", ServerLevelLogin = "ServerLevelLogin", ServerLevelServerRole = "ServerLevelServerRole", Table = "Table", diff --git a/extensions/mssql/src/objectManagement/commands.ts b/extensions/mssql/src/objectManagement/commands.ts index fab7f71e9c11..765d58ff0587 100644 --- a/extensions/mssql/src/objectManagement/commands.ts +++ b/extensions/mssql/src/objectManagement/commands.ts @@ -26,7 +26,7 @@ import { DatabasePropertiesDialog } from './ui/databasePropertiesDialog'; export function registerObjectManagementCommands(appContext: AppContext) { // Notes: Change the second parameter to false to use the actual object management service. - const service = getObjectManagementService(appContext, true); + const service = getObjectManagementService(appContext, false); appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newObject', async (context: azdata.ObjectExplorerContext) => { await handleNewObjectDialogCommand(context, service); })); @@ -108,18 +108,15 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore } try { const parentUrn = context.nodeInfo ? await getParentUrn(context) : undefined; - const objectType = context.nodeInfo && context.nodeInfo.nodeType === 'Database' ? ObjectManagement.NodeType.DatabaseProperties : context.nodeInfo.nodeType as ObjectManagement.NodeType; - const objectName = context.nodeInfo ? context.nodeInfo.label : objectManagementLoc.PropertiesHeader; - const objectUrn = context.nodeInfo ? context.nodeInfo!.metadata!.urn : undefined; - const options: ObjectManagementDialogOptions = { + command: objectManagementLoc.PropertiesCommandText, connectionUri: connectionUri, isNewObject: false, database: context.connectionProfile!.databaseName!, - objectType: objectType, - objectName: objectName, + objectType: context.nodeInfo.nodeType as ObjectManagement.NodeType, + objectName: context.nodeInfo.label, parentUrn: parentUrn, - objectUrn: objectUrn, + objectUrn: context.nodeInfo!.metadata!.urn, objectExplorerContext: context }; const dialog = getDialog(service, options); @@ -250,9 +247,8 @@ function getDialog(service: IObjectManagementService, dialogOptions: ObjectManag case ObjectManagement.NodeType.User: return new UserDialog(service, dialogOptions); case ObjectManagement.NodeType.Database: - return new DatabaseDialog(service, dialogOptions); - case ObjectManagement.NodeType.DatabaseProperties: - return new DatabasePropertiesDialog(service, dialogOptions); + return dialogOptions.command === objectManagementLoc.PropertiesCommandText ? + new DatabasePropertiesDialog(service, dialogOptions) : new DatabaseDialog(service, dialogOptions); default: throw new Error(`Unsupported object type: ${dialogOptions.objectType}`); } diff --git a/extensions/mssql/src/objectManagement/localizedConstants.ts b/extensions/mssql/src/objectManagement/localizedConstants.ts index 373a79e0328e..66a80a6dc424 100644 --- a/extensions/mssql/src/objectManagement/localizedConstants.ts +++ b/extensions/mssql/src/objectManagement/localizedConstants.ts @@ -217,8 +217,8 @@ export const ObjectSelectionMethodDialog_AllObjectsOfSchema = localize('objectMa export const ObjectSelectionMethodDialog_SelectSchemaDropdownLabel = localize('objectManagement.ObjectSelectionMethodDialog_SelectSchemaDropdownLabel', "Schema"); // Object Properties Dialog -export const PropertiesHeader = localize('objectManagement.properties', "Properties"); export const FilesHeaderText = localize('objectManagement.filesHeaderText', "Files"); +export const PropertiesCommandText = localize('objectManagement.propertiesCommandText', "Properties"); //Database properties Dialog export const LastDatabaseBackupText = localize('objectManagement.lastDatabaseBackup', "Last Database Backup"); @@ -257,8 +257,6 @@ export function getNodeTypeDisplayName(type: string, inTitle: boolean = false): return ColumnTypeDisplayName; case ObjectManagement.NodeType.Database: return inTitle ? DatabaseTypeDisplayNameInTitle : DatabaseTypeDisplayName; - case ObjectManagement.NodeType.DatabaseProperties: - return inTitle ? DatabaseTypeDisplayNameInTitle : DatabaseTypeDisplayName; default: throw new Error(`Unknown node type: ${type}`); } diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index d13cf1006204..4df01ac918a3 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -194,7 +194,7 @@ export class TestObjectManagementService implements IObjectManagementService { obj = this.getApplicationRoleView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.DatabaseRole) { obj = this.getDatabaseRoleView(isNewObject, objectUrn); - } else if (objectType === ObjectManagement.NodeType.DatabaseProperties) { + } else if (objectType === ObjectManagement.NodeType.Database) { obj = this.getDatabasePropertiesView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelLogin) { obj = this.getLoginView(isNewObject, objectUrn); @@ -435,22 +435,7 @@ export class TestObjectManagementService implements IObjectManagementService { } private getDatabasePropertiesView(isNewObject: boolean, name: string): ObjectManagement.DatabasePropertiesViewInfo { - return isNewObject ? { - objectInfo: { - name: '', - collationName: '', - dateCreated: '', - lastDatabaseBackup: '', - lastDatabaseLogBackup: '', - memoryAllocatedToMemoryOptimizedObjects: '', - memoryUsedByMemoryOptimizedObjects: '', - numberOfUsers: '', - owner: '', - size: '', - spaceAvailable: '', - status: '' - } - } : { + return { objectInfo: { name: 'Database Properties1', collationName: 'Latin1_General_100_CI_AS_KS_WS', diff --git a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts index f78313faa6a7..6c4262b3b69b 100644 --- a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts +++ b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts @@ -20,6 +20,7 @@ function getDialogName(type: ObjectManagement.NodeType, isNewObject: boolean): s } export interface ObjectManagementDialogOptions extends ScriptableDialogOptions { + command?: string; connectionUri: string; database?: string; objectType: ObjectManagement.NodeType; From 84d24c74f58db44786df3e55adeb84f709be1edd Mon Sep 17 00:00:00 2001 From: ssreerama Date: Thu, 8 Jun 2023 13:37:12 -0700 Subject: [PATCH 04/16] Changes according to STS data fetch --- extensions/mssql/src/contracts.ts | 1 + extensions/mssql/src/mssql.d.ts | 24 +++++++++---------- .../mssql/src/objectManagement/commands.ts | 11 +++++++-- .../objectManagementService.ts | 8 +++---- .../ui/databasePropertiesDialog.ts | 8 +++---- .../ui/objectManagementDialogBase.ts | 4 ++-- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/extensions/mssql/src/contracts.ts b/extensions/mssql/src/contracts.ts index 1518dfaedbb7..992b6d02384c 100644 --- a/extensions/mssql/src/contracts.ts +++ b/extensions/mssql/src/contracts.ts @@ -1554,6 +1554,7 @@ export namespace ExecutionPlanComparisonRequest { export interface InitializeViewRequestParams { connectionUri: string; database: string; + dialogType?: string; contextId: string; isNewObject: boolean; objectType: string; diff --git a/extensions/mssql/src/mssql.d.ts b/extensions/mssql/src/mssql.d.ts index e671e28f9f3e..53a924c0377f 100644 --- a/extensions/mssql/src/mssql.d.ts +++ b/extensions/mssql/src/mssql.d.ts @@ -1381,17 +1381,17 @@ declare module 'mssql' { } export interface DatabasePropertiesInfo extends SqlObject { - collationName: string; - dateCreated: string; - lastDatabaseBackup: string; - lastDatabaseLogBackup: string; - memoryAllocatedToMemoryOptimizedObjects: string; - memoryUsedByMemoryOptimizedObjects: string; - numberOfUsers: string; - owner: string; - size: string; - spaceAvailable: string; - status: string; + collationName?: string; + dateCreated?: string; + lastDatabaseBackup?: string; + lastDatabaseLogBackup?: string; + memoryAllocatedToMemoryOptimizedObjectsInMb?: string; + memoryUsedByMemoryOptimizedObjectsInMb?: string; + numberOfUsers?: string; + owner?: string; + sizeInMb?: string; + spaceAvailableInMb?: string; + status?: string; } export interface DatabasePropertiesViewInfo extends ObjectViewInfo { @@ -1409,7 +1409,7 @@ declare module 'mssql' { * @param parentUrn The parent object's URN. * @param objectUrn The object's URN. */ - initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string): Thenable>; + initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string, dialogType?: string): Thenable>; /** * Save an object. * @param contextId The object view's context id. diff --git a/extensions/mssql/src/objectManagement/commands.ts b/extensions/mssql/src/objectManagement/commands.ts index 765d58ff0587..de4525b14d6b 100644 --- a/extensions/mssql/src/objectManagement/commands.ts +++ b/extensions/mssql/src/objectManagement/commands.ts @@ -41,6 +41,12 @@ export function registerObjectManagementCommands(appContext: AppContext) { })); } +export enum DialogType { + New = 'New', + Edit = 'Edit', + Properties = 'Properties' +} + function getObjectManagementService(appContext: AppContext, useTestService: boolean): IObjectManagementService { if (useTestService) { return new TestObjectManagementService(); @@ -84,6 +90,7 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex connectionUri: connectionUri, isNewObject: true, database: context.connectionProfile!.databaseName!, + dialogType: DialogType.New, objectType: objectType, objectName: '', parentUrn: parentUrn, @@ -109,10 +116,10 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore try { const parentUrn = context.nodeInfo ? await getParentUrn(context) : undefined; const options: ObjectManagementDialogOptions = { - command: objectManagementLoc.PropertiesCommandText, connectionUri: connectionUri, isNewObject: false, database: context.connectionProfile!.databaseName!, + dialogType: DialogType.Properties, objectType: context.nodeInfo.nodeType as ObjectManagement.NodeType, objectName: context.nodeInfo.label, parentUrn: parentUrn, @@ -247,7 +254,7 @@ function getDialog(service: IObjectManagementService, dialogOptions: ObjectManag case ObjectManagement.NodeType.User: return new UserDialog(service, dialogOptions); case ObjectManagement.NodeType.Database: - return dialogOptions.command === objectManagementLoc.PropertiesCommandText ? + return dialogOptions.dialogType === DialogType.Properties ? new DatabasePropertiesDialog(service, dialogOptions) : new DatabaseDialog(service, dialogOptions); default: throw new Error(`Unsupported object type: ${dialogOptions.objectType}`); diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index 4df01ac918a3..6d97a05e9631 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -28,8 +28,8 @@ export class ObjectManagementService extends BaseService implements IObjectManag }; } - async initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string): Promise> { - const params: contracts.InitializeViewRequestParams = { connectionUri, contextId, isNewObject, objectType, database, parentUrn, objectUrn }; + async initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string, dialogType?: string): Promise> { + const params: contracts.InitializeViewRequestParams = { connectionUri, contextId, isNewObject, objectType, database, parentUrn, objectUrn, dialogType }; return this.runWithErrorHandling(contracts.InitializeViewRequest.type, params); } @@ -195,7 +195,7 @@ export class TestObjectManagementService implements IObjectManagementService { } else if (objectType === ObjectManagement.NodeType.DatabaseRole) { obj = this.getDatabaseRoleView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.Database) { - obj = this.getDatabasePropertiesView(isNewObject, objectUrn); + obj = this.getDatabasePropertiesView(objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelLogin) { obj = this.getLoginView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelServerRole) { @@ -434,7 +434,7 @@ export class TestObjectManagementService implements IObjectManagementService { }; } - private getDatabasePropertiesView(isNewObject: boolean, name: string): ObjectManagement.DatabasePropertiesViewInfo { + private getDatabasePropertiesView(name: string): ObjectManagement.DatabasePropertiesViewInfo { return { objectInfo: { name: 'Database Properties1', diff --git a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts index 68abef800c3a..6e06f6ad7d2d 100644 --- a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts @@ -86,19 +86,19 @@ export class DatabasePropertiesDialog extends ObjectManagementDialogBase { }, this.objectInfo.dateCreated, this.options.isNewObject); const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); - this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.size, this.options.isNewObject); + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.sizeInMb, this.options.isNewObject); const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); - this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailable, this.options.isNewObject); + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailableInMb, this.options.isNewObject); const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers, this.options.isNewObject); const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); - this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjects, this.options.isNewObject); + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb, this.options.isNewObject); const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); - this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjects, this.options.isNewObject); + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb, this.options.isNewObject); const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ diff --git a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts index 6c4262b3b69b..911a46c115fc 100644 --- a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts +++ b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts @@ -20,9 +20,9 @@ function getDialogName(type: ObjectManagement.NodeType, isNewObject: boolean): s } export interface ObjectManagementDialogOptions extends ScriptableDialogOptions { - command?: string; connectionUri: string; database?: string; + dialogType?: string; objectType: ObjectManagement.NodeType; isNewObject: boolean; parentUrn: string; @@ -126,7 +126,7 @@ export abstract class ObjectManagementDialogBase { - const viewInfo = await this.objectManagementService.initializeView(this._contextId, this.options.objectType, this.options.connectionUri, this.options.database, this.options.isNewObject, this.options.parentUrn, this.options.objectUrn); + const viewInfo = await this.objectManagementService.initializeView(this._contextId, this.options.objectType, this.options.connectionUri, this.options.database, this.options.isNewObject, this.options.parentUrn, this.options.objectUrn, this.options.dialogType); this._viewInfo = viewInfo as ViewInfoType; this.postInitializeData(); this._originalObjectInfo = deepClone(this.objectInfo); From 8733af82da61fa2485e608a4c0b25b5f505a84b0 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Thu, 8 Jun 2023 15:25:50 -0700 Subject: [PATCH 05/16] Reuse database Dialog --- extensions/mssql/src/mssql.d.ts | 130 +++++++----------- .../mssql/src/objectManagement/commands.ts | 12 +- .../mssql/src/objectManagement/constants.ts | 1 + .../mssql/src/objectManagement/interfaces.ts | 9 ++ .../objectManagementService.ts | 22 +-- .../src/objectManagement/ui/databaseDialog.ts | 121 ++++++++++++++-- .../ui/databasePropertiesDialog.ts | 123 ----------------- .../ui/objectManagementDialogBase.ts | 3 +- 8 files changed, 188 insertions(+), 233 deletions(-) delete mode 100644 extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts diff --git a/extensions/mssql/src/mssql.d.ts b/extensions/mssql/src/mssql.d.ts index 1e5c4eafc0fa..075972f3f593 100644 --- a/extensions/mssql/src/mssql.d.ts +++ b/extensions/mssql/src/mssql.d.ts @@ -945,84 +945,58 @@ declare module 'mssql' { } } - export interface DatabaseViewInfo extends ObjectViewInfo { - loginNames: string[]; - collationNames: string[]; - compatibilityLevels: string[]; - containmentTypes: string[]; - recoveryModels: string[]; - } - - export interface DatabasePropertiesInfo extends SqlObject { - collationName?: string; - dateCreated?: string; - lastDatabaseBackup?: string; - lastDatabaseLogBackup?: string; - memoryAllocatedToMemoryOptimizedObjectsInMb?: string; - memoryUsedByMemoryOptimizedObjectsInMb?: string; - numberOfUsers?: string; - owner?: string; - sizeInMb?: string; - spaceAvailableInMb?: string; - status?: string; - } - - export interface DatabasePropertiesViewInfo extends ObjectViewInfo { + export interface IObjectManagementService { + /** + * Initialize the object view and return the information to render the view. + * @param contextId The context id of the view, generated by the extension and will be used in subsequent save/script/dispose operations. + * @param objectType The object type. + * @param connectionUri The original connection's URI. + * @param database The target database. + * @param isNewObject Whether the view is for creating a new object. + * @param parentUrn The parent object's URN. + * @param objectUrn The object's URN. + */ + initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string): Thenable>; + /** + * Save an object. + * @param contextId The object view's context id. + * @param object The object to be saved. + */ + save(contextId: string, object: ObjectManagement.SqlObject): Thenable; + /** + * Script an object. + * @param contextId The object view's context id. + * @param object The object to be scripted. + */ + script(contextId: string, object: ObjectManagement.SqlObject): Thenable; + /** + * Dispose a view. + * @param contextId The id of the view. + */ + disposeView(contextId: string): Thenable; + /** + * Rename an object. + * @param connectionUri The URI of the server connection. + * @param objectType The object type. + * @param objectUrn SMO Urn of the object to be renamed. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo + * @param newName The new name of the object. + */ + rename(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string, newName: string): Thenable; + /** + * Drop an object. + * @param connectionUri The URI of the server connection. + * @param objectType The object type. + * @param objectUrn SMO Urn of the object to be dropped. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo + */ + drop(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string): Thenable; + /** + * Search for objects. + * @param contextId The object view's context id. + * @param objectTypes The object types to search for. + * @param searchText Search text. + * @param schema Schema to search in. + */ + search(contextId: string, objectTypes: string[], searchText?: string, schema?: string): Thenable; } -} - -export interface IObjectManagementService { - /** - * Initialize the object view and return the information to render the view. - * @param contextId The context id of the view, generated by the extension and will be used in subsequent save/script/dispose operations. - * @param objectType The object type. - * @param connectionUri The original connection's URI. - * @param database The target database. - * @param isNewObject Whether the view is for creating a new object. - * @param parentUrn The parent object's URN. - * @param objectUrn The object's URN. - */ - initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string, dialogType?: string): Thenable>; - /** - * Save an object. - * @param contextId The object view's context id. - * @param object The object to be saved. - */ - save(contextId: string, object: ObjectManagement.SqlObject): Thenable; - /** - * Script an object. - * @param contextId The object view's context id. - * @param object The object to be scripted. - */ - script(contextId: string, object: ObjectManagement.SqlObject): Thenable; - /** - * Dispose a view. - * @param contextId The id of the view. - */ - disposeView(contextId: string): Thenable; - /** - * Rename an object. - * @param connectionUri The URI of the server connection. - * @param objectType The object type. - * @param objectUrn SMO Urn of the object to be renamed. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo - * @param newName The new name of the object. - */ - rename(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string, newName: string): Thenable; - /** - * Drop an object. - * @param connectionUri The URI of the server connection. - * @param objectType The object type. - * @param objectUrn SMO Urn of the object to be dropped. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo - */ - drop(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string): Thenable; - /** - * Search for objects. - * @param contextId The object view's context id. - * @param objectTypes The object types to search for. - * @param searchText Search text. - * @param schema Schema to search in. - */ - search(contextId: string, objectTypes: string[], searchText?: string, schema?: string): Thenable; -} // Object Management - End. } diff --git a/extensions/mssql/src/objectManagement/commands.ts b/extensions/mssql/src/objectManagement/commands.ts index de4525b14d6b..0994560074d8 100644 --- a/extensions/mssql/src/objectManagement/commands.ts +++ b/extensions/mssql/src/objectManagement/commands.ts @@ -22,7 +22,6 @@ import { ServerRoleDialog } from './ui/serverRoleDialog'; import { DatabaseRoleDialog } from './ui/databaseRoleDialog'; import { ApplicationRoleDialog } from './ui/applicationRoleDialog'; import { DatabaseDialog } from './ui/databaseDialog'; -import { DatabasePropertiesDialog } from './ui/databasePropertiesDialog'; export function registerObjectManagementCommands(appContext: AppContext) { // Notes: Change the second parameter to false to use the actual object management service. @@ -41,12 +40,6 @@ export function registerObjectManagementCommands(appContext: AppContext) { })); } -export enum DialogType { - New = 'New', - Edit = 'Edit', - Properties = 'Properties' -} - function getObjectManagementService(appContext: AppContext, useTestService: boolean): IObjectManagementService { if (useTestService) { return new TestObjectManagementService(); @@ -90,7 +83,6 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex connectionUri: connectionUri, isNewObject: true, database: context.connectionProfile!.databaseName!, - dialogType: DialogType.New, objectType: objectType, objectName: '', parentUrn: parentUrn, @@ -119,7 +111,6 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore connectionUri: connectionUri, isNewObject: false, database: context.connectionProfile!.databaseName!, - dialogType: DialogType.Properties, objectType: context.nodeInfo.nodeType as ObjectManagement.NodeType, objectName: context.nodeInfo.label, parentUrn: parentUrn, @@ -254,8 +245,7 @@ function getDialog(service: IObjectManagementService, dialogOptions: ObjectManag case ObjectManagement.NodeType.User: return new UserDialog(service, dialogOptions); case ObjectManagement.NodeType.Database: - return dialogOptions.dialogType === DialogType.Properties ? - new DatabasePropertiesDialog(service, dialogOptions) : new DatabaseDialog(service, dialogOptions); + return new DatabaseDialog(service, dialogOptions); default: throw new Error(`Unsupported object type: ${dialogOptions.objectType}`); } diff --git a/extensions/mssql/src/objectManagement/constants.ts b/extensions/mssql/src/objectManagement/constants.ts index ef4255445f91..fc8b63a08bdf 100644 --- a/extensions/mssql/src/objectManagement/constants.ts +++ b/extensions/mssql/src/objectManagement/constants.ts @@ -28,6 +28,7 @@ export const AlterApplicationRoleDocUrl = 'https://learn.microsoft.com/sql/t-sql export const CreateDatabaseRoleDocUrl = 'https://learn.microsoft.com/sql/t-sql/statements/create-role-transact-sql'; export const AlterDatabaseRoleDocUrl = 'https://learn.microsoft.com/sql/t-sql/statements/alter-role-transact-sql'; export const CreateDatabaseDocUrl = 'https://learn.microsoft.com/sql/t-sql/statements/create-database-transact-sql'; +export const DatabasePropertiesDocUrl = 'https://learn.microsoft.com/sql/relational-databases/databases/database-properties-general-page'; export const enum TelemetryActions { CreateObject = 'CreateObject', diff --git a/extensions/mssql/src/objectManagement/interfaces.ts b/extensions/mssql/src/objectManagement/interfaces.ts index c449ade64fb5..812a9dbdead2 100644 --- a/extensions/mssql/src/objectManagement/interfaces.ts +++ b/extensions/mssql/src/objectManagement/interfaces.ts @@ -430,6 +430,15 @@ export interface Database extends ObjectManagement.SqlObject { recoveryModel?: string; compatibilityLevel?: string; containmentType?: string; + dateCreated?: string; + lastDatabaseBackup?: string; + lastDatabaseLogBackup?: string; + memoryAllocatedToMemoryOptimizedObjectsInMb?: string; + memoryUsedByMemoryOptimizedObjectsInMb?: string; + numberOfUsers?: string; + sizeInMb?: string; + spaceAvailableInMb?: string; + status?: string; } export interface DatabaseViewInfo extends ObjectManagement.ObjectViewInfo { diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index c76498003f6c..214d6eacf7f8 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ApplicationRoleViewInfo, AuthenticationType, DatabaseRoleViewInfo, LoginViewInfo, SecurablePermissions, SecurableTypeMetadata, ServerRoleViewInfo, User, UserType, UserViewInfo } from './interfaces'; +import { ApplicationRoleViewInfo, AuthenticationType, DatabaseRoleViewInfo, DatabaseViewInfo, LoginViewInfo, SecurablePermissions, SecurableTypeMetadata, ServerRoleViewInfo, User, UserType, UserViewInfo } from './interfaces'; import * as Utils from '../utils'; import * as constants from '../constants'; import * as contracts from '../contracts'; @@ -28,8 +28,8 @@ export class ObjectManagementService extends BaseService implements IObjectManag }; } - async initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string, dialogType?: string): Promise> { - const params: contracts.InitializeViewRequestParams = { connectionUri, contextId, isNewObject, objectType, database, parentUrn, objectUrn, dialogType }; + async initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string): Promise> { + const params: contracts.InitializeViewRequestParams = { connectionUri, contextId, isNewObject, objectType, database, parentUrn, objectUrn }; return this.runWithErrorHandling(contracts.InitializeViewRequest.type, params); } @@ -195,7 +195,7 @@ export class TestObjectManagementService implements IObjectManagementService { } else if (objectType === ObjectManagement.NodeType.DatabaseRole) { obj = this.getDatabaseRoleView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.Database) { - obj = this.getDatabasePropertiesView(objectUrn); + obj = this.getDatabaseView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelLogin) { obj = this.getLoginView(isNewObject, objectUrn); } else if (objectType === ObjectManagement.NodeType.ServerLevelServerRole) { @@ -434,20 +434,22 @@ export class TestObjectManagementService implements IObjectManagementService { }; } - private getDatabasePropertiesView(name: string): ObjectManagement.DatabasePropertiesViewInfo { - return { + private getDatabaseView(isNewObject: boolean, name: string): DatabaseViewInfo { + return isNewObject ? { + + } : { objectInfo: { name: 'Database Properties1', collationName: 'Latin1_General_100_CI_AS_KS_WS', dateCreated: '5/31/2023 8:05:55 AM', lastDatabaseBackup: 'None', lastDatabaseLogBackup: 'None', - memoryAllocatedToMemoryOptimizedObjects: '0.00 MB', - memoryUsedByMemoryOptimizedObjects: '0.00 MB', + memoryAllocatedToMemoryOptimizedObjectsInMb: '0.00 MB', + memoryUsedByMemoryOptimizedObjectsInMb: '0.00 MB', numberOfUsers: '5', owner: 'databaseProperties 1', - size: '16.00 MB', - spaceAvailable: '1.15 MB', + sizeInMb: '16.00 MB', + spaceAvailableInMb: '1.15 MB', status: 'Normal' } }; diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 37a4327d50a3..b0d3c9f64342 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -7,33 +7,72 @@ import * as azdata from 'azdata'; import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase'; import { IObjectManagementService } from 'mssql'; import * as localizedConstants from '../localizedConstants'; -import { CreateDatabaseDocUrl } from '../constants'; +import { CreateDatabaseDocUrl, DatabasePropertiesDocUrl } from '../constants'; import { Database, DatabaseViewInfo } from '../interfaces'; export class DatabaseDialog extends ObjectManagementDialogBase { - private _nameInput: azdata.InputBoxComponent; + // Horizontal Tabs + private generalTab: azdata.window.DialogTab; + private filesTab: azdata.window.DialogTab; + + private nameInput: azdata.InputBoxComponent; + private backupSection: azdata.GroupContainer; + private lastDatabaseBackupInput: azdata.InputBoxComponent; + private lastDatabaseLogBackupInput: azdata.InputBoxComponent; + private databaseSection: azdata.GroupContainer; + private statusInput: azdata.InputBoxComponent; + private ownerInput: azdata.InputBoxComponent; + private dateCreatedInput: azdata.InputBoxComponent; + private sizeInput: azdata.InputBoxComponent; + private spaceAvailabeInput: azdata.InputBoxComponent; + private numberOfUsersInput: azdata.InputBoxComponent; + private memoryAllocatedInput: azdata.InputBoxComponent; + private memoryUsedInput: azdata.InputBoxComponent; + private maintenanceSection: azdata.GroupContainer; + private collationInput: azdata.InputBoxComponent; constructor(objectManagementService: IObjectManagementService, options: ObjectManagementDialogOptions) { super(objectManagementService, options); + if (!options.isNewObject) { + this.generalTab = azdata.window.createTab(localizedConstants.GeneralSectionHeader); + this.filesTab = azdata.window.createTab(localizedConstants.FilesHeaderText); + } } protected override get helpUrl(): string { - return CreateDatabaseDocUrl; + return this.options.isNewObject ? CreateDatabaseDocUrl : DatabasePropertiesDocUrl; } protected async initializeUI(): Promise { - let generalSection = this.initializeGeneralSection(); - let optionsSection = this.initializeOptionsSection(); - this.formContainer.addItems([generalSection, optionsSection]); + if (this.options.isNewObject) { + let generalSection = this.initializeGeneralSection(); + let optionsSection = this.initializeOptionsSection(); + this.formContainer.addItems([generalSection, optionsSection]); + } else { + // Initilaize general Tab sections + this.initializeBackupSection(); + this.initializeDatabaseSection(); + this.initializeMaintenanceSection(); + + this.registerTab(this.generalTab, [this.backupSection, this.databaseSection, this.maintenanceSection]); + + this.dialogObject.content = [this.generalTab, this.filesTab]; + + // We need to close the already opened dialog during handleObjectPropertiesDialogCommand, + // which is required for the horizontal dialog tabs, as we cannot refresh the exising dialog + azdata.window.closeDialog(this.dialogObject); + azdata.window.openDialog(this.dialogObject); + } } + //#region Create Database private initializeGeneralSection(): azdata.GroupContainer { let containers: azdata.Component[] = []; - this._nameInput = this.createInputBox(localizedConstants.NameText, async () => { - this.objectInfo.name = this._nameInput.value; + this.nameInput = this.createInputBox(localizedConstants.NameText, async () => { + this.objectInfo.name = this.nameInput.value; await this.runValidation(false); }); - containers.push(this.createLabelInputContainer(localizedConstants.NameText, this._nameInput)); + containers.push(this.createLabelInputContainer(localizedConstants.NameText, this.nameInput)); if (this.viewInfo.loginNames?.length > 0) { this.objectInfo.owner = this.viewInfo.loginNames[0]; @@ -82,4 +121,68 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }, this.objectInfo.lastDatabaseBackup, this.options.isNewObject); + const lastDatabaseBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseBackupText, this.lastDatabaseBackupInput); + + this.lastDatabaseLogBackupInput = this.createInputBox(localizedConstants.LastDatabaseLogBackupText, async () => { }, this.objectInfo.lastDatabaseLogBackup, this.options.isNewObject); + const lastDatabaseLogBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseLogBackupText, this.lastDatabaseLogBackupInput); + + this.backupSection = this.createGroup(localizedConstants.BackupSectionHeader, [ + lastDatabaseBackupContainer, + lastDatabaseLogBackupContainer + ], false); + } + + private initializeDatabaseSection(): void { + this.nameInput = this.createInputBox(localizedConstants.NamePropertyText, async () => { }, this.objectInfo.name, this.options.isNewObject); + const nameContainer = this.createLabelInputContainer(localizedConstants.NamePropertyText, this.nameInput); + + this.statusInput = this.createInputBox(localizedConstants.StatusText, async () => { }, this.objectInfo.status, this.options.isNewObject); + const statusContainer = this.createLabelInputContainer(localizedConstants.StatusText, this.statusInput); + + this.ownerInput = this.createInputBox(localizedConstants.OwnerPropertyText, async () => { }, this.objectInfo.owner, this.options.isNewObject); + const ownerContainer = this.createLabelInputContainer(localizedConstants.OwnerPropertyText, this.ownerInput); + + this.dateCreatedInput = this.createInputBox(localizedConstants.DateCreatedText, async () => { }, this.objectInfo.dateCreated, this.options.isNewObject); + const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); + + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.sizeInMb, this.options.isNewObject); + const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); + + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailableInMb, this.options.isNewObject); + const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); + + this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers, this.options.isNewObject); + const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); + + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb, this.options.isNewObject); + const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); + + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb, this.options.isNewObject); + const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); + + this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ + nameContainer, + statusContainer, + ownerContainer, + dateCreatedContainer, + sizeContainer, + spaceAvailabeContainer, + numberOfUsersContainer, + memoryAllocatedContainer, + memoryUsedContainer + ], false); + } + + private initializeMaintenanceSection(): void { + this.collationInput = this.createInputBox(localizedConstants.CollationText, async () => { }, this.objectInfo.collationName, this.options.isNewObject); + const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); + + this.maintenanceSection = this.createGroup(localizedConstants.MaintenanceSectionHeader, [collationContainer], false); + } + //#endregion } diff --git a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts b/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts deleted file mode 100644 index 6e06f6ad7d2d..000000000000 --- a/extensions/mssql/src/objectManagement/ui/databasePropertiesDialog.ts +++ /dev/null @@ -1,123 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -import * as azdata from 'azdata'; -import * as localizedConstants from '../localizedConstants'; -import { IObjectManagementService, ObjectManagement } from 'mssql'; -import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase'; -import { AlterUserDocUrl, CreateUserDocUrl } from '../constants'; - -export class DatabasePropertiesDialog extends ObjectManagementDialogBase { - - // Horizontal Tabs - private generalTab: azdata.window.DialogTab; - private filesTab: azdata.window.DialogTab; - - // GeneralTab: Backup section and its inputs - private backupSection: azdata.GroupContainer; - private lastDatabaseBackupInput: azdata.InputBoxComponent; - private lastDatabaseLogBackupInput: azdata.InputBoxComponent; - - // GeneralTab: Database section and its inputs - private databaseSection: azdata.GroupContainer; - private nameInput: azdata.InputBoxComponent; - private statusInput: azdata.InputBoxComponent; - private ownerInput: azdata.InputBoxComponent; - private dateCreatedInput: azdata.InputBoxComponent; - private sizeInput: azdata.InputBoxComponent; - private spaceAvailabeInput: azdata.InputBoxComponent; - private numberOfUsersInput: azdata.InputBoxComponent; - private memoryAllocatedInput: azdata.InputBoxComponent; - private memoryUsedInput: azdata.InputBoxComponent; - - // GeneralTab: Maintenance section and its inputs - private maintenanceSection: azdata.GroupContainer; - private collationInput: azdata.InputBoxComponent; - - constructor(objectManagementService: IObjectManagementService, options: ObjectManagementDialogOptions) { - super(objectManagementService, options); - this.generalTab = azdata.window.createTab(localizedConstants.GeneralSectionHeader); - this.filesTab = azdata.window.createTab(localizedConstants.FilesHeaderText); - } - - protected async initializeUI(): Promise { - this.initializeBackupSection(); - this.initializeDatabaseSection(); - this.initializeMaintenanceSection(); - - this.registerTab(this.generalTab, [this.backupSection, this.databaseSection, this.maintenanceSection]); - - this.dialogObject.content = [this.generalTab, this.filesTab]; - - // We need to close the already opened dialog during handleObjectPropertiesDialogCommand, - // which is required for the horizontal dialog tabs, as we cannot refresh the exising dialog - azdata.window.closeDialog(this.dialogObject); - azdata.window.openDialog(this.dialogObject); - } - - protected override get helpUrl(): string { - return this.options.isNewObject ? CreateUserDocUrl : AlterUserDocUrl; - } - - private initializeBackupSection(): void { - this.lastDatabaseBackupInput = this.createInputBox(localizedConstants.LastDatabaseBackupText, async () => { }, this.objectInfo.lastDatabaseBackup, this.options.isNewObject); - const lastDatabaseBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseBackupText, this.lastDatabaseBackupInput); - - this.lastDatabaseLogBackupInput = this.createInputBox(localizedConstants.LastDatabaseLogBackupText, async () => { }, this.objectInfo.lastDatabaseLogBackup, this.options.isNewObject); - const lastDatabaseLogBackupContainer = this.createLabelInputContainer(localizedConstants.LastDatabaseLogBackupText, this.lastDatabaseLogBackupInput); - - this.backupSection = this.createGroup(localizedConstants.BackupSectionHeader, [ - lastDatabaseBackupContainer, - lastDatabaseLogBackupContainer - ], false); - } - - private initializeDatabaseSection(): void { - this.nameInput = this.createInputBox(localizedConstants.NamePropertyText, async () => { }, this.objectInfo.name, this.options.isNewObject); - const nameContainer = this.createLabelInputContainer(localizedConstants.NamePropertyText, this.nameInput); - - this.statusInput = this.createInputBox(localizedConstants.StatusText, async () => { }, this.objectInfo.status, this.options.isNewObject); - const statusContainer = this.createLabelInputContainer(localizedConstants.StatusText, this.statusInput); - - this.ownerInput = this.createInputBox(localizedConstants.OwnerPropertyText, async () => { }, this.objectInfo.owner, this.options.isNewObject); - const ownerContainer = this.createLabelInputContainer(localizedConstants.OwnerPropertyText, this.ownerInput); - - this.dateCreatedInput = this.createInputBox(localizedConstants.DateCreatedText, async () => { }, this.objectInfo.dateCreated, this.options.isNewObject); - const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); - - this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.sizeInMb, this.options.isNewObject); - const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); - - this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailableInMb, this.options.isNewObject); - const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); - - this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers, this.options.isNewObject); - const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); - - this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb, this.options.isNewObject); - const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); - - this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb, this.options.isNewObject); - const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); - - this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ - nameContainer, - statusContainer, - ownerContainer, - dateCreatedContainer, - sizeContainer, - spaceAvailabeContainer, - numberOfUsersContainer, - memoryAllocatedContainer, - memoryUsedContainer - ], false); - } - - private initializeMaintenanceSection(): void { - this.collationInput = this.createInputBox(localizedConstants.CollationText, async () => { }, this.objectInfo.collationName, this.options.isNewObject); - const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); - - this.maintenanceSection = this.createGroup(localizedConstants.MaintenanceSectionHeader, [collationContainer], false); - } -} diff --git a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts index 911a46c115fc..f78313faa6a7 100644 --- a/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts +++ b/extensions/mssql/src/objectManagement/ui/objectManagementDialogBase.ts @@ -22,7 +22,6 @@ function getDialogName(type: ObjectManagement.NodeType, isNewObject: boolean): s export interface ObjectManagementDialogOptions extends ScriptableDialogOptions { connectionUri: string; database?: string; - dialogType?: string; objectType: ObjectManagement.NodeType; isNewObject: boolean; parentUrn: string; @@ -126,7 +125,7 @@ export abstract class ObjectManagementDialogBase { - const viewInfo = await this.objectManagementService.initializeView(this._contextId, this.options.objectType, this.options.connectionUri, this.options.database, this.options.isNewObject, this.options.parentUrn, this.options.objectUrn, this.options.dialogType); + const viewInfo = await this.objectManagementService.initializeView(this._contextId, this.options.objectType, this.options.connectionUri, this.options.database, this.options.isNewObject, this.options.parentUrn, this.options.objectUrn); this._viewInfo = viewInfo as ViewInfoType; this.postInitializeData(); this._originalObjectInfo = deepClone(this.objectInfo); From 10beedcc9c6271836242d6d795a334b954842d25 Mon Sep 17 00:00:00 2001 From: Sai Avishkar Sreerama <74571829+ssreerama@users.noreply.github.com> Date: Thu, 8 Jun 2023 17:28:41 -0500 Subject: [PATCH 06/16] Undo contract file change --- extensions/mssql/src/contracts.ts | 1649 ----------------------------- 1 file changed, 1649 deletions(-) delete mode 100644 extensions/mssql/src/contracts.ts diff --git a/extensions/mssql/src/contracts.ts b/extensions/mssql/src/contracts.ts deleted file mode 100644 index 992b6d02384c..000000000000 --- a/extensions/mssql/src/contracts.ts +++ /dev/null @@ -1,1649 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { NotificationType, RequestType } from 'vscode-languageclient'; -import * as telemetry from '@microsoft/ads-extension-telemetry'; -import * as azdata from 'azdata'; -import { ConnectParams } from 'dataprotocol-client/lib/protocol'; -import * as mssql from 'mssql'; - -// ------------------------------- < Telemetry Sent Event > ------------------------------------ - -/** - * Event sent when the language service send a telemetry event - */ -export namespace TelemetryNotification { - export const type = new NotificationType('telemetry/sqlevent'); -} - -/** - * Update event parameters - */ -export class TelemetryParams { - public params: { - eventName: string; - properties: telemetry.TelemetryEventProperties; - measures: telemetry.TelemetryEventMeasures; - }; -} - -// ------------------------------- ---------------------------------- - -// ------------------------------- < Security Token Request > ------------------------------------------ -export interface RequestSecurityTokenParams { - provider: string; - authority: string; - resource: string; - scopes: string[]; -} - -export interface RequestSecurityTokenResponse { - accountKey: string; - token: string; -} - -export namespace SecurityTokenRequest { - export const type = new RequestType('account/securityTokenRequest'); -} -// ------------------------------- ------------------------------------------ - -// ------------------------------- < Refresh Token Notification > --------------------------------- - -/** - * Parameters for a refresh token notification sent from STS to ADS - */ -export interface RefreshTokenParams { - /** - * The tenant ID - */ - tenantId: string; - /** - * The provider that indicates the type of linked account to query - */ - provider: string; - /** - * The identifier of the target resource of the requested token - */ - resource: string; - /** - * The account ID - */ - accountId: string; - /** - * The URI for the editor that needs a token refresh - */ - uri: string; -} - -export namespace RefreshTokenNotification { - export const type = new NotificationType('account/refreshToken'); -} - - - -// ------------------------------- ------------------------------- - -// ------------------------------- < Token Refreshed Notification > --------------------------------- - -/** - * Parameters for a new refresh token sent from ADS to STS - */ -export interface TokenRefreshedParams { - /** - * The refresh token - */ - token: string; - /** - * The token expiration, a Unix epoch - */ - expiresOn: Number; - /** - * The URI for the editor that needs a token refresh - */ - uri: string; -} - -export namespace TokenRefreshedNotification { - export const type = new NotificationType('account/tokenRefreshed'); -} - -// ------------------------------- ------------------------------- - - -// ------------------------------- < Agent Management > ------------------------------------ -// Job management parameters -export interface AgentJobsParams { - ownerUri: string; - jobId: string; -} - -export interface AgentJobHistoryParams { - ownerUri: string; - jobId: string; - jobName: string; -} - -export interface AgentJobActionParams { - ownerUri: string; - jobName: string; - action: string; -} - -export interface CreateAgentJobParams { - ownerUri: string; - job: azdata.AgentJobInfo; -} - -export interface UpdateAgentJobParams { - ownerUri: string; - originalJobName: string; - job: azdata.AgentJobInfo; -} - -export interface DeleteAgentJobParams { - ownerUri: string; - job: azdata.AgentJobInfo; -} - -export interface AgentJobDefaultsParams { - ownerUri: string; -} - -// Job Step management parameters -export interface CreateAgentJobStepParams { - ownerUri: string; - step: azdata.AgentJobStepInfo; -} - -export interface UpdateAgentJobStepParams { - ownerUri: string; - originalJobStepName: string; - step: azdata.AgentJobStepInfo; -} - -export interface DeleteAgentJobStepParams { - ownerUri: string; - step: azdata.AgentJobStepInfo; -} - -// Notebook management parameters -export interface AgentNotebookParams { - ownerUri: string; -} - -export interface AgentNotebookHistoryParams { - ownerUri: string; - jobId: string; - jobName: string; - targetDatabase: string; -} - -export interface AgentNotebookMaterializedParams { - ownerUri: string; - targetDatabase: string; - notebookMaterializedId: number; -} - -export interface AgentNotebookTemplateParams { - ownerUri: string; - targetDatabase: string; - jobId: string; -} - -export interface CreateAgentNotebookParams { - ownerUri: string; - notebook: azdata.AgentNotebookInfo; - templateFilePath: string; -} - -export interface UpdateAgentNotebookParams { - ownerUri: string; - originalNotebookName: string; - notebook: azdata.AgentJobInfo; - templateFilePath: string; -} - -export interface UpdateAgentNotebookRunPinParams { - ownerUri: string; - targetDatabase: string; - agentNotebookHistory: azdata.AgentNotebookHistoryInfo; - materializedNotebookPin: boolean; -} - -export interface UpdateAgentNotebookRunNameParams { - ownerUri: string; - targetDatabase: string; - agentNotebookHistory: azdata.AgentNotebookHistoryInfo; - materializedNotebookName: string; -} - -export interface DeleteAgentNotebookParams { - ownerUri: string; - notebook: azdata.AgentNotebookInfo; -} - -export interface DeleteAgentMaterializedNotebookParams { - ownerUri: string; - targetDatabase: string; - agentNotebookHistory: azdata.AgentNotebookHistoryInfo; -} - -// Alert management parameters -export interface AgentAlertsParams { - ownerUri: string; -} - -export interface CreateAgentAlertParams { - ownerUri: string; - alert: azdata.AgentAlertInfo; -} - -export interface UpdateAgentAlertParams { - ownerUri: string; - originalAlertName: string; - alert: azdata.AgentAlertInfo; -} - -export interface DeleteAgentAlertParams { - ownerUri: string; - alert: azdata.AgentAlertInfo; -} - -// Operator management parameters -export interface AgentOperatorsParams { - ownerUri: string; -} - -export interface CreateAgentOperatorParams { - ownerUri: string; - operator: azdata.AgentOperatorInfo; -} - -export interface UpdateAgentOperatorParams { - ownerUri: string; - originalOperatorName: string; - operator: azdata.AgentOperatorInfo; -} - -export interface DeleteAgentOperatorParams { - ownerUri: string; - operator: azdata.AgentOperatorInfo; -} - -// Proxy management parameters -export interface AgentProxiesParams { - ownerUri: string; -} - -export interface CreateAgentProxyParams { - ownerUri: string; - proxy: azdata.AgentProxyInfo; -} - -export interface UpdateAgentProxyParams { - ownerUri: string; - originalProxyName: string; - proxy: azdata.AgentProxyInfo; -} - -export interface DeleteAgentProxyParams { - ownerUri: string; - proxy: azdata.AgentProxyInfo; -} - -// Agent Credentials parameters -export interface GetCredentialsParams { - ownerUri: string; -} - -// Job Schedule management parameters -export interface AgentJobScheduleParams { - ownerUri: string; -} - -export interface CreateAgentJobScheduleParams { - ownerUri: string; - schedule: azdata.AgentJobScheduleInfo; -} - -export interface UpdateAgentJobScheduleParams { - ownerUri: string; - originalScheduleName: string; - schedule: azdata.AgentJobScheduleInfo; -} - -export interface DeleteAgentJobScheduleParams { - ownerUri: string; - schedule: azdata.AgentJobScheduleInfo; -} - -// Agent Job management requests -export namespace AgentJobsRequest { - export const type = new RequestType('agent/jobs'); -} - -export namespace AgentJobHistoryRequest { - export const type = new RequestType('agent/jobhistory'); -} - -export namespace AgentJobActionRequest { - export const type = new RequestType('agent/jobaction'); -} - -export namespace CreateAgentJobRequest { - export const type = new RequestType('agent/createjob'); -} - -export namespace UpdateAgentJobRequest { - export const type = new RequestType('agent/updatejob'); -} - -export namespace DeleteAgentJobRequest { - export const type = new RequestType('agent/deletejob'); -} - -export namespace AgentJobDefaultsRequest { - export const type = new RequestType('agent/jobdefaults'); -} - -// Job Step requests -export namespace CreateAgentJobStepRequest { - export const type = new RequestType('agent/createjobstep'); -} - -export namespace UpdateAgentJobStepRequest { - export const type = new RequestType('agent/updatejobstep'); -} - -export namespace DeleteAgentJobStepRequest { - export const type = new RequestType('agent/deletejobstep'); -} - -// Notebooks request -export namespace AgentNotebooksRequest { - export const type = new RequestType('agent/notebooks'); -} - -export namespace AgentNotebookHistoryRequest { - export const type = new RequestType('agent/notebookhistory'); -} - -export namespace AgentNotebookMaterializedRequest { - export const type = new RequestType('agent/notebookmaterialized'); -} - -export namespace UpdateAgentNotebookRunNameRequest { - export const type = new RequestType('agent/updatenotebookname'); -} - -export namespace DeleteMaterializedNotebookRequest { - export const type = new RequestType('agent/deletematerializednotebook'); -} - -export namespace UpdateAgentNotebookRunPinRequest { - export const type = new RequestType('agent/updatenotebookpin'); -} - -export namespace AgentNotebookTemplateRequest { - export const type = new RequestType('agent/notebooktemplate'); -} - -export namespace CreateAgentNotebookRequest { - export const type = new RequestType('agent/createnotebook'); -} - -export namespace DeleteAgentNotebookRequest { - export const type = new RequestType('agent/deletenotebook'); -} - -export namespace UpdateAgentNotebookRequest { - export const type = new RequestType('agent/updatenotebook'); -} - -// Alerts requests -export namespace AgentAlertsRequest { - export const type = new RequestType('agent/alerts'); -} - -export namespace CreateAgentAlertRequest { - export const type = new RequestType('agent/createalert'); -} - -export namespace UpdateAgentAlertRequest { - export const type = new RequestType('agent/updatealert'); -} - -export namespace DeleteAgentAlertRequest { - export const type = new RequestType('agent/deletealert'); -} - -// Operators requests -export namespace AgentOperatorsRequest { - export const type = new RequestType('agent/operators'); -} - -export namespace CreateAgentOperatorRequest { - export const type = new RequestType('agent/createoperator'); -} - -export namespace UpdateAgentOperatorRequest { - export const type = new RequestType('agent/updateoperator'); -} - -export namespace DeleteAgentOperatorRequest { - export const type = new RequestType('agent/deleteoperator'); -} - -// Proxies requests -export namespace AgentProxiesRequest { - export const type = new RequestType('agent/proxies'); -} - -export namespace CreateAgentProxyRequest { - export const type = new RequestType('agent/createproxy'); -} - -export namespace UpdateAgentProxyRequest { - export const type = new RequestType('agent/updateproxy'); -} - -export namespace DeleteAgentProxyRequest { - export const type = new RequestType('agent/deleteproxy'); -} - -// Agent Credentials request -export namespace AgentCredentialsRequest { - export const type = new RequestType('security/credentials'); -} - -// Job Schedules requests -export namespace AgentJobSchedulesRequest { - export const type = new RequestType('agent/schedules'); -} - -export namespace CreateAgentJobScheduleRequest { - export const type = new RequestType('agent/createschedule'); -} - -export namespace UpdateAgentJobScheduleRequest { - export const type = new RequestType('agent/updateschedule'); -} - -export namespace DeleteAgentJobScheduleRequest { - export const type = new RequestType('agent/deleteschedule'); -} - -// ------------------------------- < Agent Management > ------------------------------------ - -// ------------------------------- < DacFx > ------------------------------------ - -export enum TaskExecutionMode { - execute = 0, - script = 1, - executeAndScript = 2, -} - -export interface ExportParams { - databaseName: string; - packageFilePath: string; - ownerUri: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface ImportParams { - packageFilePath: string; - databaseName: string; - ownerUri: string; - taskExecutionMode: TaskExecutionMode; -} - - -export interface ExtractParams { - databaseName: string; - packageFilePath: string; - applicationName: string; - applicationVersion: string; - ownerUri: string; - extractTarget?: mssql.ExtractTarget; - taskExecutionMode: TaskExecutionMode; - includePermissions?: boolean; -} - -export interface DeployParams { - packageFilePath: string; - databaseName: string; - upgradeExisting: boolean; - sqlCommandVariableValues?: Record; - deploymentOptions?: mssql.DeploymentOptions; - ownerUri: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface GenerateDeployScriptParams { - packageFilePath: string; - databaseName: string; - sqlCommandVariableValues?: Record; - deploymentOptions?: mssql.DeploymentOptions - ownerUri: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface GenerateDeployPlanParams { - packageFilePath: string; - databaseName: string; - ownerUri: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface GetOptionsFromProfileParams { - profilePath: string; -} - -export interface ValidateStreamingJobParams { - packageFilePath: string, - createStreamingJobTsql: string -} - -export interface ParseTSqlScriptParams { - filePath: string; - databaseSchemaProvider: string; -} - -export interface SavePublishProfileParams { - profilePath: string; - databaseName: string; - connectionString: string; - sqlCommandVariableValues?: Record; - deploymentOptions?: mssql.DeploymentOptions; -} - -export namespace ExportRequest { - export const type = new RequestType('dacfx/export'); -} - -export namespace ImportRequest { - export const type = new RequestType('dacfx/import'); -} - -export namespace ExtractRequest { - export const type = new RequestType('dacfx/extract'); -} - -export namespace DeployRequest { - export const type = new RequestType('dacfx/deploy'); -} - -export namespace GenerateDeployScriptRequest { - export const type = new RequestType('dacfx/generateDeploymentScript'); -} - -export namespace GenerateDeployPlanRequest { - export const type = new RequestType('dacfx/generateDeployPlan'); -} - -export namespace GetOptionsFromProfileRequest { - export const type = new RequestType('dacfx/getOptionsFromProfile'); -} - -export namespace ValidateStreamingJobRequest { - export const type = new RequestType('dacfx/validateStreamingJob'); -} - -export namespace ParseTSqlScriptRequest { - export const type = new RequestType('dacfx/parseTSqlScript'); -} - -export namespace SavePublishProfileRequest { - export const type = new RequestType('dacfx/savePublishProfile'); -} - -// ------------------------------- ------------------------------------ - -// ------------------------------- < Sql Projects > ------------------------------------ -//#region SqlProjects - -//#region Functions - -//#region Project-level functions - -export namespace CreateSqlProjectRequest { - export const type = new RequestType('sqlProjects/createProject'); -} - -export namespace OpenSqlProjectRequest { - export const type = new RequestType('sqlProjects/openProject'); -} - -export namespace CloseSqlProjectRequest { - export const type = new RequestType('sqlProjects/closeProject'); -} - -export namespace GetCrossPlatformCompatibilityRequest { - export const type = new RequestType('sqlProjects/getCrossPlatformCompatibility'); -} - -export namespace UpdateProjectForCrossPlatformRequest { - export const type = new RequestType('sqlProjects/updateProjectForCrossPlatform'); -} - -export namespace GetProjectPropertiesRequest { - export const type = new RequestType('sqlProjects/getProjectProperties'); -} - -export namespace SetDatabaseSourceRequest { - export const type = new RequestType('sqlProjects/setDatabaseSource'); -} - -export namespace SetDatabaseSchemaProviderRequest { - export const type = new RequestType('sqlProjects/setDatabaseSchemaProvider'); -} - -//#endregion - -//#region File/folder functions - -//#region SQL object script functions - -export namespace AddSqlObjectScriptRequest { - export const type = new RequestType('sqlProjects/addSqlObjectScript'); -} - -export namespace DeleteSqlObjectScriptRequest { - export const type = new RequestType('sqlProjects/deleteSqlObjectScript'); -} - -export namespace ExcludeSqlObjectScriptRequest { - export const type = new RequestType('sqlProjects/excludeSqlObjectScript'); -} - -export namespace MoveSqlObjectScriptRequest { - export const type = new RequestType('sqlProjects/moveSqlObjectScript'); -} - -export namespace GetSqlObjectScriptsRequest { - export const type = new RequestType('sqlProjects/getSqlObjectScripts'); -} - - -export namespace ExcludeFolderRequest { - export const type = new RequestType('sqlProjects/excludeFolder'); -} - -export namespace MoveFolderRequest { - export const type = new RequestType('sqlProjects/moveFolder'); -} - - -//#endregion - -//#endregion - -//#region Folder functions - -export namespace AddFolderRequest { - export const type = new RequestType('sqlProjects/addFolder'); -} - -export namespace DeleteFolderRequest { - export const type = new RequestType('sqlProjects/deleteFolder'); -} - -export namespace GetFoldersRequest { - export const type = new RequestType('sqlProjects/getFolders'); -} - -//#endregion - -//#region Pre/Post-deployment script functions - -export namespace AddPostDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/addPostDeploymentScript'); -} - -export namespace AddPreDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/addPreDeploymentScript'); -} - -export namespace DeletePostDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/deletePostDeploymentScript'); -} - -export namespace DeletePreDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/deletePreDeploymentScript'); -} - -export namespace ExcludePostDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/excludePostDeploymentScript'); -} - -export namespace GetPostDeploymentScriptsRequest { - export const type = new RequestType('sqlProjects/getPostDeploymentScripts'); -} - -export namespace ExcludePreDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/excludePreDeploymentScript'); -} - -export namespace MovePostDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/movePostDeploymentScript'); -} - -export namespace MovePreDeploymentScriptRequest { - export const type = new RequestType('sqlProjects/movePreDeploymentScript'); -} - -export namespace GetPreDeploymentScriptsRequest { - export const type = new RequestType('sqlProjects/getPreDeploymentScripts'); -} - -//#endregion - -//#region None functions - -export namespace AddNoneItemRequest { - export const type = new RequestType('sqlProjects/addNoneItem'); -} - -export namespace DeleteNoneItemRequest { - export const type = new RequestType('sqlProjects/deleteNoneItem'); -} - -export namespace ExcludeNoneItemRequest { - export const type = new RequestType('sqlProjects/excludeNoneItem'); -} - -export namespace GetNoneItemsRequest { - export const type = new RequestType('sqlProjects/getNoneItems'); -} - -export namespace MoveNoneItemRequest { - export const type = new RequestType('sqlProjects/moveNoneItem'); -} - -//#endregion - -//#endregion - -//#region SQLCMD variable functions - -export namespace AddSqlCmdVariableRequest { - export const type = new RequestType('sqlProjects/addSqlCmdVariable'); -} - -export namespace DeleteSqlCmdVariableRequest { - export const type = new RequestType('sqlProjects/deleteSqlCmdVariable'); -} - -export namespace UpdateSqlCmdVariableRequest { - export const type = new RequestType('sqlProjects/updateSqlCmdVariable'); -} - -export namespace GetSqlCmdVariablesRequest { - export const type = new RequestType('sqlProjects/getSqlCmdVariables'); -} - -//#endregion - -//#region Database reference functions - -export namespace AddDacpacReferenceRequest { - export const type = new RequestType('sqlprojects/addDacpacReference'); -} - -export namespace AddSqlProjectReferenceRequest { - export const type = new RequestType('sqlprojects/addSqlProjectReference'); -} - -export namespace AddSystemDatabaseReferenceRequest { - export const type = new RequestType('sqlprojects/addSystemDatabaseReference'); -} - -export namespace AddNugetPackageReferenceRequest { - export const type = new RequestType('sqlprojects/addNugetPackageReference'); -} - -export namespace DeleteDatabaseReferenceRequest { - export const type = new RequestType('sqlprojects/deleteDatabaseReference'); -} - -export namespace GetDatabaseReferencesRequest { - export const type = new RequestType('sqlProjects/getDatabaseReferences'); -} - -//#endregion - -//#endregion - -//#region Parameters - -export interface SqlProjectParams { - /** - * Absolute path of the project, including .sqlproj - */ - projectUri: string; -} - -export interface SqlProjectScriptParams extends SqlProjectParams { - /** - * Path of the script, including .sql, relative to the .sqlproj - */ - path: string; -} - -export interface SetDatabaseSourceParams extends SqlProjectParams { - /** - * Source of the database schema, used in telemetry - */ - databaseSource: string; -} - -export interface SetDatabaseSchemaProviderParams extends SqlProjectParams { - /** - * New DatabaseSchemaProvider value, in the form "Microsoft.Data.Tools.Schema.Sql.SqlXYZDatabaseSchemaProvider" - */ - databaseSchemaProvider: string; -} - -export interface AddDacpacReferenceParams extends AddUserDatabaseReferenceParams { - /** - * Path to the .dacpac file - */ - dacpacPath: string; -} - -export interface AddNugetPackageReferenceParams extends AddUserDatabaseReferenceParams { - /** - * NuGet package name - */ - packageName: string; - - /** - * NuGet package version - */ - packageVersion: string; -} - -export interface AddDatabaseReferenceParams extends SqlProjectParams { - /** - * Whether to suppress missing dependencies - */ - suppressMissingDependencies: boolean; - /** - * Literal name used to reference another database in the same server, if not using SQLCMD variables - */ - databaseLiteral?: string; -} - -export interface AddSqlProjectReferenceParams extends AddUserDatabaseReferenceParams { - /** - * Path to the referenced .sqlproj file - */ - projectPath: string; - /** - * GUID for the referenced SQL project - */ - projectGuid: string; -} - -export interface AddSystemDatabaseReferenceParams extends AddDatabaseReferenceParams { - /** - * Type of system database - */ - systemDatabase: mssql.SystemDatabase; -} - -export interface AddUserDatabaseReferenceParams extends AddDatabaseReferenceParams { - /** - * SQLCMD variable name for specifying the other database this reference is to, if different from that of the current project - */ - databaseVariable?: string; - /** - * SQLCMD variable name for specifying the other server this reference is to, if different from that of the current project. - * If this is set, DatabaseVariable must also be set. - */ - serverVariable?: string; -} - -export interface DeleteDatabaseReferenceParams extends SqlProjectParams { - /** - * Name of the reference to be deleted. Name of the System DB, path of the sqlproj, or path of the dacpac - */ - name: string; -} - -export interface FolderParams extends SqlProjectParams { - /** - * Path of the folder, typically relative to the .sqlproj file - */ - path: string; -} - -export interface MoveFolderParams extends FolderParams { - /** - * Path of the folder, typically relative to the .sqlproj file - */ - destinationPath: string; -} - -export interface CreateSqlProjectParams extends SqlProjectParams { - /** - * Type of SQL Project: SDK-style or Legacy - */ - sqlProjectType: mssql.ProjectType; - /** - * Database schema provider for the project, in the format - * "Microsoft.Data.Tools.Schema.Sql.SqlXYZDatabaseSchemaProvider". - * Case sensitive. - */ - databaseSchemaProvider?: string; - /** - * Version of the Microsoft.Build.Sql SDK for the project, if overriding the default - */ - buildSdkVersion?: string; -} - -export interface AddSqlCmdVariableParams extends SqlProjectParams { - /** - * Name of the SQLCMD variable - */ - name: string; - /** - * Default value of the SQLCMD variable - */ - defaultValue: string; -} - -export interface DeleteSqlCmdVariableParams extends SqlProjectParams { - /** - * Name of the SQLCMD variable to be deleted - */ - name?: string; -} - -export interface MoveItemParams extends SqlProjectScriptParams { - /** - * Destination path of the file or folder, relative to the .sqlproj - */ - destinationPath: string; -} - -//#endregion - -//#endregion - -// ------------------------------- ----------------------------------- - -// ------------------------------- ---------------------------------------- - - -export interface CreateCentralManagementServerParams { - registeredServerName: string; - registeredServerDescription: string; - connectParams: ConnectParams; -} - -export interface ListRegisteredServersParams extends RegisteredServerParamsBase { - // same as base -} - -export interface AddRegisteredServerParams extends RegisteredServerParamsBase { - registeredServerName: string; - registeredServerDescription: string; - registeredServerConnectionDetails: azdata.ConnectionInfo; -} - -export interface RemoveRegisteredServerParams extends RegisteredServerParamsBase { - registeredServerName: string; -} - -export interface AddServerGroupParams extends RegisteredServerParamsBase { - groupName: string; - groupDescription: string; -} - -export interface RemoveServerGroupParams extends RegisteredServerParamsBase { - groupName: string; -} - -export interface RegisteredServerParamsBase { - parentOwnerUri: string; - relativePath: string; -} - -export namespace CreateCentralManagementServerRequest { - export const type = new RequestType('cms/createCms'); -} - -export namespace ListRegisteredServersRequest { - export const type = new RequestType('cms/listRegisteredServers'); -} - -export namespace AddRegisteredServerRequest { - export const type = new RequestType('cms/addRegisteredServer'); -} - -export namespace RemoveRegisteredServerRequest { - export const type = new RequestType('cms/removeRegisteredServer'); -} - -export namespace AddServerGroupRequest { - export const type = new RequestType('cms/addCmsServerGroup'); -} - -export namespace RemoveServerGroupRequest { - export const type = new RequestType('cms/removeCmsServerGroup'); -} -// ------------------------------- ---------------------------------------- - -// ------------------------------- ----------------------------- - -export interface LanguageExtensionRequestParam { - ownerUri: string; -} - -export interface ExternalLanguageRequestParam extends LanguageExtensionRequestParam { - languageName: string; -} - -export interface ExternalLanguageUpdateRequestParam extends LanguageExtensionRequestParam { - language: mssql.ExternalLanguage; -} - -export interface LanguageExtensionListResponseParam { - languages: mssql.ExternalLanguage[]; -} - - -export interface ExternalLanguageResponseParam { -} - -export namespace LanguageExtensibilityListRequest { - export const type = new RequestType('languageExtension/list'); -} - -export namespace LanguageExtensibilityDeleteRequest { - export const type = new RequestType('languageExtension/delete'); -} - -export namespace LanguageExtensibilityUpdateRequest { - export const type = new RequestType('languageExtension/update'); -} - -// ------------------------------- ----------------------------- -export interface SchemaCompareParams { - operationId: string; - sourceEndpointInfo: mssql.SchemaCompareEndpointInfo; - targetEndpointInfo: mssql.SchemaCompareEndpointInfo; - taskExecutionMode: TaskExecutionMode; - deploymentOptions: mssql.DeploymentOptions; -} - -export interface SchemaCompareGenerateScriptParams { - operationId: string; - targetServerName: string; - targetDatabaseName: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface SchemaComparePublishDatabaseChangesParams { - operationId: string; - targetServerName: string; - targetDatabaseName: string; - taskExecutionMode: TaskExecutionMode; -} - -export interface SchemaComparePublishProjectChangesParams { - operationId: string; - targetProjectPath: string; - targetFolderStructure: mssql.ExtractTarget; - taskExecutionMode: TaskExecutionMode; -} - -export interface SchemaCompareGetOptionsParams { - -} - -export interface SchemaCompareNodeParams { - operationId: string; - diffEntry: mssql.DiffEntry; - includeRequest: boolean; - taskExecutionMode: TaskExecutionMode; -} - -export interface SchemaCompareOpenScmpParams { - filePath: string; -} - -export interface SchemaCompareSaveScmpParams { - sourceEndpointInfo: mssql.SchemaCompareEndpointInfo; - targetEndpointInfo: mssql.SchemaCompareEndpointInfo; - taskExecutionMode: TaskExecutionMode; - deploymentOptions: mssql.DeploymentOptions; - scmpFilePath: string; - excludedSourceObjects: mssql.SchemaCompareObjectId[]; - excludedTargetObjects: mssql.SchemaCompareObjectId[]; -} - -export interface SchemaCompareCancelParams { - operationId: string; -} - -export namespace SchemaCompareRequest { - export const type = new RequestType('schemaCompare/compare'); -} - -export namespace SchemaCompareGenerateScriptRequest { - export const type = new RequestType('schemaCompare/generateScript'); -} - -export namespace SchemaComparePublishDatabaseChangesRequest { - export const type = new RequestType('schemaCompare/publishDatabase'); -} - -export namespace SchemaComparePublishProjectChangesRequest { - export const type = new RequestType('schemaCompare/publishProject'); -} - -export namespace SchemaCompareGetDefaultOptionsRequest { - export const type = new RequestType('schemaCompare/getDefaultOptions'); -} - -export namespace SchemaCompareIncludeExcludeNodeRequest { - export const type = new RequestType('schemaCompare/includeExcludeNode'); -} - -export namespace SchemaCompareOpenScmpRequest { - export const type = new RequestType('schemaCompare/openScmp'); -} - -export namespace SchemaCompareSaveScmpRequest { - export const type = new RequestType('schemaCompare/saveScmp'); -} - -export namespace SchemaCompareCancellationRequest { - export const type = new RequestType('schemaCompare/cancel'); -} - -// ------------------------------- ----------------------------- - -/// ------------------------------- ----------------------------- - -export interface SqlAssessmentParams { - ownerUri: string; - targetType: azdata.sqlAssessment.SqlAssessmentTargetType; -} - -export interface GenerateSqlAssessmentScriptParams { - items: azdata.SqlAssessmentResultItem[]; - taskExecutionMode: azdata.TaskExecutionMode; - targetServerName: string; - targetDatabaseName: string; -} - -export namespace SqlAssessmentInvokeRequest { - export const type = new RequestType('assessment/invoke'); -} - -export namespace GetSqlAssessmentItemsRequest { - export const type = new RequestType('assessment/getAssessmentItems'); -} - -export namespace GenerateSqlAssessmentScriptRequest { - export const type = new RequestType('assessment/generateScript'); -} - -// ------------------------------- ----------------------------- - -// ------------------------------- ----------------------------- -export namespace SerializeDataStartRequest { - export const type = new RequestType('serialize/start'); -} - -export namespace SerializeDataContinueRequest { - export const type = new RequestType('serialize/continue'); -} -// ------------------------------- ----------------------------- - -// ------------------------------- < Load Completion Extension Request > ------------------------------------ -/** - * Completion extension load parameters - */ -export class CompletionExtensionParams { - /// - /// Absolute path for the assembly containing the completion extension - /// - public assemblyPath: string; - /// - /// The type name for the completion extension - /// - public typeName: string; - /// - /// Property bag for initializing the completion extension - /// - public properties: {}; -} - -export namespace CompletionExtLoadRequest { - export const type = new RequestType('completion/extLoad'); -} - -// ------------------------------- < Load Completion Extension Request > ------------------------------------ - -/// ------------------------------- ----------------------------- - -export interface ConvertNotebookToSqlParams { - content: string; -} - -export namespace ConvertNotebookToSqlRequest { - export const type = new RequestType('notebookconvert/convertnotebooktosql'); -} - -export interface ConvertNotebookToSqlResult extends azdata.ResultStatus { - content: string; -} - -export interface ConvertSqlToNotebookParams { - clientUri: string; -} - -export namespace ConvertSqlToNotebookRequest { - export const type = new RequestType('notebookconvert/convertsqltonotebook'); -} - -export interface ConvertSqlToNotebookResult extends azdata.ResultStatus { - content: string; -} - -// ------------------------------- ----------------------------- - -// ------------------------------- < SQL Profiler > ------------------------------------ - -/** - * Parameters to start a profiler session - */ -export interface CreateXEventSessionParams { - /** - * Session Owner URI - */ - ownerUri: string; - - /** - * Session name - */ - sessionName: string; - - /** - * Profiler Session template - */ - template: ProfilerSessionTemplate; -} - -export interface CreateXEventSessionResponse { } - -/** - * Parameters to start a profiler session - */ -export interface StartProfilingParams { - /** - * Session Owner URI - */ - ownerUri: string; - - /** - * Session name - */ - sessionName: string; -} - -export interface StartProfilingResponse { } - -/** - * Parameters to stop a profiler session - */ -export interface StopProfilingParams { - /** - * Session Owner URI - */ - ownerUri: string; -} - -export interface StopProfilingResponse { } - -/** - * Parameters to pause a profiler session - */ -export interface PauseProfilingParams { - /** - * Session Owner URI - */ - ownerUri: string; -} - -export interface PauseProfilingResponse { } - -/** - * Parameters to get a list of XEvent sessions - */ -export interface GetXEventSessionsParams { - /** - * Session Owner URI - */ - ownerUri: string; -} - -export interface GetXEventSessionsResponse { - /** - * List of all running XEvent Sessions on target server - */ - sessions: string[]; -} - -export interface DisconnectSessionParams { - /** - * Session Owner URI - */ - ownerUri: string; -} - -export interface DisconnectSessionResponse { } - -/** - * Profiler Event - */ -export interface ProfilerEvent { - /** - * Event class name - */ - name: string; - - /** - * Event timestamp - */ - timestamp: string; - - /** - * Event values - */ - values: {}; -} - -/** - * Profiler Session Template - */ -export interface ProfilerSessionTemplate { - /** - * Template name - */ - name: string; - - /** - * Default view for template - */ - defaultView: string; - - /** - * TSQL for creating a session - */ - createStatement: string; -} - -/** - * Profiler events available notification parameters - */ -export interface ProfilerEventsAvailableParams { - /** - * Session owner URI - */ - ownerUri: string; - - /** - * New profiler events available - */ - events: ProfilerEvent[]; - - /** - * If events may have been dropped - */ - eventsLost: boolean; -} - -/** - * Profiler events available notification parameters - */ -export interface ProfilerSessionStoppedParams { - /** - * Session owner URI - */ - ownerUri: string; - - /** - * Stopped session Id - */ - sessionId: number; -} - -/** - * Profiler session created notification parameters - */ -export interface ProfilerSessionCreatedParams { - /** - * Session owner URI - */ - ownerUri: string; - - /** - * Created session name - */ - sessionName: string; - - /** - * Template used to create session - */ - templateName: string; -} - -export namespace CreateXEventSessionRequest { - export const type = new RequestType('profiler/createsession'); -} - -export namespace StartProfilingRequest { - export const type = new RequestType('profiler/start'); -} - -export namespace StopProfilingRequest { - export const type = new RequestType('profiler/stop'); -} - -export namespace PauseProfilingRequest { - export const type = new RequestType('profiler/pause'); -} - -export namespace GetXEventSessionsRequest { - export const type = new RequestType('profiler/getsessions'); -} - -export namespace DisconnectSessionRequest { - export const type = new RequestType('profiler/disconnect'); -} - -export namespace ProfilerEventsAvailableNotification { - export const type = new NotificationType('profiler/eventsavailable'); -} - -export namespace ProfilerSessionStoppedNotification { - export const type = new NotificationType('profiler/sessionstopped'); -} - -export namespace ProfilerSessionCreatedNotification { - export const type = new NotificationType('profiler/sessioncreated'); -} - -// ------------------------------- < SQL Profiler > ------------------------------------ - -// ------------------------------- < Table Designer > ------------------------------------ - -export interface TableDesignerEditRequestParams { - tableInfo: azdata.designers.TableInfo, - tableChangeInfo: azdata.designers.DesignerEdit -} - -export namespace InitializeTableDesignerRequest { - export const type = new RequestType('tabledesigner/initialize'); -} - -export namespace ProcessTableDesignerEditRequest { - export const type = new RequestType, void, void>('tabledesigner/processedit'); -} - -export namespace PublishTableDesignerChangesRequest { - export const type = new RequestType('tabledesigner/publish'); -} - -export namespace TableDesignerGenerateScriptRequest { - export const type = new RequestType('tabledesigner/script'); -} - -export namespace TableDesignerGenerateChangePreviewReportRequest { - export const type = new RequestType('tabledesigner/generatepreviewreport'); -} -export namespace DisposeTableDesignerRequest { - export const type = new RequestType('tabledesigner/dispose'); -} -// ------------------------------- < Table Designer > ------------------------------------ - -// ------------------------------- < Azure Blob > ------------------------------------ -export interface CreateSasParams { - ownerUri: string; - blobContainerUri: string; - blobContainerKey: string; - storageAccountName: string; - expirationDate: string; -} - -export namespace CreateSasRequest { - export const type = new RequestType('blob/createSas'); -} - -// ------------------------------- < Azure Blob > ------------------------------------ - -// ------------------------------- < Execution Plan > ------------------------------------ - -export interface GetExecutionPlanParams { - graphInfo: azdata.executionPlan.ExecutionPlanGraphInfo, -} - -export namespace GetExecutionPlanRequest { - export const type = new RequestType('queryExecutionPlan/getExecutionPlan'); -} - -export interface ExecutionPlanComparisonParams { - firstExecutionPlanGraphInfo: azdata.executionPlan.ExecutionPlanGraphInfo; - secondExecutionPlanGraphInfo: azdata.executionPlan.ExecutionPlanGraphInfo; -} - -export namespace ExecutionPlanComparisonRequest { - export const type = new RequestType('queryExecutionPlan/compareExecutionPlanGraph'); -} - -// ------------------------------- < Execution Plan > ------------------------------------ - -// ------------------------------- < Object Management > ------------------------------------ -export interface InitializeViewRequestParams { - connectionUri: string; - database: string; - dialogType?: string; - contextId: string; - isNewObject: boolean; - objectType: string; - parentUrn: string; - objectUrn?: string; -} - -export namespace InitializeViewRequest { - export const type = new RequestType, void, void>('objectManagement/initializeView'); -} - -export interface SaveObjectRequestParams { - contextId: string; - object: mssql.ObjectManagement.SqlObject; -} - -export namespace SaveObjectRequest { - export const type = new RequestType('objectManagement/save'); -} - -export interface ScriptObjectRequestParams { - contextId: string; - object: mssql.ObjectManagement.SqlObject; -} - -export namespace ScriptObjectRequest { - export const type = new RequestType('objectManagement/script'); -} - -export interface DisposeViewRequestParams { - contextId: string; -} - -export namespace DisposeViewRequest { - export const type = new RequestType('objectManagement/disposeView'); -} - -export interface RenameObjectRequestParams { - connectionUri: string; - newName: string; - objectUrn: string; - objectType: mssql.ObjectManagement.NodeType; -} - -export namespace RenameObjectRequest { - export const type = new RequestType('objectManagement/rename'); -} - -export interface DropObjectRequestParams { - connectionUri: string; - objectUrn: string; - objectType: mssql.ObjectManagement.NodeType; -} - -export namespace DropObjectRequest { - export const type = new RequestType('objectManagement/drop'); -} - -export interface SearchObjectRequestParams { - contextId: string; - searchText: string | undefined; - schema: string | undefined; - objectTypes: mssql.ObjectManagement.NodeType[]; -} - -export namespace SearchObjectRequest { - export const type = new RequestType('objectManagement/search'); -} - -// ------------------------------- < Object Management > ------------------------------------ - -// ------------------------------- < Encryption IV/KEY updation Event > ------------------------------------ -/** - * Parameters for the MSAL cache encryption key notification - */ -export class DidChangeEncryptionIVKeyParams { - /** - * Buffer encoded IV string for MSAL cache encryption - */ - public iv: string; - /** - * Buffer encoded Key string for MSAL cache encryption - */ - public key: string; -} - -/** - * Notification sent when the encryption keys are changed. - */ -export namespace EncryptionKeysChangedNotification { - export const type = new NotificationType('connection/encryptionKeysChanged'); -} From 8caf792dded7cb1e6218070e9f557cc2331fba26 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Thu, 8 Jun 2023 15:31:23 -0700 Subject: [PATCH 07/16] more refactoring --- extensions/mssql/src/contracts.ts | 1648 +++++++++++++++++ .../src/objectManagement/ui/databaseDialog.ts | 2 +- extensions/mssql/src/ui/dialogBase.ts | 2 +- 3 files changed, 1650 insertions(+), 2 deletions(-) create mode 100644 extensions/mssql/src/contracts.ts diff --git a/extensions/mssql/src/contracts.ts b/extensions/mssql/src/contracts.ts new file mode 100644 index 000000000000..1518dfaedbb7 --- /dev/null +++ b/extensions/mssql/src/contracts.ts @@ -0,0 +1,1648 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { NotificationType, RequestType } from 'vscode-languageclient'; +import * as telemetry from '@microsoft/ads-extension-telemetry'; +import * as azdata from 'azdata'; +import { ConnectParams } from 'dataprotocol-client/lib/protocol'; +import * as mssql from 'mssql'; + +// ------------------------------- < Telemetry Sent Event > ------------------------------------ + +/** + * Event sent when the language service send a telemetry event + */ +export namespace TelemetryNotification { + export const type = new NotificationType('telemetry/sqlevent'); +} + +/** + * Update event parameters + */ +export class TelemetryParams { + public params: { + eventName: string; + properties: telemetry.TelemetryEventProperties; + measures: telemetry.TelemetryEventMeasures; + }; +} + +// ------------------------------- ---------------------------------- + +// ------------------------------- < Security Token Request > ------------------------------------------ +export interface RequestSecurityTokenParams { + provider: string; + authority: string; + resource: string; + scopes: string[]; +} + +export interface RequestSecurityTokenResponse { + accountKey: string; + token: string; +} + +export namespace SecurityTokenRequest { + export const type = new RequestType('account/securityTokenRequest'); +} +// ------------------------------- ------------------------------------------ + +// ------------------------------- < Refresh Token Notification > --------------------------------- + +/** + * Parameters for a refresh token notification sent from STS to ADS + */ +export interface RefreshTokenParams { + /** + * The tenant ID + */ + tenantId: string; + /** + * The provider that indicates the type of linked account to query + */ + provider: string; + /** + * The identifier of the target resource of the requested token + */ + resource: string; + /** + * The account ID + */ + accountId: string; + /** + * The URI for the editor that needs a token refresh + */ + uri: string; +} + +export namespace RefreshTokenNotification { + export const type = new NotificationType('account/refreshToken'); +} + + + +// ------------------------------- ------------------------------- + +// ------------------------------- < Token Refreshed Notification > --------------------------------- + +/** + * Parameters for a new refresh token sent from ADS to STS + */ +export interface TokenRefreshedParams { + /** + * The refresh token + */ + token: string; + /** + * The token expiration, a Unix epoch + */ + expiresOn: Number; + /** + * The URI for the editor that needs a token refresh + */ + uri: string; +} + +export namespace TokenRefreshedNotification { + export const type = new NotificationType('account/tokenRefreshed'); +} + +// ------------------------------- ------------------------------- + + +// ------------------------------- < Agent Management > ------------------------------------ +// Job management parameters +export interface AgentJobsParams { + ownerUri: string; + jobId: string; +} + +export interface AgentJobHistoryParams { + ownerUri: string; + jobId: string; + jobName: string; +} + +export interface AgentJobActionParams { + ownerUri: string; + jobName: string; + action: string; +} + +export interface CreateAgentJobParams { + ownerUri: string; + job: azdata.AgentJobInfo; +} + +export interface UpdateAgentJobParams { + ownerUri: string; + originalJobName: string; + job: azdata.AgentJobInfo; +} + +export interface DeleteAgentJobParams { + ownerUri: string; + job: azdata.AgentJobInfo; +} + +export interface AgentJobDefaultsParams { + ownerUri: string; +} + +// Job Step management parameters +export interface CreateAgentJobStepParams { + ownerUri: string; + step: azdata.AgentJobStepInfo; +} + +export interface UpdateAgentJobStepParams { + ownerUri: string; + originalJobStepName: string; + step: azdata.AgentJobStepInfo; +} + +export interface DeleteAgentJobStepParams { + ownerUri: string; + step: azdata.AgentJobStepInfo; +} + +// Notebook management parameters +export interface AgentNotebookParams { + ownerUri: string; +} + +export interface AgentNotebookHistoryParams { + ownerUri: string; + jobId: string; + jobName: string; + targetDatabase: string; +} + +export interface AgentNotebookMaterializedParams { + ownerUri: string; + targetDatabase: string; + notebookMaterializedId: number; +} + +export interface AgentNotebookTemplateParams { + ownerUri: string; + targetDatabase: string; + jobId: string; +} + +export interface CreateAgentNotebookParams { + ownerUri: string; + notebook: azdata.AgentNotebookInfo; + templateFilePath: string; +} + +export interface UpdateAgentNotebookParams { + ownerUri: string; + originalNotebookName: string; + notebook: azdata.AgentJobInfo; + templateFilePath: string; +} + +export interface UpdateAgentNotebookRunPinParams { + ownerUri: string; + targetDatabase: string; + agentNotebookHistory: azdata.AgentNotebookHistoryInfo; + materializedNotebookPin: boolean; +} + +export interface UpdateAgentNotebookRunNameParams { + ownerUri: string; + targetDatabase: string; + agentNotebookHistory: azdata.AgentNotebookHistoryInfo; + materializedNotebookName: string; +} + +export interface DeleteAgentNotebookParams { + ownerUri: string; + notebook: azdata.AgentNotebookInfo; +} + +export interface DeleteAgentMaterializedNotebookParams { + ownerUri: string; + targetDatabase: string; + agentNotebookHistory: azdata.AgentNotebookHistoryInfo; +} + +// Alert management parameters +export interface AgentAlertsParams { + ownerUri: string; +} + +export interface CreateAgentAlertParams { + ownerUri: string; + alert: azdata.AgentAlertInfo; +} + +export interface UpdateAgentAlertParams { + ownerUri: string; + originalAlertName: string; + alert: azdata.AgentAlertInfo; +} + +export interface DeleteAgentAlertParams { + ownerUri: string; + alert: azdata.AgentAlertInfo; +} + +// Operator management parameters +export interface AgentOperatorsParams { + ownerUri: string; +} + +export interface CreateAgentOperatorParams { + ownerUri: string; + operator: azdata.AgentOperatorInfo; +} + +export interface UpdateAgentOperatorParams { + ownerUri: string; + originalOperatorName: string; + operator: azdata.AgentOperatorInfo; +} + +export interface DeleteAgentOperatorParams { + ownerUri: string; + operator: azdata.AgentOperatorInfo; +} + +// Proxy management parameters +export interface AgentProxiesParams { + ownerUri: string; +} + +export interface CreateAgentProxyParams { + ownerUri: string; + proxy: azdata.AgentProxyInfo; +} + +export interface UpdateAgentProxyParams { + ownerUri: string; + originalProxyName: string; + proxy: azdata.AgentProxyInfo; +} + +export interface DeleteAgentProxyParams { + ownerUri: string; + proxy: azdata.AgentProxyInfo; +} + +// Agent Credentials parameters +export interface GetCredentialsParams { + ownerUri: string; +} + +// Job Schedule management parameters +export interface AgentJobScheduleParams { + ownerUri: string; +} + +export interface CreateAgentJobScheduleParams { + ownerUri: string; + schedule: azdata.AgentJobScheduleInfo; +} + +export interface UpdateAgentJobScheduleParams { + ownerUri: string; + originalScheduleName: string; + schedule: azdata.AgentJobScheduleInfo; +} + +export interface DeleteAgentJobScheduleParams { + ownerUri: string; + schedule: azdata.AgentJobScheduleInfo; +} + +// Agent Job management requests +export namespace AgentJobsRequest { + export const type = new RequestType('agent/jobs'); +} + +export namespace AgentJobHistoryRequest { + export const type = new RequestType('agent/jobhistory'); +} + +export namespace AgentJobActionRequest { + export const type = new RequestType('agent/jobaction'); +} + +export namespace CreateAgentJobRequest { + export const type = new RequestType('agent/createjob'); +} + +export namespace UpdateAgentJobRequest { + export const type = new RequestType('agent/updatejob'); +} + +export namespace DeleteAgentJobRequest { + export const type = new RequestType('agent/deletejob'); +} + +export namespace AgentJobDefaultsRequest { + export const type = new RequestType('agent/jobdefaults'); +} + +// Job Step requests +export namespace CreateAgentJobStepRequest { + export const type = new RequestType('agent/createjobstep'); +} + +export namespace UpdateAgentJobStepRequest { + export const type = new RequestType('agent/updatejobstep'); +} + +export namespace DeleteAgentJobStepRequest { + export const type = new RequestType('agent/deletejobstep'); +} + +// Notebooks request +export namespace AgentNotebooksRequest { + export const type = new RequestType('agent/notebooks'); +} + +export namespace AgentNotebookHistoryRequest { + export const type = new RequestType('agent/notebookhistory'); +} + +export namespace AgentNotebookMaterializedRequest { + export const type = new RequestType('agent/notebookmaterialized'); +} + +export namespace UpdateAgentNotebookRunNameRequest { + export const type = new RequestType('agent/updatenotebookname'); +} + +export namespace DeleteMaterializedNotebookRequest { + export const type = new RequestType('agent/deletematerializednotebook'); +} + +export namespace UpdateAgentNotebookRunPinRequest { + export const type = new RequestType('agent/updatenotebookpin'); +} + +export namespace AgentNotebookTemplateRequest { + export const type = new RequestType('agent/notebooktemplate'); +} + +export namespace CreateAgentNotebookRequest { + export const type = new RequestType('agent/createnotebook'); +} + +export namespace DeleteAgentNotebookRequest { + export const type = new RequestType('agent/deletenotebook'); +} + +export namespace UpdateAgentNotebookRequest { + export const type = new RequestType('agent/updatenotebook'); +} + +// Alerts requests +export namespace AgentAlertsRequest { + export const type = new RequestType('agent/alerts'); +} + +export namespace CreateAgentAlertRequest { + export const type = new RequestType('agent/createalert'); +} + +export namespace UpdateAgentAlertRequest { + export const type = new RequestType('agent/updatealert'); +} + +export namespace DeleteAgentAlertRequest { + export const type = new RequestType('agent/deletealert'); +} + +// Operators requests +export namespace AgentOperatorsRequest { + export const type = new RequestType('agent/operators'); +} + +export namespace CreateAgentOperatorRequest { + export const type = new RequestType('agent/createoperator'); +} + +export namespace UpdateAgentOperatorRequest { + export const type = new RequestType('agent/updateoperator'); +} + +export namespace DeleteAgentOperatorRequest { + export const type = new RequestType('agent/deleteoperator'); +} + +// Proxies requests +export namespace AgentProxiesRequest { + export const type = new RequestType('agent/proxies'); +} + +export namespace CreateAgentProxyRequest { + export const type = new RequestType('agent/createproxy'); +} + +export namespace UpdateAgentProxyRequest { + export const type = new RequestType('agent/updateproxy'); +} + +export namespace DeleteAgentProxyRequest { + export const type = new RequestType('agent/deleteproxy'); +} + +// Agent Credentials request +export namespace AgentCredentialsRequest { + export const type = new RequestType('security/credentials'); +} + +// Job Schedules requests +export namespace AgentJobSchedulesRequest { + export const type = new RequestType('agent/schedules'); +} + +export namespace CreateAgentJobScheduleRequest { + export const type = new RequestType('agent/createschedule'); +} + +export namespace UpdateAgentJobScheduleRequest { + export const type = new RequestType('agent/updateschedule'); +} + +export namespace DeleteAgentJobScheduleRequest { + export const type = new RequestType('agent/deleteschedule'); +} + +// ------------------------------- < Agent Management > ------------------------------------ + +// ------------------------------- < DacFx > ------------------------------------ + +export enum TaskExecutionMode { + execute = 0, + script = 1, + executeAndScript = 2, +} + +export interface ExportParams { + databaseName: string; + packageFilePath: string; + ownerUri: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface ImportParams { + packageFilePath: string; + databaseName: string; + ownerUri: string; + taskExecutionMode: TaskExecutionMode; +} + + +export interface ExtractParams { + databaseName: string; + packageFilePath: string; + applicationName: string; + applicationVersion: string; + ownerUri: string; + extractTarget?: mssql.ExtractTarget; + taskExecutionMode: TaskExecutionMode; + includePermissions?: boolean; +} + +export interface DeployParams { + packageFilePath: string; + databaseName: string; + upgradeExisting: boolean; + sqlCommandVariableValues?: Record; + deploymentOptions?: mssql.DeploymentOptions; + ownerUri: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface GenerateDeployScriptParams { + packageFilePath: string; + databaseName: string; + sqlCommandVariableValues?: Record; + deploymentOptions?: mssql.DeploymentOptions + ownerUri: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface GenerateDeployPlanParams { + packageFilePath: string; + databaseName: string; + ownerUri: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface GetOptionsFromProfileParams { + profilePath: string; +} + +export interface ValidateStreamingJobParams { + packageFilePath: string, + createStreamingJobTsql: string +} + +export interface ParseTSqlScriptParams { + filePath: string; + databaseSchemaProvider: string; +} + +export interface SavePublishProfileParams { + profilePath: string; + databaseName: string; + connectionString: string; + sqlCommandVariableValues?: Record; + deploymentOptions?: mssql.DeploymentOptions; +} + +export namespace ExportRequest { + export const type = new RequestType('dacfx/export'); +} + +export namespace ImportRequest { + export const type = new RequestType('dacfx/import'); +} + +export namespace ExtractRequest { + export const type = new RequestType('dacfx/extract'); +} + +export namespace DeployRequest { + export const type = new RequestType('dacfx/deploy'); +} + +export namespace GenerateDeployScriptRequest { + export const type = new RequestType('dacfx/generateDeploymentScript'); +} + +export namespace GenerateDeployPlanRequest { + export const type = new RequestType('dacfx/generateDeployPlan'); +} + +export namespace GetOptionsFromProfileRequest { + export const type = new RequestType('dacfx/getOptionsFromProfile'); +} + +export namespace ValidateStreamingJobRequest { + export const type = new RequestType('dacfx/validateStreamingJob'); +} + +export namespace ParseTSqlScriptRequest { + export const type = new RequestType('dacfx/parseTSqlScript'); +} + +export namespace SavePublishProfileRequest { + export const type = new RequestType('dacfx/savePublishProfile'); +} + +// ------------------------------- ------------------------------------ + +// ------------------------------- < Sql Projects > ------------------------------------ +//#region SqlProjects + +//#region Functions + +//#region Project-level functions + +export namespace CreateSqlProjectRequest { + export const type = new RequestType('sqlProjects/createProject'); +} + +export namespace OpenSqlProjectRequest { + export const type = new RequestType('sqlProjects/openProject'); +} + +export namespace CloseSqlProjectRequest { + export const type = new RequestType('sqlProjects/closeProject'); +} + +export namespace GetCrossPlatformCompatibilityRequest { + export const type = new RequestType('sqlProjects/getCrossPlatformCompatibility'); +} + +export namespace UpdateProjectForCrossPlatformRequest { + export const type = new RequestType('sqlProjects/updateProjectForCrossPlatform'); +} + +export namespace GetProjectPropertiesRequest { + export const type = new RequestType('sqlProjects/getProjectProperties'); +} + +export namespace SetDatabaseSourceRequest { + export const type = new RequestType('sqlProjects/setDatabaseSource'); +} + +export namespace SetDatabaseSchemaProviderRequest { + export const type = new RequestType('sqlProjects/setDatabaseSchemaProvider'); +} + +//#endregion + +//#region File/folder functions + +//#region SQL object script functions + +export namespace AddSqlObjectScriptRequest { + export const type = new RequestType('sqlProjects/addSqlObjectScript'); +} + +export namespace DeleteSqlObjectScriptRequest { + export const type = new RequestType('sqlProjects/deleteSqlObjectScript'); +} + +export namespace ExcludeSqlObjectScriptRequest { + export const type = new RequestType('sqlProjects/excludeSqlObjectScript'); +} + +export namespace MoveSqlObjectScriptRequest { + export const type = new RequestType('sqlProjects/moveSqlObjectScript'); +} + +export namespace GetSqlObjectScriptsRequest { + export const type = new RequestType('sqlProjects/getSqlObjectScripts'); +} + + +export namespace ExcludeFolderRequest { + export const type = new RequestType('sqlProjects/excludeFolder'); +} + +export namespace MoveFolderRequest { + export const type = new RequestType('sqlProjects/moveFolder'); +} + + +//#endregion + +//#endregion + +//#region Folder functions + +export namespace AddFolderRequest { + export const type = new RequestType('sqlProjects/addFolder'); +} + +export namespace DeleteFolderRequest { + export const type = new RequestType('sqlProjects/deleteFolder'); +} + +export namespace GetFoldersRequest { + export const type = new RequestType('sqlProjects/getFolders'); +} + +//#endregion + +//#region Pre/Post-deployment script functions + +export namespace AddPostDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/addPostDeploymentScript'); +} + +export namespace AddPreDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/addPreDeploymentScript'); +} + +export namespace DeletePostDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/deletePostDeploymentScript'); +} + +export namespace DeletePreDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/deletePreDeploymentScript'); +} + +export namespace ExcludePostDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/excludePostDeploymentScript'); +} + +export namespace GetPostDeploymentScriptsRequest { + export const type = new RequestType('sqlProjects/getPostDeploymentScripts'); +} + +export namespace ExcludePreDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/excludePreDeploymentScript'); +} + +export namespace MovePostDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/movePostDeploymentScript'); +} + +export namespace MovePreDeploymentScriptRequest { + export const type = new RequestType('sqlProjects/movePreDeploymentScript'); +} + +export namespace GetPreDeploymentScriptsRequest { + export const type = new RequestType('sqlProjects/getPreDeploymentScripts'); +} + +//#endregion + +//#region None functions + +export namespace AddNoneItemRequest { + export const type = new RequestType('sqlProjects/addNoneItem'); +} + +export namespace DeleteNoneItemRequest { + export const type = new RequestType('sqlProjects/deleteNoneItem'); +} + +export namespace ExcludeNoneItemRequest { + export const type = new RequestType('sqlProjects/excludeNoneItem'); +} + +export namespace GetNoneItemsRequest { + export const type = new RequestType('sqlProjects/getNoneItems'); +} + +export namespace MoveNoneItemRequest { + export const type = new RequestType('sqlProjects/moveNoneItem'); +} + +//#endregion + +//#endregion + +//#region SQLCMD variable functions + +export namespace AddSqlCmdVariableRequest { + export const type = new RequestType('sqlProjects/addSqlCmdVariable'); +} + +export namespace DeleteSqlCmdVariableRequest { + export const type = new RequestType('sqlProjects/deleteSqlCmdVariable'); +} + +export namespace UpdateSqlCmdVariableRequest { + export const type = new RequestType('sqlProjects/updateSqlCmdVariable'); +} + +export namespace GetSqlCmdVariablesRequest { + export const type = new RequestType('sqlProjects/getSqlCmdVariables'); +} + +//#endregion + +//#region Database reference functions + +export namespace AddDacpacReferenceRequest { + export const type = new RequestType('sqlprojects/addDacpacReference'); +} + +export namespace AddSqlProjectReferenceRequest { + export const type = new RequestType('sqlprojects/addSqlProjectReference'); +} + +export namespace AddSystemDatabaseReferenceRequest { + export const type = new RequestType('sqlprojects/addSystemDatabaseReference'); +} + +export namespace AddNugetPackageReferenceRequest { + export const type = new RequestType('sqlprojects/addNugetPackageReference'); +} + +export namespace DeleteDatabaseReferenceRequest { + export const type = new RequestType('sqlprojects/deleteDatabaseReference'); +} + +export namespace GetDatabaseReferencesRequest { + export const type = new RequestType('sqlProjects/getDatabaseReferences'); +} + +//#endregion + +//#endregion + +//#region Parameters + +export interface SqlProjectParams { + /** + * Absolute path of the project, including .sqlproj + */ + projectUri: string; +} + +export interface SqlProjectScriptParams extends SqlProjectParams { + /** + * Path of the script, including .sql, relative to the .sqlproj + */ + path: string; +} + +export interface SetDatabaseSourceParams extends SqlProjectParams { + /** + * Source of the database schema, used in telemetry + */ + databaseSource: string; +} + +export interface SetDatabaseSchemaProviderParams extends SqlProjectParams { + /** + * New DatabaseSchemaProvider value, in the form "Microsoft.Data.Tools.Schema.Sql.SqlXYZDatabaseSchemaProvider" + */ + databaseSchemaProvider: string; +} + +export interface AddDacpacReferenceParams extends AddUserDatabaseReferenceParams { + /** + * Path to the .dacpac file + */ + dacpacPath: string; +} + +export interface AddNugetPackageReferenceParams extends AddUserDatabaseReferenceParams { + /** + * NuGet package name + */ + packageName: string; + + /** + * NuGet package version + */ + packageVersion: string; +} + +export interface AddDatabaseReferenceParams extends SqlProjectParams { + /** + * Whether to suppress missing dependencies + */ + suppressMissingDependencies: boolean; + /** + * Literal name used to reference another database in the same server, if not using SQLCMD variables + */ + databaseLiteral?: string; +} + +export interface AddSqlProjectReferenceParams extends AddUserDatabaseReferenceParams { + /** + * Path to the referenced .sqlproj file + */ + projectPath: string; + /** + * GUID for the referenced SQL project + */ + projectGuid: string; +} + +export interface AddSystemDatabaseReferenceParams extends AddDatabaseReferenceParams { + /** + * Type of system database + */ + systemDatabase: mssql.SystemDatabase; +} + +export interface AddUserDatabaseReferenceParams extends AddDatabaseReferenceParams { + /** + * SQLCMD variable name for specifying the other database this reference is to, if different from that of the current project + */ + databaseVariable?: string; + /** + * SQLCMD variable name for specifying the other server this reference is to, if different from that of the current project. + * If this is set, DatabaseVariable must also be set. + */ + serverVariable?: string; +} + +export interface DeleteDatabaseReferenceParams extends SqlProjectParams { + /** + * Name of the reference to be deleted. Name of the System DB, path of the sqlproj, or path of the dacpac + */ + name: string; +} + +export interface FolderParams extends SqlProjectParams { + /** + * Path of the folder, typically relative to the .sqlproj file + */ + path: string; +} + +export interface MoveFolderParams extends FolderParams { + /** + * Path of the folder, typically relative to the .sqlproj file + */ + destinationPath: string; +} + +export interface CreateSqlProjectParams extends SqlProjectParams { + /** + * Type of SQL Project: SDK-style or Legacy + */ + sqlProjectType: mssql.ProjectType; + /** + * Database schema provider for the project, in the format + * "Microsoft.Data.Tools.Schema.Sql.SqlXYZDatabaseSchemaProvider". + * Case sensitive. + */ + databaseSchemaProvider?: string; + /** + * Version of the Microsoft.Build.Sql SDK for the project, if overriding the default + */ + buildSdkVersion?: string; +} + +export interface AddSqlCmdVariableParams extends SqlProjectParams { + /** + * Name of the SQLCMD variable + */ + name: string; + /** + * Default value of the SQLCMD variable + */ + defaultValue: string; +} + +export interface DeleteSqlCmdVariableParams extends SqlProjectParams { + /** + * Name of the SQLCMD variable to be deleted + */ + name?: string; +} + +export interface MoveItemParams extends SqlProjectScriptParams { + /** + * Destination path of the file or folder, relative to the .sqlproj + */ + destinationPath: string; +} + +//#endregion + +//#endregion + +// ------------------------------- ----------------------------------- + +// ------------------------------- ---------------------------------------- + + +export interface CreateCentralManagementServerParams { + registeredServerName: string; + registeredServerDescription: string; + connectParams: ConnectParams; +} + +export interface ListRegisteredServersParams extends RegisteredServerParamsBase { + // same as base +} + +export interface AddRegisteredServerParams extends RegisteredServerParamsBase { + registeredServerName: string; + registeredServerDescription: string; + registeredServerConnectionDetails: azdata.ConnectionInfo; +} + +export interface RemoveRegisteredServerParams extends RegisteredServerParamsBase { + registeredServerName: string; +} + +export interface AddServerGroupParams extends RegisteredServerParamsBase { + groupName: string; + groupDescription: string; +} + +export interface RemoveServerGroupParams extends RegisteredServerParamsBase { + groupName: string; +} + +export interface RegisteredServerParamsBase { + parentOwnerUri: string; + relativePath: string; +} + +export namespace CreateCentralManagementServerRequest { + export const type = new RequestType('cms/createCms'); +} + +export namespace ListRegisteredServersRequest { + export const type = new RequestType('cms/listRegisteredServers'); +} + +export namespace AddRegisteredServerRequest { + export const type = new RequestType('cms/addRegisteredServer'); +} + +export namespace RemoveRegisteredServerRequest { + export const type = new RequestType('cms/removeRegisteredServer'); +} + +export namespace AddServerGroupRequest { + export const type = new RequestType('cms/addCmsServerGroup'); +} + +export namespace RemoveServerGroupRequest { + export const type = new RequestType('cms/removeCmsServerGroup'); +} +// ------------------------------- ---------------------------------------- + +// ------------------------------- ----------------------------- + +export interface LanguageExtensionRequestParam { + ownerUri: string; +} + +export interface ExternalLanguageRequestParam extends LanguageExtensionRequestParam { + languageName: string; +} + +export interface ExternalLanguageUpdateRequestParam extends LanguageExtensionRequestParam { + language: mssql.ExternalLanguage; +} + +export interface LanguageExtensionListResponseParam { + languages: mssql.ExternalLanguage[]; +} + + +export interface ExternalLanguageResponseParam { +} + +export namespace LanguageExtensibilityListRequest { + export const type = new RequestType('languageExtension/list'); +} + +export namespace LanguageExtensibilityDeleteRequest { + export const type = new RequestType('languageExtension/delete'); +} + +export namespace LanguageExtensibilityUpdateRequest { + export const type = new RequestType('languageExtension/update'); +} + +// ------------------------------- ----------------------------- +export interface SchemaCompareParams { + operationId: string; + sourceEndpointInfo: mssql.SchemaCompareEndpointInfo; + targetEndpointInfo: mssql.SchemaCompareEndpointInfo; + taskExecutionMode: TaskExecutionMode; + deploymentOptions: mssql.DeploymentOptions; +} + +export interface SchemaCompareGenerateScriptParams { + operationId: string; + targetServerName: string; + targetDatabaseName: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface SchemaComparePublishDatabaseChangesParams { + operationId: string; + targetServerName: string; + targetDatabaseName: string; + taskExecutionMode: TaskExecutionMode; +} + +export interface SchemaComparePublishProjectChangesParams { + operationId: string; + targetProjectPath: string; + targetFolderStructure: mssql.ExtractTarget; + taskExecutionMode: TaskExecutionMode; +} + +export interface SchemaCompareGetOptionsParams { + +} + +export interface SchemaCompareNodeParams { + operationId: string; + diffEntry: mssql.DiffEntry; + includeRequest: boolean; + taskExecutionMode: TaskExecutionMode; +} + +export interface SchemaCompareOpenScmpParams { + filePath: string; +} + +export interface SchemaCompareSaveScmpParams { + sourceEndpointInfo: mssql.SchemaCompareEndpointInfo; + targetEndpointInfo: mssql.SchemaCompareEndpointInfo; + taskExecutionMode: TaskExecutionMode; + deploymentOptions: mssql.DeploymentOptions; + scmpFilePath: string; + excludedSourceObjects: mssql.SchemaCompareObjectId[]; + excludedTargetObjects: mssql.SchemaCompareObjectId[]; +} + +export interface SchemaCompareCancelParams { + operationId: string; +} + +export namespace SchemaCompareRequest { + export const type = new RequestType('schemaCompare/compare'); +} + +export namespace SchemaCompareGenerateScriptRequest { + export const type = new RequestType('schemaCompare/generateScript'); +} + +export namespace SchemaComparePublishDatabaseChangesRequest { + export const type = new RequestType('schemaCompare/publishDatabase'); +} + +export namespace SchemaComparePublishProjectChangesRequest { + export const type = new RequestType('schemaCompare/publishProject'); +} + +export namespace SchemaCompareGetDefaultOptionsRequest { + export const type = new RequestType('schemaCompare/getDefaultOptions'); +} + +export namespace SchemaCompareIncludeExcludeNodeRequest { + export const type = new RequestType('schemaCompare/includeExcludeNode'); +} + +export namespace SchemaCompareOpenScmpRequest { + export const type = new RequestType('schemaCompare/openScmp'); +} + +export namespace SchemaCompareSaveScmpRequest { + export const type = new RequestType('schemaCompare/saveScmp'); +} + +export namespace SchemaCompareCancellationRequest { + export const type = new RequestType('schemaCompare/cancel'); +} + +// ------------------------------- ----------------------------- + +/// ------------------------------- ----------------------------- + +export interface SqlAssessmentParams { + ownerUri: string; + targetType: azdata.sqlAssessment.SqlAssessmentTargetType; +} + +export interface GenerateSqlAssessmentScriptParams { + items: azdata.SqlAssessmentResultItem[]; + taskExecutionMode: azdata.TaskExecutionMode; + targetServerName: string; + targetDatabaseName: string; +} + +export namespace SqlAssessmentInvokeRequest { + export const type = new RequestType('assessment/invoke'); +} + +export namespace GetSqlAssessmentItemsRequest { + export const type = new RequestType('assessment/getAssessmentItems'); +} + +export namespace GenerateSqlAssessmentScriptRequest { + export const type = new RequestType('assessment/generateScript'); +} + +// ------------------------------- ----------------------------- + +// ------------------------------- ----------------------------- +export namespace SerializeDataStartRequest { + export const type = new RequestType('serialize/start'); +} + +export namespace SerializeDataContinueRequest { + export const type = new RequestType('serialize/continue'); +} +// ------------------------------- ----------------------------- + +// ------------------------------- < Load Completion Extension Request > ------------------------------------ +/** + * Completion extension load parameters + */ +export class CompletionExtensionParams { + /// + /// Absolute path for the assembly containing the completion extension + /// + public assemblyPath: string; + /// + /// The type name for the completion extension + /// + public typeName: string; + /// + /// Property bag for initializing the completion extension + /// + public properties: {}; +} + +export namespace CompletionExtLoadRequest { + export const type = new RequestType('completion/extLoad'); +} + +// ------------------------------- < Load Completion Extension Request > ------------------------------------ + +/// ------------------------------- ----------------------------- + +export interface ConvertNotebookToSqlParams { + content: string; +} + +export namespace ConvertNotebookToSqlRequest { + export const type = new RequestType('notebookconvert/convertnotebooktosql'); +} + +export interface ConvertNotebookToSqlResult extends azdata.ResultStatus { + content: string; +} + +export interface ConvertSqlToNotebookParams { + clientUri: string; +} + +export namespace ConvertSqlToNotebookRequest { + export const type = new RequestType('notebookconvert/convertsqltonotebook'); +} + +export interface ConvertSqlToNotebookResult extends azdata.ResultStatus { + content: string; +} + +// ------------------------------- ----------------------------- + +// ------------------------------- < SQL Profiler > ------------------------------------ + +/** + * Parameters to start a profiler session + */ +export interface CreateXEventSessionParams { + /** + * Session Owner URI + */ + ownerUri: string; + + /** + * Session name + */ + sessionName: string; + + /** + * Profiler Session template + */ + template: ProfilerSessionTemplate; +} + +export interface CreateXEventSessionResponse { } + +/** + * Parameters to start a profiler session + */ +export interface StartProfilingParams { + /** + * Session Owner URI + */ + ownerUri: string; + + /** + * Session name + */ + sessionName: string; +} + +export interface StartProfilingResponse { } + +/** + * Parameters to stop a profiler session + */ +export interface StopProfilingParams { + /** + * Session Owner URI + */ + ownerUri: string; +} + +export interface StopProfilingResponse { } + +/** + * Parameters to pause a profiler session + */ +export interface PauseProfilingParams { + /** + * Session Owner URI + */ + ownerUri: string; +} + +export interface PauseProfilingResponse { } + +/** + * Parameters to get a list of XEvent sessions + */ +export interface GetXEventSessionsParams { + /** + * Session Owner URI + */ + ownerUri: string; +} + +export interface GetXEventSessionsResponse { + /** + * List of all running XEvent Sessions on target server + */ + sessions: string[]; +} + +export interface DisconnectSessionParams { + /** + * Session Owner URI + */ + ownerUri: string; +} + +export interface DisconnectSessionResponse { } + +/** + * Profiler Event + */ +export interface ProfilerEvent { + /** + * Event class name + */ + name: string; + + /** + * Event timestamp + */ + timestamp: string; + + /** + * Event values + */ + values: {}; +} + +/** + * Profiler Session Template + */ +export interface ProfilerSessionTemplate { + /** + * Template name + */ + name: string; + + /** + * Default view for template + */ + defaultView: string; + + /** + * TSQL for creating a session + */ + createStatement: string; +} + +/** + * Profiler events available notification parameters + */ +export interface ProfilerEventsAvailableParams { + /** + * Session owner URI + */ + ownerUri: string; + + /** + * New profiler events available + */ + events: ProfilerEvent[]; + + /** + * If events may have been dropped + */ + eventsLost: boolean; +} + +/** + * Profiler events available notification parameters + */ +export interface ProfilerSessionStoppedParams { + /** + * Session owner URI + */ + ownerUri: string; + + /** + * Stopped session Id + */ + sessionId: number; +} + +/** + * Profiler session created notification parameters + */ +export interface ProfilerSessionCreatedParams { + /** + * Session owner URI + */ + ownerUri: string; + + /** + * Created session name + */ + sessionName: string; + + /** + * Template used to create session + */ + templateName: string; +} + +export namespace CreateXEventSessionRequest { + export const type = new RequestType('profiler/createsession'); +} + +export namespace StartProfilingRequest { + export const type = new RequestType('profiler/start'); +} + +export namespace StopProfilingRequest { + export const type = new RequestType('profiler/stop'); +} + +export namespace PauseProfilingRequest { + export const type = new RequestType('profiler/pause'); +} + +export namespace GetXEventSessionsRequest { + export const type = new RequestType('profiler/getsessions'); +} + +export namespace DisconnectSessionRequest { + export const type = new RequestType('profiler/disconnect'); +} + +export namespace ProfilerEventsAvailableNotification { + export const type = new NotificationType('profiler/eventsavailable'); +} + +export namespace ProfilerSessionStoppedNotification { + export const type = new NotificationType('profiler/sessionstopped'); +} + +export namespace ProfilerSessionCreatedNotification { + export const type = new NotificationType('profiler/sessioncreated'); +} + +// ------------------------------- < SQL Profiler > ------------------------------------ + +// ------------------------------- < Table Designer > ------------------------------------ + +export interface TableDesignerEditRequestParams { + tableInfo: azdata.designers.TableInfo, + tableChangeInfo: azdata.designers.DesignerEdit +} + +export namespace InitializeTableDesignerRequest { + export const type = new RequestType('tabledesigner/initialize'); +} + +export namespace ProcessTableDesignerEditRequest { + export const type = new RequestType, void, void>('tabledesigner/processedit'); +} + +export namespace PublishTableDesignerChangesRequest { + export const type = new RequestType('tabledesigner/publish'); +} + +export namespace TableDesignerGenerateScriptRequest { + export const type = new RequestType('tabledesigner/script'); +} + +export namespace TableDesignerGenerateChangePreviewReportRequest { + export const type = new RequestType('tabledesigner/generatepreviewreport'); +} +export namespace DisposeTableDesignerRequest { + export const type = new RequestType('tabledesigner/dispose'); +} +// ------------------------------- < Table Designer > ------------------------------------ + +// ------------------------------- < Azure Blob > ------------------------------------ +export interface CreateSasParams { + ownerUri: string; + blobContainerUri: string; + blobContainerKey: string; + storageAccountName: string; + expirationDate: string; +} + +export namespace CreateSasRequest { + export const type = new RequestType('blob/createSas'); +} + +// ------------------------------- < Azure Blob > ------------------------------------ + +// ------------------------------- < Execution Plan > ------------------------------------ + +export interface GetExecutionPlanParams { + graphInfo: azdata.executionPlan.ExecutionPlanGraphInfo, +} + +export namespace GetExecutionPlanRequest { + export const type = new RequestType('queryExecutionPlan/getExecutionPlan'); +} + +export interface ExecutionPlanComparisonParams { + firstExecutionPlanGraphInfo: azdata.executionPlan.ExecutionPlanGraphInfo; + secondExecutionPlanGraphInfo: azdata.executionPlan.ExecutionPlanGraphInfo; +} + +export namespace ExecutionPlanComparisonRequest { + export const type = new RequestType('queryExecutionPlan/compareExecutionPlanGraph'); +} + +// ------------------------------- < Execution Plan > ------------------------------------ + +// ------------------------------- < Object Management > ------------------------------------ +export interface InitializeViewRequestParams { + connectionUri: string; + database: string; + contextId: string; + isNewObject: boolean; + objectType: string; + parentUrn: string; + objectUrn?: string; +} + +export namespace InitializeViewRequest { + export const type = new RequestType, void, void>('objectManagement/initializeView'); +} + +export interface SaveObjectRequestParams { + contextId: string; + object: mssql.ObjectManagement.SqlObject; +} + +export namespace SaveObjectRequest { + export const type = new RequestType('objectManagement/save'); +} + +export interface ScriptObjectRequestParams { + contextId: string; + object: mssql.ObjectManagement.SqlObject; +} + +export namespace ScriptObjectRequest { + export const type = new RequestType('objectManagement/script'); +} + +export interface DisposeViewRequestParams { + contextId: string; +} + +export namespace DisposeViewRequest { + export const type = new RequestType('objectManagement/disposeView'); +} + +export interface RenameObjectRequestParams { + connectionUri: string; + newName: string; + objectUrn: string; + objectType: mssql.ObjectManagement.NodeType; +} + +export namespace RenameObjectRequest { + export const type = new RequestType('objectManagement/rename'); +} + +export interface DropObjectRequestParams { + connectionUri: string; + objectUrn: string; + objectType: mssql.ObjectManagement.NodeType; +} + +export namespace DropObjectRequest { + export const type = new RequestType('objectManagement/drop'); +} + +export interface SearchObjectRequestParams { + contextId: string; + searchText: string | undefined; + schema: string | undefined; + objectTypes: mssql.ObjectManagement.NodeType[]; +} + +export namespace SearchObjectRequest { + export const type = new RequestType('objectManagement/search'); +} + +// ------------------------------- < Object Management > ------------------------------------ + +// ------------------------------- < Encryption IV/KEY updation Event > ------------------------------------ +/** + * Parameters for the MSAL cache encryption key notification + */ +export class DidChangeEncryptionIVKeyParams { + /** + * Buffer encoded IV string for MSAL cache encryption + */ + public iv: string; + /** + * Buffer encoded Key string for MSAL cache encryption + */ + public key: string; +} + +/** + * Notification sent when the encryption keys are changed. + */ +export namespace EncryptionKeysChangedNotification { + export const type = new NotificationType('connection/encryptionKeysChanged'); +} diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index b0d3c9f64342..6a64eb78149c 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -54,7 +54,7 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }).withItems(items).component(); } - protected registerTab(tab: azdata.window.DialogTab, items: azdata.Component[]): void { + protected registerTabContent(tab: azdata.window.DialogTab, items: azdata.Component[]): void { tab.registerContent(async view => { let formModel = this.modelView.modelBuilder.formContainer().withFormItems( [ From 09475f103c9a6199175cc690ffe4b2c94bdb51f1 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Fri, 9 Jun 2023 12:33:56 -0700 Subject: [PATCH 08/16] fetched scrollbar fix into this PR --- extensions/mssql/src/ui/dialogBase.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/extensions/mssql/src/ui/dialogBase.ts b/extensions/mssql/src/ui/dialogBase.ts index cc77775236d1..24636eb75557 100644 --- a/extensions/mssql/src/ui/dialogBase.ts +++ b/extensions/mssql/src/ui/dialogBase.ts @@ -167,17 +167,7 @@ export abstract class DialogBase { protected registerTabContent(tab: azdata.window.DialogTab, items: azdata.Component[]): void { tab.registerContent(async view => { - let formModel = this.modelView.modelBuilder.formContainer().withFormItems( - [ - { - component: this.modelView.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).withItems(items).component(), - title: '' - } - ], - { - horizontal: true - } - ).component(); + let formModel = this.createFormContainer(items); await view.initializeModel(formModel); }); } From cfbabdf583815b89f6df48712f199b2fe7202a4d Mon Sep 17 00:00:00 2001 From: ssreerama Date: Mon, 12 Jun 2023 20:35:45 -0700 Subject: [PATCH 09/16] Tabbed panel is being used for horizontal tabs --- .../src/objectManagement/ui/databaseDialog.ts | 28 +++++++++++-------- extensions/mssql/src/ui/dialogBase.ts | 7 ----- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 6a64eb78149c..de9fce9e6620 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -11,10 +11,10 @@ import { CreateDatabaseDocUrl, DatabasePropertiesDocUrl } from '../constants'; import { Database, DatabaseViewInfo } from '../interfaces'; export class DatabaseDialog extends ObjectManagementDialogBase { - // Horizontal Tabs - private generalTab: azdata.window.DialogTab; - private filesTab: azdata.window.DialogTab; + // Database Properties tabs + private generalTab: azdata.Tab; + //Database properties options private nameInput: azdata.InputBoxComponent; private backupSection: azdata.GroupContainer; private lastDatabaseBackupInput: azdata.InputBoxComponent; @@ -34,8 +34,11 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }).withItems(items).component(); } - protected registerTabContent(tab: azdata.window.DialogTab, items: azdata.Component[]): void { - tab.registerContent(async view => { - let formModel = this.createFormContainer(items); - await view.initializeModel(formModel); - }); - } - protected createTableList(ariaLabel: string, columnNames: string[], allItems: T[], From cd2feb5b3279b443004eca616a4b5735b30a9385 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Tue, 13 Jun 2023 08:04:00 -0700 Subject: [PATCH 10/16] stying fix for general tab button --- .../mssql/src/objectManagement/ui/databaseDialog.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index de9fce9e6620..ca9760079b05 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -64,7 +64,14 @@ export class DatabaseDialog extends ObjectManagementDialogBase Date: Tue, 13 Jun 2023 17:43:45 -0700 Subject: [PATCH 11/16] final commit for today :) --- extensions/mssql/package.json | 5 +++++ .../src/objectManagement/ui/databaseDialog.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index 8923e007eb58..600398d28fad 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -513,6 +513,11 @@ "group": "0_query@1", "isDefault": true }, + { + "command": "mssql.objectProperties", + "when": "connectionProvider == MSSQL && serverInfo && !isCloud && nodeType && nodeType =~ /^(Database|Server)$/ && mssql:engineedition != 11 && isDevelopment", + "group": "0_query@1" + }, { "command": "mssql.deleteObject", "when": "connectionProvider == MSSQL && nodeType =~ /^(ServerLevelLogin|User|ServerLevelServerRole|ApplicationRole|DatabaseRole|Database)$/ && config.workbench.enablePreviewFeatures", diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 33ee8cf75c26..c09ab5d7c3d2 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -47,14 +47,14 @@ export class DatabaseDialog extends ObjectManagementDialogBase { - if (this.options.isNewObject) { - let components = []; - components.push(this.initializeGeneralSection()); - components.push(this.initializeOptionsSection()); - if (this.viewInfo.isAzureDB) { - components.push(this.initializeConfigureSLOSection()); - } - this.formContainer.addItems(components); + if (this.options.isNewObject) { + let components = []; + components.push(this.initializeGeneralSection()); + components.push(this.initializeOptionsSection()); + if (this.viewInfo.isAzureDB) { + components.push(this.initializeConfigureSLOSection()); + } + this.formContainer.addItems(components); } else { // Initilaize general Tab sections this.initializeBackupSection(); From 552a35ee69cc4a75b759894e4faafdea8b637e20 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Wed, 14 Jun 2023 13:49:39 -0700 Subject: [PATCH 12/16] Updates according to STS changes --- extensions/mssql/src/objectManagement/interfaces.ts | 10 +++++----- .../mssql/src/objectManagement/ui/databaseDialog.ts | 11 ++++++----- extensions/mssql/src/objectManagement/utils.ts | 5 +++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/extensions/mssql/src/objectManagement/interfaces.ts b/extensions/mssql/src/objectManagement/interfaces.ts index 6581461470fe..eabb78239064 100644 --- a/extensions/mssql/src/objectManagement/interfaces.ts +++ b/extensions/mssql/src/objectManagement/interfaces.ts @@ -433,11 +433,11 @@ export interface Database extends ObjectManagement.SqlObject { dateCreated?: string; lastDatabaseBackup?: string; lastDatabaseLogBackup?: string; - memoryAllocatedToMemoryOptimizedObjectsInMb?: string; - memoryUsedByMemoryOptimizedObjectsInMb?: string; - numberOfUsers?: string; - sizeInMb?: string; - spaceAvailableInMb?: string; + memoryAllocatedToMemoryOptimizedObjectsInMb?: number; + memoryUsedByMemoryOptimizedObjectsInMb?: number; + numberOfUsers?: number; + sizeInMb?: number; + spaceAvailableInMb?: number; status?: string; azureBackupRedundancyLevel?: string; azureServiceLevelObjective?: string; diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index c09ab5d7c3d2..6aaa3b057d7e 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -9,6 +9,7 @@ import { IObjectManagementService } from 'mssql'; import * as localizedConstants from '../localizedConstants'; import { CreateDatabaseDocUrl, DatabasePropertiesDocUrl } from '../constants'; import { Database, DatabaseViewInfo } from '../interfaces'; +import { ConvertNumberToTwoDecimalString } from '../utils'; export class DatabaseDialog extends ObjectManagementDialogBase { // Database Properties tabs @@ -165,19 +166,19 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }, this.objectInfo.dateCreated, this.options.isNewObject); const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); - this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, this.objectInfo.sizeInMb, this.options.isNewObject); + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.sizeInMb), this.options.isNewObject); const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); - this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, this.objectInfo.spaceAvailableInMb, this.options.isNewObject); + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.spaceAvailableInMb), this.options.isNewObject); const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); - this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers, this.options.isNewObject); + this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers.toString(), this.options.isNewObject); const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); - this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb, this.options.isNewObject); + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb), this.options.isNewObject); const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); - this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb, this.options.isNewObject); + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb), this.options.isNewObject); const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ diff --git a/extensions/mssql/src/objectManagement/utils.ts b/extensions/mssql/src/objectManagement/utils.ts index 5dc721e0f114..0c6c201c5f31 100644 --- a/extensions/mssql/src/objectManagement/utils.ts +++ b/extensions/mssql/src/objectManagement/utils.ts @@ -42,3 +42,8 @@ export function isValidSQLPassword(password: string, userName: string = 'sa'): b const hasNonAlphas = /\W/.test(password) ? 1 : 0; return !containsUserName && password.length >= 8 && password.length <= 128 && (hasUpperCase + hasLowerCase + hasNumbers + hasNonAlphas >= 3); } + +// Converts number to two decimal placed string +export function ConvertNumberToTwoDecimalString(value: number) { + return value.toFixed(2).toString() + " MB"; +} From 1bbc647e79e93431efdb6e71c33febd654db0921 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Wed, 14 Jun 2023 13:51:18 -0700 Subject: [PATCH 13/16] missed updates --- .../src/objectManagement/objectManagementService.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index 214d6eacf7f8..a20a2ce5d2f6 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -444,12 +444,12 @@ export class TestObjectManagementService implements IObjectManagementService { dateCreated: '5/31/2023 8:05:55 AM', lastDatabaseBackup: 'None', lastDatabaseLogBackup: 'None', - memoryAllocatedToMemoryOptimizedObjectsInMb: '0.00 MB', - memoryUsedByMemoryOptimizedObjectsInMb: '0.00 MB', - numberOfUsers: '5', + memoryAllocatedToMemoryOptimizedObjectsInMb: 0, + memoryUsedByMemoryOptimizedObjectsInMb: 0, + numberOfUsers: 5, owner: 'databaseProperties 1', - sizeInMb: '16.00 MB', - spaceAvailableInMb: '1.15 MB', + sizeInMb: 16.00, + spaceAvailableInMb: 1.15, status: 'Normal' } }; From 7a112c75754aec376046d2f4f539f5976b4ca729 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Mon, 19 Jun 2023 09:59:43 -0700 Subject: [PATCH 14/16] Refactored updates --- .../objectManagement/localizedConstants.ts | 5 +-- .../objectManagementService.ts | 13 +++++++- .../src/objectManagement/ui/databaseDialog.ts | 33 +++++++++---------- .../mssql/src/objectManagement/utils.ts | 4 +-- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/extensions/mssql/src/objectManagement/localizedConstants.ts b/extensions/mssql/src/objectManagement/localizedConstants.ts index 8931e8694a8a..8e9af67585bb 100644 --- a/extensions/mssql/src/objectManagement/localizedConstants.ts +++ b/extensions/mssql/src/objectManagement/localizedConstants.ts @@ -221,10 +221,6 @@ export const ObjectSelectionMethodDialog_AllObjectsOfTypes = localize('objectMan export const ObjectSelectionMethodDialog_AllObjectsOfSchema = localize('objectManagement.ObjectSelectionMethodDialog_AllObjectsOfSchema', "All objects belonging to a schema"); export const ObjectSelectionMethodDialog_SelectSchemaDropdownLabel = localize('objectManagement.ObjectSelectionMethodDialog_SelectSchemaDropdownLabel', "Schema"); -// Object Properties Dialog -export const FilesHeaderText = localize('objectManagement.filesHeaderText', "Files"); -export const PropertiesCommandText = localize('objectManagement.propertiesCommandText', "Properties"); - //Database properties Dialog export const LastDatabaseBackupText = localize('objectManagement.lastDatabaseBackup', "Last Database Backup"); export const LastDatabaseLogBackupText = localize('objectManagement.lastDatabaseLogBackup', "Last Database Log Backup"); @@ -240,6 +236,7 @@ export const SpaceAvailableText = localize('objectManagement.databaseProperties. export const NumberOfUsersText = localize('objectManagement.databaseProperties.numberOfUsers', "Number of Users"); export const MemoryAllocatedText = localize('objectManagement.databaseProperties.memoryAllocated', "Memory Allocated To Memory Optimized Objects"); export const MemoryUsedText = localize('objectManagement.databaseProperties.memoryUsed', "Memory Used By Memory Optimized Objects"); +export const StringValueInMB = (value: string) => localize('objectManagement.databaseProperties.mbUnitText', "{0} MB", value); // Util functions export function getNodeTypeDisplayName(type: string, inTitle: boolean = false): string { diff --git a/extensions/mssql/src/objectManagement/objectManagementService.ts b/extensions/mssql/src/objectManagement/objectManagementService.ts index a20a2ce5d2f6..b08970010b6c 100644 --- a/extensions/mssql/src/objectManagement/objectManagementService.ts +++ b/extensions/mssql/src/objectManagement/objectManagementService.ts @@ -436,7 +436,18 @@ export class TestObjectManagementService implements IObjectManagementService { private getDatabaseView(isNewObject: boolean, name: string): DatabaseViewInfo { return isNewObject ? { - + objectInfo: { + name: 'New Database Name', + owner: '', + collationName: '', + compatibilityLevel: '', + containmentType: '', + recoveryModel: '', + azureEdition: '', + azureMaxSize: '', + azureBackupRedundancyLevel: '', + azureServiceLevelObjective: '' + } } : { objectInfo: { name: 'Database Properties1', diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 6aaa3b057d7e..ff08d180b9ae 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -9,7 +9,7 @@ import { IObjectManagementService } from 'mssql'; import * as localizedConstants from '../localizedConstants'; import { CreateDatabaseDocUrl, DatabasePropertiesDocUrl } from '../constants'; import { Database, DatabaseViewInfo } from '../interfaces'; -import { ConvertNumberToTwoDecimalString } from '../utils'; +import { convertNumToTwoDecimalStringinMB } from '../utils'; export class DatabaseDialog extends ObjectManagementDialogBase { // Database Properties tabs @@ -34,13 +34,6 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }, this.objectInfo.dateCreated, this.options.isNewObject); const dateCreatedContainer = this.createLabelInputContainer(localizedConstants.DateCreatedText, this.dateCreatedInput); - this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.sizeInMb), this.options.isNewObject); + this.sizeInput = this.createInputBox(localizedConstants.SizeText, async () => { }, convertNumToTwoDecimalStringinMB(this.objectInfo.sizeInMb), this.options.isNewObject); const sizeContainer = this.createLabelInputContainer(localizedConstants.SizeText, this.sizeInput); - this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.spaceAvailableInMb), this.options.isNewObject); + this.spaceAvailabeInput = this.createInputBox(localizedConstants.SpaceAvailableText, async () => { }, convertNumToTwoDecimalStringinMB(this.objectInfo.spaceAvailableInMb), this.options.isNewObject); const spaceAvailabeContainer = this.createLabelInputContainer(localizedConstants.SpaceAvailableText, this.spaceAvailabeInput); this.numberOfUsersInput = this.createInputBox(localizedConstants.NumberOfUsersText, async () => { }, this.objectInfo.numberOfUsers.toString(), this.options.isNewObject); const numberOfUsersContainer = this.createLabelInputContainer(localizedConstants.NumberOfUsersText, this.numberOfUsersInput); - this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb), this.options.isNewObject); + this.memoryAllocatedInput = this.createInputBox(localizedConstants.MemoryAllocatedText, async () => { }, convertNumToTwoDecimalStringinMB(this.objectInfo.memoryAllocatedToMemoryOptimizedObjectsInMb), this.options.isNewObject); const memoryAllocatedContainer = this.createLabelInputContainer(localizedConstants.MemoryAllocatedText, this.memoryAllocatedInput); - this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, ConvertNumberToTwoDecimalString(this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb), this.options.isNewObject); + this.memoryUsedInput = this.createInputBox(localizedConstants.MemoryUsedText, async () => { }, convertNumToTwoDecimalStringinMB(this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb), this.options.isNewObject); const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ diff --git a/extensions/mssql/src/objectManagement/utils.ts b/extensions/mssql/src/objectManagement/utils.ts index 0c6c201c5f31..893713e48e75 100644 --- a/extensions/mssql/src/objectManagement/utils.ts +++ b/extensions/mssql/src/objectManagement/utils.ts @@ -44,6 +44,6 @@ export function isValidSQLPassword(password: string, userName: string = 'sa'): b } // Converts number to two decimal placed string -export function ConvertNumberToTwoDecimalString(value: number) { - return value.toFixed(2).toString() + " MB"; +export function convertNumToTwoDecimalStringinMB(value: number): string { + return localizedConstants.StringValueInMB(value.toFixed(2)); } From 9465829e598c1d929fe08c6ee44e583ff9d0cc69 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Tue, 20 Jun 2023 16:27:06 -0700 Subject: [PATCH 15/16] moved options as discussed and added collapsible sections... need to fix scroll bar --- .../src/objectManagement/ui/databaseDialog.ts | 20 +++++++------------ .../mssql/src/objectManagement/utils.ts | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 81dfaaae2ea8..0256a0f9371e 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -29,7 +29,6 @@ export class DatabaseDialog extends ObjectManagementDialogBase { }, convertNumToTwoDecimalStringinMB(this.objectInfo.memoryUsedByMemoryOptimizedObjectsInMb), this.options.isNewObject); const memoryUsedContainer = this.createLabelInputContainer(localizedConstants.MemoryUsedText, this.memoryUsedInput); + this.collationInput = this.createInputBox(localizedConstants.CollationText, async () => { }, this.objectInfo.collationName, this.options.isNewObject); + const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); + this.databaseSection = this.createGroup(localizedConstants.DatabaseSectionHeader, [ nameContainer, statusContainer, ownerContainer, + collationContainer, dateCreatedContainer, sizeContainer, spaceAvailabeContainer, numberOfUsersContainer, memoryAllocatedContainer, memoryUsedContainer - ], false); - } - - private initializeMaintenanceSection(): void { - this.collationInput = this.createInputBox(localizedConstants.CollationText, async () => { }, this.objectInfo.collationName, this.options.isNewObject); - const collationContainer = this.createLabelInputContainer(localizedConstants.CollationText, this.collationInput); - - this.maintenanceSection = this.createGroup(localizedConstants.MaintenanceSectionHeader, [collationContainer], false); + ], true); } //#endregion diff --git a/extensions/mssql/src/objectManagement/utils.ts b/extensions/mssql/src/objectManagement/utils.ts index 893713e48e75..9d509f11f503 100644 --- a/extensions/mssql/src/objectManagement/utils.ts +++ b/extensions/mssql/src/objectManagement/utils.ts @@ -45,5 +45,5 @@ export function isValidSQLPassword(password: string, userName: string = 'sa'): b // Converts number to two decimal placed string export function convertNumToTwoDecimalStringinMB(value: number): string { - return localizedConstants.StringValueInMB(value.toFixed(2)); + return localizedConstants.StringValueInMB(value?.toFixed(2)); } From 03217e693742fe1ff808aae03a6b3b0ea7eb0a52 Mon Sep 17 00:00:00 2001 From: ssreerama Date: Wed, 21 Jun 2023 10:13:39 -0700 Subject: [PATCH 16/16] Fixing the horizontal scroll bar of tabbedpanel --- extensions/mssql/src/objectManagement/localizedConstants.ts | 1 - extensions/mssql/src/objectManagement/ui/databaseDialog.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/mssql/src/objectManagement/localizedConstants.ts b/extensions/mssql/src/objectManagement/localizedConstants.ts index c0da4bcb5da6..4d17a00dcb20 100644 --- a/extensions/mssql/src/objectManagement/localizedConstants.ts +++ b/extensions/mssql/src/objectManagement/localizedConstants.ts @@ -227,7 +227,6 @@ export const LastDatabaseBackupText = localize('objectManagement.lastDatabaseBac export const LastDatabaseLogBackupText = localize('objectManagement.lastDatabaseLogBackup', "Last Database Log Backup"); export const BackupSectionHeader = localize('objectManagement.databaseProperties.backupSectionHeader', "Backup"); export const DatabaseSectionHeader = localize('objectManagement.databaseProperties.databaseSectionHeader', "Database"); -export const MaintenanceSectionHeader = localize('objectManagement.databaseProperties.maintenanceSectionHeader', "Maintenance"); export const NamePropertyText = localize('objectManagement.databaseProperties.name', "Name"); export const StatusText = localize('objectManagement.databaseProperties.status', "Status"); export const OwnerPropertyText = localize('objectManagement.databaseProperties.owner', "Owner"); diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 0256a0f9371e..86a7b6cab708 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -69,7 +69,7 @@ export class DatabaseDialog extends ObjectManagementDialogBase