diff --git a/extensions/mssql/config.json b/extensions/mssql/config.json index e3aa081b31..b13c01fb40 100644 --- a/extensions/mssql/config.json +++ b/extensions/mssql/config.json @@ -1,6 +1,6 @@ { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "4.3.0.15", + "version": "4.3.0.18", "downloadFileNames": { "Windows_86": "win-x86-net6.0.zip", "Windows_64": "win-x64-net6.0.zip", diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 8d18cb9c90..bd80c4a8e2 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -817,6 +817,7 @@ declare module 'azdata' { ForeignKeys = 'foreignKeys', CheckConstraints = 'checkConstraints', Indexes = 'indexes', + PrimaryKey = 'primaryKey', PrimaryKeyName = 'primaryKeyName', PrimaryKeyDescription = 'primaryKeyDescription', PrimaryKeyColumns = 'primaryKeyColumns' @@ -944,6 +945,10 @@ declare module 'azdata' { * Additional primary key properties. Common primary key properties: primaryKeyName, primaryKeyDescription. */ additionalPrimaryKeyProperties?: DesignerDataPropertyInfo[]; + /** + * Components to be placed under the pre-defined tabs. + */ + additionalComponents?: DesignerDataPropertyWithTabInfo[]; /** * Whether to use advanced save mode. for advanced save mode, a publish changes dialog will be opened with preview of changes. */ @@ -1016,6 +1021,16 @@ declare module 'azdata' { componentProperties: InputBoxProperties | CheckBoxProperties | DropDownProperties | DesignerTableProperties; } + /** + * The definition of the property in the designer with tab info. + */ + export interface DesignerDataPropertyWithTabInfo extends DesignerDataPropertyInfo { + /** + * The tab info where this property belongs to. + */ + tab: TableProperty.Columns | TableProperty.PrimaryKey | TableProperty.ForeignKeys | TableProperty.CheckConstraints | TableProperty.Indexes; + } + /** * The child component types supported by designer. */ diff --git a/src/sql/workbench/api/common/sqlExtHostTypes.ts b/src/sql/workbench/api/common/sqlExtHostTypes.ts index 469d08cf29..fa8e84a650 100644 --- a/src/sql/workbench/api/common/sqlExtHostTypes.ts +++ b/src/sql/workbench/api/common/sqlExtHostTypes.ts @@ -972,6 +972,7 @@ export namespace designers { ForeignKeys = 'foreignKeys', CheckConstraints = 'checkConstraints', Indexes = 'indexes', + PrimaryKey = 'primaryKey', PrimaryKeyName = 'primaryKeyName', PrimaryKeyDescription = 'primaryKeyDescription', PrimaryKeyColumns = 'primaryKeyColumns' diff --git a/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts b/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts index e80b028387..163bd5d884 100644 --- a/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts +++ b/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts @@ -327,21 +327,21 @@ export class TableDesignerComponentInput implements DesignerComponentInput { const tabs = []; if (tableDesignerView.columnTableOptions?.showTable) { - tabs.push(this.getColumnsTab(tableDesignerView.columnTableOptions)); + tabs.push(this.getColumnsTab(tableDesignerView.columnTableOptions, tableDesignerView.additionalComponents)); } - tabs.push(this.getPrimaryKeyTab(tableDesignerView)); + tabs.push(this.getPrimaryKeyTab(tableDesignerView, tableDesignerView.additionalComponents)); if (tableDesignerView.foreignKeyTableOptions?.showTable) { - tabs.push(this.getForeignKeysTab(tableDesignerView.foreignKeyTableOptions, tableDesignerView.foreignKeyColumnMappingTableOptions)); + tabs.push(this.getForeignKeysTab(tableDesignerView.foreignKeyTableOptions, tableDesignerView.foreignKeyColumnMappingTableOptions, tableDesignerView.additionalComponents)); } if (tableDesignerView.checkConstraintTableOptions?.showTable) { - tabs.push(this.getCheckConstraintsTab(tableDesignerView.checkConstraintTableOptions)); + tabs.push(this.getCheckConstraintsTab(tableDesignerView.checkConstraintTableOptions, tableDesignerView.additionalComponents)); } if (tableDesignerView.indexTableOptions?.showTable) { - tabs.push(this.getIndexesTab(tableDesignerView.indexTableOptions, tableDesignerView.indexColumnSpecificationTableOptions)); + tabs.push(this.getIndexesTab(tableDesignerView.indexTableOptions, tableDesignerView.indexColumnSpecificationTableOptions, tableDesignerView.additionalComponents)); } if (tableDesignerView.additionalTabs) { @@ -393,7 +393,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { }; } - private getColumnsTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions): DesignerTab { + private getColumnsTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, additionalComponents: azdata.designers.DesignerDataPropertyWithTabInfo[]): DesignerTab { const columnProperties: DesignerDataPropertyInfo[] = [ { @@ -488,7 +488,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { designers.TableColumnProperty.DefaultValue, ]); - return { + const tab = { title: localize('tableDesigner.columnsTabTitle', "Columns"), components: [ { @@ -511,9 +511,11 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ] }; + this.appendAdditionalComponents(tab, additionalComponents, designers.TableProperty.Columns); + return tab; } - private getForeignKeysTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, columnMappingTableOptions: azdata.designers.TableDesignerBuiltInTableViewOptions): DesignerTab { + private getForeignKeysTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, columnMappingTableOptions: azdata.designers.TableDesignerBuiltInTableViewOptions, additionalComponents: azdata.designers.DesignerDataPropertyWithTabInfo[]): DesignerTab { const foreignKeyColumnMappingProperties: DesignerDataPropertyInfo[] = [ { @@ -596,7 +598,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ]; - return { + const tab = { title: localize('tableDesigner.foreignKeysTabTitle', "Foreign Keys"), components: [ { @@ -617,9 +619,11 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ] }; + this.appendAdditionalComponents(tab, additionalComponents, designers.TableProperty.ForeignKeys); + return tab; } - private getPrimaryKeyTab(view: azdata.designers.TableDesignerView): DesignerTab { + private getPrimaryKeyTab(view: azdata.designers.TableDesignerView, additionalComponents: azdata.designers.DesignerDataPropertyWithTabInfo[]): DesignerTab { const options = view.primaryKeyColumnSpecificationTableOptions; const columnSpecProperties: DesignerDataPropertyInfo[] = [ { @@ -678,13 +682,15 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } }); - return { + const tab = { title: localize('tableDesigner.PrimaryKeyTabTitle', "Primary Key"), components: tabComponents }; + this.appendAdditionalComponents(tab, additionalComponents, designers.TableProperty.PrimaryKey); + return tab; } - private getCheckConstraintsTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions): DesignerTab { + private getCheckConstraintsTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, additionalComponents: azdata.designers.DesignerDataPropertyWithTabInfo[]): DesignerTab { const checkConstraintProperties: DesignerDataPropertyInfo[] = [ { componentType: 'input', @@ -712,7 +718,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ]; - return { + const tab = { title: localize('tableDesigner.checkConstraintsTabTitle', "Check Constraints"), components: [ { @@ -733,9 +739,11 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ] }; + this.appendAdditionalComponents(tab, additionalComponents, designers.TableProperty.CheckConstraints); + return tab; } - private getIndexesTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, columnSpecTableOptions: azdata.designers.TableDesignerBuiltInTableViewOptions): DesignerTab { + private getIndexesTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, columnSpecTableOptions: azdata.designers.TableDesignerBuiltInTableViewOptions, additionalComponents: azdata.designers.DesignerDataPropertyWithTabInfo[]): DesignerTab { const columnSpecProperties: DesignerDataPropertyInfo[] = [ { componentType: 'dropdown', @@ -782,7 +790,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ]; - return { + const tab = { title: localize('tableDesigner.indexesTabTitle', "Indexes"), components: [ { @@ -803,6 +811,22 @@ export class TableDesignerComponentInput implements DesignerComponentInput { } ] }; + this.appendAdditionalComponents(tab, additionalComponents, designers.TableProperty.Indexes); + return tab; + } + + private appendAdditionalComponents(tab: DesignerTab, components: azdata.designers.DesignerDataPropertyWithTabInfo[], tabInfo: designers.TableProperty.Columns | designers.TableProperty.PrimaryKey | designers.TableProperty.ForeignKeys | designers.TableProperty.CheckConstraints | designers.TableProperty.Indexes) { + const additionalTables = this.getAdditionalComponentsForTab(components, tabInfo); + if (additionalTables) { + tab.components.push(...additionalTables); + } + } + + private getAdditionalComponentsForTab(components: azdata.designers.DesignerDataPropertyWithTabInfo[], tab: designers.TableProperty.Columns | designers.TableProperty.PrimaryKey | designers.TableProperty.ForeignKeys | designers.TableProperty.CheckConstraints | designers.TableProperty.Indexes): azdata.designers.DesignerDataPropertyInfo[] { + if (components) { + return components.filter(c => c.tab === tab); + } + return []; } private getTableDisplayProperties(options: azdata.designers.TableDesignerBuiltInTableViewOptions, defaultProperties: string[]): string[] {