Added 'serverMajorVersion' key to context which is missed currently and caused failure for loading 'Create External Table' menu (#4423)

This commit is contained in:
Gene Lee
2019-03-13 13:32:04 -07:00
committed by GitHub
parent ace6012c1c
commit c9b3e2b156
2 changed files with 49 additions and 3 deletions

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

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as azdata from 'azdata';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
@@ -15,8 +16,7 @@ import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import {
DisconnectConnectionAction, AddServerAction,
DeleteConnectionAction, RefreshAction, EditServerGroupAction
}
from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
} from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
import {
ObjectExplorerActionUtilities, ManageConnectionAction, OEAction
} 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 { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
import * as constants from 'sql/common/constants';
import { ServerInfoContextKey } from 'sql/parts/connection/common/serverInfoContextKey';
/**
* Provides actions for the server tree elements
@@ -132,7 +133,13 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
private getContextKeyService(context: ObjectExplorerContext): IContextKeyService {
let scopedContextService = this._contextKeyService.createScoped();
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);
if (context.treeNode) {
treeNodeContextKey.set(context.treeNode);