More work around isolating node imports (#6512)

* more work around isolating node imports

* rewrite query plan input

* fix hygiene errors

* fix tests

* address feedback

* remove welcome page changes
This commit is contained in:
Anthony Dresser
2019-07-30 14:01:37 -07:00
committed by GitHub
parent c99ce4de07
commit c1acf6ae93
89 changed files with 1430 additions and 1097 deletions

View File

@@ -20,11 +20,13 @@ import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilitie
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { localize } from 'vs/nls';
import { MessageLevel } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as os from 'os';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { ILogService } from 'vs/platform/log/common/log';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
export const MODAL_SHOWING_KEY = 'modalShowing';
export const MODAL_SHOWING_CONTEXT = new RawContextKey<Array<string>>(MODAL_SHOWING_KEY, []);
@@ -142,11 +144,12 @@ export abstract class Modal extends Disposable implements IThemable {
constructor(
private _title: string,
private _name: string,
private _telemetryService: ITelemetryService,
protected layoutService: IWorkbenchLayoutService,
protected _clipboardService: IClipboardService,
protected _themeService: IThemeService,
protected logService: ILogService,
private readonly _telemetryService: ITelemetryService,
protected readonly layoutService: IWorkbenchLayoutService,
protected readonly _clipboardService: IClipboardService,
protected readonly _themeService: IThemeService,
protected readonly logService: ILogService,
protected readonly textResourcePropertiesService: ITextResourcePropertiesService,
_contextKeyService: IContextKeyService,
options?: IModalOptions
) {
@@ -284,7 +287,8 @@ export abstract class Modal extends Disposable implements IThemable {
}
private getTextForClipboard(): string {
return this._messageDetailText === '' ? this._messageSummaryText : `${this._messageSummaryText}${os.EOL}========================${os.EOL}${this._messageDetailText}`;
const eol = this.textResourcePropertiesService.getEOL(URI.from({ scheme: Schemas.untitled }));
return this._messageDetailText === '' ? this._messageSummaryText : `${this._messageSummaryText}${eol}========================${eol}${this._messageDetailText}`;
}
private updateExpandMessageState() {

View File

@@ -33,6 +33,7 @@ import { append, $ } from 'vs/base/browser/dom';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
export class CategoryView extends ViewletPanel {
@@ -95,9 +96,10 @@ export class OptionsDialog extends Modal {
@ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IClipboardService clipboardService: IClipboardService,
@ILogService logService: ILogService
@ILogService logService: ILogService,
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService
) {
super(title, name, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, options);
super(title, name, telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, options);
}
public render() {

View File

@@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import {
IConnectableInput, IConnectionManagementService,
IConnectionCompletionOptions, ConnectionType,
RunQueryOnConnectionMode, IConnectionResult
} from 'sql/platform/connection/common/connectionManagement';
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput';
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
import { DashboardInput } from 'sql/workbench/parts/dashboard/common/dashboardInput';
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
export function newQuery(
connectionProfile: IConnectionProfile,
connectionService: IConnectionManagementService,
queryEditorService: IQueryEditorService,
objectExplorerService: IObjectExplorerService,
workbenchEditorService: IEditorService,
sqlContent?: string,
executeOnOpen: RunQueryOnConnectionMode = RunQueryOnConnectionMode.none
): Promise<void> {
return new Promise<void>((resolve) => {
if (!connectionProfile) {
connectionProfile = getCurrentGlobalConnection(objectExplorerService, connectionService, workbenchEditorService);
}
queryEditorService.newSqlEditor(sqlContent).then((owner: IConnectableInput) => {
// Connect our editor to the input connection
let options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: executeOnOpen, input: owner },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
if (connectionProfile) {
connectionService.connect(connectionProfile, owner.uri, options).then(() => {
resolve();
});
} else {
resolve();
}
});
});
}
export function replaceConnection(oldUri: string, newUri: string, connectionService: IConnectionManagementService): Promise<IConnectionResult> {
return new Promise<IConnectionResult>((resolve, reject) => {
let defaultResult: IConnectionResult = {
connected: false,
errorMessage: undefined,
errorCode: undefined,
callStack: undefined
};
if (connectionService) {
let connectionProfile = connectionService.getConnectionProfile(oldUri);
if (connectionProfile) {
let options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: RunQueryOnConnectionMode.none },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
connectionService.disconnect(oldUri).then(() => {
connectionService.connect(connectionProfile, newUri, options).then(result => {
resolve(result);
}, connectError => {
reject(connectError);
});
}, disconnectError => {
reject(disconnectError);
});
} else {
resolve(defaultResult);
}
} else {
resolve(defaultResult);
}
});
}
export function showBackup(connection: IConnectionProfile, backupUiService: IBackupUiService): Promise<void> {
return new Promise<void>((resolve) => {
backupUiService.showBackup(connection).then(() => {
resolve(void 0);
});
});
}
export function showRestore(connection: IConnectionProfile, restoreDialogService: IRestoreDialogController): Promise<void> {
return new Promise<void>((resolve) => {
restoreDialogService.showDialog(connection).then(() => {
resolve(void 0);
});
});
}
export function openInsight(query: IInsightsConfig, profile: IConnectionProfile, insightDialogService: IInsightsDialogService) {
insightDialogService.show(query, profile);
}
/**
* Get the current global connection, which is the connection from the active editor, unless OE
* is focused or there is no such editor, in which case it comes from the OE selection. Returns
* undefined when there is no such connection.
*
* @param topLevelOnly If true, only return top-level (i.e. connected) Object Explorer connections instead of database connections when appropriate
*/
export function getCurrentGlobalConnection(objectExplorerService: IObjectExplorerService, connectionManagementService: IConnectionManagementService, workbenchEditorService: IEditorService, topLevelOnly: boolean = false): IConnectionProfile {
let connection: IConnectionProfile;
let objectExplorerSelection = objectExplorerService.getSelectedProfileAndDatabase();
if (objectExplorerSelection) {
let objectExplorerProfile = objectExplorerSelection.profile;
if (connectionManagementService.isProfileConnected(objectExplorerProfile)) {
if (objectExplorerSelection.databaseName && !topLevelOnly) {
connection = objectExplorerProfile.cloneWithDatabase(objectExplorerSelection.databaseName);
} else {
connection = objectExplorerProfile;
}
}
if (objectExplorerService.isFocused()) {
return connection;
}
}
let activeInput = workbenchEditorService.activeEditor;
if (activeInput) {
if (activeInput instanceof QueryInput || activeInput instanceof EditDataInput || activeInput instanceof DashboardInput) {
connection = connectionManagementService.getConnectionProfile(activeInput.uri);
}
else if (activeInput instanceof ProfilerInput) {
connection = activeInput.connection;
}
}
return connection;
}