mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Auto-refresh OE with table designer (#23370)
This commit is contained in:
@@ -53,7 +53,7 @@ export function RefreshObjectExplorerError(error: string): string {
|
|||||||
return localize({
|
return localize({
|
||||||
key: 'objectManagement.refreshOEError',
|
key: 'objectManagement.refreshOEError',
|
||||||
comment: ['{0}: error message.']
|
comment: ['{0}: error message.']
|
||||||
}, "An error occurred while while refreshing the object explorer. {0}", error);
|
}, "An error occurred while refreshing the object explorer. {0}", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DeleteObjectConfirmationText(objectType: string, objectName: string): string {
|
export function DeleteObjectConfirmationText(objectType: string, objectName: string): string {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
|||||||
connectionString: connectionString,
|
connectionString: connectionString,
|
||||||
accessToken: context.connectionProfile!.options.azureAccountToken,
|
accessToken: context.connectionProfile!.options.azureAccountToken,
|
||||||
tableIcon: tableIcon
|
tableIcon: tableIcon
|
||||||
}, telemetryInfo);
|
}, telemetryInfo, context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
await vscode.window.showErrorMessage(getErrorMessage(error), { modal: true });
|
await vscode.window.showErrorMessage(getErrorMessage(error), { modal: true });
|
||||||
@@ -70,7 +70,7 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
|||||||
connectionString: connectionString,
|
connectionString: connectionString,
|
||||||
accessToken: context.connectionProfile!.options.azureAccountToken,
|
accessToken: context.connectionProfile!.options.azureAccountToken,
|
||||||
tableIcon: tableIcon
|
tableIcon: tableIcon
|
||||||
}, telemetryInfo);
|
}, telemetryInfo, context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
await vscode.window.showErrorMessage(getErrorMessage(error), { modal: true });
|
await vscode.window.showErrorMessage(getErrorMessage(error), { modal: true });
|
||||||
|
|||||||
3
src/sql/azdata.proposed.d.ts
vendored
3
src/sql/azdata.proposed.d.ts
vendored
@@ -893,8 +893,9 @@ declare module 'azdata' {
|
|||||||
* @param providerId The table designer provider Id.
|
* @param providerId The table designer provider Id.
|
||||||
* @param tableInfo The table information. The object will be passed back to the table designer provider as the unique identifier for the table.
|
* @param tableInfo The table information. The object will be passed back to the table designer provider as the unique identifier for the table.
|
||||||
* @param telemetryInfo Optional Key-value pair containing any extra information that needs to be sent via telemetry
|
* @param telemetryInfo Optional Key-value pair containing any extra information that needs to be sent via telemetry
|
||||||
|
* @param objectExplorerContext Optional The context used to refresh Object Explorer after the table is created or edited
|
||||||
*/
|
*/
|
||||||
export function openTableDesigner(providerId: string, tableInfo: TableInfo, telemetryInfo?: { [key: string]: string }): Thenable<void>;
|
export function openTableDesigner(providerId: string, tableInfo: TableInfo, telemetryInfo?: { [key: string]: string }, objectExplorerContext?: ObjectExplorerContext): Thenable<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Definition for the table designer provider.
|
* Definition for the table designer provider.
|
||||||
|
|||||||
@@ -668,8 +668,8 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Table Designer
|
// Table Designer
|
||||||
public $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): void {
|
public $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): void {
|
||||||
this._tableDesignerService.openTableDesigner(providerId, tableInfo, telemetryInfo);
|
this._tableDesignerService.openTableDesigner(providerId, tableInfo, telemetryInfo, objectExplorerContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public $unregisterProvider(handle: number): Promise<any> {
|
public $unregisterProvider(handle: number): Promise<any> {
|
||||||
|
|||||||
@@ -946,8 +946,8 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
|||||||
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).disposeTableDesigner(table);
|
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).disposeTableDesigner(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void> {
|
public override $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
this._proxy.$openTableDesigner(providerId, tableInfo, telemetryInfo);
|
this._proxy.$openTableDesigner(providerId, tableInfo, telemetryInfo, objectExplorerContext);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -608,8 +608,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
TableIndexColumnSpecificationProperty: sqlExtHostTypes.designers.TableIndexColumnSpecificationProperty,
|
TableIndexColumnSpecificationProperty: sqlExtHostTypes.designers.TableIndexColumnSpecificationProperty,
|
||||||
DesignerEditType: sqlExtHostTypes.designers.DesignerEditType,
|
DesignerEditType: sqlExtHostTypes.designers.DesignerEditType,
|
||||||
TableIcon: sqlExtHostTypes.designers.TableIcon,
|
TableIcon: sqlExtHostTypes.designers.TableIcon,
|
||||||
openTableDesigner(providerId, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void> {
|
openTableDesigner(providerId, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
return extHostDataProvider.$openTableDesigner(providerId, tableInfo, telemetryInfo);
|
return extHostDataProvider.$openTableDesigner(providerId, tableInfo, telemetryInfo, objectExplorerContext);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ export abstract class ExtHostDataProtocolShape {
|
|||||||
/**
|
/**
|
||||||
* Open a new instance of table designer.
|
* Open a new instance of table designer.
|
||||||
*/
|
*/
|
||||||
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): void { throw ni(); }
|
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): void { throw ni(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the generic execution plan graph for a plan file.
|
* Gets the generic execution plan graph for a plan file.
|
||||||
@@ -710,7 +710,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
|
|||||||
$onSessionStopped(handle: number, response: azdata.ProfilerSessionStoppedParams): void;
|
$onSessionStopped(handle: number, response: azdata.ProfilerSessionStoppedParams): void;
|
||||||
$onProfilerSessionCreated(handle: number, response: azdata.ProfilerSessionCreatedParams): void;
|
$onProfilerSessionCreated(handle: number, response: azdata.ProfilerSessionCreatedParams): void;
|
||||||
$onJobDataUpdated(handle: Number): void;
|
$onJobDataUpdated(handle: Number): void;
|
||||||
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): void;
|
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): void;
|
||||||
/**
|
/**
|
||||||
* Callback when a session has completed initialization
|
* Callback when a session has completed initialization
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ export class TableDesignerInput extends EditorInput {
|
|||||||
private _provider: TableDesignerProvider,
|
private _provider: TableDesignerProvider,
|
||||||
tableInfo: azdata.designers.TableInfo,
|
tableInfo: azdata.designers.TableInfo,
|
||||||
telemetryInfo: { [key: string]: string },
|
telemetryInfo: { [key: string]: string },
|
||||||
|
objectExplorerContext: azdata.ObjectExplorerContext,
|
||||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
@INotificationService private readonly _notificationService: INotificationService) {
|
@INotificationService private readonly _notificationService: INotificationService) {
|
||||||
super();
|
super();
|
||||||
this._designerComponentInput = this._instantiationService.createInstance(TableDesignerComponentInput, this._provider, tableInfo, telemetryInfo);
|
this._designerComponentInput = this._instantiationService.createInstance(TableDesignerComponentInput, this._provider, tableInfo, telemetryInfo, objectExplorerContext);
|
||||||
this._register(this._designerComponentInput.onStateChange((e) => {
|
this._register(this._designerComponentInput.onStateChange((e) => {
|
||||||
if (e.previousState.pendingAction === 'publish') {
|
if (e.previousState.pendingAction === 'publish') {
|
||||||
this.setEditorLabel();
|
this.setEditorLabel();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { TelemetryAction, TelemetryView } from 'sql/platform/telemetry/common/te
|
|||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||||
import { TableDesignerMetadata } from 'sql/workbench/services/tableDesigner/browser/tableDesignerMetadata';
|
import { TableDesignerMetadata } from 'sql/workbench/services/tableDesigner/browser/tableDesignerMetadata';
|
||||||
import { Queue, timeout } from 'vs/base/common/async';
|
import { Queue, timeout } from 'vs/base/common/async';
|
||||||
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||||
|
|
||||||
const ErrorDialogTitle: string = localize('tableDesigner.ErrorDialogTitle', "Table Designer Error");
|
const ErrorDialogTitle: string = localize('tableDesigner.ErrorDialogTitle', "Table Designer Error");
|
||||||
export class TableDesignerComponentInput implements DesignerComponentInput {
|
export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||||
@@ -55,11 +56,13 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
constructor(private readonly _provider: TableDesignerProvider,
|
constructor(private readonly _provider: TableDesignerProvider,
|
||||||
public tableInfo: azdata.designers.TableInfo,
|
public tableInfo: azdata.designers.TableInfo,
|
||||||
private _telemetryInfo: ITelemetryEventProperties,
|
private _telemetryInfo: ITelemetryEventProperties,
|
||||||
|
private _objectExplorerContext: azdata.ObjectExplorerContext,
|
||||||
@INotificationService private readonly _notificationService: INotificationService,
|
@INotificationService private readonly _notificationService: INotificationService,
|
||||||
@IAdsTelemetryService readonly _adsTelemetryService: IAdsTelemetryService,
|
@IAdsTelemetryService readonly _adsTelemetryService: IAdsTelemetryService,
|
||||||
@IQueryEditorService private readonly _queryEditorService: IQueryEditorService,
|
@IQueryEditorService private readonly _queryEditorService: IQueryEditorService,
|
||||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
@IErrorMessageService private readonly _errorMessageService: IErrorMessageService) {
|
@IErrorMessageService private readonly _errorMessageService: IErrorMessageService,
|
||||||
|
@IObjectExplorerService private readonly _objectExplorerService: IObjectExplorerService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public designerUIState?: DesignerUIState = undefined;
|
public designerUIState?: DesignerUIState = undefined;
|
||||||
@@ -138,6 +141,8 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
sticky: true
|
sticky: true
|
||||||
});
|
});
|
||||||
const startTime = new Date().getTime();
|
const startTime = new Date().getTime();
|
||||||
|
let isPublishSuccessful = false;
|
||||||
|
const isNewTable = this.tableInfo.isNewTable;
|
||||||
try {
|
try {
|
||||||
this.updateState(this.valid, this.dirty, 'publish');
|
this.updateState(this.valid, this.dirty, 'publish');
|
||||||
const result = await this._provider.publishChanges(this.tableInfo);
|
const result = await this._provider.publishChanges(this.tableInfo);
|
||||||
@@ -152,11 +157,48 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
publishEvent.withAdditionalMeasurements({
|
publishEvent.withAdditionalMeasurements({
|
||||||
'elapsedTimeMs': new Date().getTime() - startTime
|
'elapsedTimeMs': new Date().getTime() - startTime
|
||||||
}).withAdditionalProperties(metadataTelemetryInfo).send();
|
}).withAdditionalProperties(metadataTelemetryInfo).send();
|
||||||
|
isPublishSuccessful = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.publishChangeError', "An error occured while publishing changes: {0}", error?.message ?? error), error?.data);
|
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.publishChangeError', "An error occured while publishing changes: {0}", error?.message ?? error), error?.data);
|
||||||
this.updateState(this.valid, this.dirty);
|
this.updateState(this.valid, this.dirty);
|
||||||
this._adsTelemetryService.createErrorEvent(TelemetryView.TableDesigner, TelemetryAction.PublishChanges).withAdditionalProperties(telemetryInfo).send();
|
this._adsTelemetryService.createErrorEvent(TelemetryView.TableDesigner, TelemetryAction.PublishChanges).withAdditionalProperties(telemetryInfo).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPublishSuccessful) {
|
||||||
|
await this.refreshNodeInOE(isNewTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async refreshNodeInOE(isNewTable: boolean) {
|
||||||
|
if (!this._objectExplorerContext) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const connectionId = this._objectExplorerContext.connectionProfile?.id;
|
||||||
|
const nodeInfo = this._objectExplorerContext.nodeInfo;
|
||||||
|
const node = await this._objectExplorerService.getTreeNode(connectionId, nodeInfo?.nodePath);
|
||||||
|
let refreshNodePath: string;
|
||||||
|
|
||||||
|
if (isNewTable) {
|
||||||
|
refreshNodePath = nodeInfo?.nodePath;
|
||||||
|
} else {
|
||||||
|
// This handle the case where a user publishes a table then edit the same table within the same designer then publish again. In that case node path in OE context is already correct.
|
||||||
|
if (node?.objectType === 'Tables') {
|
||||||
|
refreshNodePath = nodeInfo?.nodePath
|
||||||
|
} else {
|
||||||
|
refreshNodePath = nodeInfo?.parentNodePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await this._objectExplorerService.refreshNodeInView(connectionId, refreshNodePath);
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage = localize({
|
||||||
|
key: 'tableDesigner.refreshOEError',
|
||||||
|
comment: ['{0}: error message.']
|
||||||
|
}, "An error occurred while refreshing the object explorer. {0}", error);
|
||||||
|
this._notificationService.error(errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(): Promise<void> {
|
async save(): Promise<void> {
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ export class TableDesignerService implements ITableDesignerService {
|
|||||||
throw invalidProvider(providerId);
|
throw invalidProvider(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void> {
|
public async openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
this._adsTelemetryService.createActionEvent(TelemetryView.TableDesigner, TelemetryAction.Open).withAdditionalProperties(telemetryInfo).send();
|
this._adsTelemetryService.createActionEvent(TelemetryView.TableDesigner, TelemetryAction.Open).withAdditionalProperties(telemetryInfo).send();
|
||||||
const provider = this.getProvider(providerId);
|
const provider = this.getProvider(providerId);
|
||||||
const tableDesignerInput = this._instantiationService.createInstance(TableDesignerInput, provider, tableInfo, telemetryInfo);
|
const tableDesignerInput = this._instantiationService.createInstance(TableDesignerInput, provider, tableInfo, telemetryInfo, objectExplorerContext);
|
||||||
await this._editorService.openEditor(tableDesignerInput, { pinned: true }, ACTIVE_GROUP);
|
await this._editorService.openEditor(tableDesignerInput, { pinned: true }, ACTIVE_GROUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export interface ITableDesignerService {
|
|||||||
* Open a table designer for the given table
|
* Open a table designer for the given table
|
||||||
* @param providerId The provider id
|
* @param providerId The provider id
|
||||||
* @param tableInfo The table information
|
* @param tableInfo The table information
|
||||||
|
* @param telemetryInfo Telemetry information
|
||||||
|
* @param objectExplorerContext The object explorer context
|
||||||
*/
|
*/
|
||||||
openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void>;
|
openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties, objectExplorerContext?: azdata.ObjectExplorerContext): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user