mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Strict nulls for contrib/restore and contrib/views (#12044)
* strict nulls for contrib/restore and contrib/views * remove unnecessary function * compile error
This commit is contained in:
@@ -45,13 +45,13 @@ export class ManageAction extends Action {
|
||||
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;
|
||||
}
|
||||
);
|
||||
async run(actionContext: ManageActionContext): Promise<boolean> {
|
||||
if (actionContext.profile) {
|
||||
await this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true });
|
||||
this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ export class InsightAction extends Action {
|
||||
}
|
||||
|
||||
async run(actionContext: InsightActionContext): Promise<void> {
|
||||
await this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
if (actionContext.profile) {
|
||||
await this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
|
||||
import { EditorInput } from 'vs/workbench/common/editor';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -15,22 +15,22 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
export class DashboardInput extends EditorInput {
|
||||
|
||||
private _uri: string;
|
||||
private _uri?: string;
|
||||
public static ID: string = 'workbench.editorinputs.connectiondashboardinputs';
|
||||
public static SCHEMA: string = 'sqldashboard';
|
||||
|
||||
private _initializedPromise: Thenable<void>;
|
||||
private _onConnectionChanged: IDisposable;
|
||||
private _onConnectionChanged?: IDisposable;
|
||||
|
||||
public get initializedPromise(): Thenable<void> {
|
||||
return this._initializedPromise;
|
||||
}
|
||||
|
||||
private _uniqueSelector: string;
|
||||
private _uniqueSelector?: string;
|
||||
|
||||
public hasBootstrapped = false;
|
||||
// Holds the HTML content for the editor when the editor discards this input and loads another
|
||||
private _parentContainer: HTMLElement;
|
||||
private _parentContainer?: HTMLElement;
|
||||
|
||||
constructor(
|
||||
_connectionProfile: IConnectionProfile,
|
||||
@@ -98,7 +98,7 @@ export class DashboardInput extends EditorInput {
|
||||
&& this.connectionProfile.databaseName.toLowerCase() === 'master';
|
||||
}
|
||||
|
||||
public get uri(): string {
|
||||
public get uri(): string | undefined {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export class DashboardInput extends EditorInput {
|
||||
if (this._onConnectionChanged) {
|
||||
this._onConnectionChanged.dispose();
|
||||
}
|
||||
this._connectionService.disconnect(this._uri);
|
||||
this._connectionService.disconnect(this._uri!);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ export class DashboardInput extends EditorInput {
|
||||
const parentNode = this._parentContainer.parentNode;
|
||||
if (parentNode) {
|
||||
parentNode.removeChild(this._parentContainer);
|
||||
this._parentContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ export class DashboardInput extends EditorInput {
|
||||
this._parentContainer = container;
|
||||
}
|
||||
|
||||
get container(): HTMLElement {
|
||||
getContainer(): HTMLElement | undefined {
|
||||
return this._parentContainer;
|
||||
}
|
||||
|
||||
@@ -137,18 +136,14 @@ export class DashboardInput extends EditorInput {
|
||||
}
|
||||
|
||||
public get connectionProfile(): IConnectionProfile {
|
||||
return this._connectionService.getConnectionProfile(this._uri);
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): Promise<EditorModel> {
|
||||
return undefined;
|
||||
return this._connectionService.getConnectionProfile(this._uri!);
|
||||
}
|
||||
|
||||
public get hasInitialized(): boolean {
|
||||
return !!this._uniqueSelector;
|
||||
}
|
||||
|
||||
public get uniqueSelector(): string {
|
||||
public get uniqueSelector(): string | undefined {
|
||||
return this._uniqueSelector;
|
||||
}
|
||||
|
||||
@@ -168,6 +163,6 @@ export class DashboardInput extends EditorInput {
|
||||
}
|
||||
|
||||
public get tabColor(): string {
|
||||
return this._connectionService.getTabColorForUri(this.uri);
|
||||
return this._connectionService.getTabColorForUri(this.uri!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,52 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import {
|
||||
IConnectionManagementService,
|
||||
IConnectionCompletionOptions, ConnectionType,
|
||||
RunQueryOnConnectionMode, IConnectionResult
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { DashboardInput } from 'sql/workbench/browser/editor/profiler/dashboardInput';
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -58,16 +17,17 @@ export function replaceConnection(oldUri: string, newUri: string, connectionServ
|
||||
* @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 | undefined {
|
||||
let connection: IConnectionProfile;
|
||||
let connection: IConnectionProfile | undefined;
|
||||
// object Explorer Connection
|
||||
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 (objectExplorerSelection.profile) {
|
||||
if (connectionManagementService.isProfileConnected(objectExplorerSelection.profile)) {
|
||||
if (objectExplorerSelection.databaseName && !topLevelOnly) {
|
||||
connection = objectExplorerSelection.profile.cloneWithDatabase(objectExplorerSelection.databaseName);
|
||||
} else {
|
||||
connection = objectExplorerSelection.profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (objectExplorerService.isFocused()) {
|
||||
|
||||
Reference in New Issue
Block a user