mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 09:35:36 -05:00
Merge dashboardCommandCenter to master (#697)
* Initial work of adding tab in the dashboard (#526) * refactor dashboard to have the home tab * formatting * fix grid layout issue * fix initailize issue in database dashboard * Add action bar to the panel and add close tab to the dashboard (#562) * add action bar to the panel and add close tab to the dashboard * formatting * Tab contribution (#564) * added contrib * disabled edit for extensions; fixed new name for insights contrib * fix merge issue * move file * formatting * fix builds * moving imports * Expand on tab contrib (#581) * added contrib * disabled edit for extensions; fixed new name for insights contrib * fix merge issue * move file * formatting * fix builds * adding to contrib * updated contrib * format * moving imports * updated contribution to map to current design * implemented actually using provider and edition filtering * Refactor and fix issues in close tab and add the placeholder for pin tab (#588) * refactor and fix issues in close tab and add the placeholder for pin tab * formatting * remove the redundant code * add clear all tabs in dashboard page init * Initial work for adding a feature tab dialog (#594) * initial work for add new dashboard tab * formatting * fix add panel action issue * fix breaking change * fix issues and tab and panels * formatting * minor fix * address comments * Add tab status to add extension tab dialog (#610) * add tab status to add extension tab dialog * add tab status to add extension tab dialog * rename add feature tab action * address comments * Webview widget (#618) * getting closer * webview widget now works * fix problem with rerendering webview * formatting * ensure that webview only shows up for extensions * formatting * comments * fix more compile issues * Change dashboard page init (#640) * changed init of serverpage * formatting * Webview tab (#638) * getting closer * webview widget now works * fix problem with rerendering webview * formatting * ensure that webview only shows up for extensions * formatting * comments * fix more compile issues * refacting stuff * added inital webview tab * piped through messaging and tested * Implement pin/unpin feature and always on tabs (#629) * implement pin/unpin feature * fix issue where insight can't be loaded after reopen * fix tab look and feel * implement always show tabs * make AddFeatureTabAction to track always show and pinned tabs * formatting * make dashboard tabs looks like the UX design * load always show before pinned tab * fix regression in panel for restore and connection dialog * fix merge conflict * don't worry about no widgets if its a webview (#656) * expose the dashboard server info when a webview is rendering (#644) * Fix few issues in dashboard command center (#655) * fix reloading insight wigets and create new tab when there is no extension * show possible tabIDs in the setting file * formatting * address comment * fix import name * fixes problem with size of webview widget being wrong (#654) * Refactor tab contribution to support content type (#685) * refactor tab contribution to support content type * formatting * address comment * fix rendering tab issue (#694) * Add layout option to panel for supporting horizontal and vertical navigation bar (#700) * Add left navigation panel for inner tab in the dashboard * add layout option in panel * remove panel option in dashboard Page
This commit is contained in:
94
src/sql/workbench/api/node/extHostDashboardWebview.ts
Normal file
94
src/sql/workbench/api/node/extHostDashboardWebview.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { SqlMainContext, ExtHostDashboardWebviewsShape, MainThreadDashboardWebviewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as data from 'data';
|
||||
|
||||
class ExtHostDashboardWebview implements data.DashboardWebview {
|
||||
|
||||
private _html: string;
|
||||
public onMessageEmitter = new Emitter<any>();
|
||||
public onClosedEmitter = new Emitter<any>();
|
||||
|
||||
constructor(
|
||||
private readonly _proxy: MainThreadDashboardWebviewShape,
|
||||
private readonly _handle: number,
|
||||
private readonly _connection: data.connection.Connection,
|
||||
private readonly _serverInfo: data.ServerInfo
|
||||
) { }
|
||||
|
||||
public postMessage(message: any): Thenable<any> {
|
||||
return this._proxy.$sendMessage(this._handle, message);
|
||||
}
|
||||
|
||||
public get onMessage(): vscode.Event<any> {
|
||||
return this.onMessageEmitter.event;
|
||||
}
|
||||
|
||||
public get onClosed(): vscode.Event<any> {
|
||||
return this.onClosedEmitter.event;
|
||||
}
|
||||
|
||||
public get connection(): data.connection.Connection {
|
||||
return deepClone(this._connection);
|
||||
}
|
||||
|
||||
public get serverInfo(): data.ServerInfo {
|
||||
return deepClone(this._serverInfo);
|
||||
}
|
||||
|
||||
get html(): string {
|
||||
return this._html;
|
||||
}
|
||||
|
||||
set html(value: string) {
|
||||
if (this._html !== value) {
|
||||
this._html = value;
|
||||
this._proxy.$setHtml(this._handle, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostDashboardWebviews implements ExtHostDashboardWebviewsShape {
|
||||
private readonly _proxy: MainThreadDashboardWebviewShape;
|
||||
|
||||
private readonly _webviews = new Map<number, ExtHostDashboardWebview>();
|
||||
private readonly _handlers = new Map<string, (webview: data.DashboardWebview) => void>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.get(SqlMainContext.MainThreadDashboardWebview);
|
||||
}
|
||||
|
||||
$onMessage(handle: number, message: any): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onMessageEmitter.fire(message);
|
||||
}
|
||||
|
||||
$onClosed(handle: number): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onClosedEmitter.fire();
|
||||
this._webviews.delete(handle);
|
||||
}
|
||||
|
||||
$registerProvider(widgetId: string, handler: (webview: data.DashboardWebview) => void): void {
|
||||
this._handlers.set(widgetId, handler);
|
||||
this._proxy.$registerProvider(widgetId);
|
||||
}
|
||||
|
||||
$registerWidget(handle: number, id: string, connection: data.connection.Connection, serverInfo: data.ServerInfo): void {
|
||||
let webview = new ExtHostDashboardWebview(this._proxy, handle, connection, serverInfo);
|
||||
this._webviews.set(handle, webview);
|
||||
this._handlers.get(id)(webview);
|
||||
}
|
||||
}
|
||||
@@ -119,4 +119,4 @@ export class ExtHostModalDialogs implements ExtHostModalDialogsShape {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onClosedEmitter.fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
src/sql/workbench/api/node/mainThreadDashboardWebview.ts
Normal file
53
src/sql/workbench/api/node/mainThreadDashboardWebview.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { MainThreadDashboardWebviewShape, SqlMainContext, ExtHostDashboardWebviewsShape, SqlExtHostContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { IDashboardWebviewService, IDashboardWebview } from 'sql/services/dashboardWebview/common/dashboardWebviewService';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadDashboardWebview)
|
||||
export class MainThreadDashboardWebview implements MainThreadDashboardWebviewShape {
|
||||
|
||||
private static _handlePool = 0;
|
||||
private readonly _proxy: ExtHostDashboardWebviewsShape;
|
||||
private readonly _dialogs = new Map<number, IDashboardWebview>();
|
||||
|
||||
private knownWidgets = new Array<string>();
|
||||
|
||||
constructor(
|
||||
context: IExtHostContext,
|
||||
@IDashboardWebviewService webviewService: IDashboardWebviewService
|
||||
) {
|
||||
this._proxy = context.get(SqlExtHostContext.ExtHostDashboardWebviews);
|
||||
webviewService.onRegisteredWebview(e => {
|
||||
if (this.knownWidgets.includes(e.id)) {
|
||||
let handle = MainThreadDashboardWebview._handlePool++;
|
||||
this._dialogs.set(handle, e);
|
||||
this._proxy.$registerWidget(handle, e.id, e.connection, e.serverInfo);
|
||||
e.onMessage(e => {
|
||||
this._proxy.$onMessage(handle, e);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
$sendMessage(handle: number, message: string) {
|
||||
this._dialogs.get(handle).sendMessage(message);
|
||||
}
|
||||
|
||||
$setHtml(handle: number, value: string) {
|
||||
this._dialogs.get(handle).setHtml(value);
|
||||
}
|
||||
|
||||
$registerProvider(widgetId: string) {
|
||||
this.knownWidgets.push(widgetId);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration
|
||||
import { ExtHostModalDialogs } from 'sql/workbench/api/node/extHostModalDialog';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IExtensionApiFactory } from 'vs/workbench/api/node/extHost.api.impl';
|
||||
import { ExtHostDashboardWebviews } from 'sql/workbench/api/node/extHostDashboardWebview';
|
||||
import { ExtHostConnectionManagement } from 'sql/workbench/api/node/extHostConnectionManagement';
|
||||
|
||||
export interface ISqlExtensionApiFactory {
|
||||
@@ -56,6 +57,7 @@ export function createApiFactory(
|
||||
const extHostSerializationProvider = threadService.set(SqlExtHostContext.ExtHostSerializationProvider, new ExtHostSerializationProvider(threadService));
|
||||
const extHostResourceProvider = threadService.set(SqlExtHostContext.ExtHostResourceProvider, new ExtHostResourceProvider(threadService));
|
||||
const extHostModalDialogs = threadService.set(SqlExtHostContext.ExtHostModalDialogs, new ExtHostModalDialogs(threadService));
|
||||
const extHostWebviewWidgets = threadService.set(SqlExtHostContext.ExtHostDashboardWebviews, new ExtHostDashboardWebviews(threadService));
|
||||
|
||||
return {
|
||||
vsCodeFactory: vsCodeFactory,
|
||||
@@ -259,6 +261,12 @@ export function createApiFactory(
|
||||
}
|
||||
};
|
||||
|
||||
const dashboard = {
|
||||
registerWebviewProvider(widgetId: string, handler: (webview: data.DashboardWebview) => void) {
|
||||
extHostWebviewWidgets.$registerProvider(widgetId, handler);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
accounts,
|
||||
connection,
|
||||
@@ -273,7 +281,8 @@ export function createApiFactory(
|
||||
TaskStatus: sqlExtHostTypes.TaskStatus,
|
||||
TaskExecutionMode: sqlExtHostTypes.TaskExecutionMode,
|
||||
ScriptOperation: sqlExtHostTypes.ScriptOperation,
|
||||
window
|
||||
window,
|
||||
dashboard
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'sql/workbench/api/node/mainThreadCredentialManagement';
|
||||
import 'sql/workbench/api/node/mainThreadDataProtocol';
|
||||
import 'sql/workbench/api/node/mainThreadSerializationProvider';
|
||||
import 'sql/workbench/api/node/mainThreadResourceProvider';
|
||||
import 'sql/workbench/api/node/mainThreadDashboardWebview';
|
||||
import './mainThreadAccountManagement';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import * as data from 'data';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export abstract class ExtHostAccountManagementShape {
|
||||
$autoOAuthCancelled(handle: number): Thenable<void> { throw ni(); }
|
||||
$clear(handle: number, accountKey: data.AccountKey): Thenable<void> { throw ni(); }
|
||||
@@ -420,6 +421,7 @@ export const SqlMainContext = {
|
||||
MainThreadSerializationProvider: createMainId<MainThreadSerializationProviderShape>('MainThreadSerializationProvider'),
|
||||
MainThreadResourceProvider: createMainId<MainThreadResourceProviderShape>('MainThreadResourceProvider'),
|
||||
MainThreadModalDialog: createMainId<MainThreadModalDialogShape>('MainThreadModalDialog'),
|
||||
MainThreadDashboardWebview: createMainId<MainThreadDashboardWebviewShape>('MainThreadDashboardWebview')
|
||||
};
|
||||
|
||||
export const SqlExtHostContext = {
|
||||
@@ -429,7 +431,8 @@ export const SqlExtHostContext = {
|
||||
ExtHostDataProtocol: createExtId<ExtHostDataProtocolShape>('ExtHostDataProtocol'),
|
||||
ExtHostSerializationProvider: createExtId<ExtHostSerializationProviderShape>('ExtHostSerializationProvider'),
|
||||
ExtHostResourceProvider: createExtId<ExtHostResourceProviderShape>('ExtHostResourceProvider'),
|
||||
ExtHostModalDialogs: createExtId<ExtHostModalDialogsShape>('ExtHostModalDialogs')
|
||||
ExtHostModalDialogs: createExtId<ExtHostModalDialogsShape>('ExtHostModalDialogs'),
|
||||
ExtHostDashboardWebviews: createExtId<ExtHostDashboardWebviewsShape>('ExtHostDashboardWebviews')
|
||||
};
|
||||
|
||||
export interface MainThreadModalDialogShape extends IDisposable {
|
||||
@@ -440,7 +443,21 @@ export interface MainThreadModalDialogShape extends IDisposable {
|
||||
$setHtml(handle: number, value: string): void;
|
||||
$sendMessage(handle: number, value: any): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export interface ExtHostModalDialogsShape {
|
||||
$onMessage(handle: number, message: any): void;
|
||||
$onClosed(handle: number): void;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ExtHostDashboardWebviewsShape {
|
||||
$registerProvider(widgetId: string, handler: (webview: data.DashboardWebview) => void): void;
|
||||
$onMessage(handle: number, message: any): void;
|
||||
$onClosed(handle: number): void;
|
||||
$registerWidget(handle: number, id: string, connection: data.connection.Connection, serverInfo: data.ServerInfo): void;
|
||||
}
|
||||
|
||||
export interface MainThreadDashboardWebviewShape extends IDisposable {
|
||||
$sendMessage(handle: number, message: string);
|
||||
$registerProvider(widgetId: string);
|
||||
$setHtml(handle: number, value: string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user