mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
No browser from common (#7178)
* no browser from common * clean up some imports
This commit is contained in:
90
src/sql/workbench/browser/actions.ts
Normal file
90
src/sql/workbench/browser/actions.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { IAngularEventingService, AngularEventType } from 'sql/platform/angularEventing/common/angularEventingService';
|
||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
|
||||
import { Task } from 'sql/platform/tasks/browser/tasksRegistry';
|
||||
|
||||
import { ObjectMetadata } from 'azdata';
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
|
||||
export interface BaseActionContext {
|
||||
object?: ObjectMetadata;
|
||||
profile?: IConnectionProfile;
|
||||
}
|
||||
|
||||
export interface InsightActionContext extends BaseActionContext {
|
||||
insight: IInsightsConfig;
|
||||
}
|
||||
|
||||
export interface ManageActionContext extends BaseActionContext {
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export class ManageAction extends Action {
|
||||
public static ID = 'manage';
|
||||
public static LABEL = nls.localize('manage', "Manage");
|
||||
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IConnectionManagementService protected _connectionManagementService: IConnectionManagementService,
|
||||
@IAngularEventingService protected _angularEventingService: IAngularEventingService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(actionContext: ManageActionContext): Promise<boolean> {
|
||||
return this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
||||
() => {
|
||||
this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class InsightAction extends Action {
|
||||
public static ID = 'showInsight';
|
||||
public static LABEL = nls.localize('showDetails', "Show Details");
|
||||
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IInsightsDialogService protected _insightsDialogService: IInsightsDialogService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(actionContext: InsightActionContext): Promise<boolean> {
|
||||
this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfigureDashboardAction extends Task {
|
||||
public static readonly ID = 'configureDashboard';
|
||||
public static readonly LABEL = nls.localize('configureDashboard', "Learn How To Configure The Dashboard");
|
||||
public static readonly ICON = 'configure-dashboard';
|
||||
private static readonly configHelpUri = 'https://aka.ms/sqldashboardconfig';
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: ConfigureDashboardAction.ID,
|
||||
title: ConfigureDashboardAction.LABEL,
|
||||
iconPath: undefined,
|
||||
iconClass: ConfigureDashboardAction.ICON
|
||||
});
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor): Promise<void> {
|
||||
return accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user