mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
td support indexes (#18121)
* support indexes * add pending action warning * vbump STS
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||||
"version": "3.0.0-release.182",
|
"version": "3.0.0-release.184",
|
||||||
"downloadFileNames": {
|
"downloadFileNames": {
|
||||||
"Windows_86": "win-x86-net6.0.zip",
|
"Windows_86": "win-x86-net6.0.zip",
|
||||||
"Windows_64": "win-x64-net6.0.zip",
|
"Windows_64": "win-x64-net6.0.zip",
|
||||||
|
|||||||
30
src/sql/azdata.proposed.d.ts
vendored
30
src/sql/azdata.proposed.d.ts
vendored
@@ -1134,6 +1134,7 @@ declare module 'azdata' {
|
|||||||
Script = 'script',
|
Script = 'script',
|
||||||
ForeignKeys = 'foreignKeys',
|
ForeignKeys = 'foreignKeys',
|
||||||
CheckConstraints = 'checkConstraints',
|
CheckConstraints = 'checkConstraints',
|
||||||
|
Indexes = 'indexes'
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Name of the common table column properties.
|
* Name of the common table column properties.
|
||||||
@@ -1179,6 +1180,22 @@ declare module 'azdata' {
|
|||||||
Expression = 'expression'
|
Expression = 'expression'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the common index properties.
|
||||||
|
* Extensions can use the name to access the designer view model.
|
||||||
|
*/
|
||||||
|
export enum TableIndexProperty {
|
||||||
|
Name = 'name',
|
||||||
|
Columns = 'columns'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the common properties of table index column specification.
|
||||||
|
*/
|
||||||
|
export enum TableIndexColumnSpecificationProperty {
|
||||||
|
Column = 'column'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table designer view definition.
|
* The table designer view definition.
|
||||||
*/
|
*/
|
||||||
@@ -1209,6 +1226,19 @@ declare module 'azdata' {
|
|||||||
* Default columns to display values are: Name, Expression.
|
* Default columns to display values are: Name, Expression.
|
||||||
*/
|
*/
|
||||||
checkConstraintTableOptions?: TableDesignerBuiltInTableViewOptions;
|
checkConstraintTableOptions?: TableDesignerBuiltInTableViewOptions;
|
||||||
|
/**
|
||||||
|
* Indexes table options.
|
||||||
|
* Common index properties are handled by Azure Data Studio. see {@link TableIndexProperty}
|
||||||
|
* Default columns to display values are: Name.
|
||||||
|
*/
|
||||||
|
indexTableOptions?: TableDesignerBuiltInTableViewOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index column specification table options.
|
||||||
|
* Common index properties are handled by Azure Data Studio. see {@link TableIndexColumnSpecificationProperty}
|
||||||
|
* Default columns to display values are: Column.
|
||||||
|
*/
|
||||||
|
indexColumnSpecificationTableOptions?: TableDesignerBuiltInTableViewOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TableDesignerBuiltInTableViewOptions {
|
export interface TableDesignerBuiltInTableViewOptions {
|
||||||
|
|||||||
@@ -575,6 +575,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
TableForeignKeyProperty: sqlExtHostTypes.designers.TableForeignKeyProperty,
|
TableForeignKeyProperty: sqlExtHostTypes.designers.TableForeignKeyProperty,
|
||||||
ForeignKeyColumnMappingProperty: sqlExtHostTypes.designers.ForeignKeyColumnMappingProperty,
|
ForeignKeyColumnMappingProperty: sqlExtHostTypes.designers.ForeignKeyColumnMappingProperty,
|
||||||
TableCheckConstraintProperty: sqlExtHostTypes.designers.TableCheckConstraintProperty,
|
TableCheckConstraintProperty: sqlExtHostTypes.designers.TableCheckConstraintProperty,
|
||||||
|
TableIndexProperty: sqlExtHostTypes.designers.TableIndexProperty,
|
||||||
|
TableIndexColumnSpecificationProperty: sqlExtHostTypes.designers.TableIndexColumnSpecificationProperty,
|
||||||
DesignerEditType: sqlExtHostTypes.designers.DesignerEditType,
|
DesignerEditType: sqlExtHostTypes.designers.DesignerEditType,
|
||||||
openTableDesigner(providerId, tableInfo: azdata.designers.TableInfo): Promise<void> {
|
openTableDesigner(providerId, tableInfo: azdata.designers.TableInfo): Promise<void> {
|
||||||
return extHostDataProvider.$openTableDesigner(providerId, tableInfo);
|
return extHostDataProvider.$openTableDesigner(providerId, tableInfo);
|
||||||
|
|||||||
@@ -953,6 +953,7 @@ export namespace designers {
|
|||||||
Script = 'script',
|
Script = 'script',
|
||||||
ForeignKeys = 'foreignKeys',
|
ForeignKeys = 'foreignKeys',
|
||||||
CheckConstraints = 'checkConstraints',
|
CheckConstraints = 'checkConstraints',
|
||||||
|
Indexes = 'indexes'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TableColumnProperty {
|
export enum TableColumnProperty {
|
||||||
@@ -984,6 +985,15 @@ export namespace designers {
|
|||||||
Expression = 'expression'
|
Expression = 'expression'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TableIndexProperty {
|
||||||
|
Name = 'name',
|
||||||
|
Columns = 'columns'
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TableIndexColumnSpecificationProperty {
|
||||||
|
Column = 'column'
|
||||||
|
}
|
||||||
|
|
||||||
export enum DesignerEditType {
|
export enum DesignerEditType {
|
||||||
Add = 0,
|
Add = 0,
|
||||||
Remove = 1,
|
Remove = 1,
|
||||||
|
|||||||
@@ -639,7 +639,7 @@ export class Designer extends Disposable implements IThemable {
|
|||||||
autoEdit: true,
|
autoEdit: true,
|
||||||
dataItemColumnValueExtractor: (data: any, column: Slick.Column<Slick.SlickData>): string => {
|
dataItemColumnValueExtractor: (data: any, column: Slick.Column<Slick.SlickData>): string => {
|
||||||
if (column.field) {
|
if (column.field) {
|
||||||
return data[column.field].value;
|
return data[column.field]?.value;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
import { Schemas } from 'sql/base/common/schemas';
|
import { Schemas } from 'sql/base/common/schemas';
|
||||||
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
|
|
||||||
const NewTable: string = localize('tableDesigner.newTable', "New Table");
|
const NewTable: string = localize('tableDesigner.newTable', "New Table");
|
||||||
|
|
||||||
@@ -27,7 +28,8 @@ export class TableDesignerInput extends EditorInput {
|
|||||||
private _provider: TableDesignerProvider,
|
private _provider: TableDesignerProvider,
|
||||||
private _tableInfo: azdata.designers.TableInfo,
|
private _tableInfo: azdata.designers.TableInfo,
|
||||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
@IEditorService editorService: IEditorService) {
|
@IEditorService editorService: IEditorService,
|
||||||
|
@INotificationService private readonly _notificationService: INotificationService) {
|
||||||
super();
|
super();
|
||||||
this._designerComponentInput = this._instantiationService.createInstance(TableDesignerComponentInput, this._provider, this._tableInfo);
|
this._designerComponentInput = this._instantiationService.createInstance(TableDesignerComponentInput, this._provider, this._tableInfo);
|
||||||
this._register(this._designerComponentInput.onStateChange((e) => {
|
this._register(this._designerComponentInput.onStateChange((e) => {
|
||||||
@@ -81,7 +83,11 @@ export class TableDesignerInput extends EditorInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async save(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
override async save(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||||
await this._designerComponentInput.openPublishDialog();
|
if (this._designerComponentInput.pendingAction) {
|
||||||
|
this._notificationService.warn(localize('tableDesigner.OperationInProgressWarning', "The operation cannot be performed while another operation is in progress."));
|
||||||
|
} else {
|
||||||
|
await this._designerComponentInput.openPublishDialog();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
tabs.push(this.getCheckConstraintsTab(designerInfo.view.checkConstraintTableOptions));
|
tabs.push(this.getCheckConstraintsTab(designerInfo.view.checkConstraintTableOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (designerInfo.view.indexTableOptions?.showTable) {
|
||||||
|
tabs.push(this.getIndexesTab(designerInfo.view.indexTableOptions, designerInfo.view.indexColumnSpecificationTableOptions));
|
||||||
|
}
|
||||||
|
|
||||||
if (designerInfo.view.additionalTabs) {
|
if (designerInfo.view.additionalTabs) {
|
||||||
tabs.push(...designerInfo.view.additionalTabs);
|
tabs.push(...designerInfo.view.additionalTabs);
|
||||||
}
|
}
|
||||||
@@ -331,11 +335,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (options.additionalProperties) {
|
const displayProperties = this.getTableDisplayProperties(options, [
|
||||||
columnProperties.push(...options.additionalProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
const displayProperties = options.propertiesToDisplay?.length > 0 ? options.propertiesToDisplay : [
|
|
||||||
designers.TableColumnProperty.Name,
|
designers.TableColumnProperty.Name,
|
||||||
designers.TableColumnProperty.Type,
|
designers.TableColumnProperty.Type,
|
||||||
designers.TableColumnProperty.Length,
|
designers.TableColumnProperty.Length,
|
||||||
@@ -344,7 +344,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
designers.TableColumnProperty.IsPrimaryKey,
|
designers.TableColumnProperty.IsPrimaryKey,
|
||||||
designers.TableColumnProperty.AllowNulls,
|
designers.TableColumnProperty.AllowNulls,
|
||||||
designers.TableColumnProperty.DefaultValue,
|
designers.TableColumnProperty.DefaultValue,
|
||||||
];
|
]);
|
||||||
|
|
||||||
return <DesignerTab>{
|
return <DesignerTab>{
|
||||||
title: localize('tableDesigner.columnsTabTitle', "Columns"),
|
title: localize('tableDesigner.columnsTabTitle', "Columns"),
|
||||||
@@ -356,7 +356,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
componentProperties: <DesignerTableProperties>{
|
componentProperties: <DesignerTableProperties>{
|
||||||
ariaLabel: localize('tableDesigner.columnsTabTitle', "Columns"),
|
ariaLabel: localize('tableDesigner.columnsTabTitle', "Columns"),
|
||||||
columns: displayProperties,
|
columns: displayProperties,
|
||||||
itemProperties: columnProperties,
|
itemProperties: this.addAdditionalTableProperties(options, columnProperties),
|
||||||
objectTypeDisplayName: localize('tableDesigner.columnTypeName', "Column"),
|
objectTypeDisplayName: localize('tableDesigner.columnTypeName', "Column"),
|
||||||
canAddRows: options.canAddRows,
|
canAddRows: options.canAddRows,
|
||||||
canRemoveRows: options.canRemoveRows
|
canRemoveRows: options.canRemoveRows
|
||||||
@@ -437,16 +437,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
canAddRows: options.canAddRows,
|
canAddRows: options.canAddRows,
|
||||||
canRemoveRows: options.canRemoveRows
|
canRemoveRows: options.canRemoveRows
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
|
||||||
|
|
||||||
if (options.additionalProperties) {
|
|
||||||
foreignKeyProperties.push(...options.additionalProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
const displayProperties = options.propertiesToDisplay?.length > 0 ? options.propertiesToDisplay : [
|
|
||||||
designers.TableForeignKeyProperty.Name,
|
|
||||||
designers.TableForeignKeyProperty.PrimaryKeyTable
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return <DesignerTab>{
|
return <DesignerTab>{
|
||||||
@@ -458,8 +449,8 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
showInPropertiesView: false,
|
showInPropertiesView: false,
|
||||||
componentProperties: <DesignerTableProperties>{
|
componentProperties: <DesignerTableProperties>{
|
||||||
ariaLabel: localize('tableDesigner.foreignKeysTabTitle', "Foreign Keys"),
|
ariaLabel: localize('tableDesigner.foreignKeysTabTitle', "Foreign Keys"),
|
||||||
columns: displayProperties,
|
columns: this.getTableDisplayProperties(options, [designers.TableForeignKeyProperty.Name, designers.TableForeignKeyProperty.PrimaryKeyTable]),
|
||||||
itemProperties: foreignKeyProperties,
|
itemProperties: this.addAdditionalTableProperties(options, foreignKeyProperties),
|
||||||
objectTypeDisplayName: localize('tableDesigner.ForeignKeyTypeName', "Foreign Key"),
|
objectTypeDisplayName: localize('tableDesigner.ForeignKeyTypeName', "Foreign Key"),
|
||||||
canAddRows: options.canAddRows,
|
canAddRows: options.canAddRows,
|
||||||
canRemoveRows: options.canRemoveRows
|
canRemoveRows: options.canRemoveRows
|
||||||
@@ -490,12 +481,6 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (options.additionalProperties) {
|
|
||||||
checkConstraintProperties.push(...options.additionalProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
const displayProperties = options.propertiesToDisplay?.length > 0 ? options.propertiesToDisplay : [designers.TableCheckConstraintProperty.Name, designers.TableCheckConstraintProperty.Expression];
|
|
||||||
|
|
||||||
return <DesignerTab>{
|
return <DesignerTab>{
|
||||||
title: localize('tableDesigner.checkConstraintsTabTitle', "Check Constraints"),
|
title: localize('tableDesigner.checkConstraintsTabTitle', "Check Constraints"),
|
||||||
components: [
|
components: [
|
||||||
@@ -505,8 +490,8 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
showInPropertiesView: false,
|
showInPropertiesView: false,
|
||||||
componentProperties: <DesignerTableProperties>{
|
componentProperties: <DesignerTableProperties>{
|
||||||
ariaLabel: localize('tableDesigner.checkConstraintsTabTitle', "Check Constraints"),
|
ariaLabel: localize('tableDesigner.checkConstraintsTabTitle', "Check Constraints"),
|
||||||
columns: displayProperties,
|
columns: this.getTableDisplayProperties(options, [designers.TableCheckConstraintProperty.Name, designers.TableCheckConstraintProperty.Expression]),
|
||||||
itemProperties: checkConstraintProperties,
|
itemProperties: this.addAdditionalTableProperties(options, checkConstraintProperties),
|
||||||
objectTypeDisplayName: localize('tableDesigner.checkConstraintTypeName', "Check Constraint"),
|
objectTypeDisplayName: localize('tableDesigner.checkConstraintTypeName', "Check Constraint"),
|
||||||
canAddRows: options.canAddRows,
|
canAddRows: options.canAddRows,
|
||||||
canRemoveRows: options.canRemoveRows
|
canRemoveRows: options.canRemoveRows
|
||||||
@@ -515,6 +500,74 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getIndexesTab(options: azdata.designers.TableDesignerBuiltInTableViewOptions, columnSpecTableOptions: azdata.designers.TableDesignerBuiltInTableViewOptions): DesignerTab {
|
||||||
|
const columnSpecProperties: DesignerDataPropertyInfo[] = [
|
||||||
|
{
|
||||||
|
componentType: 'dropdown',
|
||||||
|
propertyName: designers.TableIndexColumnSpecificationProperty.Column,
|
||||||
|
description: localize('designer.index.column.description.name', "The name of the column."),
|
||||||
|
componentProperties: {
|
||||||
|
title: localize('tableDesigner.index.column.name', "Column"),
|
||||||
|
width: 100
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
const indexProperties: DesignerDataPropertyInfo[] = [
|
||||||
|
{
|
||||||
|
componentType: 'input',
|
||||||
|
propertyName: designers.TableIndexProperty.Name,
|
||||||
|
description: localize('designer.index.description.name', "The name of the index."),
|
||||||
|
componentProperties: {
|
||||||
|
title: localize('tableDesigner.indexName', "Name"),
|
||||||
|
width: 200
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
componentType: 'table',
|
||||||
|
propertyName: designers.TableIndexProperty.Columns,
|
||||||
|
description: localize('designer.index.description.columns', "The columns of the index."),
|
||||||
|
group: localize('tableDesigner.indexColumns', "Columns"),
|
||||||
|
componentProperties: <DesignerTableProperties>{
|
||||||
|
ariaLabel: localize('tableDesigner.indexColumns', "Columns"),
|
||||||
|
columns: this.getTableDisplayProperties(columnSpecTableOptions, [designers.TableIndexColumnSpecificationProperty.Column]),
|
||||||
|
itemProperties: this.addAdditionalTableProperties(columnSpecTableOptions, columnSpecProperties),
|
||||||
|
objectTypeDisplayName: '',
|
||||||
|
canAddRows: columnSpecTableOptions.canAddRows,
|
||||||
|
canRemoveRows: columnSpecTableOptions.canRemoveRows
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return <DesignerTab>{
|
||||||
|
title: localize('tableDesigner.indexesTabTitle', "Indexes"),
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
componentType: 'table',
|
||||||
|
propertyName: designers.TableProperty.Indexes,
|
||||||
|
showInPropertiesView: false,
|
||||||
|
componentProperties: <DesignerTableProperties>{
|
||||||
|
ariaLabel: localize('tableDesigner.indexesTabTitle', "Indexes"),
|
||||||
|
columns: this.getTableDisplayProperties(options, [designers.TableIndexProperty.Name]),
|
||||||
|
itemProperties: this.addAdditionalTableProperties(options, indexProperties),
|
||||||
|
objectTypeDisplayName: localize('tableDesigner.IndexTypeName', "Index"),
|
||||||
|
canAddRows: options.canAddRows,
|
||||||
|
canRemoveRows: options.canRemoveRows
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private getTableDisplayProperties(options: azdata.designers.TableDesignerBuiltInTableViewOptions, defaultProperties: string[]): string[] {
|
||||||
|
return options.propertiesToDisplay?.length > 0 ? options.propertiesToDisplay : defaultProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addAdditionalTableProperties(options: azdata.designers.TableDesignerBuiltInTableViewOptions, properties: DesignerDataPropertyInfo[]): DesignerDataPropertyInfo[] {
|
||||||
|
if (options.additionalProperties) {
|
||||||
|
properties.push(...options.additionalProperties);
|
||||||
|
}
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
private setDefaultData(): void {
|
private setDefaultData(): void {
|
||||||
const properties = Object.keys(this._viewModel);
|
const properties = Object.keys(this._viewModel);
|
||||||
this.setDefaultInputData(properties, designers.TableProperty.Name);
|
this.setDefaultInputData(properties, designers.TableProperty.Name);
|
||||||
|
|||||||
Reference in New Issue
Block a user