mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Refactor and rename dashboard tabs part 1 (#755)
* refactor and rename dashboard tabs * undo incorrect changes
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
|
||||
import { Extensions as ConfigurationExtension } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
|
||||
export const Extensions = {
|
||||
dashboardContainerContributions: 'dashboard.contributions.container'
|
||||
};
|
||||
|
||||
export interface IDashboardContainer {
|
||||
id: string;
|
||||
title: string;
|
||||
hasIcon: boolean;
|
||||
container?: object;
|
||||
}
|
||||
|
||||
export interface IDashboardContainerRegistry {
|
||||
registerContainer(tab: IDashboardContainer): void;
|
||||
registerContainerType(id: string, schema: IJSONSchema): void;
|
||||
containers: Array<IDashboardContainer>;
|
||||
containerTypeSchemaProperties: IJSONSchemaMap;
|
||||
}
|
||||
|
||||
class DashboardContainerRegistry implements IDashboardContainerRegistry {
|
||||
private _containers = new Array<IDashboardContainer>();
|
||||
private _dashboardContainerTypeSchemaProperties: IJSONSchemaMap = {};
|
||||
|
||||
public registerContainer(tab: IDashboardContainer): void {
|
||||
this._containers.push(tab);
|
||||
}
|
||||
|
||||
public get containers(): Array<IDashboardContainer> {
|
||||
return this._containers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a dashboard widget
|
||||
* @param id id of the widget
|
||||
* @param schema config schema of the widget
|
||||
*/
|
||||
public registerContainerType(id: string, schema: IJSONSchema): void {
|
||||
this._dashboardContainerTypeSchemaProperties[id] = schema;
|
||||
}
|
||||
|
||||
public get containerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return deepClone(this._dashboardContainerTypeSchemaProperties);
|
||||
}
|
||||
}
|
||||
|
||||
const dashboardContainerRegistry = new DashboardContainerRegistry();
|
||||
Registry.add(Extensions.dashboardContainerContributions, dashboardContainerRegistry);
|
||||
|
||||
export function registerContainer(innerTab: IDashboardContainer): void {
|
||||
dashboardContainerRegistry.registerContainer(innerTab);
|
||||
}
|
||||
|
||||
export function registerContainerType(id: string, schema: IJSONSchema): void {
|
||||
dashboardContainerRegistry.registerContainerType(id, schema);
|
||||
}
|
||||
|
||||
export function generateContainerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return dashboardContainerRegistry.containerTypeSchemaProperties;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export interface IDashboardTab {
|
||||
title: string;
|
||||
publisher: string;
|
||||
description?: string;
|
||||
content?: object;
|
||||
container?: object;
|
||||
provider?: string | string[];
|
||||
edition?: number | number[];
|
||||
alwaysShow?: boolean;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
|
||||
import { Extensions as ConfigurationExtension } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
|
||||
export const Extensions = {
|
||||
InnerTabContributions: 'dashboard.contributions.innerTabs'
|
||||
};
|
||||
|
||||
export interface IDashboardInnerTab {
|
||||
id: string;
|
||||
title: string;
|
||||
hasIcon: boolean;
|
||||
content?: object;
|
||||
}
|
||||
|
||||
export interface IDashboardInnerTabRegistry {
|
||||
registerInnerTab(tab: IDashboardInnerTab): void;
|
||||
registerInnerTabContent(id: string, schema: IJSONSchema): void;
|
||||
innerTabs: Array<IDashboardInnerTab>;
|
||||
innerTabContentSchemaProperties: IJSONSchemaMap;
|
||||
}
|
||||
|
||||
class DashboardInnerTabRegistry implements IDashboardInnerTabRegistry {
|
||||
private _innertabs = new Array<IDashboardInnerTab>();
|
||||
private _dashboardInnerTabContentSchemaProperties: IJSONSchemaMap = {};
|
||||
|
||||
public registerInnerTab(tab: IDashboardInnerTab): void {
|
||||
this._innertabs.push(tab);
|
||||
}
|
||||
|
||||
public get innerTabs(): Array<IDashboardInnerTab> {
|
||||
return this._innertabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a dashboard widget
|
||||
* @param id id of the widget
|
||||
* @param schema config schema of the widget
|
||||
*/
|
||||
public registerInnerTabContent(id: string, schema: IJSONSchema): void {
|
||||
this._dashboardInnerTabContentSchemaProperties[id] = schema;
|
||||
}
|
||||
|
||||
public get innerTabContentSchemaProperties(): IJSONSchemaMap {
|
||||
return deepClone(this._dashboardInnerTabContentSchemaProperties);
|
||||
}
|
||||
}
|
||||
|
||||
const dashboardInnerTabRegistry = new DashboardInnerTabRegistry();
|
||||
Registry.add(Extensions.InnerTabContributions, dashboardInnerTabRegistry);
|
||||
|
||||
export function registerInnerTab(innerTab: IDashboardInnerTab): void {
|
||||
dashboardInnerTabRegistry.registerInnerTab(innerTab);
|
||||
}
|
||||
|
||||
export function registerInnerTabContent(id: string, schema: IJSONSchema): void {
|
||||
dashboardInnerTabRegistry.registerInnerTabContent(id, schema);
|
||||
}
|
||||
|
||||
export function generateInnerTabContentSchemaProperties(): IJSONSchemaMap {
|
||||
return dashboardInnerTabRegistry.innerTabContentSchemaProperties;
|
||||
}
|
||||
Reference in New Issue
Block a user