mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Refactor out extensions-modules and rewrite mssql extension (#909)
* commting .d.ts changes * added serverinfo to .d.ts * maybe its working? * works * updated contrib * remove unnecessary code * fix compile errors * init * conitnue * on the way to working maybe? * close * EVERYTHING WORKS * moved src out of client folder * formatting * reenable logging * working on build file * fixed install service gulp command * fix the command to properly return promises * clean up code * add telemetry * formatting * added logging/telemetry/statusview * formatting * address comments * resolute vscode-language versions
This commit is contained in:
52
extensions/mssql/src/contextProvider.ts
Normal file
52
extensions/mssql/src/contextProvider.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as vscode from 'vscode';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
export enum BuiltInCommands {
|
||||
SetContext = 'setContext',
|
||||
}
|
||||
|
||||
export enum ContextKeys {
|
||||
ISCLOUD = 'mssql:iscloud'
|
||||
}
|
||||
|
||||
const isCloudEditions = [
|
||||
5,
|
||||
6
|
||||
];
|
||||
|
||||
export function setCommandContext(key: ContextKeys | string, value: any) {
|
||||
return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value);
|
||||
}
|
||||
|
||||
export default class ContextProvider {
|
||||
private _disposables = new Array<vscode.Disposable>();
|
||||
|
||||
constructor() {
|
||||
this._disposables.push(sqlops.workspace.onDidOpenDashboard(this.onDashboardOpen, this));
|
||||
this._disposables.push(sqlops.workspace.onDidChangeToDashboard(this.onDashboardOpen, this));
|
||||
}
|
||||
|
||||
public onDashboardOpen(e: sqlops.DashboardDocument): void {
|
||||
let iscloud: boolean;
|
||||
if (e.profile.providerName.toLowerCase() === 'mssql' && e.serverInfo.engineEditionId) {
|
||||
if (isCloudEditions.some(i => i === e.serverInfo.engineEditionId)) {
|
||||
iscloud = true;
|
||||
} else {
|
||||
iscloud = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (iscloud === true || iscloud === false) {
|
||||
setCommandContext(ContextKeys.ISCLOUD, iscloud);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._disposables = this._disposables.map(i => i.dispose());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user