From e1f2f7479f8289e2d0cf59dedecef02c6513aa35 Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Tue, 14 Apr 2020 15:35:44 -0700 Subject: [PATCH] Only show Create Insight button in Query Editor charts. (#9973) --- .../contrib/charts/browser/chartView.ts | 17 +++++++++-------- .../charts/test/browser/chartView.test.ts | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/sql/workbench/contrib/charts/browser/chartView.ts b/src/sql/workbench/contrib/charts/browser/chartView.ts index 73bb15da4f..4fa8e78b62 100644 --- a/src/sql/workbench/contrib/charts/browser/chartView.ts +++ b/src/sql/workbench/contrib/charts/browser/chartView.ts @@ -86,7 +86,7 @@ export class ChartView extends Disposable implements IPanelView { public readonly onOptionsChange: Event = this._onOptionsChange.event; constructor( - private readonly _renderOptionsInline: boolean, + private readonly _isQueryEditorChart: boolean, @IContextViewService private _contextViewService: IContextViewService, @IThemeService private _themeService: IThemeService, @IInstantiationService private _instantiationService: IInstantiationService, @@ -102,15 +102,15 @@ export class ChartView extends Disposable implements IPanelView { this.typeControls = DOM.$('div.type-controls'); this.optionsControl.appendChild(this.typeControls); - this._createInsightAction = this._instantiationService.createInstance(CreateInsightAction); this._copyAction = this._instantiationService.createInstance(CopyAction); this._saveAction = this._instantiationService.createInstance(SaveImageAction); - if (this._renderOptionsInline) { + if (this._isQueryEditorChart) { + this._createInsightAction = this._instantiationService.createInstance(CreateInsightAction); this.taskbar.setContent([{ action: this._createInsightAction }]); } else { this._configureChartAction = this._instantiationService.createInstance(ConfigureChartAction, this); - this.taskbar.setContent([{ action: this._createInsightAction }, { action: this._configureChartAction }]); + this.taskbar.setContent([{ action: this._configureChartAction }]); } const self = this; @@ -177,7 +177,7 @@ export class ChartView extends Disposable implements IPanelView { this.container.appendChild(this.taskbarContainer); this.container.appendChild(this.chartingContainer); this.chartingContainer.appendChild(this.insightContainer); - if (this._renderOptionsInline) { + if (this._isQueryEditorChart) { this.chartingContainer.appendChild(this.optionsControl); } this.insight = new Insight(this.insightContainer, this._options, this._instantiationService); @@ -301,14 +301,15 @@ export class ChartView extends Disposable implements IPanelView { if (this.insight && this.insight.isCopyable) { this.taskbar.context = { insight: this.insight.insight, options: this._options }; actions = [ - { action: this._createInsightAction }, { action: this._copyAction }, { action: this._saveAction } ]; } else { - actions = [{ action: this._createInsightAction }]; + actions = []; } - if (!this._renderOptionsInline) { + if (this._isQueryEditorChart) { + actions.unshift({ action: this._createInsightAction }); + } else { actions.push({ action: this._configureChartAction }); } this.taskbar.setContent(actions); diff --git a/src/sql/workbench/contrib/charts/test/browser/chartView.test.ts b/src/sql/workbench/contrib/charts/test/browser/chartView.test.ts index ca6974c359..993cf07c97 100644 --- a/src/sql/workbench/contrib/charts/test/browser/chartView.test.ts +++ b/src/sql/workbench/contrib/charts/test/browser/chartView.test.ts @@ -34,12 +34,12 @@ suite('Chart View', () => { }); }); -function createChartView(renderOptions: boolean): ChartView { +function createChartView(isQueryEditorChart: boolean): ChartView { const layoutService = new TestLayoutService(); const contextViewService = new ContextViewService(layoutService); const themeService = new TestThemeService(); const instantiationService = new TestInstantiationService(); const notificationService = new TestNotificationService(); instantiationService.stub(IThemeService, themeService); - return new ChartView(renderOptions, contextViewService, themeService, instantiationService, notificationService); + return new ChartView(isQueryEditorChart, contextViewService, themeService, instantiationService, notificationService); }