mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
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:
@@ -33,6 +33,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||
private _onEditProcessed = new Emitter<DesignerEditProcessedEventArgs>();
|
||||
private _onRefreshRequested = new Emitter<void>();
|
||||
private _originalViewModel: DesignerViewModel;
|
||||
private _tableDesignerView: azdata.designers.TableDesignerView;
|
||||
|
||||
public readonly onInitialized: Event<void> = this._onInitialized.event;
|
||||
public readonly onEditProcessed: Event<DesignerEditProcessedEventArgs> = this._onEditProcessed.event;
|
||||
@@ -81,6 +82,10 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||
return this._issues;
|
||||
}
|
||||
|
||||
get tableDesignerView(): azdata.designers.TableDesignerView {
|
||||
return this._tableDesignerView;
|
||||
}
|
||||
|
||||
processEdit(edit: DesignerEdit): void {
|
||||
const telemetryInfo = this.createTelemetryInfo();
|
||||
telemetryInfo.tableObjectType = this.getObjectTypeFromPath(edit.path);
|
||||
@@ -177,6 +182,14 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||
}
|
||||
}
|
||||
|
||||
async save(): Promise<void> {
|
||||
if (this.tableDesignerView?.useAdvancedSaveMode) {
|
||||
await this.openPublishDialog();
|
||||
} else {
|
||||
await this.publishChanges();
|
||||
}
|
||||
}
|
||||
|
||||
async openPublishDialog(): Promise<void> {
|
||||
const reportNotificationHandle = this._notificationService.notify({
|
||||
severity: Severity.Info,
|
||||
@@ -243,24 +256,28 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||
}
|
||||
}
|
||||
|
||||
initialize(): void {
|
||||
async initialize(): Promise<void> {
|
||||
if (this._view !== undefined || this.pendingAction === 'initialize') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateState(this.valid, this.dirty, 'initialize');
|
||||
this._provider.initializeTableDesigner(this.tableInfo).then(result => {
|
||||
try {
|
||||
const result = await this._provider.initializeTableDesigner(this.tableInfo);
|
||||
this.doInitialization(result);
|
||||
this._onInitialized.fire();
|
||||
}, error => {
|
||||
} catch (error) {
|
||||
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.errorInitializingTableDesigner', "An error occurred while initializing the table designer: {0}", error?.message ?? error));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private doInitialization(designerInfo: azdata.designers.TableDesignerInfo): void {
|
||||
this.tableInfo = designerInfo.tableInfo;
|
||||
this.updateState(true, this.tableInfo.isNewTable);
|
||||
this._viewModel = designerInfo.viewModel;
|
||||
this._originalViewModel = this.tableInfo.isNewTable ? undefined : deepClone(this._viewModel);
|
||||
this._tableDesignerView = designerInfo.view;
|
||||
this._issues = designerInfo.issues;
|
||||
this.setDesignerView(designerInfo.view);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user