mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Added 'serverMajorVersion' key to context which is missed currently and caused failure for loading 'Create External Table' menu (#4423)
This commit is contained in:
39
src/sql/parts/connection/common/serverInfoContextKey.ts
Normal file
39
src/sql/parts/connection/common/serverInfoContextKey.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { ServerInfo } from 'azdata';
|
||||||
|
|
||||||
|
export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||||
|
|
||||||
|
static ServerInfo = new RawContextKey<ServerInfo>('serverInfo', undefined);
|
||||||
|
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
|
||||||
|
|
||||||
|
private _serverInfo: IContextKey<ServerInfo>;
|
||||||
|
private _serverMajorVersion: IContextKey<string>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@IContextKeyService contextKeyService: IContextKeyService
|
||||||
|
) {
|
||||||
|
this._serverInfo = ServerInfoContextKey.ServerInfo.bindTo(contextKeyService);
|
||||||
|
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
|
||||||
|
}
|
||||||
|
|
||||||
|
set(value: ServerInfo) {
|
||||||
|
this._serverInfo.set(value);
|
||||||
|
let majorVersion = value && value.serverMajorVersion;
|
||||||
|
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
this._serverMajorVersion.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public get(): ServerInfo {
|
||||||
|
return this._serverInfo.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import * as azdata from 'azdata';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
import { TPromise } from 'vs/base/common/winjs.base';
|
||||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||||
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
|
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
|
||||||
@@ -15,8 +16,7 @@ import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
|
|||||||
import {
|
import {
|
||||||
DisconnectConnectionAction, AddServerAction,
|
DisconnectConnectionAction, AddServerAction,
|
||||||
DeleteConnectionAction, RefreshAction, EditServerGroupAction
|
DeleteConnectionAction, RefreshAction, EditServerGroupAction
|
||||||
}
|
} from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
|
||||||
from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
|
|
||||||
import {
|
import {
|
||||||
ObjectExplorerActionUtilities, ManageConnectionAction, OEAction
|
ObjectExplorerActionUtilities, ManageConnectionAction, OEAction
|
||||||
} from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
|
} from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
|
||||||
@@ -34,6 +34,7 @@ import { TreeNodeContextKey } from 'sql/parts/objectExplorer/viewlet/treeNodeCon
|
|||||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
||||||
import * as constants from 'sql/common/constants';
|
import * as constants from 'sql/common/constants';
|
||||||
|
import { ServerInfoContextKey } from 'sql/parts/connection/common/serverInfoContextKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides actions for the server tree elements
|
* Provides actions for the server tree elements
|
||||||
@@ -132,7 +133,13 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
private getContextKeyService(context: ObjectExplorerContext): IContextKeyService {
|
private getContextKeyService(context: ObjectExplorerContext): IContextKeyService {
|
||||||
let scopedContextService = this._contextKeyService.createScoped();
|
let scopedContextService = this._contextKeyService.createScoped();
|
||||||
let connectionContextKey = new ConnectionContextKey(scopedContextService);
|
let connectionContextKey = new ConnectionContextKey(scopedContextService);
|
||||||
connectionContextKey.set(context.profile);
|
let connectionProfile = context && context.profile;
|
||||||
|
connectionContextKey.set(connectionProfile);
|
||||||
|
let serverInfoContextKey = new ServerInfoContextKey(scopedContextService);
|
||||||
|
if (connectionProfile.id) {
|
||||||
|
let serverInfo = this._connectionManagementService.getServerInfo(connectionProfile.id);
|
||||||
|
serverInfoContextKey.set(serverInfo);
|
||||||
|
}
|
||||||
let treeNodeContextKey = new TreeNodeContextKey(scopedContextService);
|
let treeNodeContextKey = new TreeNodeContextKey(scopedContextService);
|
||||||
if (context.treeNode) {
|
if (context.treeNode) {
|
||||||
treeNodeContextKey.set(context.treeNode);
|
treeNodeContextKey.set(context.treeNode);
|
||||||
|
|||||||
Reference in New Issue
Block a user