Task contribution (#742)

* work in progress

* set up necessary code. need to work on getting it working

* formatting

* work in progress

* work in progress

* formatting

* work in progress

* work in progress

* work in progress

* formatting

* needs a lot of work regarding how we do actions vs how extensions do actions

* formatting

* use connection profile for actions

* change action to be
This commit is contained in:
Anthony Dresser
2018-02-27 11:40:13 -08:00
committed by GitHub
parent 5adab4fafb
commit 3432dac261
23 changed files with 518 additions and 323 deletions

View File

@@ -9,7 +9,7 @@ import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { Modal } from 'sql/base/browser/ui/modal/modal';
import { IInsightsConfigDetails } from 'sql/parts/dashboard/widgets/insights/interfaces';
import { attachButtonStyler, attachModalDialogStyler, attachTableStyler } from 'sql/common/theme/styler';
import { ITaskRegistry, Extensions as TaskExtensions } from 'sql/platform/tasks/taskRegistry';
import { TaskRegistry } from 'sql/platform/tasks/common/tasks';
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
import * as TelemetryKeys from 'sql/common/telemetryKeys';
import { IInsightsDialogModel, ListResource, IInsightDialogActionContext, insertValueRegex } from 'sql/parts/insights/common/interfaces';
@@ -29,7 +29,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IListService } from 'vs/platform/list/browser/listService';
import * as nls from 'vs/nls';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Registry } from 'vs/platform/registry/common/platform';
import { IAction } from 'vs/base/common/actions';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -37,6 +36,8 @@ import * as types from 'vs/base/common/types';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { MenuRegistry, ExecuteCommandAction } from 'vs/platform/actions/common/actions';
const labelDisplay = nls.localize("item", "Item");
const valueDisplay = nls.localize("value", "Value");
@@ -127,7 +128,8 @@ export class InsightsDialogView extends Modal {
@IPartService partService: IPartService,
@IContextMenuService private _contextMenuService: IContextMenuService,
@ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService
@IContextKeyService contextKeyService: IContextKeyService,
@ICommandService private _commandService: ICommandService
) {
super(nls.localize("InsightsDialogTitle", "Insights"), TelemetryKeys.Insights, partService, telemetryService, contextKeyService);
this._model.onDataChange(e => this.build());
@@ -284,12 +286,12 @@ export class InsightsDialogView extends Modal {
this._topTableData.clear();
this._topTableData.push(inputArray);
if (this._insight.actions && this._insight.actions.types) {
const taskRegistry = Registry.as<ITaskRegistry>(TaskExtensions.TaskContribution);
let tasks = taskRegistry.idToCtorMap;
let tasks = TaskRegistry.getTasks();
for (let action of this._insight.actions.types) {
let ctor = tasks[action];
if (ctor) {
let button = this.addFooterButton(ctor.LABEL, () => {
let task = tasks.includes(action);
let commandAction = MenuRegistry.getCommand(action);
if (task) {
let button = this.addFooterButton(types.isString(commandAction.title) ? commandAction.title : commandAction.title.value, () => {
let element = this._topTable.getSelectedRows();
let resource: ListResource;
if (element && element.length > 0) {
@@ -297,7 +299,7 @@ export class InsightsDialogView extends Modal {
} else {
return;
}
this._instantiationService.createInstance(ctor, ctor.ID, ctor.LABEL, ctor.ICON).run(this.topInsightContext(resource));
this._commandService.executeCommand(action, this._connectionProfile);
}, 'left');
button.enabled = false;
this._taskButtonDisposables.push(button);
@@ -333,14 +335,14 @@ export class InsightsDialogView extends Modal {
}
private get insightActions(): TPromise<IAction[]> {
const taskRegistry = Registry.as<ITaskRegistry>(TaskExtensions.TaskContribution);
let tasks = taskRegistry.idToCtorMap;
let tasks = TaskRegistry.getTasks();
let actions = this._insight.actions.types;
let returnActions: IAction[] = [];
for (let action of actions) {
let ctor = tasks[action];
if (ctor) {
returnActions.push(this._instantiationService.createInstance(ctor, ctor.ID, ctor.LABEL, ctor.ICON));
let task = tasks.includes(action);
let commandAction = MenuRegistry.getCommand(action);
if (task) {
returnActions.push(this._instantiationService.createInstance(ExecuteCommandAction, commandAction.title, commandAction.iconClass));
}
}
return TPromise.as(returnActions);
@@ -413,4 +415,4 @@ export class InsightsDialogView extends Modal {
}
}
}
}
}