enable table designer for table script in sql database project (#19237)

* add 'open in designer' to context menu of tables in sql projects

* fix tests

* Address comments

* enable table designer for sql database proj

* update label and issues on init

* vbump sts

* use promisified fs

* pr comments

Co-authored-by: Alan Ren <alanren@microsoft.com>
This commit is contained in:
Kim Santiago
2022-06-02 10:27:47 -10:00
committed by GitHub
parent d3c474162d
commit 1bbf5a78c1
16 changed files with 219 additions and 118 deletions

View File

@@ -51,7 +51,7 @@ export interface DesignerComponentInput {
/**
* Start initilizing the designer input object.
*/
initialize(): void;
initialize(): Promise<void>;
/**
* Start processing the edit made in the designer, the OnEditProcessed event will be fired when the processing is done.

View File

@@ -11,13 +11,10 @@ import { TableDesignerProvider } from 'sql/workbench/services/tableDesigner/comm
import * as azdata from 'azdata';
import { GroupIdentifier, IEditorInput, IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Schemas } from 'sql/base/common/schemas';
import { INotificationService } from 'vs/platform/notification/common/notification';
const NewTable: string = localize('tableDesigner.newTable', "New Table");
enum TableIcon {
Basic = 'Basic',
Temporal = 'Temporal',
@@ -43,19 +40,20 @@ export class TableDesignerInput extends EditorInput {
tableInfo: azdata.designers.TableInfo,
telemetryInfo: { [key: string]: string },
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IEditorService private readonly _editorService: IEditorService,
@INotificationService private readonly _notificationService: INotificationService) {
super();
this._designerComponentInput = this._instantiationService.createInstance(TableDesignerComponentInput, this._provider, tableInfo, telemetryInfo);
this._register(this._designerComponentInput.onStateChange((e) => {
if (e.previousState.pendingAction === 'publish') {
this.setEditorLabel();
this._onDidChangeLabel.fire();
}
if (e.currentState.dirty !== e.previousState.dirty) {
this._onDidChangeDirty.fire();
}
}));
this._register(this._designerComponentInput.onInitialized(() => {
this.setEditorLabel();
}));
// default to basic if icon is null (new table) or no sub type
this._tableIcon = tableInfo.tableIcon ? tableInfo.tableIcon as TableIcon : TableIcon.Basic;
@@ -97,7 +95,7 @@ export class TableDesignerInput extends EditorInput {
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();
await this._designerComponentInput.save();
}
return this;
}
@@ -118,18 +116,8 @@ export class TableDesignerInput extends EditorInput {
}
private setEditorLabel(): void {
const tableInfo = this._designerComponentInput.tableInfo;
if (tableInfo.isNewTable) {
const existingNames = this._editorService.editors.map(editor => editor.getName());
// Find the next available unique name for the new table designer
let idx = 1;
do {
this._name = `${NewTable} ${idx}`;
idx++;
} while (existingNames.indexOf(this._name) !== -1);
} else {
this._name = `${tableInfo.schema}.${tableInfo.name}`;
}
this._title = `${tableInfo.server}.${tableInfo.database} - ${this._name}`;
this._name = this._designerComponentInput.tableInfo.title;
this._title = this._designerComponentInput.tableInfo.tooltip;
this._onDidChangeLabel.fire();
}
}