mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 09:35:38 -05:00
* dashboard improvement - WIP (#8836) * wip * wip * tabgroup * tab group * agent views * clean up * formats * feedback * fix error * contribute top level server/db dashboard tab (#8868) * tabbedPanel component (#8861) * tabbed panel * tabbed panel * fix errors * revert main.ts changes * use margin * address comments * remove orientation property * content tab group (#8878) * add databases tab * use more extensible approach * remove unnecessary code * add when expression * objects tab for database dashboard (#8892) * fix build errors * fix build error * Dashboard toolbar (#9118) * remove old toolbar with only edit and refresh * remove tasks widgets from server and databases dashboards * adding toolbar to dashboardpage and clicking new query works * restore and new notebook now do something * add backup to toolbar for database dashboards * new notebook connects to db * only show backup and restore for non-azure * new backup and restore svgs * clean up * got toolbar actions to show up from contribution * some cleanup and add database dashboard toolbar contributions * don't show all tasks when there should be no tasks * fix toolbar showing multiple times when switching opening another dashboard from OE * only show toolbar for home page * update to new icons - same icons for light and dark theme * don't show separator if there aren't any actions * read toolbar actions from tasks-widget * remove tasks widget from home dashboard page * show extension's actions in toolbar * clean up * more cleaning up * fix extension actions not always loading the first time * add configure dashboard * remove old edit icon css * change tasks back to original order * make sure tasks widget is the one being removed * collapsible tab panel (#9221) * collapsible vertical tab panel * fix lint error * comments batch 1 * pr comments * update new query icon (#9351) * Update toolbar actions (#9313) * remove edit and configure dashboard and add refresh to toolbar for other dashboard pages too * Add refresh for tabs that have container type with refresh implemented * change refresh to only refresh the current tab * remove map for tab to actions * add back configure dashboard to home toolbar * check if index is -1 before trying to remove tasks widget from widgets * Move objects widget back to database home tab (#9432) * move objects widget back to database home tab and reorder toolbar * change order of actions back to previous order * Allow extensions to add actions to home toolbar (#9269) * add support for extensions to add actions to home toolbar * fix spacing * use menu contribution point * undo previous changes that added dashboardToolbarHomeAction contribution * remove home from name * add context key for tab name * allow actions to also be added to the toolbar of other tabs * add extension contributed actions even if no tasks-widget * fix refresh being added twice after merging * hide the tab list when collapsed (#9529) * update the order of css selectors (#9606) * Update dashboard style to be closer to mockups (#9570) * update style to be closer to mockups * tab panel styling * change back tab styling for tabs in a tab contributed by an extension * change color of borders when theme changes * set dark theme active tab background to same as OE for now * update border colors * move colors to theme file * fix a few issues (#9690) * couple fixes * comments * small dashboard toolbar fixes (#9695) * fix backup icon in toolbar * fix database page toolbar border color * add back center center in common-icons.css (#9703) * change padding so bottom border shows again (#9710) * tab panel fixes (#9724) * tab panel fixes * fix package.nls.json * feedbacks (#9761) * feedbacks * remove comments Co-authored-by: Kim Santiago <31145923+kisantia@users.noreply.github.com>
190 lines
7.1 KiB
TypeScript
190 lines
7.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* 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 { IConfigurationRegistry, Extensions as ConfigurationExtension } from 'vs/platform/configuration/common/configurationRegistry';
|
|
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
|
import * as nls from 'vs/nls';
|
|
import { IExtensionPointUser, ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
|
|
|
import { ProviderProperties } from 'sql/workbench/contrib/dashboard/browser/widgets/properties/propertiesWidget.component';
|
|
import { DATABASE_DASHBOARD_TABS } from 'sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.contribution';
|
|
import { SERVER_DASHBOARD_TABS } from 'sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.contribution';
|
|
import { DASHBOARD_CONFIG_ID, DASHBOARD_TABS_KEY_PROPERTY } from 'sql/workbench/contrib/dashboard/browser/pages/dashboardPageContribution';
|
|
import { find } from 'vs/base/common/arrays';
|
|
import { IDashboardTab, IDashboardTabGroup } from 'sql/workbench/services/dashboard/browser/common/interfaces';
|
|
|
|
export const Extensions = {
|
|
DashboardContributions: 'dashboard.contributions'
|
|
};
|
|
|
|
export interface IDashboardRegistry {
|
|
registerDashboardProvider(id: string, properties: ProviderProperties): void;
|
|
getProperties(id: string): ProviderProperties;
|
|
registerTab(tab: IDashboardTab): void;
|
|
registerTabGroup(tabGroup: IDashboardTabGroup): void;
|
|
tabs: Array<IDashboardTab>;
|
|
tabGroups: Array<IDashboardTabGroup>;
|
|
}
|
|
|
|
class DashboardRegistry implements IDashboardRegistry {
|
|
private _properties = new Map<string, ProviderProperties>();
|
|
private _tabs = new Array<IDashboardTab>();
|
|
private _tabGroups = new Array<IDashboardTabGroup>();
|
|
private _configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtension.Configuration);
|
|
|
|
/**
|
|
* Register a dashboard widget
|
|
* @param id id of the widget
|
|
*/
|
|
public registerDashboardProvider(id: string, properties: ProviderProperties): void {
|
|
this._properties.set(id, properties);
|
|
}
|
|
|
|
public getProperties(id: string): ProviderProperties {
|
|
return this._properties.get(id);
|
|
}
|
|
|
|
public registerTab(tab: IDashboardTab): void {
|
|
this._tabs.push(tab);
|
|
let dashboardConfig = find(this._configurationRegistry.getConfigurations(), c => c.id === DASHBOARD_CONFIG_ID);
|
|
|
|
if (dashboardConfig) {
|
|
let dashboardDatabaseTabProperty = (<IJSONSchema>dashboardConfig.properties[DATABASE_DASHBOARD_TABS].items).properties[DASHBOARD_TABS_KEY_PROPERTY];
|
|
dashboardDatabaseTabProperty.enum.push(tab.id);
|
|
dashboardDatabaseTabProperty.enumDescriptions.push(tab.description || '');
|
|
|
|
let dashboardServerTabProperty = (<IJSONSchema>dashboardConfig.properties[SERVER_DASHBOARD_TABS].items).properties[DASHBOARD_TABS_KEY_PROPERTY];
|
|
dashboardServerTabProperty.enum.push(tab.id);
|
|
dashboardServerTabProperty.enumDescriptions.push(tab.description || '');
|
|
|
|
this._configurationRegistry.notifyConfigurationSchemaUpdated(dashboardConfig);
|
|
}
|
|
}
|
|
|
|
registerTabGroup(tabGroup: IDashboardTabGroup): void {
|
|
if (this.tabGroups.findIndex(group => group.id === tabGroup.id) === -1) {
|
|
this.tabGroups.push(tabGroup);
|
|
}
|
|
}
|
|
|
|
public get tabs(): Array<IDashboardTab> {
|
|
return this._tabs;
|
|
}
|
|
|
|
public get tabGroups(): Array<IDashboardTabGroup> {
|
|
return this._tabGroups;
|
|
}
|
|
}
|
|
|
|
const dashboardRegistry = new DashboardRegistry();
|
|
Registry.add(Extensions.DashboardContributions, dashboardRegistry);
|
|
|
|
export function registerTab(tab: IDashboardTab): void {
|
|
dashboardRegistry.registerTab(tab);
|
|
}
|
|
|
|
export function registerTabGroup(tabGroup: IDashboardTabGroup): void {
|
|
dashboardRegistry.registerTabGroup(tabGroup);
|
|
}
|
|
|
|
const dashboardPropertiesPropertyContrib: IJSONSchema = {
|
|
description: nls.localize('dashboard.properties.property', "Defines a property to show on the dashboard"),
|
|
type: 'object',
|
|
properties: {
|
|
displayName: {
|
|
description: nls.localize('dashboard.properties.property.displayName', "What value to use as a label for the property"),
|
|
type: 'string'
|
|
},
|
|
value: {
|
|
description: nls.localize('dashboard.properties.property.value', "What value in the object to access for the value"),
|
|
type: 'string'
|
|
},
|
|
ignore: {
|
|
description: nls.localize('dashboard.properties.property.ignore', "Specify values to be ignored"),
|
|
type: 'array',
|
|
items: { type: 'string' }
|
|
},
|
|
default: {
|
|
description: nls.localize('dashboard.properties.property.default', "Default value to show if ignored or no value"),
|
|
type: 'string'
|
|
}
|
|
}
|
|
};
|
|
|
|
const dashboardPropertyFlavorContrib: IJSONSchema = {
|
|
description: nls.localize('dashboard.properties.flavor', "A flavor for defining dashboard properties"),
|
|
type: 'object',
|
|
properties: {
|
|
id: {
|
|
description: nls.localize('dashboard.properties.flavor.id', "Id of the flavor"),
|
|
type: 'string'
|
|
},
|
|
condition: {
|
|
description: nls.localize('dashboard.properties.flavor.condition', "Condition to use this flavor"),
|
|
type: 'object',
|
|
properties: {
|
|
field: {
|
|
description: nls.localize('dashboard.properties.flavor.condition.field', "Field to compare to"),
|
|
type: 'string'
|
|
},
|
|
operator: {
|
|
description: nls.localize('dashboard.properties.flavor.condition.operator', "Which operator to use for comparison"),
|
|
type: 'string',
|
|
enum: ['==', '<=', '>=', '!=']
|
|
},
|
|
value: {
|
|
description: nls.localize('dashboard.properties.flavor.condition.value', "Value to compare the field to"),
|
|
type: ['string', 'boolean']
|
|
}
|
|
}
|
|
},
|
|
databaseProperties: {
|
|
description: nls.localize('dashboard.properties.databaseProperties', "Properties to show for database page"),
|
|
type: 'array',
|
|
items: dashboardPropertiesPropertyContrib
|
|
},
|
|
serverProperties: {
|
|
description: nls.localize('dashboard.properties.serverProperties', "Properties to show for server page"),
|
|
type: 'array',
|
|
items: dashboardPropertiesPropertyContrib
|
|
}
|
|
}
|
|
};
|
|
|
|
const dashboardContrib: IJSONSchema = {
|
|
description: nls.localize('carbon.extension.dashboard', "Defines that this provider supports the dashboard"),
|
|
type: 'object',
|
|
properties: {
|
|
provider: {
|
|
description: nls.localize('dashboard.id', "Provider id (ex. MSSQL)"),
|
|
type: 'string'
|
|
},
|
|
flavors: {
|
|
description: nls.localize('dashboard.properties', "Property values to show on dashboard"),
|
|
type: 'array',
|
|
items: dashboardPropertyFlavorContrib
|
|
}
|
|
}
|
|
};
|
|
|
|
ExtensionsRegistry.registerExtensionPoint<ProviderProperties | ProviderProperties[]>({ extensionPoint: 'dashboard', jsonSchema: dashboardContrib }).setHandler(extensions => {
|
|
|
|
function handleCommand(contrib: ProviderProperties, extension: IExtensionPointUser<any>) {
|
|
dashboardRegistry.registerDashboardProvider(contrib.provider, contrib);
|
|
}
|
|
|
|
for (let extension of extensions) {
|
|
const { value } = extension;
|
|
if (Array.isArray<ProviderProperties>(value)) {
|
|
for (let command of value) {
|
|
handleCommand(command, extension);
|
|
}
|
|
} else {
|
|
handleCommand(value, extension);
|
|
}
|
|
}
|
|
});
|