mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Mssql edition context (#1537)
* added sql server edition context * formatting * change context key to engine edition
This commit is contained in:
@@ -6,12 +6,15 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as sqlops from 'sqlops';
|
import * as sqlops from 'sqlops';
|
||||||
|
|
||||||
|
import * as types from './types';
|
||||||
|
|
||||||
export enum BuiltInCommands {
|
export enum BuiltInCommands {
|
||||||
SetContext = 'setContext',
|
SetContext = 'setContext',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ContextKeys {
|
export enum ContextKeys {
|
||||||
ISCLOUD = 'mssql:iscloud'
|
ISCLOUD = 'mssql:iscloud',
|
||||||
|
EDITIONID = 'mssql:engineedition'
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCloudEditions = [
|
const isCloudEditions = [
|
||||||
@@ -20,7 +23,7 @@ const isCloudEditions = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export function setCommandContext(key: ContextKeys | string, value: any) {
|
export function setCommandContext(key: ContextKeys | string, value: any) {
|
||||||
return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value);
|
return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ContextProvider {
|
export default class ContextProvider {
|
||||||
@@ -33,17 +36,24 @@ export default class ContextProvider {
|
|||||||
|
|
||||||
public onDashboardOpen(e: sqlops.DashboardDocument): void {
|
public onDashboardOpen(e: sqlops.DashboardDocument): void {
|
||||||
let iscloud: boolean;
|
let iscloud: boolean;
|
||||||
if (e.profile.providerName.toLowerCase() === 'mssql' && e.serverInfo.engineEditionId) {
|
let edition: number;
|
||||||
|
if (e.profile.providerName.toLowerCase() === 'mssql' && !types.isUndefinedOrNull(e.serverInfo.engineEditionId)) {
|
||||||
if (isCloudEditions.some(i => i === e.serverInfo.engineEditionId)) {
|
if (isCloudEditions.some(i => i === e.serverInfo.engineEditionId)) {
|
||||||
iscloud = true;
|
iscloud = true;
|
||||||
} else {
|
} else {
|
||||||
iscloud = false;
|
iscloud = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edition = e.serverInfo.engineEditionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iscloud === true || iscloud === false) {
|
if (iscloud === true || iscloud === false) {
|
||||||
setCommandContext(ContextKeys.ISCLOUD, iscloud);
|
setCommandContext(ContextKeys.ISCLOUD, iscloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!types.isUndefinedOrNull(edition)) {
|
||||||
|
setCommandContext(ContextKeys.EDITIONID, edition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
|
|||||||
27
extensions/mssql/src/types.ts
Normal file
27
extensions/mssql/src/types.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const _typeof = {
|
||||||
|
number: 'number',
|
||||||
|
string: 'string',
|
||||||
|
undefined: 'undefined',
|
||||||
|
object: 'object',
|
||||||
|
function: 'function'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns whether the provided parameter is undefined or null.
|
||||||
|
*/
|
||||||
|
export function isUndefinedOrNull(obj: any): boolean {
|
||||||
|
return isUndefined(obj) || obj === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns whether the provided parameter is undefined.
|
||||||
|
*/
|
||||||
|
export function isUndefined(obj: any): boolean {
|
||||||
|
return typeof (obj) === _typeof.undefined;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user