No browser from common (#7178)

* no browser from common

* clean up some imports
This commit is contained in:
Anthony Dresser
2019-09-12 14:52:42 -07:00
committed by GitHub
parent a67e62b2d0
commit 823d136a00
134 changed files with 269 additions and 274 deletions

View File

@@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as Actions from './actions';
import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
new Actions.ConfigureDashboardAction().registerTask();
Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConfiguration({
'id': 'previewFeatures',
'title': nls.localize('previewFeatures.configTitle', "Preview Features"),
'type': 'object',
'properties': {
'workbench.enablePreviewFeatures': {
'type': 'boolean',
'default': undefined,
'description': nls.localize('previewFeatures.configEnable', "Enable unreleased preview features")
}
}
});
Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConfiguration({
'id': 'showConnectDialogOnStartup',
'title': nls.localize('showConnectDialogOnStartup', "Show connect dialog on startup"),
'type': 'object',
'properties': {
'workbench.showConnectDialogOnStartup': {
'type': 'boolean',
'default': true,
'description': nls.localize('showConnectDialogOnStartup', "Show connect dialog on startup")
}
}
});
Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConfiguration({
'id': 'enableObsoleteApiUsageNotification',
'title': nls.localize('enableObsoleteApiUsageNotificationTitle', "Obsolete API Notification"),
'type': 'object',
'properties': {
'workbench.enableObsoleteApiUsageNotification': {
'type': 'boolean',
'default': true,
'description': nls.localize('enableObsoleteApiUsageNotification', "Enable/disable obsolete API usage notification")
}
}
});

View 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();
}
}

View File

@@ -0,0 +1,245 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EditorInput, IEditorInput } from 'vs/workbench/common/editor';
import { IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { URI } from 'vs/base/common/uri';
import { QueryResultsInput } from 'sql/workbench/parts/query/common/queryResultsInput';
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
import { IQueryEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
import { QueryPlanInput } from 'sql/workbench/parts/queryPlan/common/queryPlanInput';
import { NotebookInput } from 'sql/workbench/parts/notebook/browser/models/notebookInput';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
////// Exported public functions/vars
// prefix for untitled sql editors
export const untitledFilePrefix = 'SQLQuery';
// mode identifier for SQL mode
export const sqlModeId = 'sql';
export const notebookModeId = 'notebook';
/**
* Checks if the specified input is supported by one our custom input types, and if so convert it
* to that type.
* @param input The input to check for conversion
* @param options Editor options for controlling the conversion
* @param instantiationService The instantiation service to use to create the new input types
*/
export function convertEditorInput(input: EditorInput, options: IQueryEditorOptions, instantiationService: IInstantiationService): EditorInput {
let denyQueryEditor: boolean = options && options.denyQueryEditor;
let untitledEditorInput: UntitledEditorInput = input as UntitledEditorInput;
let mode: string = (untitledEditorInput && untitledEditorInput.getMode) ? untitledEditorInput.getMode() : 'sql';
if (input && !denyQueryEditor) {
let uri: URI;
if (mode === 'sql') {
//QueryInput
uri = getQueryEditorFileUri(input);
if (uri) {
const queryResultsInput: QueryResultsInput = instantiationService.createInstance(QueryResultsInput, uri.toString(true));
let queryInput: QueryInput = instantiationService.createInstance(QueryInput, '', input, queryResultsInput, undefined);
return queryInput;
}
//QueryPlanInput
uri = getQueryPlanEditorUri(input);
if (uri) {
return instantiationService.createInstance(QueryPlanInput, uri, undefined);
}
}
//Notebook
uri = getNotebookEditorUri(input, instantiationService);
if (uri) {
let notebookInput: NotebookInput = instantiationService.createInstance(NotebookInput, input.getName(), uri, input);
return notebookInput;
}
}
return input;
}
/**
* Gets the resource of the input if it's one of the ones we support.
* @param input The IEditorInput to get the resource of
*/
export function getSupportedInputResource(input: IEditorInput): URI {
if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
if (untitledCast) {
return untitledCast.getResource();
}
}
if (input instanceof FileEditorInput) {
let fileCast: FileEditorInput = <FileEditorInput>input;
if (fileCast) {
return fileCast.getResource();
}
}
if (input instanceof ResourceEditorInput) {
let resourceCast: ResourceEditorInput = <ResourceEditorInput>input;
if (resourceCast) {
return resourceCast.getResource();
}
}
return undefined;
}
////// Non-Exported Private functions/vars
// file extensions for the inputs we support (should be all upper case for comparison)
const sqlFileTypes = ['SQL'];
const sqlPlanFileTypes = ['SQLPLAN'];
/**
* If input is a supported query editor file, return it's URI. Otherwise return undefined.
* @param input The EditorInput to retrieve the URI of
*/
function getQueryEditorFileUri(input: EditorInput): URI {
if (!input || !input.getName()) {
return undefined;
}
// If this editor is not already of type queryinput
if (!(input instanceof QueryInput)) {
// If this editor has a URI
let uri: URI = getSupportedInputResource(input);
if (uri) {
let isValidUri: boolean = !!uri && !!uri.toString;
if (isValidUri && (hasFileExtension(sqlFileTypes, input, true) || hasSqlFileMode(input))) {
return uri;
}
}
}
return undefined;
}
/**
* If input is a supported query plan editor file (.sqlplan), return it's URI. Otherwise return undefined.
* @param input The EditorInput to get the URI of
*/
function getQueryPlanEditorUri(input: EditorInput): URI {
if (!input || !input.getName()) {
return undefined;
}
// If this editor is not already of type queryinput
if (!(input instanceof QueryPlanInput)) {
let uri: URI = getSupportedInputResource(input);
if (uri) {
if (hasFileExtension(sqlPlanFileTypes, input, false)) {
return uri;
}
}
}
return undefined;
}
/**
* If input is a supported notebook editor file (.ipynb), return it's URI. Otherwise return undefined.
* @param input The EditorInput to get the URI of.
*/
function getNotebookEditorUri(input: EditorInput, instantiationService: IInstantiationService): URI {
if (!input || !input.getName()) {
return undefined;
}
// If this editor is not already of type notebook input
if (!(input instanceof NotebookInput)) {
let uri: URI = getSupportedInputResource(input);
if (uri) {
if (hasFileExtension(getNotebookFileExtensions(instantiationService), input, false) || hasNotebookFileMode(input)) {
return uri;
}
}
}
return undefined;
}
function getNotebookFileExtensions(instantiationService: IInstantiationService): string[] {
return withService<INotebookService, string[]>(instantiationService, INotebookService, notebookService => {
return notebookService.getSupportedFileExtensions();
});
}
/**
* Checks whether the given EditorInput is set to either undefined or notebook mode
* @param input The EditorInput to check the mode of
*/
function hasNotebookFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return (untitledCast && untitledCast.getMode() === notebookModeId);
}
return false;
}
function withService<TService, TResult>(instantiationService: IInstantiationService, serviceId: ServiceIdentifier<TService>, action: (service: TService) => TResult, ): TResult {
return instantiationService.invokeFunction(accessor => {
let service = accessor.get(serviceId);
return action(service);
});
}
/**
* Checks whether the given EditorInput is set to either undefined or sql mode
* @param input The EditorInput to check the mode of
*/
function hasSqlFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return untitledCast && (untitledCast.getMode() === undefined || untitledCast.getMode() === sqlModeId);
}
return false;
}
/**
* Checks whether the name of the specified input has an extension that is
* @param extensions The extensions to check for
* @param input The input to check for the specified extensions
*/
function hasFileExtension(extensions: string[], input: EditorInput, checkUntitledFileType: boolean): boolean {
// Check the extension type
let lastPeriodIndex = input.getName().lastIndexOf('.');
if (lastPeriodIndex > -1) {
let extension: string = input.getName().substr(lastPeriodIndex + 1).toUpperCase();
return !!extensions.find(x => x === extension);
}
// Check for untitled file type
if (checkUntitledFileType && input.getName().includes(untitledFilePrefix)) {
return true;
}
// Return false if not a queryEditor file
return false;
}
// Returns file mode - notebookModeId or sqlModeId
export function getFileMode(instantiationService: IInstantiationService, resource: URI): string {
if (!resource) {
return sqlModeId;
}
return withService<INotebookService, string>(instantiationService, INotebookService, notebookService => {
for (const editor of notebookService.listNotebookEditors()) {
if (editor.notebookParams.notebookUri === resource) {
return notebookModeId;
}
}
return sqlModeId;
});
}

View File

@@ -11,9 +11,9 @@ import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { memoize } from 'vs/base/common/decorators';
import { CommonServiceInterface } from 'sql/platform/bootstrap/browser/commonServiceInterface.service';
import { IModelView } from 'sql/platform/model/common/modelViewService';
import { IModelView } from 'sql/platform/model/browser/modelViewService';
import { ViewBase } from 'sql/workbench/browser/modelComponents/viewBase';
import { IModelViewService } from 'sql/platform/modelComponents/common/modelViewService';
import { IModelViewService } from 'sql/platform/modelComponents/browser/modelViewService';
import * as azdata from 'azdata';

View File

@@ -11,7 +11,7 @@ import * as nls from 'vs/nls';
import * as azdata from 'azdata';
import { IModelStore, IComponentDescriptor, IComponent } from './interfaces';
import { IItemConfig, ModelComponentTypes, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IModelView, IModelViewEventArgs } from 'sql/platform/model/common/modelViewService';
import { IModelView, IModelViewEventArgs } from 'sql/platform/model/browser/modelViewService';
import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/browser/modelComponentRegistry';
import { AngularDisposable } from 'sql/base/browser/lifecycle';
import { ModelStore } from 'sql/workbench/browser/modelComponents/modelStore';

View File

@@ -46,8 +46,8 @@ import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults';
import { ITreeItem, ITreeView } from 'sql/workbench/common/views';
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/common/objectExplorerViewTreeShim';
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim';
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/browser/nodeContext';
export class CustomTreeViewPanel extends ViewletPanel {

View File

@@ -11,7 +11,7 @@ import {
} from 'sql/platform/connection/common/connectionManagement';
import { EditDataInput } from 'sql/workbench/parts/editData/browser/editDataInput';
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
import { DashboardInput } from 'sql/workbench/parts/dashboard/browser/dashboardInput';
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';