mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
137
src/sql/platform/dashboard/common/dashboardRegistry.ts
Normal file
137
src/sql/platform/dashboard/common/dashboardRegistry.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 } from 'vs/base/common/jsonSchema';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IExtensionPointUser, ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
|
||||
import { ProviderProperties } from 'sql/parts/dashboard/widgets/properties/propertiesWidget.component';
|
||||
|
||||
export const Extensions = {
|
||||
DashboardContributions: 'dashboard.contributions'
|
||||
};
|
||||
|
||||
export interface IDashboardRegistry {
|
||||
registerDashboardProvider(id: string, properties: ProviderProperties): void;
|
||||
getProperties(id: string): ProviderProperties;
|
||||
}
|
||||
|
||||
class DashboardRegistry implements IDashboardRegistry {
|
||||
private _properties = new Map<string, ProviderProperties>();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
const dashboardRegistry = new DashboardRegistry();
|
||||
Registry.add(Extensions.DashboardContributions, dashboardRegistry);
|
||||
|
||||
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[]>('dashboard', [], 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -11,12 +11,22 @@ import * as nls from 'vs/nls';
|
||||
|
||||
export type TaskIdentifier = string;
|
||||
|
||||
export interface ActionICtor extends IConstructorSignature3<string, string, string, Action> {
|
||||
export interface ActionICtor extends IConstructorSignature3<string, string, string, TaskAction> {
|
||||
ID: string;
|
||||
LABEL: string;
|
||||
ICON: string;
|
||||
}
|
||||
|
||||
export class TaskAction extends Action {
|
||||
constructor(id: string, label: string, private _icon: string) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
get icon(): string {
|
||||
return this._icon;
|
||||
}
|
||||
}
|
||||
|
||||
export const Extensions = {
|
||||
TaskContribution: 'workbench.contributions.tasks'
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import objects = require('vs/base/common/objects');
|
||||
|
||||
import {
|
||||
ICollapsibleViewOptions, AbstractCollapsibleView, ViewSizing, CollapsibleState
|
||||
} from 'vs/base/browser/ui/splitview/splitview';
|
||||
} from 'sql/base/browser/ui/splitview/splitview';
|
||||
|
||||
export interface IFixedCollapsibleViewOptions extends ICollapsibleViewOptions {
|
||||
expandedBodySize?: number;
|
||||
@@ -34,5 +34,14 @@ export abstract class FixedCollapsibleView extends AbstractCollapsibleView {
|
||||
protected changeState(state: CollapsibleState): void {
|
||||
super.changeState(state);
|
||||
this.setFixed(this.fixedSize);
|
||||
|
||||
if (this.body) {
|
||||
if (state == CollapsibleState.COLLAPSED) {
|
||||
// make sure the body goes out of the tabindex world by hiding it
|
||||
$(this.body).hide();
|
||||
} else {
|
||||
$(this.body).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { CollapsibleView, ICollapsibleViewOptions } from 'vs/workbench/parts/views/browser/views';
|
||||
import { CollapsibleView, ICollapsibleViewOptions } from 'sql/base/browser/ui/views/browser/views';
|
||||
import { List } from 'vs/base/browser/ui/list/listWidget';
|
||||
import { IAction, ActionRunner } from 'vs/base/common/actions';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
@@ -15,7 +15,7 @@ import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
|
||||
import { CollapsibleState } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { CollapsibleState } from 'sql/base/browser/ui/splitview/splitview';
|
||||
|
||||
export class FixedListView<T> extends CollapsibleView {
|
||||
private _badge: CountBadge;
|
||||
|
||||
Reference in New Issue
Block a user