mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
* Sql on demand changes * Formating files * Removing features for new Engine Edition * Fixing Restore & Backup issue. Adding support for multiple conditions per flavor * tabifying * Formating documents * Work in progress * Resolving comments * Resolving comments. * Fixing typo
This commit is contained in:
committed by
Karl Burtram
parent
ea71c0e39c
commit
fe896e8b1a
@@ -50,17 +50,17 @@
|
|||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
{
|
{
|
||||||
"command": "adminToolExtWin.launchSsmsMinGswDialog",
|
"command": "adminToolExtWin.launchSsmsMinGswDialog",
|
||||||
"when": "isWindows && connectionProvider == MSSQL && nodeType && nodeType == Database",
|
"when": "isWindows && connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||||
"group": "z-AdminToolExt@1"
|
"group": "z-AdminToolExt@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "adminToolExtWin.launchSsmsMinPropertiesDialog",
|
"command": "adminToolExtWin.launchSsmsMinPropertiesDialog",
|
||||||
"when": "isWindows && connectionProvider == MSSQL && serverInfo && !isCloud && nodeType && nodeType == Server",
|
"when": "isWindows && connectionProvider == MSSQL && serverInfo && !isCloud && nodeType && nodeType == Server && mssql:engineedition != 11",
|
||||||
"group": "z-AdminToolExt@2"
|
"group": "z-AdminToolExt@2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "adminToolExtWin.launchSsmsMinPropertiesDialog",
|
"command": "adminToolExtWin.launchSsmsMinPropertiesDialog",
|
||||||
"when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelLogin|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|User|DatabaseRole|ApplicationRole|Schema|SecurityPolicy|ServerLevelLinkedServer)$/",
|
"when": "isWindows && connectionProvider == MSSQL && serverInfo && nodeType && mssql:engineedition != 11 && nodeType =~ /^(Database|Table|Column|Index|Statistic|View|ServerLevelLogin|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|User|DatabaseRole|ApplicationRole|Schema|SecurityPolicy|ServerLevelLinkedServer)$/",
|
||||||
"group": "z-AdminToolExt@2"
|
"group": "z-AdminToolExt@2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"description": "Manage and troubleshoot SQL Agent jobs",
|
"description": "Manage and troubleshoot SQL Agent jobs",
|
||||||
"provider": "MSSQL",
|
"provider": "MSSQL",
|
||||||
"title": "SQL Agent",
|
"title": "SQL Agent",
|
||||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||||
"container": {
|
"container": {
|
||||||
"controlhost-container": {
|
"controlhost-container": {
|
||||||
"type": "agent"
|
"type": "agent"
|
||||||
|
|||||||
@@ -35,17 +35,17 @@
|
|||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
{
|
{
|
||||||
"command": "dacFx.start",
|
"command": "dacFx.start",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||||
"group": "export"
|
"group": "export"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "dacFx.start",
|
"command": "dacFx.start",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server && mssql:engineedition != 11",
|
||||||
"group": "export"
|
"group": "export"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "dacFx.start",
|
"command": "dacFx.start",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Folder && nodeLabel == 'Databases'",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Folder && nodeLabel == 'Databases' && mssql:engineedition != 11",
|
||||||
"group": "export"
|
"group": "export"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
{
|
{
|
||||||
"command": "flatFileImport.start",
|
"command": "flatFileImport.start",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||||
"group": "import"
|
"group": "import"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
"id": "all-database-size-server-insight",
|
"id": "all-database-size-server-insight",
|
||||||
"contrib": {
|
"contrib": {
|
||||||
"name": "Database Size (MB)",
|
"name": "Database Size (MB)",
|
||||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"x": 2,
|
"x": 2,
|
||||||
"y": 2
|
"y": 2
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
"contrib": {
|
"contrib": {
|
||||||
"cacheId": "backup-history-server-insight",
|
"cacheId": "backup-history-server-insight",
|
||||||
"name": "Backup Status",
|
"name": "Backup Status",
|
||||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"x": 1,
|
"x": 1,
|
||||||
"y": 1
|
"y": 1
|
||||||
@@ -133,4 +133,4 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,11 +308,18 @@
|
|||||||
"flavors": [
|
"flavors": [
|
||||||
{
|
{
|
||||||
"flavor": "on_prem",
|
"flavor": "on_prem",
|
||||||
"condition": {
|
"conditions": [
|
||||||
"field": "isCloud",
|
{
|
||||||
"operator": "!=",
|
"field": "isCloud",
|
||||||
"value": true
|
"operator": "!=",
|
||||||
},
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "engineEditionId",
|
||||||
|
"operator": "!=",
|
||||||
|
"value": "11"
|
||||||
|
}
|
||||||
|
],
|
||||||
"databaseProperties": [
|
"databaseProperties": [
|
||||||
{
|
{
|
||||||
"displayName": "%onprem.databaseProperties.recoveryModel%",
|
"displayName": "%onprem.databaseProperties.recoveryModel%",
|
||||||
@@ -362,11 +369,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"flavor": "cloud",
|
"flavor": "cloud",
|
||||||
"condition": {
|
"conditions": [
|
||||||
"field": "isCloud",
|
{
|
||||||
"operator": "==",
|
"field": "isCloud",
|
||||||
"value": true
|
"operator": "==",
|
||||||
},
|
"value": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"databaseProperties": [
|
"databaseProperties": [
|
||||||
{
|
{
|
||||||
"displayName": "%cloud.databaseProperties.azureEdition%",
|
"displayName": "%cloud.databaseProperties.azureEdition%",
|
||||||
@@ -395,6 +404,36 @@
|
|||||||
"value": "serverEdition"
|
"value": "serverEdition"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"flavor": "on_demand",
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"field": "engineEditionId",
|
||||||
|
"operator": "==",
|
||||||
|
"value": "11"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"databaseProperties": [
|
||||||
|
{
|
||||||
|
"displayName": "%cloud.databaseProperties.compatibilityLevel%",
|
||||||
|
"value": "compatibilityLevel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": "%cloud.databaseProperties.owner%",
|
||||||
|
"value": "owner"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"serverProperties": [
|
||||||
|
{
|
||||||
|
"displayName": "%cloud.serverProperties.serverVersion%",
|
||||||
|
"value": "serverVersion"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": "%cloud.serverProperties.serverEdition%",
|
||||||
|
"value": "serverEdition"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ export enum ContextKeys {
|
|||||||
|
|
||||||
const isCloudEditions = [
|
const isCloudEditions = [
|
||||||
5,
|
5,
|
||||||
6
|
6,
|
||||||
|
11
|
||||||
];
|
];
|
||||||
|
|
||||||
export function setCommandContext(key: ContextKeys | string, value: any) {
|
export function setCommandContext(key: ContextKeys | string, value: any) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
{
|
{
|
||||||
"command": "profiler.newProfiler",
|
"command": "profiler.newProfiler",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server && mssql:engineedition != 11",
|
||||||
"group": "profiler"
|
"group": "profiler"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
{
|
{
|
||||||
"command": "schemaCompare.start",
|
"command": "schemaCompare.start",
|
||||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||||
"group": "export"
|
"group": "export"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -109,11 +109,11 @@
|
|||||||
"tasks-widget": [
|
"tasks-widget": [
|
||||||
{
|
{
|
||||||
"name": "backup",
|
"name": "backup",
|
||||||
"when": "!mssql:iscloud"
|
"when": "!mssql:iscloud && mssql:engineedition != 11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "restore",
|
"name": "restore",
|
||||||
"when": "!mssql:iscloud"
|
"when": "!mssql:iscloud && mssql:engineedition != 11"
|
||||||
},
|
},
|
||||||
"configureDashboard",
|
"configureDashboard",
|
||||||
"newQuery"
|
"newQuery"
|
||||||
|
|||||||
16
src/sql/azdata.d.ts
vendored
16
src/sql/azdata.d.ts
vendored
@@ -429,6 +429,22 @@ declare module 'azdata' {
|
|||||||
options: { [key: string]: any };
|
options: { [key: string]: any };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The possible values of the server engine edition
|
||||||
|
*/
|
||||||
|
export enum DatabaseEngineEdition {
|
||||||
|
Unknown = 0,
|
||||||
|
Personal = 1,
|
||||||
|
Standard = 2,
|
||||||
|
Enterprise = 3,
|
||||||
|
Express = 4,
|
||||||
|
SqlDatabase = 5,
|
||||||
|
SqlDataWarehouse = 6,
|
||||||
|
SqlStretchDatabase = 7,
|
||||||
|
SqlManagedInstance = 8,
|
||||||
|
SqlOnDemand = 11
|
||||||
|
}
|
||||||
|
|
||||||
export interface DataProvider {
|
export interface DataProvider {
|
||||||
handle?: number;
|
handle?: number;
|
||||||
readonly providerId: string;
|
readonly providerId: string;
|
||||||
|
|||||||
@@ -558,7 +558,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
StepCompletionAction: sqlExtHostTypes.StepCompletionAction,
|
StepCompletionAction: sqlExtHostTypes.StepCompletionAction,
|
||||||
AgentSubSystem: sqlExtHostTypes.AgentSubSystem,
|
AgentSubSystem: sqlExtHostTypes.AgentSubSystem,
|
||||||
ExtensionNodeType: sqlExtHostTypes.ExtensionNodeType,
|
ExtensionNodeType: sqlExtHostTypes.ExtensionNodeType,
|
||||||
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode
|
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode,
|
||||||
|
DatabaseEngineEdition: sqlExtHostTypes.DatabaseEngineEdition
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,22 @@ export enum Orientation {
|
|||||||
Vertical = 'vertial'
|
Vertical = 'vertial'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The possible values of the server engine edition
|
||||||
|
*/
|
||||||
|
export enum DatabaseEngineEdition {
|
||||||
|
Unknown = 0,
|
||||||
|
Personal = 1,
|
||||||
|
Standard = 2,
|
||||||
|
Enterprise = 3,
|
||||||
|
Express = 4,
|
||||||
|
SqlDatabase = 5,
|
||||||
|
SqlDataWarehouse = 6,
|
||||||
|
SqlStretchDatabase = 7,
|
||||||
|
SqlManagedInstance = 8,
|
||||||
|
SqlOnDemand = 11
|
||||||
|
}
|
||||||
|
|
||||||
export interface ToolbarLayout {
|
export interface ToolbarLayout {
|
||||||
orientation: Orientation;
|
orientation: Orientation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ const targetDatabaseEngineEditionMap = {
|
|||||||
4: 'SqlServerExpressEdition',
|
4: 'SqlServerExpressEdition',
|
||||||
5: 'SqlAzureDatabaseEdition',
|
5: 'SqlAzureDatabaseEdition',
|
||||||
6: 'SqlDatawarehouseEdition',
|
6: 'SqlDatawarehouseEdition',
|
||||||
7: 'SqlServerStretchEdition'
|
7: 'SqlServerStretchEdition',
|
||||||
|
11: 'SqlServerSqlOnDemandEdition',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/tr
|
|||||||
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
||||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
|
||||||
new BackupAction().registerTask();
|
new BackupAction().registerTask();
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('backup', "Backup")
|
title: localize('backup', "Backup")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database), MssqlNodeContext.IsCloud.toNegated())
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database), MssqlNodeContext.IsCloud.toNegated(), MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// oe
|
// oe
|
||||||
@@ -61,7 +62,8 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
id: OE_BACKUP_COMMAND_ID,
|
id: OE_BACKUP_COMMAND_ID,
|
||||||
title: localize('backup', "Backup")
|
title: localize('backup', "Backup")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(TreeNodeContextKey.NodeType.isEqualTo(NodeType.Database), ConnectionContextKey.Provider.isEqualTo(mssqlProviderName), ServerInfoContextKey.IsCloud.toNegated())
|
when: ContextKeyExpr.and(TreeNodeContextKey.NodeType.isEqualTo(NodeType.Database), ConnectionContextKey.Provider.isEqualTo(mssqlProviderName),
|
||||||
|
ServerInfoContextKey.IsCloud.toNegated(), ServerInfoContextKey.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// dashboard explorer
|
// dashboard explorer
|
||||||
@@ -76,6 +78,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
|||||||
id: ExplorerBackUpActionID,
|
id: ExplorerBackUpActionID,
|
||||||
title: BackupAction.LABEL
|
title: BackupAction.LABEL
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('database'), ItemContextKey.ConnectionProvider.isEqualTo('mssql'), ItemContextKey.IsCloud.toNegated()),
|
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('database'), ItemContextKey.ConnectionProvider.isEqualTo('mssql'),
|
||||||
|
ItemContextKey.IsCloud.toNegated(), ItemContextKey.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString())),
|
||||||
order: 2
|
order: 2
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { ServerInfo } from 'azdata';
|
import { ServerInfo } from 'azdata';
|
||||||
|
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
|
||||||
export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||||
|
|
||||||
@@ -12,11 +13,13 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
|||||||
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
|
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
|
||||||
static IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
static IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
||||||
static IsBigDataCluster = new RawContextKey<boolean>('isBigDataCluster', undefined);
|
static IsBigDataCluster = new RawContextKey<boolean>('isBigDataCluster', undefined);
|
||||||
|
static EngineEdition = new RawContextKey<number>('engineEdition', undefined);
|
||||||
|
|
||||||
private _serverInfo: IContextKey<ServerInfo>;
|
private _serverInfo: IContextKey<ServerInfo>;
|
||||||
private _serverMajorVersion: IContextKey<string>;
|
private _serverMajorVersion: IContextKey<string>;
|
||||||
private _isCloud: IContextKey<boolean>;
|
private _isCloud: IContextKey<boolean>;
|
||||||
private _isBigDataCluster: IContextKey<boolean>;
|
private _isBigDataCluster: IContextKey<boolean>;
|
||||||
|
private _engineEdition: IContextKey<number>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IContextKeyService contextKeyService: IContextKeyService
|
@IContextKeyService contextKeyService: IContextKeyService
|
||||||
@@ -25,6 +28,7 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
|||||||
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
|
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
|
||||||
this._isCloud = ServerInfoContextKey.IsCloud.bindTo(contextKeyService);
|
this._isCloud = ServerInfoContextKey.IsCloud.bindTo(contextKeyService);
|
||||||
this._isBigDataCluster = ServerInfoContextKey.IsBigDataCluster.bindTo(contextKeyService);
|
this._isBigDataCluster = ServerInfoContextKey.IsBigDataCluster.bindTo(contextKeyService);
|
||||||
|
this._engineEdition = ServerInfoContextKey.EngineEdition.bindTo(contextKeyService);
|
||||||
}
|
}
|
||||||
|
|
||||||
set(value: ServerInfo) {
|
set(value: ServerInfo) {
|
||||||
@@ -33,12 +37,15 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
|||||||
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
|
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
|
||||||
this._isCloud.set(value && value.isCloud);
|
this._isCloud.set(value && value.isCloud);
|
||||||
this._isBigDataCluster.set(value && value.options && value.options['isBigDataCluster']);
|
this._isBigDataCluster.set(value && value.options && value.options['isBigDataCluster']);
|
||||||
|
let engineEditionId = value && value.engineEditionId;
|
||||||
|
engineEditionId ? this._engineEdition.set(engineEditionId) : this._engineEdition.set(DatabaseEngineEdition.Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(): void {
|
reset(): void {
|
||||||
this._serverMajorVersion.reset();
|
this._serverMajorVersion.reset();
|
||||||
this._isCloud.reset();
|
this._isCloud.reset();
|
||||||
this._isBigDataCluster.reset();
|
this._isBigDataCluster.reset();
|
||||||
|
this._engineEdition.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(): ServerInfo {
|
public get(): ServerInfo {
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ export const databaseDashboardSettingSchema: IJSONSchema = {
|
|||||||
'tasks-widget': [
|
'tasks-widget': [
|
||||||
'newQuery',
|
'newQuery',
|
||||||
'mssqlCluster.task.newNotebook',
|
'mssqlCluster.task.newNotebook',
|
||||||
{ name: 'backup', when: '!mssql:iscloud' },
|
{ name: 'backup', when: '!mssql:iscloud && mssql:engineedition != 11' },
|
||||||
{ name: 'restore', when: '!mssql:iscloud' },
|
{ name: 'restore', when: '!mssql:iscloud && mssql:engineedition != 11' },
|
||||||
'configureDashboard'
|
'configureDashboard'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ const defaultVal = [
|
|||||||
{
|
{
|
||||||
name: 'Tasks',
|
name: 'Tasks',
|
||||||
widget: {
|
widget: {
|
||||||
'tasks-widget': [{ name: 'restore', when: '!mssql:iscloud' }, 'configureDashboard', 'newQuery', 'mssqlCluster.task.newNotebook']
|
'tasks-widget': [{ name: 'restore', when: '!mssql:iscloud && mssql:engineedition != 11' }, 'configureDashboard', 'newQuery', 'mssqlCluster.task.newNotebook']
|
||||||
},
|
},
|
||||||
gridItemConfig: {
|
gridItemConfig: {
|
||||||
sizex: 1,
|
sizex: 1,
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ export class ExplorerController extends TreeDefaults.DefaultController {
|
|||||||
this.contextKey.set({
|
this.contextKey.set({
|
||||||
resource: element,
|
resource: element,
|
||||||
providerName: this.bootStrapService.connectionManagementService.connectionInfo.providerId,
|
providerName: this.bootStrapService.connectionManagementService.connectionInfo.providerId,
|
||||||
isCloud: this.bootStrapService.connectionManagementService.connectionInfo.serverInfo.isCloud
|
isCloud: this.bootStrapService.connectionManagementService.connectionInfo.serverInfo.isCloud,
|
||||||
|
engineEdition: this.bootStrapService.connectionManagementService.connectionInfo.serverInfo.engineEditionId
|
||||||
});
|
});
|
||||||
|
|
||||||
let context: ManageActionContext | BaseActionContext;
|
let context: ManageActionContext | BaseActionContext;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface IContextValue {
|
|||||||
resource: ContextResource;
|
resource: ContextResource;
|
||||||
providerName: string;
|
providerName: string;
|
||||||
isCloud: boolean;
|
isCloud: boolean;
|
||||||
|
engineEdition: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ItemContextKey extends Disposable implements IContextKey<IContextValue> {
|
export class ItemContextKey extends Disposable implements IContextKey<IContextValue> {
|
||||||
@@ -23,11 +24,13 @@ export class ItemContextKey extends Disposable implements IContextKey<IContextVa
|
|||||||
static readonly Item = new RawContextKey<IContextValue>('item', undefined);
|
static readonly Item = new RawContextKey<IContextValue>('item', undefined);
|
||||||
static readonly ConnectionProvider = new RawContextKey<string>('provider', undefined);
|
static readonly ConnectionProvider = new RawContextKey<string>('provider', undefined);
|
||||||
static readonly IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
static readonly IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
||||||
|
static readonly EngineEdition = new RawContextKey<number>('engineEdition', undefined);
|
||||||
|
|
||||||
private _itemTypeKey: IContextKey<string>;
|
private _itemTypeKey: IContextKey<string>;
|
||||||
private _itemKey: IContextKey<IContextValue>;
|
private _itemKey: IContextKey<IContextValue>;
|
||||||
private _connectionProviderKey: IContextKey<string>;
|
private _connectionProviderKey: IContextKey<string>;
|
||||||
private _isCloudKey: IContextKey<boolean>;
|
private _isCloudKey: IContextKey<boolean>;
|
||||||
|
private _engineEditionKey: IContextKey<number>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IContextKeyService contextKeyService: IContextKeyService
|
@IContextKeyService contextKeyService: IContextKeyService
|
||||||
@@ -38,12 +41,14 @@ export class ItemContextKey extends Disposable implements IContextKey<IContextVa
|
|||||||
this._itemKey = ItemContextKey.Item.bindTo(contextKeyService);
|
this._itemKey = ItemContextKey.Item.bindTo(contextKeyService);
|
||||||
this._connectionProviderKey = ItemContextKey.ConnectionProvider.bindTo(contextKeyService);
|
this._connectionProviderKey = ItemContextKey.ConnectionProvider.bindTo(contextKeyService);
|
||||||
this._isCloudKey = ItemContextKey.IsCloud.bindTo(contextKeyService);
|
this._isCloudKey = ItemContextKey.IsCloud.bindTo(contextKeyService);
|
||||||
|
this._engineEditionKey = ItemContextKey.EngineEdition.bindTo(contextKeyService);
|
||||||
}
|
}
|
||||||
|
|
||||||
set(value: IContextValue) {
|
set(value: IContextValue) {
|
||||||
this._itemKey.set(value);
|
this._itemKey.set(value);
|
||||||
this._connectionProviderKey.set(value.providerName.toLowerCase());
|
this._connectionProviderKey.set(value.providerName.toLowerCase());
|
||||||
this._isCloudKey.set(value.isCloud);
|
this._isCloudKey.set(value.isCloud);
|
||||||
|
this._engineEditionKey.set(value.engineEdition);
|
||||||
if (value.resource instanceof ObjectMetadataWrapper) {
|
if (value.resource instanceof ObjectMetadataWrapper) {
|
||||||
switch (value.resource.metadataType) {
|
switch (value.resource.metadataType) {
|
||||||
case MetadataType.Function:
|
case MetadataType.Function:
|
||||||
@@ -69,6 +74,7 @@ export class ItemContextKey extends Disposable implements IContextKey<IContextVa
|
|||||||
this._itemKey.reset();
|
this._itemKey.reset();
|
||||||
this._connectionProviderKey.reset();
|
this._connectionProviderKey.reset();
|
||||||
this._isCloudKey.reset();
|
this._isCloudKey.reset();
|
||||||
|
this._engineEditionKey.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
get(): IContextValue | undefined {
|
get(): IContextValue | undefined {
|
||||||
|
|||||||
@@ -16,11 +16,18 @@ export const properties: Array<ProviderProperties> = [
|
|||||||
flavors: [
|
flavors: [
|
||||||
{
|
{
|
||||||
flavor: 'on_prem',
|
flavor: 'on_prem',
|
||||||
condition: {
|
conditions: [
|
||||||
field: 'isCloud',
|
{
|
||||||
operator: '!=',
|
field: 'isCloud',
|
||||||
value: true
|
operator: '!=',
|
||||||
},
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'engineEditionId',
|
||||||
|
operator: '!=',
|
||||||
|
value: '11'
|
||||||
|
}
|
||||||
|
],
|
||||||
databaseProperties: [
|
databaseProperties: [
|
||||||
{
|
{
|
||||||
displayName: nls.localize('recoveryModel', "Recovery Model"),
|
displayName: nls.localize('recoveryModel', "Recovery Model"),
|
||||||
@@ -70,11 +77,13 @@ export const properties: Array<ProviderProperties> = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
flavor: 'cloud',
|
flavor: 'cloud',
|
||||||
condition: {
|
conditions: [
|
||||||
field: 'isCloud',
|
{
|
||||||
operator: '==',
|
field: 'isCloud',
|
||||||
value: true
|
operator: '==',
|
||||||
},
|
value: true
|
||||||
|
}
|
||||||
|
],
|
||||||
databaseProperties: [
|
databaseProperties: [
|
||||||
{
|
{
|
||||||
displayName: azureEditionDisplayName,
|
displayName: azureEditionDisplayName,
|
||||||
@@ -103,7 +112,37 @@ export const properties: Array<ProviderProperties> = [
|
|||||||
value: 'serverEdition'
|
value: 'serverEdition'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
flavor: 'on_demand',
|
||||||
|
conditions: [
|
||||||
|
{
|
||||||
|
field: 'engineEditionId',
|
||||||
|
operator: '==',
|
||||||
|
value: '11'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
databaseProperties: [
|
||||||
|
{
|
||||||
|
displayName: nls.localize('compatibilityLevel', "Compatibility Level"),
|
||||||
|
value: 'compatibilityLevel'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: nls.localize('owner', "Owner"),
|
||||||
|
value: 'owner'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
serverProperties: [
|
||||||
|
{
|
||||||
|
displayName: nls.localize('version', "Version"),
|
||||||
|
value: 'serverVersion'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: azureType,
|
||||||
|
value: 'serverEdition'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -25,15 +25,18 @@ export interface PropertiesConfig {
|
|||||||
|
|
||||||
export interface FlavorProperties {
|
export interface FlavorProperties {
|
||||||
flavor: string;
|
flavor: string;
|
||||||
condition?: {
|
condition?: ConditionProperties;
|
||||||
field: string;
|
conditions?: Array<ConditionProperties>;
|
||||||
operator: '==' | '<=' | '>=' | '!=';
|
|
||||||
value: string | boolean;
|
|
||||||
};
|
|
||||||
databaseProperties: Array<Property>;
|
databaseProperties: Array<Property>;
|
||||||
serverProperties: Array<Property>;
|
serverProperties: Array<Property>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ConditionProperties {
|
||||||
|
field: string;
|
||||||
|
operator: '==' | '<=' | '>=' | '!=';
|
||||||
|
value: string | boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ProviderProperties {
|
export interface ProviderProperties {
|
||||||
provider: string;
|
provider: string;
|
||||||
flavors: Array<FlavorProperties>;
|
flavors: Array<FlavorProperties>;
|
||||||
@@ -139,20 +142,23 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const flavorArray = providerProperties.flavors.filter((item) => {
|
const flavorArray = providerProperties.flavors.filter((item) => {
|
||||||
const condition = this._connection.serverInfo[item.condition.field];
|
|
||||||
switch (item.condition.operator) {
|
// For backward compatibility we are supporting array of conditions and single condition.
|
||||||
case '==':
|
// If nothing is specified, we return false.
|
||||||
return condition === item.condition.value;
|
if (item.conditions) {
|
||||||
case '!=':
|
let conditionResult = true;
|
||||||
return condition !== item.condition.value;
|
for (let i = 0; i < item.conditions.length; i++) {
|
||||||
case '>=':
|
conditionResult = conditionResult && this.getConditionResult(item, item.conditions[i]);
|
||||||
return condition >= item.condition.value;
|
}
|
||||||
case '<=':
|
|
||||||
return condition <= item.condition.value;
|
return conditionResult;
|
||||||
default:
|
}
|
||||||
this.logService.error('Could not parse operator: "', item.condition.operator,
|
else if (item.condition) {
|
||||||
'" on item "', item, '"');
|
return this.getConditionResult(item, item.condition);
|
||||||
return false;
|
}
|
||||||
|
else {
|
||||||
|
this.logService.error('No condition was specified.');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -224,6 +230,31 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getConditionResult(item: FlavorProperties, conditionItem: ConditionProperties): boolean {
|
||||||
|
let condition = this._connection.serverInfo[conditionItem.field];
|
||||||
|
|
||||||
|
// If we need to compare strings, then we should ensure that condition is string
|
||||||
|
// Otherwise tripple equals/unequals would return false values
|
||||||
|
if (typeof conditionItem.value === 'string') {
|
||||||
|
condition = condition.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (conditionItem.operator) {
|
||||||
|
case '==':
|
||||||
|
return condition === conditionItem.value;
|
||||||
|
case '!=':
|
||||||
|
return condition !== conditionItem.value;
|
||||||
|
case '>=':
|
||||||
|
return condition >= conditionItem.value;
|
||||||
|
case '<=':
|
||||||
|
return condition <= conditionItem.value;
|
||||||
|
default:
|
||||||
|
this.logService.error('Could not parse operator: "', conditionItem.operator,
|
||||||
|
'" on item "', item, '"');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private getValueOrDefault<T>(infoObject: ServerInfo | {}, propertyValue: string, defaultVal?: any): T {
|
private getValueOrDefault<T>(infoObject: ServerInfo | {}, propertyValue: string, defaultVal?: any): T {
|
||||||
let val: T = undefined;
|
let val: T = undefined;
|
||||||
if (infoObject) {
|
if (infoObject) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/browser/mssql
|
|||||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
|
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
|
||||||
// Data-Tier Application Wizard
|
// Data-Tier Application Wizard
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
@@ -20,7 +21,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('dacFx', "Data-tier Application Wizard")
|
title: localize('dacFx', "Data-tier Application Wizard")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.IsDatabaseOrServer)
|
MssqlNodeContext.IsDatabaseOrServer, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Folder),
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Folder),
|
||||||
MssqlNodeContext.NodeLabel.isEqualTo('Databases'))
|
MssqlNodeContext.NodeLabel.isEqualTo('Databases'),
|
||||||
|
MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// Profiler
|
// Profiler
|
||||||
@@ -45,7 +47,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('profiler', "Launch Profiler")
|
title: localize('profiler', "Launch Profiler")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Server))
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Server), MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// Flat File Import
|
// Flat File Import
|
||||||
@@ -69,7 +71,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('schemaCompare', "Schema Compare")
|
title: localize('schemaCompare', "Schema Compare")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database))
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database), MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate Scripts Action
|
// Generate Scripts Action
|
||||||
@@ -82,7 +84,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database),
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database),
|
||||||
MssqlNodeContext.IsWindows)
|
MssqlNodeContext.IsWindows, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// Properties Action
|
// Properties Action
|
||||||
@@ -95,7 +97,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Server), ContextKeyExpr.not('isCloud'),
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Server), ContextKeyExpr.not('isCloud'),
|
||||||
MssqlNodeContext.IsWindows)
|
MssqlNodeContext.IsWindows, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
@@ -106,6 +108,6 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('properties', "Properties")
|
title: localize('properties', "Properties")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.IsWindows,
|
MssqlNodeContext.IsWindows, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()),
|
||||||
ContextKeyRegexExpr.create('nodeType', /^(Database|Table|Column|Index|Statistic|View|ServerLevelLogin|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|User|DatabaseRole|ApplicationRole|Schema|SecurityPolicy|ServerLevelLinkedServer)$/))
|
ContextKeyRegexExpr.create('nodeType', /^(Database|Table|Column|Index|Statistic|View|ServerLevelLogin|ServerLevelServerRole|ServerLevelCredential|ServerLevelServerAudit|ServerLevelServerAuditSpecification|StoredProcedure|ScalarValuedFunction|TableValuedFunction|AggregateFunction|Synonym|Assembly|UserDefinedDataType|UserDefinedType|UserDefinedTableType|Sequence|User|DatabaseRole|ApplicationRole|Schema|SecurityPolicy|ServerLevelLinkedServer)$/))
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +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 * as azdata from 'azdata';
|
||||||
import { INodeContextValue } from 'sql/workbench/parts/dataExplorer/browser/nodeContext';
|
import { INodeContextValue } from 'sql/workbench/parts/dataExplorer/browser/nodeContext';
|
||||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
@@ -11,7 +12,7 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
|||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||||
import { ExtensionNodeType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ExtensionNodeType, DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
import { isWindows } from 'vs/base/common/platform';
|
import { isWindows } from 'vs/base/common/platform';
|
||||||
|
|
||||||
export class MssqlNodeContext extends Disposable {
|
export class MssqlNodeContext extends Disposable {
|
||||||
@@ -32,6 +33,7 @@ export class MssqlNodeContext extends Disposable {
|
|||||||
static IsCloud = new RawContextKey<boolean>('isCloud', false);
|
static IsCloud = new RawContextKey<boolean>('isCloud', false);
|
||||||
static NodeType = new RawContextKey<string>('nodeType', undefined);
|
static NodeType = new RawContextKey<string>('nodeType', undefined);
|
||||||
static NodeLabel = new RawContextKey<string>('nodeLabel', undefined);
|
static NodeLabel = new RawContextKey<string>('nodeLabel', undefined);
|
||||||
|
static EngineEdition = new RawContextKey<number>('engineEdition', DatabaseEngineEdition.Unknown);
|
||||||
|
|
||||||
// Scripting context keys
|
// Scripting context keys
|
||||||
static CanScriptAsSelect = new RawContextKey<boolean>('canScriptAsSelect', false);
|
static CanScriptAsSelect = new RawContextKey<boolean>('canScriptAsSelect', false);
|
||||||
@@ -45,6 +47,7 @@ export class MssqlNodeContext extends Disposable {
|
|||||||
private nodeTypeKey: IContextKey<string>;
|
private nodeTypeKey: IContextKey<string>;
|
||||||
private nodeLabelKey: IContextKey<string>;
|
private nodeLabelKey: IContextKey<string>;
|
||||||
private isDatabaseOrServerKey: IContextKey<boolean>;
|
private isDatabaseOrServerKey: IContextKey<boolean>;
|
||||||
|
private engineEditionKey: IContextKey<number>;
|
||||||
|
|
||||||
private canScriptAsSelectKey: IContextKey<boolean>;
|
private canScriptAsSelectKey: IContextKey<boolean>;
|
||||||
private canEditDataKey: IContextKey<boolean>;
|
private canEditDataKey: IContextKey<boolean>;
|
||||||
@@ -67,6 +70,7 @@ export class MssqlNodeContext extends Disposable {
|
|||||||
if (node.payload) {
|
if (node.payload) {
|
||||||
this.setNodeProvider();
|
this.setNodeProvider();
|
||||||
this.setIsCloud();
|
this.setIsCloud();
|
||||||
|
this.setEngineEdition();
|
||||||
if (node.type) {
|
if (node.type) {
|
||||||
this.setIsDatabaseOrServer();
|
this.setIsDatabaseOrServer();
|
||||||
this.nodeTypeKey.set(node.type);
|
this.nodeTypeKey.set(node.type);
|
||||||
@@ -84,6 +88,7 @@ export class MssqlNodeContext extends Disposable {
|
|||||||
|
|
||||||
private bindContextKeys(): void {
|
private bindContextKeys(): void {
|
||||||
this.isCloudKey = MssqlNodeContext.IsCloud.bindTo(this.contextKeyService);
|
this.isCloudKey = MssqlNodeContext.IsCloud.bindTo(this.contextKeyService);
|
||||||
|
this.engineEditionKey = MssqlNodeContext.EngineEdition.bindTo(this.contextKeyService);
|
||||||
this.nodeTypeKey = MssqlNodeContext.NodeType.bindTo(this.contextKeyService);
|
this.nodeTypeKey = MssqlNodeContext.NodeType.bindTo(this.contextKeyService);
|
||||||
this.nodeLabelKey = MssqlNodeContext.NodeLabel.bindTo(this.contextKeyService);
|
this.nodeLabelKey = MssqlNodeContext.NodeLabel.bindTo(this.contextKeyService);
|
||||||
this.isDatabaseOrServerKey = MssqlNodeContext.IsDatabaseOrServer.bindTo(this.contextKeyService);
|
this.isDatabaseOrServerKey = MssqlNodeContext.IsDatabaseOrServer.bindTo(this.contextKeyService);
|
||||||
@@ -110,15 +115,34 @@ export class MssqlNodeContext extends Disposable {
|
|||||||
* Helper function to tell whether a connected node is cloud or not
|
* Helper function to tell whether a connected node is cloud or not
|
||||||
*/
|
*/
|
||||||
private setIsCloud(): void {
|
private setIsCloud(): void {
|
||||||
|
let serverInfo: azdata.ServerInfo = this.getServerInfo();
|
||||||
|
if (serverInfo && serverInfo.isCloud) {
|
||||||
|
this.isCloudKey.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to set engine edition
|
||||||
|
*/
|
||||||
|
private setEngineEdition(): void {
|
||||||
|
|
||||||
|
let serverInfo: azdata.ServerInfo = this.getServerInfo();
|
||||||
|
if (serverInfo && serverInfo.engineEditionId) {
|
||||||
|
this.engineEditionKey.set(serverInfo.engineEditionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function fetching the server info
|
||||||
|
*/
|
||||||
|
private getServerInfo(): azdata.ServerInfo | undefined {
|
||||||
const profile = new ConnectionProfile(this.capabilitiesService,
|
const profile = new ConnectionProfile(this.capabilitiesService,
|
||||||
this.nodeContextValue.node.payload);
|
this.nodeContextValue.node.payload);
|
||||||
const connection = this.connectionManagementService.findExistingConnection(profile);
|
const connection = this.connectionManagementService.findExistingConnection(profile);
|
||||||
if (connection) {
|
if (connection) {
|
||||||
const serverInfo = this.connectionManagementService.getServerInfo(connection.id);
|
return this.connectionManagementService.getServerInfo(connection.id);
|
||||||
if (serverInfo.isCloud) {
|
|
||||||
this.isCloudKey.set(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/conn
|
|||||||
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
||||||
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||||
|
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
|
||||||
new RestoreAction().registerTask();
|
new RestoreAction().registerTask();
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
title: localize('restore', "Restore")
|
title: localize('restore', "Restore")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database), MssqlNodeContext.IsCloud.toNegated())
|
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database), MssqlNodeContext.IsCloud.toNegated(),
|
||||||
|
MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
// oe
|
// oe
|
||||||
@@ -60,7 +62,8 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
id: OE_RESTORE_COMMAND_ID,
|
id: OE_RESTORE_COMMAND_ID,
|
||||||
title: localize('backup', "Restore")
|
title: localize('backup', "Restore")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(TreeNodeContextKey.NodeType.isEqualTo(NodeType.Database), ConnectionContextKey.Provider.isEqualTo(mssqlProviderName), ServerInfoContextKey.IsCloud.toNegated())
|
when: ContextKeyExpr.and(TreeNodeContextKey.NodeType.isEqualTo(NodeType.Database), ConnectionContextKey.Provider.isEqualTo(mssqlProviderName),
|
||||||
|
ServerInfoContextKey.IsCloud.toNegated(), ServerInfoContextKey.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||||
});
|
});
|
||||||
|
|
||||||
const ExplorerRestoreActionID = 'explorer.restore';
|
const ExplorerRestoreActionID = 'explorer.restore';
|
||||||
@@ -74,6 +77,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
|||||||
id: ExplorerRestoreActionID,
|
id: ExplorerRestoreActionID,
|
||||||
title: RestoreAction.LABEL
|
title: RestoreAction.LABEL
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('database'), ItemContextKey.ConnectionProvider.isEqualTo('mssql'), ItemContextKey.IsCloud.toNegated()),
|
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('database'), ItemContextKey.ConnectionProvider.isEqualTo('mssql'),
|
||||||
|
ItemContextKey.IsCloud.toNegated(), ItemContextKey.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString())),
|
||||||
order: 2
|
order: 2
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user