readd check on start up for tabs (#1585)

This commit is contained in:
Anthony Dresser
2018-06-07 17:20:28 -07:00
committed by GitHub
parent 63fb4e2827
commit 44de602e52

View File

@@ -4,15 +4,13 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { import {
Component, ContentChildren, QueryList, AfterContentInit, Inject, forwardRef, NgZone, Component, ContentChildren, QueryList, Inject, forwardRef, NgZone,
OnInit, Input, EventEmitter, Output, ViewChild, ElementRef, OnChanges, OnDestroy, ViewChildren, Input, EventEmitter, Output, ViewChild, ElementRef
AfterViewInit
} from '@angular/core'; } from '@angular/core';
import './panelStyles'; import './panelStyles';
import { TabComponent } from './tab.component'; import { TabComponent } from './tab.component';
import { TabHeaderComponent } from './tabHeader.component';
import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive'; import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive';
import { subscriptionToDisposable } from 'sql/base/common/lifecycle'; import { subscriptionToDisposable } from 'sql/base/common/lifecycle';
@@ -21,7 +19,6 @@ import { Action } from 'vs/base/common/actions';
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
import { mixin } from 'vs/base/common/objects'; import { mixin } from 'vs/base/common/objects';
import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
export interface IPanelOptions { export interface IPanelOptions {
@@ -44,9 +41,6 @@ const defaultOptions: IPanelOptions = {
showIcon: false showIcon: false
}; };
const verticalLayout = 'vertical';
const horizontalLayout = 'horizontal';
let idPool = 0; let idPool = 0;
@Component({ @Component({
@@ -78,7 +72,6 @@ export class PanelComponent extends Disposable {
@Input() public options: IPanelOptions; @Input() public options: IPanelOptions;
@Input() public actions: Array<Action>; @Input() public actions: Array<Action>;
@ContentChildren(TabComponent) private _tabs: QueryList<TabComponent>; @ContentChildren(TabComponent) private _tabs: QueryList<TabComponent>;
@ViewChildren(TabHeaderComponent) private _headerTabs: QueryList<TabHeaderComponent>;
@ViewChild(ScrollableDirective) private scrollable: ScrollableDirective; @ViewChild(ScrollableDirective) private scrollable: ScrollableDirective;
@Output() public onTabChange = new EventEmitter<TabComponent>(); @Output() public onTabChange = new EventEmitter<TabComponent>();
@@ -88,8 +81,8 @@ export class PanelComponent extends Disposable {
private _actionbar: ActionBar; private _actionbar: ActionBar;
private _mru: TabComponent[]; private _mru: TabComponent[];
private ScrollbarVisibility = ScrollbarVisibility; protected ScrollbarVisibility = ScrollbarVisibility;
private NavigationBarLayout = NavigationBarLayout; protected NavigationBarLayout = NavigationBarLayout;
@ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef: ElementRef; @ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef: ElementRef;
constructor( @Inject(forwardRef(() => NgZone)) private _zone: NgZone) { constructor( @Inject(forwardRef(() => NgZone)) private _zone: NgZone) {
@@ -102,6 +95,10 @@ export class PanelComponent extends Disposable {
} }
ngAfterContentInit(): void { ngAfterContentInit(): void {
if (this._tabs && this._tabs.length > 0) {
this.selectTab(this._tabs.first);
}
this._register(subscriptionToDisposable(this._tabs.changes.subscribe(() => { this._register(subscriptionToDisposable(this._tabs.changes.subscribe(() => {
if (this._tabs && this._tabs.length > 0) { if (this._tabs && this._tabs.length > 0) {
this.selectTab(this._tabs.first); this.selectTab(this._tabs.first);