mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Task context + schema (#849)
* commting .d.ts changes * added serverinfo to .d.ts * maybe its working? * works * updated contrib * remove unnecessary code * fix compile errors * update task schema and add the ability to specifiy a when clause * update defaults for tasks widget * add when to restore and back up tasks to not show up for cloud servers * formatting * fixing engine * add restore to server page
This commit is contained in:
@@ -95,7 +95,7 @@ export const databaseDashboardSettingSchema: IJSONSchema = {
|
||||
sizey: 1
|
||||
},
|
||||
widget: {
|
||||
'tasks-widget': {}
|
||||
'tasks-widget': [{ name: 'backup', when: '!mssql:iscloud' }, { name: 'restore', when: '!mssql:iscloud' }, 'configureDashboard', 'newQuery']
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ let defaultVal = [
|
||||
{
|
||||
name: 'Tasks',
|
||||
widget: {
|
||||
'tasks-widget': {}
|
||||
'tasks-widget': [{ name: 'restore', when: '!mssql:iscloud' }, 'configureDashboard', 'newQuery']
|
||||
},
|
||||
gridItemConfig: {
|
||||
sizex: 1,
|
||||
|
||||
@@ -30,13 +30,17 @@ import { $, Builder } from 'vs/base/browser/builder';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { CommandsRegistry, ICommand } from 'vs/platform/commands/common/commands';
|
||||
import { MenuRegistry, ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
interface IConfig {
|
||||
tasks: Array<Object>;
|
||||
interface ITask {
|
||||
name: string;
|
||||
when: string;
|
||||
}
|
||||
|
||||
const selector = 'tasks-widget';
|
||||
|
||||
@Component({
|
||||
selector: 'tasks-widget',
|
||||
selector,
|
||||
templateUrl: decodeURI(require.toUrl('sql/parts/dashboard/widgets/tasks/tasksWidget.component.html'))
|
||||
})
|
||||
export class TasksWidget extends DashboardWidget implements IDashboardWidget, OnInit {
|
||||
@@ -58,11 +62,22 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
|
||||
) {
|
||||
super();
|
||||
this._profile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
|
||||
let tasksConfig = <IConfig>Object.values(this._config.widget)[0];
|
||||
let tasksConfig = this._config.widget[selector] as Array<string | ITask>;
|
||||
let tasks = TaskRegistry.getTasks();
|
||||
|
||||
if (tasksConfig.tasks) {
|
||||
tasks = Object.keys(tasksConfig.tasks).filter(i => tasks.includes(i));
|
||||
if (types.isArray(tasksConfig) && tasksConfig.length > 0) {
|
||||
tasks = tasksConfig.map(i => {
|
||||
if (types.isString(i)) {
|
||||
if (tasks.includes(i)) {
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
if (tasks.includes(i.name) && _bootstrap.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(i.when))) {
|
||||
return i.name;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}).filter(i => !!i);
|
||||
}
|
||||
|
||||
this._tasks = tasks.map(i => MenuRegistry.getCommand(i));
|
||||
|
||||
@@ -6,12 +6,25 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import { registerDashboardWidget } from 'sql/platform/dashboard/common/widgetRegistry';
|
||||
import { TaskRegistry } from 'sql/platform/tasks/common/tasks';
|
||||
|
||||
let tasksSchema: IJSONSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
tasks: {
|
||||
type: 'object'
|
||||
}
|
||||
const tasksSchema: IJSONSchema = {
|
||||
type: 'array',
|
||||
items: {
|
||||
anyOf: [{
|
||||
type: 'string',
|
||||
enum: TaskRegistry.getTasks()
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
enum: TaskRegistry.getTasks()
|
||||
},
|
||||
when: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user