diff --git a/extensions/agent/package.json b/extensions/agent/package.json index fbbb9541d7..dd2d7effe1 100644 --- a/extensions/agent/package.json +++ b/extensions/agent/package.json @@ -26,12 +26,6 @@ "outputChannels": [ "sqlagent" ], - "commands": [ - { - "command": "agent.openNewStepDialog", - "title": "agent.openNewStepDialog" - } - ], "dashboard.tabs": [ { "id": "data-management-agent", diff --git a/extensions/agent/src/data/jobData.ts b/extensions/agent/src/data/jobData.ts index ca16a07208..9f6f24cc87 100644 --- a/extensions/agent/src/data/jobData.ts +++ b/extensions/agent/src/data/jobData.ts @@ -136,8 +136,13 @@ export class JobData implements IAgentDialogData { } public addJobSchedule(schedule: sqlops.AgentJobScheduleInfo) { - let existingSchedule = this.jobSchedules.find(item => item.name === schedule.name); - if (!existingSchedule) { + if (this.jobSchedules) { + let existingSchedule = this.jobSchedules.find(item => item.name === schedule.name); + if (!existingSchedule) { + this.jobSchedules.push(schedule); + } + } else { + this.jobSchedules = []; this.jobSchedules.push(schedule); } } diff --git a/extensions/agent/src/data/pickScheduleData.ts b/extensions/agent/src/data/pickScheduleData.ts index 0192aa3176..15ad4c0f34 100644 --- a/extensions/agent/src/data/pickScheduleData.ts +++ b/extensions/agent/src/data/pickScheduleData.ts @@ -13,9 +13,11 @@ export class PickScheduleData implements IAgentDialogData { public ownerUri: string; public schedules: sqlops.AgentJobScheduleInfo[]; public selectedSchedule: sqlops.AgentJobScheduleInfo; + private jobName: string; - constructor(ownerUri:string) { + constructor(ownerUri:string, jobName: string) { this.ownerUri = ownerUri; + this.jobName = jobName; } public async initialize() { @@ -27,5 +29,8 @@ export class PickScheduleData implements IAgentDialogData { } public async save() { + let agentService = await AgentUtils.getAgentService(); + this.selectedSchedule.jobName = this.jobName; + let result = await agentService.createJobSchedule(this.ownerUri, this.selectedSchedule); } } diff --git a/extensions/agent/src/dialogs/jobDialog.ts b/extensions/agent/src/dialogs/jobDialog.ts index e77baa2261..bf3523daf1 100644 --- a/extensions/agent/src/dialogs/jobDialog.ts +++ b/extensions/agent/src/dialogs/jobDialog.ts @@ -108,12 +108,14 @@ export class JobDialog extends AgentDialog { // Alert tab controls private alertsTable: sqlops.TableComponent; private newAlertButton: sqlops.ButtonComponent; + private isEdit: boolean = false; constructor(ownerUri: string, jobInfo: sqlops.AgentJobInfo = undefined) { super( ownerUri, new JobData(ownerUri, jobInfo), jobInfo ? JobDialog.EditDialogTitle : JobDialog.CreateDialogTitle); + this.isEdit = jobInfo ? true : false; } protected async initializeDialog() { @@ -373,12 +375,12 @@ export class JobDialog extends AgentDialog { label: this.PickScheduleButtonString, width: 80 }).component(); - this.pickScheduleButton.onDidClick((e)=>{ - let pickScheduleDialog = new PickScheduleDialog(this.model.ownerUri); + let pickScheduleDialog = new PickScheduleDialog(this.model.ownerUri, this.model.name); pickScheduleDialog.onSuccess((dialogModel) => { let selectedSchedule = dialogModel.selectedSchedule; if (selectedSchedule) { + selectedSchedule.jobName = this.model.name; this.model.addJobSchedule(selectedSchedule); this.populateScheduleTable(); } diff --git a/extensions/agent/src/dialogs/pickScheduleDialog.ts b/extensions/agent/src/dialogs/pickScheduleDialog.ts index 5fcd1ac1d1..91c5e23e98 100644 --- a/extensions/agent/src/dialogs/pickScheduleDialog.ts +++ b/extensions/agent/src/dialogs/pickScheduleDialog.ts @@ -33,8 +33,8 @@ export class PickScheduleDialog { private _onSuccess: vscode.EventEmitter = new vscode.EventEmitter(); public readonly onSuccess: vscode.Event = this._onSuccess.event; - constructor(ownerUri: string) { - this.model = new PickScheduleData(ownerUri); + constructor(ownerUri: string, jobName: string) { + this.model = new PickScheduleData(ownerUri, jobName); } public async showDialog() { diff --git a/extensions/agent/src/mainController.ts b/extensions/agent/src/mainController.ts index d7f6b3fde4..af10fa01be 100644 --- a/extensions/agent/src/mainController.ts +++ b/extensions/agent/src/mainController.ts @@ -41,12 +41,12 @@ export class MainController { let dialog = new JobDialog(ownerUri, jobInfo); dialog.openDialog(); }); - vscode.commands.registerCommand('agent.openNewStepDialog', (ownerUri: string, server: string, jobData: JobData) => { - let dialog = new JobStepDialog(ownerUri, server, jobData); + vscode.commands.registerCommand('agent.openNewStepDialog', (ownerUri: string, server: string, jobData: JobData, jobStepInfo: sqlops.AgentJobStepInfo) => { + let dialog = new JobStepDialog(ownerUri, server, jobData, jobStepInfo); dialog.openDialog(); }); - vscode.commands.registerCommand('agent.openPickScheduleDialog', (ownerUri: string) => { - let dialog = new PickScheduleDialog(ownerUri); + vscode.commands.registerCommand('agent.openPickScheduleDialog', (ownerUri: string, jobName: string) => { + let dialog = new PickScheduleDialog(ownerUri, jobName); dialog.showDialog(); }); vscode.commands.registerCommand('agent.openAlertDialog', (ownerUri: string, alertInfo: sqlops.AgentAlertInfo, jobs: string[]) => { diff --git a/src/sql/parts/modelComponents/editor.component.ts b/src/sql/parts/modelComponents/editor.component.ts index cf1dc2c852..d42a8a8929 100644 --- a/src/sql/parts/modelComponents/editor.component.ts +++ b/src/sql/parts/modelComponents/editor.component.ts @@ -39,6 +39,7 @@ export default class EditorComponent extends ComponentBase implements IComponent private _languageMode: string; private _uri: string; private _isAutoResizable: boolean; + private _minimumHeight: number; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @@ -79,6 +80,9 @@ export default class EditorComponent extends ComponentBase implements IComponent this._register(this._editorModel.onDidChangeContent(e => { this.content = this._editorModel.getValue(); if (this._isAutoResizable) { + if (this._minimumHeight) { + this._editor.setMinimumHeight(this._minimumHeight); + } this._editor.setHeightToScrollHeight(); } @@ -109,7 +113,8 @@ export default class EditorComponent extends ComponentBase implements IComponent let height: number = this.convertSizeToNumber(this.height); if (this._isAutoResizable) { - height = this._editor.scrollHeight; + this._editor.setHeightToScrollHeight(); + height = Math.max(this._editor.scrollHeight, this._minimumHeight ? this._minimumHeight : 0); } this._editor.layout(new DOM.Dimension( width && width > 0 ? width : DOM.getContentWidth(this._el.nativeElement), @@ -152,6 +157,7 @@ export default class EditorComponent extends ComponentBase implements IComponent // Intentionally always updating editorUri as it's wiped out by parent setProperties call. this.editorUri = this._uri; this._isAutoResizable = this.isAutoResizable; + this._minimumHeight = this.minimumHeight; } // CSS-bound properties @@ -179,6 +185,14 @@ export default class EditorComponent extends ComponentBase implements IComponent this.setPropertyFromUI((properties, isAutoResizable) => { properties.isAutoResizable = isAutoResizable; }, newValue); } + public get minimumHeight(): number { + return this.getPropertyOrDefault((props) => props.minimumHeight, this._editor.minimumHeight); + } + + public set minimumHeight(newValue: number) { + this.setPropertyFromUI((properties, minimumHeight) => { properties.minimumHeight = minimumHeight; }, newValue); + } + public get editorUri(): string { return this.getPropertyOrDefault((props) => props.editorUri, ''); } diff --git a/src/sql/parts/modelComponents/queryTextEditor.ts b/src/sql/parts/modelComponents/queryTextEditor.ts index 15017de2cb..f18e2ed6b6 100644 --- a/src/sql/parts/modelComponents/queryTextEditor.ts +++ b/src/sql/parts/modelComponents/queryTextEditor.ts @@ -34,6 +34,7 @@ export class QueryTextEditor extends BaseTextEditor { public static ID = 'modelview.editors.textEditor'; private _dimension: DOM.Dimension; private _config: editorCommon.IConfiguration; + private _minHeight: number; constructor( @ITelemetryService telemetryService: ITelemetryService, @IInstantiationService instantiationService: IInstantiationService, @@ -116,6 +117,11 @@ export class QueryTextEditor extends BaseTextEditor { this._config = new Configuration(undefined, editorWidget.getDomNode()); } let editorHeightUsingLines = this._config.editor.lineHeight * editorWidget.getModel().getLineCount(); - this.setHeight(editorHeightUsingLines); + let editorHeightUsingMinHeight = Math.max(editorHeightUsingLines, this._minHeight); + this.setHeight(editorHeightUsingMinHeight); + } + + public setMinimumHeight(height: number) : void { + this._minHeight = height; } } diff --git a/src/sql/parts/query/execution/queryRunner.ts b/src/sql/parts/query/execution/queryRunner.ts index b0450ce27b..03cdfd3ea6 100644 --- a/src/sql/parts/query/execution/queryRunner.ts +++ b/src/sql/parts/query/execution/queryRunner.ts @@ -184,6 +184,7 @@ export default class QueryRunner { this._echoedResultSet.clear(); this._debouncedMessage.clear(); this._debouncedResultSet.clear(); + this._planXml = new Deferred(); let ownerUri = this.uri; this._batchSets = []; this._hasCompleted = false; @@ -343,7 +344,11 @@ export default class QueryRunner { } // handle getting queryPlanxml if we need too if (this.isQueryPlan) { - this.getQueryRows(0, 1, 0, 0).then(e => this._planXml.resolve(e.resultSubset.rows[0][0].displayValue)); + // check if this result has show plan, this needs work, it won't work for any other provider + let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan'); + if (hasShowPlan) { + this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => this._planXml.resolve(e.resultSubset.rows[0][0].displayValue)); + } } if (batchSet) { // Store the result set in the batch and emit that a result set has completed diff --git a/src/sql/parts/queryPlan/queryPlan.ts b/src/sql/parts/queryPlan/queryPlan.ts index 420ee11bce..f4e56a1207 100644 --- a/src/sql/parts/queryPlan/queryPlan.ts +++ b/src/sql/parts/queryPlan/queryPlan.ts @@ -41,7 +41,7 @@ export class QueryPlanView implements IPanelView { } } container.appendChild(this.container); - container.style.overflow = 'scroll'; + this.container.style.overflow = 'scroll'; } public layout(dimension: Dimension): void { diff --git a/src/sql/sqlops.proposed.d.ts b/src/sql/sqlops.proposed.d.ts index 3e830bd80d..0989c95ee9 100644 --- a/src/sql/sqlops.proposed.d.ts +++ b/src/sql/sqlops.proposed.d.ts @@ -595,6 +595,10 @@ declare module 'sqlops' { * The languge mode for this text editor. The language mode is SQL by default. */ languageMode?: string; + /** + * Minimum height for editor component + */ + minimumHeight?: number; } export interface ButtonProperties extends ComponentProperties, ComponentWithIcon { @@ -722,6 +726,11 @@ declare module 'sqlops' { */ isAutoResizable: boolean; + /** + * Minimum height for editor component + */ + minimumHeight: number; + } export interface ButtonComponent extends Component, ButtonProperties { diff --git a/src/sql/workbench/api/node/extHostModelView.ts b/src/sql/workbench/api/node/extHostModelView.ts index fd4bbfbee0..314110c367 100644 --- a/src/sql/workbench/api/node/extHostModelView.ts +++ b/src/sql/workbench/api/node/extHostModelView.ts @@ -913,6 +913,14 @@ class EditorWrapper extends ComponentWrapper implements sqlops.EditorComponent { this.setProperty('isAutoResizable', v); } + public get minimumHeight(): number { + return this.properties['minimumHeight']; + } + + public set minimumHeight(v: number) { + this.setProperty('minimumHeight', v); + } + public get onContentChanged(): vscode.Event { let emitter = this._emitterMap.get(ComponentEventType.onDidChange); return emitter && emitter.event;