mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -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);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
run(actionContext: ManageActionContext): Promise<boolean> {
|
async run(actionContext: ManageActionContext): Promise<boolean> {
|
||||||
return this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
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);
|
this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,9 @@ export class InsightAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(actionContext: InsightActionContext): Promise<void> {
|
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.
|
* 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 { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
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 {
|
export class DashboardInput extends EditorInput {
|
||||||
|
|
||||||
private _uri: string;
|
private _uri?: string;
|
||||||
public static ID: string = 'workbench.editorinputs.connectiondashboardinputs';
|
public static ID: string = 'workbench.editorinputs.connectiondashboardinputs';
|
||||||
public static SCHEMA: string = 'sqldashboard';
|
public static SCHEMA: string = 'sqldashboard';
|
||||||
|
|
||||||
private _initializedPromise: Thenable<void>;
|
private _initializedPromise: Thenable<void>;
|
||||||
private _onConnectionChanged: IDisposable;
|
private _onConnectionChanged?: IDisposable;
|
||||||
|
|
||||||
public get initializedPromise(): Thenable<void> {
|
public get initializedPromise(): Thenable<void> {
|
||||||
return this._initializedPromise;
|
return this._initializedPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _uniqueSelector: string;
|
private _uniqueSelector?: string;
|
||||||
|
|
||||||
public hasBootstrapped = false;
|
public hasBootstrapped = false;
|
||||||
// Holds the HTML content for the editor when the editor discards this input and loads another
|
// Holds the HTML content for the editor when the editor discards this input and loads another
|
||||||
private _parentContainer: HTMLElement;
|
private _parentContainer?: HTMLElement;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
_connectionProfile: IConnectionProfile,
|
_connectionProfile: IConnectionProfile,
|
||||||
@@ -98,7 +98,7 @@ export class DashboardInput extends EditorInput {
|
|||||||
&& this.connectionProfile.databaseName.toLowerCase() === 'master';
|
&& this.connectionProfile.databaseName.toLowerCase() === 'master';
|
||||||
}
|
}
|
||||||
|
|
||||||
public get uri(): string {
|
public get uri(): string | undefined {
|
||||||
return this._uri;
|
return this._uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export class DashboardInput extends EditorInput {
|
|||||||
if (this._onConnectionChanged) {
|
if (this._onConnectionChanged) {
|
||||||
this._onConnectionChanged.dispose();
|
this._onConnectionChanged.dispose();
|
||||||
}
|
}
|
||||||
this._connectionService.disconnect(this._uri);
|
this._connectionService.disconnect(this._uri!);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,6 @@ export class DashboardInput extends EditorInput {
|
|||||||
const parentNode = this._parentContainer.parentNode;
|
const parentNode = this._parentContainer.parentNode;
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
parentNode.removeChild(this._parentContainer);
|
parentNode.removeChild(this._parentContainer);
|
||||||
this._parentContainer = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ export class DashboardInput extends EditorInput {
|
|||||||
this._parentContainer = container;
|
this._parentContainer = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
get container(): HTMLElement {
|
getContainer(): HTMLElement | undefined {
|
||||||
return this._parentContainer;
|
return this._parentContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,18 +136,14 @@ export class DashboardInput extends EditorInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get connectionProfile(): IConnectionProfile {
|
public get connectionProfile(): IConnectionProfile {
|
||||||
return this._connectionService.getConnectionProfile(this._uri);
|
return this._connectionService.getConnectionProfile(this._uri!);
|
||||||
}
|
|
||||||
|
|
||||||
public resolve(refresh?: boolean): Promise<EditorModel> {
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get hasInitialized(): boolean {
|
public get hasInitialized(): boolean {
|
||||||
return !!this._uniqueSelector;
|
return !!this._uniqueSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get uniqueSelector(): string {
|
public get uniqueSelector(): string | undefined {
|
||||||
return this._uniqueSelector;
|
return this._uniqueSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +163,6 @@ export class DashboardInput extends EditorInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get tabColor(): string {
|
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 { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
import {
|
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||||
IConnectionManagementService,
|
|
||||||
IConnectionCompletionOptions, ConnectionType,
|
|
||||||
RunQueryOnConnectionMode, IConnectionResult
|
|
||||||
} from 'sql/platform/connection/common/connectionManagement';
|
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { DashboardInput } from 'sql/workbench/browser/editor/profiler/dashboardInput';
|
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
|
* 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
|
* 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
|
* @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 {
|
export function getCurrentGlobalConnection(objectExplorerService: IObjectExplorerService, connectionManagementService: IConnectionManagementService, workbenchEditorService: IEditorService, topLevelOnly: boolean = false): IConnectionProfile | undefined {
|
||||||
let connection: IConnectionProfile;
|
let connection: IConnectionProfile | undefined;
|
||||||
// object Explorer Connection
|
// object Explorer Connection
|
||||||
let objectExplorerSelection = objectExplorerService.getSelectedProfileAndDatabase();
|
let objectExplorerSelection = objectExplorerService.getSelectedProfileAndDatabase();
|
||||||
if (objectExplorerSelection) {
|
if (objectExplorerSelection) {
|
||||||
let objectExplorerProfile = objectExplorerSelection.profile;
|
if (objectExplorerSelection.profile) {
|
||||||
if (connectionManagementService.isProfileConnected(objectExplorerProfile)) {
|
if (connectionManagementService.isProfileConnected(objectExplorerSelection.profile)) {
|
||||||
if (objectExplorerSelection.databaseName && !topLevelOnly) {
|
if (objectExplorerSelection.databaseName && !topLevelOnly) {
|
||||||
connection = objectExplorerProfile.cloneWithDatabase(objectExplorerSelection.databaseName);
|
connection = objectExplorerSelection.profile.cloneWithDatabase(objectExplorerSelection.databaseName);
|
||||||
} else {
|
} else {
|
||||||
connection = objectExplorerProfile;
|
connection = objectExplorerSelection.profile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (objectExplorerService.isFocused()) {
|
if (objectExplorerService.isFocused()) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser
|
|||||||
import { alert } from 'vs/base/browser/ui/aria/aria';
|
import { alert } from 'vs/base/browser/ui/aria/aria';
|
||||||
import { IInputOptions, InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
import { IInputOptions, InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||||
import { Delayer } from 'vs/base/common/async';
|
import { Delayer } from 'vs/base/common/async';
|
||||||
import { assign } from 'vs/base/common/objects';
|
|
||||||
import { isStringArray } from 'vs/base/common/types';
|
import { isStringArray } from 'vs/base/common/types';
|
||||||
import 'vs/css!./media/explorerWidget';
|
import 'vs/css!./media/explorerWidget';
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
@@ -104,7 +103,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
|
|||||||
this._register(subscriptionToDisposable(this._bootstrap.metadataService.metadata.subscribe(
|
this._register(subscriptionToDisposable(this._bootstrap.metadataService.metadata.subscribe(
|
||||||
data => {
|
data => {
|
||||||
if (data) {
|
if (data) {
|
||||||
const objectData = ObjectMetadataWrapper.createFromObjectMetadata(data.objectMetadata);
|
const objectData = data.objectMetadata.map(o => new ObjectMetadataWrapper(o));
|
||||||
objectData.sort(ObjectMetadataWrapper.sort);
|
objectData.sort(ObjectMetadataWrapper.sort);
|
||||||
this.updateTable(objectData);
|
this.updateTable(objectData);
|
||||||
}
|
}
|
||||||
@@ -155,7 +154,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
|
|||||||
|
|
||||||
const currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
|
const currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
|
||||||
this.updateTable(data.map(d => {
|
this.updateTable(data.map(d => {
|
||||||
const item = assign({}, d.options);
|
const item = Object.assign({}, d.options);
|
||||||
const profile = new ConnectionProfile(this.capabilitiesService, currentProfile);
|
const profile = new ConnectionProfile(this.capabilitiesService, currentProfile);
|
||||||
profile.databaseName = d.options[NameProperty];
|
profile.databaseName = d.options[NameProperty];
|
||||||
item[ConnectionProfilePropertyName] = profile;
|
item[ConnectionProfilePropertyName] = profile;
|
||||||
|
|||||||
@@ -17,14 +17,12 @@ export class ObjectMetadataWrapper implements ObjectMetadata {
|
|||||||
return `${this.schema}.${this.name}`;
|
return `${this.schema}.${this.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(from?: ObjectMetadata) {
|
constructor(from: ObjectMetadata) {
|
||||||
if (from) {
|
this.metadataType = from.metadataType;
|
||||||
this.metadataType = from.metadataType;
|
this.metadataTypeName = from.metadataTypeName;
|
||||||
this.metadataTypeName = from.metadataTypeName;
|
this.urn = from.urn;
|
||||||
this.urn = from.urn;
|
this.name = from.name;
|
||||||
this.name = from.name;
|
this.schema = from.schema;
|
||||||
this.schema = from.schema;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public matches(other: ObjectMetadataWrapper): boolean {
|
public matches(other: ObjectMetadataWrapper): boolean {
|
||||||
@@ -37,14 +35,6 @@ export class ObjectMetadataWrapper implements ObjectMetadata {
|
|||||||
&& this.name === other.name;
|
&& this.name === other.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createFromObjectMetadata(objectMetadata: ObjectMetadata[]): ObjectMetadataWrapper[] {
|
|
||||||
if (!objectMetadata) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return objectMetadata.map(m => new ObjectMetadataWrapper(m));
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom sort : Table > View > Stored Procedures > Function
|
// custom sort : Table > View > Stored Procedures > Function
|
||||||
public static sort(metadata1: ObjectMetadataWrapper, metadata2: ObjectMetadataWrapper): number {
|
public static sort(metadata1: ObjectMetadataWrapper, metadata2: ObjectMetadataWrapper): number {
|
||||||
// compare the object type
|
// compare the object type
|
||||||
|
|||||||
@@ -13,44 +13,43 @@ import { FlavorProperties } from 'sql/workbench/contrib/dashboard/browser/dashbo
|
|||||||
|
|
||||||
suite('Explorer Widget Tests', () => {
|
suite('Explorer Widget Tests', () => {
|
||||||
test('Sorting dashboard search objects works correctly', () => {
|
test('Sorting dashboard search objects works correctly', () => {
|
||||||
let testMetadata = ObjectMetadataWrapper.createFromObjectMetadata(
|
let testMetadata = [
|
||||||
[
|
{
|
||||||
{
|
metadataType: MetadataType.View,
|
||||||
metadataType: MetadataType.View,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testView',
|
||||||
name: 'testView',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.Table,
|
||||||
metadataType: MetadataType.Table,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testTable',
|
||||||
name: 'testTable',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.SProc,
|
||||||
metadataType: MetadataType.SProc,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testSProc',
|
||||||
name: 'testSProc',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.Function,
|
||||||
metadataType: MetadataType.Function,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testFunction',
|
||||||
name: 'testFunction',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.View,
|
||||||
metadataType: MetadataType.View,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'firstView',
|
||||||
name: 'firstView',
|
schema: undefined
|
||||||
schema: undefined
|
}
|
||||||
}
|
].map(m => new ObjectMetadataWrapper(m));
|
||||||
]);
|
|
||||||
|
|
||||||
// If I sort the object metadata wrapper list using ExplorerWidget's sort function
|
// If I sort the object metadata wrapper list using ExplorerWidget's sort function
|
||||||
let sortedMetadata = testMetadata.slice().sort(ObjectMetadataWrapper.sort);
|
let sortedMetadata = testMetadata.slice().sort(ObjectMetadataWrapper.sort);
|
||||||
@@ -79,44 +78,43 @@ suite('Explorer Widget Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('object type filter', () => {
|
test('object type filter', () => {
|
||||||
const testMetadata = ObjectMetadataWrapper.createFromObjectMetadata(
|
const testMetadata = [
|
||||||
[
|
{
|
||||||
{
|
metadataType: MetadataType.View,
|
||||||
metadataType: MetadataType.View,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testView',
|
||||||
name: 'testView',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.Table,
|
||||||
metadataType: MetadataType.Table,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testTable',
|
||||||
name: 'testTable',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.SProc,
|
||||||
metadataType: MetadataType.SProc,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testSProc',
|
||||||
name: 'testSProc',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.Function,
|
||||||
metadataType: MetadataType.Function,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'testFunction',
|
||||||
name: 'testFunction',
|
schema: undefined
|
||||||
schema: undefined
|
},
|
||||||
},
|
{
|
||||||
{
|
metadataType: MetadataType.View,
|
||||||
metadataType: MetadataType.View,
|
metadataTypeName: undefined,
|
||||||
metadataTypeName: undefined,
|
urn: undefined,
|
||||||
urn: undefined,
|
name: 'firstView',
|
||||||
name: 'firstView',
|
schema: undefined
|
||||||
schema: undefined
|
}
|
||||||
}
|
].map(o => new ObjectMetadataWrapper(o));
|
||||||
]);
|
|
||||||
const filter = new ExplorerFilter('database', ['name']);
|
const filter = new ExplorerFilter('database', ['name']);
|
||||||
let result = filter.filter('t:', testMetadata);
|
let result = filter.filter('t:', testMetadata);
|
||||||
assert.equal(result.length, 1, 'table type filter should return only 1 item');
|
assert.equal(result.length, 1, 'table type filter should return only 1 item');
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ const DE_RESTORE_COMMAND_ID = 'dataExplorer.restore';
|
|||||||
// Restore
|
// Restore
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: DE_RESTORE_COMMAND_ID,
|
id: DE_RESTORE_COMMAND_ID,
|
||||||
handler: (accessor, args: TreeViewItemHandleArg) => {
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
const commandService = accessor.get(ICommandService);
|
if (args.$treeItem?.payload) {
|
||||||
return commandService.executeCommand(RestoreAction.ID, args.$treeItem.payload);
|
const commandService = accessor.get(ICommandService);
|
||||||
|
return commandService.executeCommand(RestoreAction.ID, args.$treeItem.payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ export class RestoreAction extends Task {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise<void> {
|
runTask(accessor: ServicesAccessor, withProfile?: IConnectionProfile): void | Promise<void> {
|
||||||
|
let profile = withProfile;
|
||||||
const configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
const configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||||
const previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures'];
|
const previewFeaturesEnabled: boolean = configurationService.getValue<{ enablePreviewFeatures: boolean }>('workbench').enablePreviewFeatures;
|
||||||
if (!previewFeaturesEnabled) {
|
if (!previewFeaturesEnabled) {
|
||||||
return accessor.get<INotificationService>(INotificationService).info(localize('restore.isPreviewFeature', "You must enable preview features in order to use restore"));
|
return accessor.get<INotificationService>(INotificationService).info(localize('restore.isPreviewFeature', "You must enable preview features in order to use restore"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class NodeContextKey extends Disposable implements IContextKey<INodeConte
|
|||||||
private readonly _viewItemKey: IContextKey<string>;
|
private readonly _viewItemKey: IContextKey<string>;
|
||||||
private readonly _nodeContextKey: IContextKey<INodeContextValue>;
|
private readonly _nodeContextKey: IContextKey<INodeContextValue>;
|
||||||
|
|
||||||
private _nodeContextUtils: MssqlNodeContext;
|
private _nodeContextUtils?: MssqlNodeContext;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||||
@@ -47,7 +47,7 @@ export class NodeContextKey extends Disposable implements IContextKey<INodeConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
set(value: INodeContextValue) {
|
set(value: INodeContextValue) {
|
||||||
if (value.node && value.node.payload) {
|
if (value.node?.payload) {
|
||||||
this._connectableKey.set(true);
|
this._connectableKey.set(true);
|
||||||
this._connectedKey.set(this.oeService.isNodeConnected(value.viewId, value.node));
|
this._connectedKey.set(this.oeService.isNodeConnected(value.viewId, value.node));
|
||||||
this._connectionContextKey.set(value.node.payload);
|
this._connectionContextKey.set(value.node.payload);
|
||||||
@@ -56,14 +56,14 @@ export class NodeContextKey extends Disposable implements IContextKey<INodeConte
|
|||||||
this._connectedKey.set(false);
|
this._connectedKey.set(false);
|
||||||
this._connectionContextKey.reset();
|
this._connectionContextKey.reset();
|
||||||
}
|
}
|
||||||
if (value.node) {
|
if (value.node?.contextValue) {
|
||||||
this._viewItemKey.set(value.node.contextValue);
|
this._viewItemKey.set(value.node.contextValue);
|
||||||
} else {
|
} else {
|
||||||
this._viewItemKey.reset();
|
this._viewItemKey.reset();
|
||||||
}
|
}
|
||||||
this._nodeContextKey.set(value);
|
this._nodeContextKey.set(value);
|
||||||
this._viewIdKey.set(value.viewId);
|
this._viewIdKey.set(value.viewId);
|
||||||
this._nodeContextUtils = new MssqlNodeContext(this._nodeContextKey.get(), this.contextKeyService,
|
this._nodeContextUtils = new MssqlNodeContext(this._nodeContextKey.get()!, this.contextKeyService,
|
||||||
this.connectionManagementService, this.capabilitiesService);
|
this.connectionManagementService, this.capabilitiesService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export class NodeContextKey extends Disposable implements IContextKey<INodeConte
|
|||||||
this._connectedKey.reset();
|
this._connectedKey.reset();
|
||||||
this._connectionContextKey.reset();
|
this._connectionContextKey.reset();
|
||||||
this._nodeContextKey.reset();
|
this._nodeContextKey.reset();
|
||||||
this._nodeContextUtils.dispose();
|
this._nodeContextUtils?.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
get(): INodeContextValue | undefined {
|
get(): INodeContextValue | undefined {
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ class TreeDataSource implements IAsyncDataSource<ITreeItem, ITreeItem> {
|
|||||||
if (node.childProvider) {
|
if (node.childProvider) {
|
||||||
return this.objectExplorerService.providerExists(node.childProvider) && node.collapsibleState !== TreeItemCollapsibleState.None;
|
return this.objectExplorerService.providerExists(node.childProvider) && node.collapsibleState !== TreeItemCollapsibleState.None;
|
||||||
}
|
}
|
||||||
return this.treeView.dataProvider && node.collapsibleState !== TreeItemCollapsibleState.None;
|
return !!this.treeView.dataProvider && node.collapsibleState !== TreeItemCollapsibleState.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(node: ITreeItem): Promise<any[]> {
|
async getChildren(node: ITreeItem): Promise<any[]> {
|
||||||
@@ -812,7 +812,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
|
|||||||
|
|
||||||
if (iconUrl || sqlIcon) {
|
if (iconUrl || sqlIcon) {
|
||||||
templateData.icon.className = 'custom-view-tree-node-item-icon';
|
templateData.icon.className = 'custom-view-tree-node-item-icon';
|
||||||
DOM.toggleClass(templateData.icon, sqlIcon, !!sqlIcon); // tracked change
|
DOM.toggleClass(templateData.icon, sqlIcon ?? '', !!sqlIcon); // tracked change
|
||||||
DOM.toggleClass(templateData.icon, 'icon', !!sqlIcon);
|
DOM.toggleClass(templateData.icon, 'icon', !!sqlIcon);
|
||||||
templateData.icon.style.backgroundImage = iconUrl ? DOM.asCSSUrl(iconUrl) : '';
|
templateData.icon.style.backgroundImage = iconUrl ? DOM.asCSSUrl(iconUrl) : '';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import { TreeItemCollapsibleState } from 'vs/workbench/common/views';
|
|||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||||
import { UserCancelledConnectionError } from 'sql/base/common/errors';
|
import { UserCancelledConnectionError } from 'sql/base/common/errors';
|
||||||
import { assign } from 'vs/base/common/objects';
|
|
||||||
|
|
||||||
export const SERVICE_ID = 'oeShimService';
|
export const SERVICE_ID = 'oeShimService';
|
||||||
export const IOEShimService = createDecorator<IOEShimService>(SERVICE_ID);
|
export const IOEShimService = createDecorator<IOEShimService>(SERVICE_ID);
|
||||||
@@ -29,7 +28,7 @@ export interface IOEShimService {
|
|||||||
disconnectNode(viewId: string, node: ITreeItem): Promise<boolean>;
|
disconnectNode(viewId: string, node: ITreeItem): Promise<boolean>;
|
||||||
providerExists(providerId: string): boolean;
|
providerExists(providerId: string): boolean;
|
||||||
isNodeConnected(viewId: string, node: ITreeItem): boolean;
|
isNodeConnected(viewId: string, node: ITreeItem): boolean;
|
||||||
getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo;
|
getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OEShimService extends Disposable implements IOEShimService {
|
export class OEShimService extends Disposable implements IOEShimService {
|
||||||
@@ -67,10 +66,14 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
reject(new Error(e.errorMessage));
|
reject(new Error(e.errorMessage));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let rootNode = this.oe.getSession(sessionResp.sessionId).rootNode;
|
let session = this.oe.getSession(sessionResp.sessionId);
|
||||||
|
if (!session) {
|
||||||
|
reject(new Error(`Could not have session for ${sessionResp.sessionId}`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
// this is how we know it was shimmed
|
// this is how we know it was shimmed
|
||||||
if (rootNode.nodePath) {
|
if (session.rootNode.nodePath) {
|
||||||
this.nodeHandleMap.set(generateNodeMapKey(viewId, node), rootNode.nodePath);
|
this.nodeHandleMap.set(generateNodeMapKey(viewId, node), session.rootNode.nodePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener.dispose();
|
listener.dispose();
|
||||||
@@ -92,9 +95,9 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
onConnectCanceled: () => {
|
onConnectCanceled: () => {
|
||||||
reject(new UserCancelledConnectionError(localize('loginCanceled', "User canceled")));
|
reject(new UserCancelledConnectionError(localize('loginCanceled', "User canceled")));
|
||||||
},
|
},
|
||||||
onConnectReject: undefined,
|
onConnectReject: () => { },
|
||||||
onConnectStart: undefined,
|
onConnectStart: () => { },
|
||||||
onDisconnect: undefined
|
onDisconnect: () => { }
|
||||||
});
|
});
|
||||||
// connection cancelled from firewall dialog
|
// connection cancelled from firewall dialog
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -110,7 +113,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
let key = generateSessionMapKey(viewId, node);
|
let key = generateSessionMapKey(viewId, node);
|
||||||
let session = this.sessionMap.get(key);
|
let session = this.sessionMap.get(key);
|
||||||
if (session) {
|
if (session) {
|
||||||
let closed = (await this.oe.closeSession(node.childProvider, this.oe.getSession(session))).success;
|
let closed = (await this.oe.closeSession(node.childProvider!, this.oe.getSession(session)!))!.success;
|
||||||
if (closed) {
|
if (closed) {
|
||||||
this.sessionMap.delete(key);
|
this.sessionMap.delete(key);
|
||||||
}
|
}
|
||||||
@@ -123,21 +126,21 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
// verify the map is correct
|
// verify the map is correct
|
||||||
let key = generateSessionMapKey(viewId, node);
|
let key = generateSessionMapKey(viewId, node);
|
||||||
if (!this.sessionMap.has(key)) {
|
if (!this.sessionMap.has(key)) {
|
||||||
this.sessionMap.set(key, await this.createSession(viewId, node.childProvider, node));
|
this.sessionMap.set(key, await this.createSession(viewId, node.childProvider!, node));
|
||||||
}
|
}
|
||||||
return this.sessionMap.get(key);
|
return this.sessionMap.get(key)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getChildren(node: ITreeItem, viewId: string): Promise<ITreeItem[]> {
|
public async getChildren(node: ITreeItem, viewId: string): Promise<ITreeItem[]> {
|
||||||
if (node.payload) {
|
if (node.payload) {
|
||||||
const sessionId = await this.getOrCreateSession(viewId, node);
|
const sessionId = await this.getOrCreateSession(viewId, node);
|
||||||
const requestHandle = this.nodeHandleMap.get(generateNodeMapKey(viewId, node)) || node.handle;
|
const requestHandle = this.nodeHandleMap.get(generateNodeMapKey(viewId, node)) || node.handle;
|
||||||
const treeNode = new TreeNode(undefined, undefined, undefined, requestHandle, undefined, undefined, undefined, undefined, undefined, undefined);
|
const treeNode = new TreeNode(undefined!, undefined!, undefined!, requestHandle, undefined!); // hack since this entire system is a hack anyways
|
||||||
treeNode.connection = new ConnectionProfile(this.capabilities, node.payload);
|
treeNode.connection = new ConnectionProfile(this.capabilities, node.payload);
|
||||||
const childrenNodes = await this.oe.refreshTreeNode({
|
const childrenNodes = await this.oe.refreshTreeNode({
|
||||||
success: undefined,
|
success: true,
|
||||||
sessionId,
|
sessionId,
|
||||||
rootNode: undefined,
|
rootNode: undefined!, // hack since this entire system is a hack anyways
|
||||||
errorMessage: undefined
|
errorMessage: undefined
|
||||||
}, treeNode);
|
}, treeNode);
|
||||||
return childrenNodes.map(n => this.treeNodeToITreeItem(viewId, n, node));
|
return childrenNodes.map(n => this.treeNodeToITreeItem(viewId, n, node));
|
||||||
@@ -169,7 +172,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
const database = node.getDatabaseName();
|
const database = node.getDatabaseName();
|
||||||
if (database) {
|
if (database) {
|
||||||
databaseChanged = true;
|
databaseChanged = true;
|
||||||
updatedPayload = assign(updatedPayload, parentNode.payload);
|
updatedPayload = Object.assign(updatedPayload, parentNode.payload);
|
||||||
updatedPayload.databaseName = node.getDatabaseName();
|
updatedPayload.databaseName = node.getDatabaseName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +190,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
payload: node.payload || (databaseChanged ? updatedPayload : parentNode.payload)
|
payload: node.payload || (databaseChanged ? updatedPayload : parentNode.payload)
|
||||||
};
|
};
|
||||||
let newTreeItem: ITreeItem = {
|
let newTreeItem: ITreeItem = {
|
||||||
parentHandle: node.parent.id,
|
parentHandle: node.parent!.id,
|
||||||
handle,
|
handle,
|
||||||
collapsibleState: node.isAlwaysLeaf ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Collapsed,
|
collapsibleState: node.isAlwaysLeaf ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Collapsed,
|
||||||
label: {
|
label: {
|
||||||
@@ -213,7 +216,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
|||||||
return this.sessionMap.has(generateSessionMapKey(viewId, node));
|
return this.sessionMap.has(generateSessionMapKey(viewId, node));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo {
|
public getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo | undefined {
|
||||||
if (this.nodeInfoMap.has(treeItem)) {
|
if (this.nodeInfoMap.has(treeItem)) {
|
||||||
return this.nodeInfoMap.get(treeItem);
|
return this.nodeInfoMap.get(treeItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
|||||||
export interface ITaskOptions {
|
export interface ITaskOptions {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
iconPath: { dark: string; light?: string; };
|
iconPath?: { dark: string; light?: string; };
|
||||||
description?: ITaskHandlerDescription;
|
description?: ITaskHandlerDescription;
|
||||||
iconClass?: string;
|
iconClass?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,9 +73,7 @@
|
|||||||
"./sql/workbench/contrib/profiler/**/*.ts", // 114 errors
|
"./sql/workbench/contrib/profiler/**/*.ts", // 114 errors
|
||||||
"./sql/workbench/contrib/query/**/*.ts", // 3191 errors
|
"./sql/workbench/contrib/query/**/*.ts", // 3191 errors
|
||||||
"./sql/workbench/contrib/queryHistory/**/*.ts", // 305 errors
|
"./sql/workbench/contrib/queryHistory/**/*.ts", // 305 errors
|
||||||
"./sql/workbench/contrib/restore/**/*.ts", // 28 errors
|
|
||||||
"./sql/workbench/contrib/scripting/**/*.ts", // 195 errors
|
"./sql/workbench/contrib/scripting/**/*.ts", // 195 errors
|
||||||
"./sql/workbench/contrib/views/**/*.ts", // 19 errors
|
|
||||||
"./sql/workbench/contrib/welcome/**/*.ts", // 66 errors
|
"./sql/workbench/contrib/welcome/**/*.ts", // 66 errors
|
||||||
"./sql/workbench/services/connection/**/*.ts", // 3244 errors
|
"./sql/workbench/services/connection/**/*.ts", // 3244 errors
|
||||||
"./sql/workbench/services/dialog/**/*.ts", // 3109 errors
|
"./sql/workbench/services/dialog/**/*.ts", // 3109 errors
|
||||||
|
|||||||
Reference in New Issue
Block a user