mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Port bf9646ba98 (#12738)
This commit is contained in:
@@ -9,7 +9,7 @@ export abstract class Dashboard {
|
|||||||
|
|
||||||
private dashboard!: azdata.window.ModelViewDashboard;
|
private dashboard!: azdata.window.ModelViewDashboard;
|
||||||
|
|
||||||
constructor(protected title: string) { }
|
constructor(protected title: string, protected readonly name: string) { }
|
||||||
|
|
||||||
public async showDashboard(): Promise<void> {
|
public async showDashboard(): Promise<void> {
|
||||||
this.dashboard = this.createDashboard();
|
this.dashboard = this.createDashboard();
|
||||||
@@ -17,7 +17,7 @@ export abstract class Dashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected createDashboard(): azdata.window.ModelViewDashboard {
|
protected createDashboard(): azdata.window.ModelViewDashboard {
|
||||||
const dashboard = azdata.window.createModelViewDashboard(this.title);
|
const dashboard = azdata.window.createModelViewDashboard(this.title, this.name);
|
||||||
dashboard.registerTabs(async modelView => {
|
dashboard.registerTabs(async modelView => {
|
||||||
return await this.registerTabs(modelView);
|
return await this.registerTabs(modelView);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import * as loc from '../../../localizedConstants';
|
|||||||
export class ControllerDashboard extends Dashboard {
|
export class ControllerDashboard extends Dashboard {
|
||||||
|
|
||||||
constructor(private _controllerModel: ControllerModel) {
|
constructor(private _controllerModel: ControllerModel) {
|
||||||
super(loc.arcControllerDashboard(_controllerModel.info.name));
|
super(loc.arcControllerDashboard(_controllerModel.info.name), 'ArcDataControllerDashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async showDashboard(): Promise<void> {
|
public async showDashboard(): Promise<void> {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { MiaaModel } from '../../../models/miaaModel';
|
|||||||
export class MiaaDashboard extends Dashboard {
|
export class MiaaDashboard extends Dashboard {
|
||||||
|
|
||||||
constructor(private _controllerModel: ControllerModel, private _miaaModel: MiaaModel) {
|
constructor(private _controllerModel: ControllerModel, private _miaaModel: MiaaModel) {
|
||||||
super(loc.miaaDashboard(_miaaModel.info.name));
|
super(loc.miaaDashboard(_miaaModel.info.name), 'ArcMiaaDashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async showDashboard(): Promise<void> {
|
public async showDashboard(): Promise<void> {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { PostgresResourceHealthPage } from './postgresResourceHealthPage';
|
|||||||
|
|
||||||
export class PostgresDashboard extends Dashboard {
|
export class PostgresDashboard extends Dashboard {
|
||||||
constructor(private _context: vscode.ExtensionContext, private _controllerModel: ControllerModel, private _postgresModel: PostgresModel) {
|
constructor(private _context: vscode.ExtensionContext, private _controllerModel: ControllerModel, private _postgresModel: PostgresModel) {
|
||||||
super(loc.postgresDashboard(_postgresModel.name));
|
super(loc.postgresDashboard(_postgresModel.name), 'ArcPgDashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async showDashboard(): Promise<void> {
|
public async showDashboard(): Promise<void> {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class BdcDashboard extends InitializingComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async createDashboard(): Promise<void> {
|
private async createDashboard(): Promise<void> {
|
||||||
this.dashboard = azdata.window.createModelViewDashboard(this.title, { alwaysShowTabs: true });
|
this.dashboard = azdata.window.createModelViewDashboard(this.title, 'BdcDashboard', { alwaysShowTabs: true });
|
||||||
this.dashboard.registerTabs(async (modelView: azdata.ModelView) => {
|
this.dashboard.registerTabs(async (modelView: azdata.ModelView) => {
|
||||||
this.modelView = modelView;
|
this.modelView = modelView;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class SchemaCompareMainWindow {
|
|||||||
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Change] = loc.changeAction;
|
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Change] = loc.changeAction;
|
||||||
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Add] = loc.addAction;
|
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Add] = loc.addAction;
|
||||||
|
|
||||||
this.editor = azdata.workspace.createModelViewEditor(loc.SchemaCompareLabel, { retainContextWhenHidden: true, supportsSave: true, resourceName: schemaCompareResourceName });
|
this.editor = azdata.workspace.createModelViewEditor(loc.SchemaCompareLabel, { retainContextWhenHidden: true, supportsSave: true, resourceName: schemaCompareResourceName }, 'SchemaCompareEditor');
|
||||||
}
|
}
|
||||||
|
|
||||||
// schema compare can get started with three contexts for the source:
|
// schema compare can get started with three contexts for the source:
|
||||||
|
|||||||
4
src/sql/azdata.d.ts
vendored
4
src/sql/azdata.d.ts
vendored
@@ -2485,7 +2485,9 @@ declare module 'azdata' {
|
|||||||
export const onDidChangeToDashboard: vscode.Event<DashboardDocument>;
|
export const onDidChangeToDashboard: vscode.Event<DashboardDocument>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new model view editor
|
* Create a new ModelView editor
|
||||||
|
* @param title The title shown in the editor tab
|
||||||
|
* @param options Options to configure the editor
|
||||||
*/
|
*/
|
||||||
export function createModelViewEditor(title: string, options?: ModelViewEditorOptions): ModelViewEditor;
|
export function createModelViewEditor(title: string, options?: ModelViewEditorOptions): ModelViewEditor;
|
||||||
|
|
||||||
|
|||||||
18
src/sql/azdata.proposed.d.ts
vendored
18
src/sql/azdata.proposed.d.ts
vendored
@@ -513,7 +513,13 @@ declare module 'azdata' {
|
|||||||
selectTab(id: string): void;
|
selectTab(id: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createModelViewDashboard(title: string, options?: ModelViewDashboardOptions): ModelViewDashboard;
|
/**
|
||||||
|
*
|
||||||
|
* @param title The title displayed in the editor tab for the dashboard
|
||||||
|
* @param name The name used to identify this dashboard in telemetry
|
||||||
|
* @param options Options to configure the dashboard
|
||||||
|
*/
|
||||||
|
export function createModelViewDashboard(title: string, name?: string, options?: ModelViewDashboardOptions): ModelViewDashboard;
|
||||||
|
|
||||||
export interface Dialog {
|
export interface Dialog {
|
||||||
/**
|
/**
|
||||||
@@ -547,6 +553,16 @@ declare module 'azdata' {
|
|||||||
export function createWizard(title: string, width?: DialogWidth): Wizard;
|
export function createWizard(title: string, width?: DialogWidth): Wizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace workspace {
|
||||||
|
/**
|
||||||
|
* Create a new ModelView editor
|
||||||
|
* @param title The title shown in the editor tab
|
||||||
|
* @param options Options to configure the editor
|
||||||
|
* @param name The name used to identify the editor in telemetry
|
||||||
|
*/
|
||||||
|
export function createModelViewEditor(title: string, options?: ModelViewEditorOptions, name?: string,): ModelViewEditor;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DashboardTab extends Tab {
|
export interface DashboardTab extends Tab {
|
||||||
/**
|
/**
|
||||||
* Toolbar of the tab, optional.
|
* Toolbar of the tab, optional.
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export enum TelemetryView {
|
|||||||
|
|
||||||
export enum TelemetryAction {
|
export enum TelemetryAction {
|
||||||
Click = 'Click',
|
Click = 'Click',
|
||||||
Open = 'Open'
|
Open = 'Open',
|
||||||
|
ModelViewDashboardOpened = 'ModelViewDashboardOpened'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import { ModelViewInput, ModelViewInputModel, ModeViewSaveHandler } from 'sql/wo
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { assign } from 'vs/base/common/objects';
|
import { assign } from 'vs/base/common/objects';
|
||||||
|
import { TelemetryView, TelemetryAction } from 'sql/platform/telemetry/common/telemetryKeys';
|
||||||
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
|
|
||||||
@extHostNamedCustomer(SqlMainContext.MainThreadModelViewDialog)
|
@extHostNamedCustomer(SqlMainContext.MainThreadModelViewDialog)
|
||||||
export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape {
|
export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape {
|
||||||
@@ -33,7 +35,8 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
|
|||||||
constructor(
|
constructor(
|
||||||
context: IExtHostContext,
|
context: IExtHostContext,
|
||||||
@IInstantiationService private _instatiationService: IInstantiationService,
|
@IInstantiationService private _instatiationService: IInstantiationService,
|
||||||
@IEditorService private _editorService: IEditorService
|
@IEditorService private _editorService: IEditorService,
|
||||||
|
@IAdsTelemetryService private _telemetryService: IAdsTelemetryService
|
||||||
) {
|
) {
|
||||||
this._proxy = context.getProxy(SqlExtHostContext.ExtHostModelViewDialog);
|
this._proxy = context.getProxy(SqlExtHostContext.ExtHostModelViewDialog);
|
||||||
this._dialogService = new CustomDialogService(_instatiationService);
|
this._dialogService = new CustomDialogService(_instatiationService);
|
||||||
@@ -43,7 +46,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
|
|||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public $openEditor(handle: number, modelViewId: string, title: string, options?: azdata.ModelViewEditorOptions, position?: vscode.ViewColumn): Thenable<void> {
|
public $openEditor(handle: number, modelViewId: string, title: string, name?: string, options?: azdata.ModelViewEditorOptions, position?: vscode.ViewColumn): Thenable<void> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
let saveHandler: ModeViewSaveHandler = options && options.supportsSave ? (h) => this.handleSave(h) : undefined;
|
let saveHandler: ModeViewSaveHandler = options && options.supportsSave ? (h) => this.handleSave(h) : undefined;
|
||||||
let model = new ModelViewInputModel(modelViewId, handle, saveHandler);
|
let model = new ModelViewInputModel(modelViewId, handle, saveHandler);
|
||||||
@@ -52,7 +55,9 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
|
|||||||
preserveFocus: true,
|
preserveFocus: true,
|
||||||
pinned: true
|
pinned: true
|
||||||
};
|
};
|
||||||
|
this._telemetryService.createActionEvent(TelemetryView.Shell, TelemetryAction.ModelViewDashboardOpened)
|
||||||
|
.withAdditionalProperties({ name: name })
|
||||||
|
.send();
|
||||||
this._editorService.openEditor(input, editorOptions, position as any).then((editor) => {
|
this._editorService.openEditor(input, editorOptions, position as any).then((editor) => {
|
||||||
this._editorInputModels.set(handle, model);
|
this._editorInputModels.set(handle, model);
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class ModelViewEditorImpl extends ModelViewPanelImpl implements azdata.workspace
|
|||||||
extension: IExtensionDescription,
|
extension: IExtensionDescription,
|
||||||
private _proxy: MainThreadModelViewDialogShape,
|
private _proxy: MainThreadModelViewDialogShape,
|
||||||
private _title: string,
|
private _title: string,
|
||||||
|
private _name: string,
|
||||||
private _options: azdata.ModelViewEditorOptions
|
private _options: azdata.ModelViewEditorOptions
|
||||||
) {
|
) {
|
||||||
super('modelViewEditor', extHostModelViewDialog, extHostModelView, extension);
|
super('modelViewEditor', extHostModelViewDialog, extHostModelView, extension);
|
||||||
@@ -89,7 +90,7 @@ class ModelViewEditorImpl extends ModelViewPanelImpl implements azdata.workspace
|
|||||||
}
|
}
|
||||||
|
|
||||||
public openEditor(position?: vscode.ViewColumn): Thenable<void> {
|
public openEditor(position?: vscode.ViewColumn): Thenable<void> {
|
||||||
return this._proxy.$openEditor(this.handle, this._modelViewId, this._title, this._options, position);
|
return this._proxy.$openEditor(this.handle, this._modelViewId, this._title, this._name, this._options, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isDirty(): boolean {
|
public get isDirty(): boolean {
|
||||||
@@ -648,14 +649,16 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
|
|||||||
this._proxy.$closeDialog(handle);
|
this._proxy.$closeDialog(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createModelViewEditor(title: string, extension: IExtensionDescription, options?: azdata.ModelViewEditorOptions): azdata.workspace.ModelViewEditor {
|
public createModelViewEditor(title: string, extension: IExtensionDescription, name?: string, options?: azdata.ModelViewEditorOptions): azdata.workspace.ModelViewEditor {
|
||||||
let editor = new ModelViewEditorImpl(this, this._extHostModelView, extension, this._proxy, title, options);
|
name = name ?? 'ModelViewEditor';
|
||||||
|
let editor = new ModelViewEditorImpl(this, this._extHostModelView, extension, this._proxy, title, name, options);
|
||||||
editor.handle = this.getHandle(editor);
|
editor.handle = this.getHandle(editor);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public createModelViewDashboard(title: string, options: azdata.ModelViewDashboardOptions | undefined, extension: IExtensionDescription): azdata.window.ModelViewDashboard {
|
public createModelViewDashboard(title: string, name: string | undefined, options: azdata.ModelViewDashboardOptions | undefined, extension: IExtensionDescription): azdata.window.ModelViewDashboard {
|
||||||
const editor = this.createModelViewEditor(title, extension, { supportsSave: false }) as ModelViewEditorImpl;
|
name = name ?? 'ModelViewDashboard';
|
||||||
|
const editor = this.createModelViewEditor(title, extension, name, { supportsSave: false }) as ModelViewEditorImpl;
|
||||||
return new ModelViewDashboardImpl(editor, options);
|
return new ModelViewDashboardImpl(editor, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -440,8 +440,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
createWizard(title: string, width?: azdata.window.DialogWidth): azdata.window.Wizard {
|
createWizard(title: string, width?: azdata.window.DialogWidth): azdata.window.Wizard {
|
||||||
return extHostModelViewDialog.createWizard(title, width);
|
return extHostModelViewDialog.createWizard(title, width);
|
||||||
},
|
},
|
||||||
createModelViewDashboard(title: string, options?: azdata.ModelViewDashboardOptions): azdata.window.ModelViewDashboard {
|
createModelViewDashboard(title: string, name?: string, options?: azdata.ModelViewDashboardOptions): azdata.window.ModelViewDashboard {
|
||||||
return extHostModelViewDialog.createModelViewDashboard(title, options, extension);
|
return extHostModelViewDialog.createModelViewDashboard(title, name, options, extension);
|
||||||
},
|
},
|
||||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||||
};
|
};
|
||||||
@@ -458,8 +458,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
const workspace: typeof azdata.workspace = {
|
const workspace: typeof azdata.workspace = {
|
||||||
onDidOpenDashboard: extHostDashboard.onDidOpenDashboard,
|
onDidOpenDashboard: extHostDashboard.onDidOpenDashboard,
|
||||||
onDidChangeToDashboard: extHostDashboard.onDidChangeToDashboard,
|
onDidChangeToDashboard: extHostDashboard.onDidChangeToDashboard,
|
||||||
createModelViewEditor(title: string, options?: azdata.ModelViewEditorOptions): azdata.workspace.ModelViewEditor {
|
createModelViewEditor(title: string, options?: azdata.ModelViewEditorOptions, name?: string): azdata.workspace.ModelViewEditor {
|
||||||
return extHostModelViewDialog.createModelViewEditor(title, extension, options);
|
return extHostModelViewDialog.createModelViewEditor(title, extension, name, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ export interface ExtHostModelViewDialogShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface MainThreadModelViewDialogShape extends IDisposable {
|
export interface MainThreadModelViewDialogShape extends IDisposable {
|
||||||
$openEditor(handle: number, modelViewId: string, title: string, options?: azdata.ModelViewEditorOptions, position?: vscode.ViewColumn): Thenable<void>;
|
$openEditor(handle: number, modelViewId: string, title: string, name?: string, options?: azdata.ModelViewEditorOptions, position?: vscode.ViewColumn): Thenable<void>;
|
||||||
$openDialog(handle: number, dialogName?: string): Thenable<void>;
|
$openDialog(handle: number, dialogName?: string): Thenable<void>;
|
||||||
$closeDialog(handle: number): Thenable<void>;
|
$closeDialog(handle: number): Thenable<void>;
|
||||||
$setDialogDetails(handle: number, details: IModelViewDialogDetails): Thenable<void>;
|
$setDialogDetails(handle: number, details: IModelViewDialogDetails): Thenable<void>;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
|||||||
let extHostContext = <IExtHostContext>{
|
let extHostContext = <IExtHostContext>{
|
||||||
getProxy: proxyType => mockExtHostModelViewDialog.object
|
getProxy: proxyType => mockExtHostModelViewDialog.object
|
||||||
};
|
};
|
||||||
mainThreadModelViewDialog = new MainThreadModelViewDialog(extHostContext, undefined, undefined);
|
mainThreadModelViewDialog = new MainThreadModelViewDialog(extHostContext, undefined, undefined, undefined);
|
||||||
|
|
||||||
// Set up the mock dialog service
|
// Set up the mock dialog service
|
||||||
mockDialogService = Mock.ofType(CustomDialogService, undefined);
|
mockDialogService = Mock.ofType(CustomDialogService, undefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user