mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Tab contribution support both inline container and registered container (#766)
* accept inline nav section contribution * contribution accepted both inline container and registered container * address comments * formatting
This commit is contained in:
@@ -16,34 +16,35 @@ export const Extensions = {
|
||||
|
||||
export interface IDashboardContainer {
|
||||
id: string;
|
||||
title: string;
|
||||
hasIcon: boolean;
|
||||
container?: object;
|
||||
}
|
||||
|
||||
export interface IDashboardContainerRegistry {
|
||||
registerContainer(tab: IDashboardContainer): void;
|
||||
registerContainer(container: IDashboardContainer): void;
|
||||
registerContainerType(id: string, schema: IJSONSchema): void;
|
||||
containers: Array<IDashboardContainer>;
|
||||
registerNavSectionContainerType(id: string, schema: IJSONSchema): void;
|
||||
getRegisteredContainer(id: string): IDashboardContainer;
|
||||
containerTypeSchemaProperties: IJSONSchemaMap;
|
||||
navSectionContainerTypeSchemaProperties: IJSONSchemaMap;
|
||||
}
|
||||
|
||||
class DashboardContainerRegistry implements IDashboardContainerRegistry {
|
||||
private _containers = new Array<IDashboardContainer>();
|
||||
private _containers: { [x: string]: IDashboardContainer } = {};
|
||||
private _dashboardContainerTypeSchemaProperties: IJSONSchemaMap = {};
|
||||
private _dashboardNavSectionContainerTypeSchemaProperties: IJSONSchemaMap = {};
|
||||
|
||||
public registerContainer(tab: IDashboardContainer): void {
|
||||
this._containers.push(tab);
|
||||
public registerContainer(container: IDashboardContainer): void {
|
||||
this._containers[container.id] = container;
|
||||
}
|
||||
|
||||
public get containers(): Array<IDashboardContainer> {
|
||||
return this._containers;
|
||||
public getRegisteredContainer(id: string): IDashboardContainer {
|
||||
return this._containers[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a dashboard widget
|
||||
* @param id id of the widget
|
||||
* @param schema config schema of the widget
|
||||
* Register a dashboard container
|
||||
* @param id id of the container
|
||||
* @param schema config schema of the container
|
||||
*/
|
||||
public registerContainerType(id: string, schema: IJSONSchema): void {
|
||||
this._dashboardContainerTypeSchemaProperties[id] = schema;
|
||||
@@ -52,13 +53,26 @@ class DashboardContainerRegistry implements IDashboardContainerRegistry {
|
||||
public get containerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return deepClone(this._dashboardContainerTypeSchemaProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a dashboard nav section container
|
||||
* @param id id of the container
|
||||
* @param schema config schema of the container
|
||||
*/
|
||||
public registerNavSectionContainerType(id: string, schema: IJSONSchema): void {
|
||||
this._dashboardNavSectionContainerTypeSchemaProperties[id] = schema;
|
||||
}
|
||||
|
||||
public get navSectionContainerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return deepClone(this._dashboardNavSectionContainerTypeSchemaProperties);
|
||||
}
|
||||
}
|
||||
|
||||
const dashboardContainerRegistry = new DashboardContainerRegistry();
|
||||
Registry.add(Extensions.dashboardContainerContributions, dashboardContainerRegistry);
|
||||
|
||||
export function registerContainer(innerTab: IDashboardContainer): void {
|
||||
dashboardContainerRegistry.registerContainer(innerTab);
|
||||
export function registerContainer(container: IDashboardContainer): void {
|
||||
dashboardContainerRegistry.registerContainer(container);
|
||||
}
|
||||
|
||||
export function registerContainerType(id: string, schema: IJSONSchema): void {
|
||||
@@ -67,4 +81,12 @@ export function registerContainerType(id: string, schema: IJSONSchema): void {
|
||||
|
||||
export function generateContainerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return dashboardContainerRegistry.containerTypeSchemaProperties;
|
||||
}
|
||||
|
||||
export function registerNavSectionContainerType(id: string, schema: IJSONSchema): void {
|
||||
dashboardContainerRegistry.registerNavSectionContainerType(id, schema);
|
||||
}
|
||||
|
||||
export function generateNavSectionContainerTypeSchemaProperties(): IJSONSchemaMap {
|
||||
return dashboardContainerRegistry.navSectionContainerTypeSchemaProperties;
|
||||
}
|
||||
@@ -34,9 +34,7 @@ export interface IDashboardRegistry {
|
||||
registerDashboardProvider(id: string, properties: ProviderProperties): void;
|
||||
getProperties(id: string): ProviderProperties;
|
||||
registerTab(tab: IDashboardTab): void;
|
||||
registerTabContent(id: string, schema: IJSONSchema): void;
|
||||
tabs: Array<IDashboardTab>;
|
||||
tabContentSchemaProperties: IJSONSchemaMap;
|
||||
}
|
||||
|
||||
class DashboardRegistry implements IDashboardRegistry {
|
||||
@@ -77,19 +75,6 @@ class DashboardRegistry implements IDashboardRegistry {
|
||||
public get tabs(): Array<IDashboardTab> {
|
||||
return this._tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a dashboard widget
|
||||
* @param id id of the widget
|
||||
* @param schema config schema of the widget
|
||||
*/
|
||||
public registerTabContent(id: string, schema: IJSONSchema): void {
|
||||
this._dashboardTabContentSchemaProperties[id] = schema;
|
||||
}
|
||||
|
||||
public get tabContentSchemaProperties(): IJSONSchemaMap {
|
||||
return deepClone(this._dashboardTabContentSchemaProperties);
|
||||
}
|
||||
}
|
||||
|
||||
const dashboardRegistry = new DashboardRegistry();
|
||||
@@ -99,14 +84,6 @@ export function registerTab(tab: IDashboardTab): void {
|
||||
dashboardRegistry.registerTab(tab);
|
||||
}
|
||||
|
||||
export function registerTabContent(id: string, schema: IJSONSchema): void {
|
||||
dashboardRegistry.registerTabContent(id, schema);
|
||||
}
|
||||
|
||||
export function generateTabContentSchemaProperties(): IJSONSchemaMap {
|
||||
return dashboardRegistry.tabContentSchemaProperties;
|
||||
}
|
||||
|
||||
const dashboardPropertiesPropertyContrib: IJSONSchema = {
|
||||
description: nls.localize('dashboard.properties.property', "Defines a property to show on the dashboard"),
|
||||
type: 'object',
|
||||
|
||||
Reference in New Issue
Block a user