mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
ADS changes for new engine edition (#7695)
* 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
GitHub
parent
65fb77ef5c
commit
397f6afaf1
@@ -50,17 +50,17 @@
|
||||
"objectExplorer/item/context": [
|
||||
{
|
||||
"command": "adminToolExtWin.launchSsmsMinGswDialog",
|
||||
"when": "isWindows && connectionProvider == MSSQL && nodeType && nodeType == Database",
|
||||
"when": "isWindows && connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||
"group": "z-AdminToolExt@1"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"description": "Manage and troubleshoot SQL Agent jobs",
|
||||
"provider": "MSSQL",
|
||||
"title": "SQL Agent",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||
"container": {
|
||||
"controlhost-container": {
|
||||
"type": "agent"
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
"objectExplorer/item/context": [
|
||||
{
|
||||
"command": "dacFx.start",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||
"group": "export"
|
||||
},
|
||||
{
|
||||
"command": "dacFx.start",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server && mssql:engineedition != 11",
|
||||
"group": "export"
|
||||
},
|
||||
{
|
||||
"command": "dacFx.start",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Folder && nodeLabel == 'Databases'",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Folder && nodeLabel == 'Databases' && mssql:engineedition != 11",
|
||||
"group": "export"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"objectExplorer/item/context": [
|
||||
{
|
||||
"command": "flatFileImport.start",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||
"group": "import"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
"id": "all-database-size-server-insight",
|
||||
"contrib": {
|
||||
"name": "Database Size (MB)",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||
"gridItemConfig": {
|
||||
"x": 2,
|
||||
"y": 2
|
||||
@@ -83,7 +83,7 @@
|
||||
"contrib": {
|
||||
"cacheId": "backup-history-server-insight",
|
||||
"name": "Backup Status",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
|
||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 11",
|
||||
"gridItemConfig": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
|
||||
@@ -308,11 +308,18 @@
|
||||
"flavors": [
|
||||
{
|
||||
"flavor": "on_prem",
|
||||
"condition": {
|
||||
"field": "isCloud",
|
||||
"operator": "!=",
|
||||
"value": true
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"field": "isCloud",
|
||||
"operator": "!=",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"field": "engineEditionId",
|
||||
"operator": "!=",
|
||||
"value": "11"
|
||||
}
|
||||
],
|
||||
"databaseProperties": [
|
||||
{
|
||||
"displayName": "%onprem.databaseProperties.recoveryModel%",
|
||||
@@ -362,11 +369,13 @@
|
||||
},
|
||||
{
|
||||
"flavor": "cloud",
|
||||
"condition": {
|
||||
"field": "isCloud",
|
||||
"operator": "==",
|
||||
"value": true
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"field": "isCloud",
|
||||
"operator": "==",
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"databaseProperties": [
|
||||
{
|
||||
"displayName": "%cloud.databaseProperties.azureEdition%",
|
||||
@@ -395,6 +404,36 @@
|
||||
"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 = [
|
||||
5,
|
||||
6
|
||||
6,
|
||||
11
|
||||
];
|
||||
|
||||
export function setCommandContext(key: ContextKeys | string, value: any) {
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
"objectExplorer/item/context": [
|
||||
{
|
||||
"command": "profiler.newProfiler",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Server && mssql:engineedition != 11",
|
||||
"group": "profiler"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
"objectExplorer/item/context": [
|
||||
{
|
||||
"command": "schemaCompare.start",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
|
||||
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database && mssql:engineedition != 11",
|
||||
"group": "export"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -109,11 +109,11 @@
|
||||
"tasks-widget": [
|
||||
{
|
||||
"name": "backup",
|
||||
"when": "!mssql:iscloud"
|
||||
"when": "!mssql:iscloud && mssql:engineedition != 11"
|
||||
},
|
||||
{
|
||||
"name": "restore",
|
||||
"when": "!mssql:iscloud"
|
||||
"when": "!mssql:iscloud && mssql:engineedition != 11"
|
||||
},
|
||||
"configureDashboard",
|
||||
"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 };
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
handle?: number;
|
||||
readonly providerId: string;
|
||||
|
||||
@@ -558,7 +558,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
StepCompletionAction: sqlExtHostTypes.StepCompletionAction,
|
||||
AgentSubSystem: sqlExtHostTypes.AgentSubSystem,
|
||||
ExtensionNodeType: sqlExtHostTypes.ExtensionNodeType,
|
||||
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode
|
||||
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode,
|
||||
DatabaseEngineEdition: sqlExtHostTypes.DatabaseEngineEdition
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -357,6 +357,22 @@ export enum Orientation {
|
||||
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 {
|
||||
orientation: Orientation;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ const targetDatabaseEngineEditionMap = {
|
||||
4: 'SqlServerExpressEdition',
|
||||
5: 'SqlAzureDatabaseEdition',
|
||||
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 { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
new BackupAction().registerTask();
|
||||
|
||||
@@ -41,7 +42,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('backup', "Backup")
|
||||
},
|
||||
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
|
||||
@@ -61,7 +62,8 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||
id: OE_BACKUP_COMMAND_ID,
|
||||
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
|
||||
@@ -76,6 +78,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
id: ExplorerBackUpActionID,
|
||||
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
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ServerInfo } from 'azdata';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||
|
||||
@@ -12,11 +13,13 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
|
||||
static IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
||||
static IsBigDataCluster = new RawContextKey<boolean>('isBigDataCluster', undefined);
|
||||
static EngineEdition = new RawContextKey<number>('engineEdition', undefined);
|
||||
|
||||
private _serverInfo: IContextKey<ServerInfo>;
|
||||
private _serverMajorVersion: IContextKey<string>;
|
||||
private _isCloud: IContextKey<boolean>;
|
||||
private _isBigDataCluster: IContextKey<boolean>;
|
||||
private _engineEdition: IContextKey<number>;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
@@ -25,6 +28,7 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
|
||||
this._isCloud = ServerInfoContextKey.IsCloud.bindTo(contextKeyService);
|
||||
this._isBigDataCluster = ServerInfoContextKey.IsBigDataCluster.bindTo(contextKeyService);
|
||||
this._engineEdition = ServerInfoContextKey.EngineEdition.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
set(value: ServerInfo) {
|
||||
@@ -33,12 +37,15 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
|
||||
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
|
||||
this._isCloud.set(value && value.isCloud);
|
||||
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 {
|
||||
this._serverMajorVersion.reset();
|
||||
this._isCloud.reset();
|
||||
this._isBigDataCluster.reset();
|
||||
this._engineEdition.reset();
|
||||
}
|
||||
|
||||
public get(): ServerInfo {
|
||||
|
||||
@@ -98,8 +98,8 @@ export const databaseDashboardSettingSchema: IJSONSchema = {
|
||||
'tasks-widget': [
|
||||
'newQuery',
|
||||
'mssqlCluster.task.newNotebook',
|
||||
{ name: 'backup', when: '!mssql:iscloud' },
|
||||
{ name: 'restore', when: '!mssql:iscloud' },
|
||||
{ name: 'backup', when: '!mssql:iscloud && mssql:engineedition != 11' },
|
||||
{ name: 'restore', when: '!mssql:iscloud && mssql:engineedition != 11' },
|
||||
'configureDashboard'
|
||||
]
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const defaultVal = [
|
||||
{
|
||||
name: 'Tasks',
|
||||
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: {
|
||||
sizex: 1,
|
||||
|
||||
@@ -78,7 +78,8 @@ export class ExplorerController extends TreeDefaults.DefaultController {
|
||||
this.contextKey.set({
|
||||
resource: element,
|
||||
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;
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface IContextValue {
|
||||
resource: ContextResource;
|
||||
providerName: string;
|
||||
isCloud: boolean;
|
||||
engineEdition: number;
|
||||
}
|
||||
|
||||
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 ConnectionProvider = new RawContextKey<string>('provider', undefined);
|
||||
static readonly IsCloud = new RawContextKey<boolean>('isCloud', undefined);
|
||||
static readonly EngineEdition = new RawContextKey<number>('engineEdition', undefined);
|
||||
|
||||
private _itemTypeKey: IContextKey<string>;
|
||||
private _itemKey: IContextKey<IContextValue>;
|
||||
private _connectionProviderKey: IContextKey<string>;
|
||||
private _isCloudKey: IContextKey<boolean>;
|
||||
private _engineEditionKey: IContextKey<number>;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
@@ -38,12 +41,14 @@ export class ItemContextKey extends Disposable implements IContextKey<IContextVa
|
||||
this._itemKey = ItemContextKey.Item.bindTo(contextKeyService);
|
||||
this._connectionProviderKey = ItemContextKey.ConnectionProvider.bindTo(contextKeyService);
|
||||
this._isCloudKey = ItemContextKey.IsCloud.bindTo(contextKeyService);
|
||||
this._engineEditionKey = ItemContextKey.EngineEdition.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
set(value: IContextValue) {
|
||||
this._itemKey.set(value);
|
||||
this._connectionProviderKey.set(value.providerName.toLowerCase());
|
||||
this._isCloudKey.set(value.isCloud);
|
||||
this._engineEditionKey.set(value.engineEdition);
|
||||
if (value.resource instanceof ObjectMetadataWrapper) {
|
||||
switch (value.resource.metadataType) {
|
||||
case MetadataType.Function:
|
||||
@@ -69,6 +74,7 @@ export class ItemContextKey extends Disposable implements IContextKey<IContextVa
|
||||
this._itemKey.reset();
|
||||
this._connectionProviderKey.reset();
|
||||
this._isCloudKey.reset();
|
||||
this._engineEditionKey.reset();
|
||||
}
|
||||
|
||||
get(): IContextValue | undefined {
|
||||
|
||||
@@ -16,11 +16,18 @@ export const properties: Array<ProviderProperties> = [
|
||||
flavors: [
|
||||
{
|
||||
flavor: 'on_prem',
|
||||
condition: {
|
||||
field: 'isCloud',
|
||||
operator: '!=',
|
||||
value: true
|
||||
},
|
||||
conditions: [
|
||||
{
|
||||
field: 'isCloud',
|
||||
operator: '!=',
|
||||
value: true
|
||||
},
|
||||
{
|
||||
field: 'engineEditionId',
|
||||
operator: '!=',
|
||||
value: '11'
|
||||
}
|
||||
],
|
||||
databaseProperties: [
|
||||
{
|
||||
displayName: nls.localize('recoveryModel', "Recovery Model"),
|
||||
@@ -70,11 +77,13 @@ export const properties: Array<ProviderProperties> = [
|
||||
},
|
||||
{
|
||||
flavor: 'cloud',
|
||||
condition: {
|
||||
field: 'isCloud',
|
||||
operator: '==',
|
||||
value: true
|
||||
},
|
||||
conditions: [
|
||||
{
|
||||
field: 'isCloud',
|
||||
operator: '==',
|
||||
value: true
|
||||
}
|
||||
],
|
||||
databaseProperties: [
|
||||
{
|
||||
displayName: azureEditionDisplayName,
|
||||
@@ -103,6 +112,36 @@ export const properties: Array<ProviderProperties> = [
|
||||
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 {
|
||||
flavor: string;
|
||||
condition?: {
|
||||
field: string;
|
||||
operator: '==' | '<=' | '>=' | '!=';
|
||||
value: string | boolean;
|
||||
};
|
||||
condition?: ConditionProperties;
|
||||
conditions?: Array<ConditionProperties>;
|
||||
databaseProperties: Array<Property>;
|
||||
serverProperties: Array<Property>;
|
||||
}
|
||||
|
||||
export interface ConditionProperties {
|
||||
field: string;
|
||||
operator: '==' | '<=' | '>=' | '!=';
|
||||
value: string | boolean;
|
||||
}
|
||||
|
||||
export interface ProviderProperties {
|
||||
provider: string;
|
||||
flavors: Array<FlavorProperties>;
|
||||
@@ -139,20 +142,23 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
|
||||
return;
|
||||
} else {
|
||||
const flavorArray = providerProperties.flavors.filter((item) => {
|
||||
const condition = this._connection.serverInfo[item.condition.field];
|
||||
switch (item.condition.operator) {
|
||||
case '==':
|
||||
return condition === item.condition.value;
|
||||
case '!=':
|
||||
return condition !== item.condition.value;
|
||||
case '>=':
|
||||
return condition >= item.condition.value;
|
||||
case '<=':
|
||||
return condition <= item.condition.value;
|
||||
default:
|
||||
this.logService.error('Could not parse operator: "', item.condition.operator,
|
||||
'" on item "', item, '"');
|
||||
return false;
|
||||
|
||||
// For backward compatibility we are supporting array of conditions and single condition.
|
||||
// If nothing is specified, we return false.
|
||||
if (item.conditions) {
|
||||
let conditionResult = true;
|
||||
for (let i = 0; i < item.conditions.length; i++) {
|
||||
conditionResult = conditionResult && this.getConditionResult(item, item.conditions[i]);
|
||||
}
|
||||
|
||||
return conditionResult;
|
||||
}
|
||||
else if (item.condition) {
|
||||
return this.getConditionResult(item, item.condition);
|
||||
}
|
||||
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 {
|
||||
let val: T = undefined;
|
||||
if (infoObject) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/browser/mssql
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||
import { localize } from 'vs/nls';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
// Data-Tier Application Wizard
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
@@ -20,7 +21,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('dacFx', "Data-tier Application Wizard")
|
||||
},
|
||||
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),
|
||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Folder),
|
||||
MssqlNodeContext.NodeLabel.isEqualTo('Databases'))
|
||||
MssqlNodeContext.NodeLabel.isEqualTo('Databases'),
|
||||
MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||
});
|
||||
|
||||
// Profiler
|
||||
@@ -45,7 +47,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('profiler', "Launch Profiler")
|
||||
},
|
||||
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
|
||||
@@ -69,7 +71,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('schemaCompare', "Schema Compare")
|
||||
},
|
||||
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
|
||||
@@ -82,7 +84,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
},
|
||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Database),
|
||||
MssqlNodeContext.IsWindows)
|
||||
MssqlNodeContext.IsWindows, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||
});
|
||||
|
||||
// Properties Action
|
||||
@@ -95,7 +97,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
},
|
||||
when: ContextKeyExpr.and(MssqlNodeContext.NodeProvider.isEqualTo(mssqlProviderName),
|
||||
MssqlNodeContext.NodeType.isEqualTo(NodeType.Server), ContextKeyExpr.not('isCloud'),
|
||||
MssqlNodeContext.IsWindows)
|
||||
MssqlNodeContext.IsWindows, MssqlNodeContext.EngineEdition.notEqualsTo(DatabaseEngineEdition.SqlOnDemand.toString()))
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
@@ -106,6 +108,6 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('properties', "Properties")
|
||||
},
|
||||
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)$/))
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* 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 { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
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 { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
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';
|
||||
|
||||
export class MssqlNodeContext extends Disposable {
|
||||
@@ -32,6 +33,7 @@ export class MssqlNodeContext extends Disposable {
|
||||
static IsCloud = new RawContextKey<boolean>('isCloud', false);
|
||||
static NodeType = new RawContextKey<string>('nodeType', undefined);
|
||||
static NodeLabel = new RawContextKey<string>('nodeLabel', undefined);
|
||||
static EngineEdition = new RawContextKey<number>('engineEdition', DatabaseEngineEdition.Unknown);
|
||||
|
||||
// Scripting context keys
|
||||
static CanScriptAsSelect = new RawContextKey<boolean>('canScriptAsSelect', false);
|
||||
@@ -45,6 +47,7 @@ export class MssqlNodeContext extends Disposable {
|
||||
private nodeTypeKey: IContextKey<string>;
|
||||
private nodeLabelKey: IContextKey<string>;
|
||||
private isDatabaseOrServerKey: IContextKey<boolean>;
|
||||
private engineEditionKey: IContextKey<number>;
|
||||
|
||||
private canScriptAsSelectKey: IContextKey<boolean>;
|
||||
private canEditDataKey: IContextKey<boolean>;
|
||||
@@ -67,6 +70,7 @@ export class MssqlNodeContext extends Disposable {
|
||||
if (node.payload) {
|
||||
this.setNodeProvider();
|
||||
this.setIsCloud();
|
||||
this.setEngineEdition();
|
||||
if (node.type) {
|
||||
this.setIsDatabaseOrServer();
|
||||
this.nodeTypeKey.set(node.type);
|
||||
@@ -84,6 +88,7 @@ export class MssqlNodeContext extends Disposable {
|
||||
|
||||
private bindContextKeys(): void {
|
||||
this.isCloudKey = MssqlNodeContext.IsCloud.bindTo(this.contextKeyService);
|
||||
this.engineEditionKey = MssqlNodeContext.EngineEdition.bindTo(this.contextKeyService);
|
||||
this.nodeTypeKey = MssqlNodeContext.NodeType.bindTo(this.contextKeyService);
|
||||
this.nodeLabelKey = MssqlNodeContext.NodeLabel.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
|
||||
*/
|
||||
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,
|
||||
this.nodeContextValue.node.payload);
|
||||
const connection = this.connectionManagementService.findExistingConnection(profile);
|
||||
if (connection) {
|
||||
const serverInfo = this.connectionManagementService.getServerInfo(connection.id);
|
||||
if (serverInfo.isCloud) {
|
||||
this.isCloudKey.set(true);
|
||||
}
|
||||
return this.connectionManagementService.getServerInfo(connection.id);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/conn
|
||||
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
||||
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
new RestoreAction().registerTask();
|
||||
|
||||
@@ -40,7 +41,8 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
title: localize('restore', "Restore")
|
||||
},
|
||||
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
|
||||
@@ -60,7 +62,8 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||
id: OE_RESTORE_COMMAND_ID,
|
||||
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';
|
||||
@@ -74,6 +77,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
id: ExplorerRestoreActionID,
|
||||
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
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user