mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Change logic to not show results until there are results to show (#6310)
* change logic to not show results until there are results to show * wip * simplify code * address feedback
This commit is contained in:
@@ -13,15 +13,16 @@ import { ChartTab } from 'sql/workbench/parts/charts/browser/chartTab';
|
|||||||
import { QueryPlanTab } from 'sql/workbench/parts/queryPlan/browser/queryPlan';
|
import { QueryPlanTab } from 'sql/workbench/parts/queryPlan/browser/queryPlan';
|
||||||
import { TopOperationsTab } from 'sql/workbench/parts/queryPlan/browser/topOperations';
|
import { TopOperationsTab } from 'sql/workbench/parts/queryPlan/browser/topOperations';
|
||||||
import { QueryModelViewTab } from 'sql/workbench/parts/query/browser/modelViewTab/queryModelViewTab';
|
import { QueryModelViewTab } from 'sql/workbench/parts/query/browser/modelViewTab/queryModelViewTab';
|
||||||
|
import { MessagePanelState } from 'sql/workbench/parts/query/common/messagePanelState';
|
||||||
|
import { GridPanelState } from 'sql/workbench/parts/query/common/gridPanelState';
|
||||||
|
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
import { dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||||
import { attachTabbedPanelStyler } from 'sql/platform/theme/common/styler';
|
import { attachTabbedPanelStyler } from 'sql/platform/theme/common/styler';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
import { MessagePanelState } from 'sql/workbench/parts/query/common/messagePanelState';
|
import { Event } from 'vs/base/common/event';
|
||||||
import { GridPanelState } from 'sql/workbench/parts/query/common/gridPanelState';
|
|
||||||
|
|
||||||
class MessagesView extends Disposable implements IPanelView {
|
class MessagesView extends Disposable implements IPanelView {
|
||||||
private messagePanel: MessagePanel;
|
private messagePanel: MessagePanel;
|
||||||
@@ -173,7 +174,7 @@ export class QueryResultsView extends Disposable {
|
|||||||
private topOperationsTab: TopOperationsTab;
|
private topOperationsTab: TopOperationsTab;
|
||||||
private dynamicModelViewTabs: QueryModelViewTab[] = [];
|
private dynamicModelViewTabs: QueryModelViewTab[] = [];
|
||||||
|
|
||||||
private runnerDisposables: IDisposable[];
|
private runnerDisposables = new DisposableStore();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
@@ -212,26 +213,27 @@ export class QueryResultsView extends Disposable {
|
|||||||
|
|
||||||
private setQueryRunner(runner: QueryRunner) {
|
private setQueryRunner(runner: QueryRunner) {
|
||||||
const activeTab = this._input.state.activeTab;
|
const activeTab = this._input.state.activeTab;
|
||||||
if (runner.hasCompleted && !this.hasResults(runner)) {
|
if (this.hasResults(runner)) {
|
||||||
this.hideResults();
|
|
||||||
} else {
|
|
||||||
this.showResults();
|
this.showResults();
|
||||||
|
} else {
|
||||||
|
if (runner.isExecuting) { // in case we don't have results yet, but we also have already started executing
|
||||||
|
this.runnerDisposables.add(Event.once(runner.onResultSet)(() => this.showResults()));
|
||||||
|
}
|
||||||
|
this.hideResults();
|
||||||
}
|
}
|
||||||
this.resultsTab.queryRunner = runner;
|
this.resultsTab.queryRunner = runner;
|
||||||
this.messagesTab.queryRunner = runner;
|
this.messagesTab.queryRunner = runner;
|
||||||
this.chartTab.queryRunner = runner;
|
this.chartTab.queryRunner = runner;
|
||||||
this.runnerDisposables.push(runner.onQueryStart(e => {
|
this.runnerDisposables.add(runner.onQueryStart(e => {
|
||||||
this.showResults();
|
this.runnerDisposables.add(Event.once(runner.onResultSet)(() => this.showResults()));
|
||||||
|
this.hideResults();
|
||||||
this.hideChart();
|
this.hideChart();
|
||||||
this.hidePlan();
|
this.hidePlan();
|
||||||
this.hideDynamicViewModelTabs();
|
this.hideDynamicViewModelTabs();
|
||||||
this.input.state.visibleTabs = new Set();
|
this.input.state.visibleTabs = new Set();
|
||||||
this.input.state.activeTab = this.resultsTab.identifier;
|
this.input.state.activeTab = this.resultsTab.identifier;
|
||||||
}));
|
}));
|
||||||
this.runnerDisposables.push(runner.onQueryEnd(() => {
|
this.runnerDisposables.add(runner.onQueryEnd(() => {
|
||||||
if (!this.hasResults(runner)) {
|
|
||||||
this.hideResults();
|
|
||||||
}
|
|
||||||
if (runner.messages.find(v => v.isError)) {
|
if (runner.messages.find(v => v.isError)) {
|
||||||
this._panelView.showTab(this.messagesTab.identifier);
|
this._panelView.showTab(this.messagesTab.identifier);
|
||||||
}
|
}
|
||||||
@@ -278,7 +280,7 @@ export class QueryResultsView extends Disposable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.runnerDisposables.push(runner.onQueryEnd(() => {
|
this.runnerDisposables.add(runner.onQueryEnd(() => {
|
||||||
if (runner.isQueryPlan) {
|
if (runner.isQueryPlan) {
|
||||||
runner.planXml.then(e => {
|
runner.planXml.then(e => {
|
||||||
this.showPlan(e);
|
this.showPlan(e);
|
||||||
@@ -294,8 +296,8 @@ export class QueryResultsView extends Disposable {
|
|||||||
|
|
||||||
public set input(input: QueryResultsInput) {
|
public set input(input: QueryResultsInput) {
|
||||||
this._input = input;
|
this._input = input;
|
||||||
dispose(this.runnerDisposables);
|
this.runnerDisposables.dispose();
|
||||||
this.runnerDisposables = [];
|
this.runnerDisposables = new DisposableStore();
|
||||||
|
|
||||||
[this.resultsTab, this.messagesTab, this.qpTab, this.topOperationsTab, this.chartTab].forEach(t => t.clear());
|
[this.resultsTab, this.messagesTab, this.qpTab, this.topOperationsTab, this.chartTab].forEach(t => t.clear());
|
||||||
this.dynamicModelViewTabs.forEach(t => t.clear());
|
this.dynamicModelViewTabs.forEach(t => t.clear());
|
||||||
@@ -320,14 +322,14 @@ export class QueryResultsView extends Disposable {
|
|||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.runnerDisposables.push(disposable);
|
this.runnerDisposables.add(disposable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInput() {
|
clearInput() {
|
||||||
this._input = undefined;
|
this._input = undefined;
|
||||||
dispose(this.runnerDisposables);
|
this.runnerDisposables.dispose();
|
||||||
this.runnerDisposables = [];
|
this.runnerDisposables = new DisposableStore();
|
||||||
this.resultsTab.clear();
|
this.resultsTab.clear();
|
||||||
this.messagesTab.clear();
|
this.messagesTab.clear();
|
||||||
this.qpTab.clear();
|
this.qpTab.clear();
|
||||||
@@ -409,8 +411,8 @@ export class QueryResultsView extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public dispose() {
|
public dispose() {
|
||||||
dispose(this.runnerDisposables);
|
this.runnerDisposables.dispose();
|
||||||
this.runnerDisposables = [];
|
this.runnerDisposables = new DisposableStore();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user