Filter templates by supported engine type (#6133)

* Filter templates by supported engine type

* fix the azure sql db name
This commit is contained in:
Alan Ren
2019-06-24 23:37:56 -07:00
committed by GitHub
parent a906a9c862
commit ac76302d6c
4 changed files with 27 additions and 5 deletions

View File

@@ -147,8 +147,14 @@ export interface IProfilerViewTemplate {
columns: Array<IColumnViewTemplate>;
}
export enum EngineType {
AzureSQLDB = 'AzureSQLDB',
Standalone = 'Standalone'
}
export interface IProfilerSessionTemplate {
name: string;
engineTypes?: EngineType[];
defaultView: string;
createStatement: string;
}

View File

@@ -6,7 +6,7 @@
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
import {
ProfilerSessionID, IProfilerSession, IProfilerService, IProfilerViewTemplate, IProfilerSessionTemplate,
PROFILER_SETTINGS, IProfilerSettings
PROFILER_SETTINGS, IProfilerSettings, EngineType
} from './interfaces';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
@@ -225,8 +225,17 @@ export class ProfilerService implements IProfilerService {
return Promise.resolve(null);
}
public launchCreateSessionDialog(input?: ProfilerInput): Thenable<void> {
return this._commandService.executeCommand('profiler.openCreateSessionDialog', input.id, input.providerType, this.getSessionTemplates());
public launchCreateSessionDialog(input: ProfilerInput): Thenable<void> {
const serverInfo = this._connectionService.getConnectionInfo(input.id).serverInfo;
let templates = this.getSessionTemplates();
if (serverInfo) {
const engineType = serverInfo.isCloud ? EngineType.AzureSQLDB : EngineType.Standalone;
// only use the templates that matches the following criteria:
// 1. the template doesn't have any engine types specified - for backward compatibility (user with custom templates) or the templates applicable to both AzureSQLDB and standalone server
// 2. the template supports the current engine type
templates = templates.filter(template => !template.engineTypes || template.engineTypes.length === 0 || template.engineTypes.includes(engineType));
}
return this._commandService.executeCommand('profiler.openCreateSessionDialog', input.id, input.providerType, templates);
}
public launchFilterSessionDialog(input: ProfilerInput): void {