mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
Hide results tab when there are none (#5763)
* wip * add behavior around hiding results when there are none * fix strict null access
This commit is contained in:
@@ -181,7 +181,7 @@ export class QueryResultsView extends Disposable {
|
||||
this.resultsTab = this._register(new ResultsTab(instantiationService));
|
||||
this.messagesTab = this._register(new MessagesTab(instantiationService));
|
||||
this.chartTab = this._register(new ChartTab(instantiationService));
|
||||
this._panelView = this._register(new TabbedPanel(container, { showHeaderWhenSingleView: false }));
|
||||
this._panelView = this._register(new TabbedPanel(container, { showHeaderWhenSingleView: true }));
|
||||
this._register(attachTabbedPanelStyler(this._panelView, themeService));
|
||||
this.qpTab = this._register(new QueryPlanTab());
|
||||
this.topOperationsTab = this._register(new TopOperationsTab(instantiationService));
|
||||
@@ -195,17 +195,40 @@ export class QueryResultsView extends Disposable {
|
||||
}));
|
||||
}
|
||||
|
||||
private hasResults(runner: QueryRunner): boolean {
|
||||
let hasResults = false;
|
||||
for (const batch of runner.batchSets) {
|
||||
if (batch.resultSetSummaries.length > 0) {
|
||||
hasResults = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasResults;
|
||||
}
|
||||
|
||||
private setQueryRunner(runner: QueryRunner) {
|
||||
if (runner.hasCompleted && !this.hasResults(runner)) {
|
||||
this.hideResults();
|
||||
} else {
|
||||
this.showResults();
|
||||
}
|
||||
this.resultsTab.queryRunner = runner;
|
||||
this.messagesTab.queryRunner = runner;
|
||||
this.chartTab.queryRunner = runner;
|
||||
this.runnerDisposables.push(runner.onQueryStart(e => {
|
||||
this.showResults();
|
||||
this.hideChart();
|
||||
this.hidePlan();
|
||||
this.hideDynamicViewModelTabs();
|
||||
this.input.state.visibleTabs = new Set();
|
||||
this.input.state.activeTab = this.resultsTab.identifier;
|
||||
}));
|
||||
this.runnerDisposables.push(runner.onQueryEnd(() => {
|
||||
if (!this.hasResults(runner)) {
|
||||
this.hideResults();
|
||||
}
|
||||
}));
|
||||
|
||||
if (this.input.state.visibleTabs.has(this.chartTab.identifier) && !this._panelView.contains(this.chartTab)) {
|
||||
this._panelView.pushTab(this.chartTab);
|
||||
} else if (!this.input.state.visibleTabs.has(this.chartTab.identifier) && this._panelView.contains(this.chartTab)) {
|
||||
@@ -311,6 +334,19 @@ export class QueryResultsView extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public hideResults() {
|
||||
if (this._panelView.contains(this.resultsTab)) {
|
||||
this._panelView.removeTab(this.resultsTab.identifier);
|
||||
}
|
||||
}
|
||||
|
||||
public showResults() {
|
||||
if (!this._panelView.contains(this.resultsTab)) {
|
||||
this._panelView.pushTab(this.resultsTab, 0);
|
||||
}
|
||||
this._panelView.showTab(this.resultsTab.identifier);
|
||||
}
|
||||
|
||||
public showPlan(xml: string) {
|
||||
this.input.state.visibleTabs.add(this.qpTab.identifier);
|
||||
if (!this._panelView.contains(this.qpTab)) {
|
||||
|
||||
Reference in New Issue
Block a user