Add typing for TabbedPanelLayout and set defaults (#9955)

* Add typing for TabbedPanelLayout on withLayout and set appropriate defaults

* Move enum def
This commit is contained in:
Charles Gagnon
2020-04-15 16:42:42 -07:00
committed by GitHub
parent 3566da328a
commit f44e78aef4
4 changed files with 22 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ import * as azdata from 'azdata';
import { SqlMainContext, ExtHostModelViewDialogShape, MainThreadModelViewDialogShape, ExtHostModelViewShape, ExtHostBackgroundTaskManagementShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { TabOrientation } from 'sql/workbench/api/common/sqlExtHostTypes';
const DONE_LABEL = nls.localize('dialogDoneLabel', "Done");
const CANCEL_LABEL = nls.localize('dialogCancelLabel', "Cancel");
@@ -481,7 +482,7 @@ class ModelViewDashboardImpl implements azdata.window.ModelViewDashboard {
const dashboardTabs = await handler(view);
const tabs = this.createTabs(dashboardTabs, view);
this._tabbedPanel = view.modelBuilder.tabbedPanel().withTabs(tabs).withLayout({
orientation: 'vertical',
orientation: TabOrientation.Vertical,
showIcon: this._options?.showIcon ?? true,
alwaysShowTabs: this._options?.alwaysShowTabs ?? false
}).component();

View File

@@ -836,7 +836,6 @@ export enum TabOrientation {
Horizontal = 'horizontal'
}
export interface TabbedPanelLayout {
orientation: TabOrientation;
showIcon: boolean;

View File

@@ -5,14 +5,13 @@
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, forwardRef, Inject, Input, OnDestroy, ViewChild } from '@angular/core';
import { NavigationBarLayout, PanelComponent } from 'sql/base/browser/ui/panel/panel.component';
import { TabType } from 'sql/base/browser/ui/panel/tab.component';
// eslint-disable-next-line code-import-patterns
import { TabOrientation, TabbedPanelLayout } from 'sql/workbench/api/common/sqlExtHostTypes';
import { ContainerBase } from 'sql/workbench/browser/modelComponents/componentBase';
import { ComponentEventType, IComponent, IComponentDescriptor, IModelStore } from 'sql/platform/dashboard/browser/interfaces';
import 'vs/css!./media/tabbedPanel';
import { IUserFriendlyIcon, createIconCssClass } from 'sql/workbench/browser/modelComponents/iconUtils';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { attachTabbedPanelStyler } from 'sql/workbench/common/styler';
import { TabbedPanelLayout } from 'azdata';
export interface TabConfig {
title: string;
@@ -29,6 +28,14 @@ interface Tab {
iconClass?: string;
}
/**
* Defines the tab orientation of TabbedPanelComponent
*/
export enum TabOrientation {
Vertical = 'vertical',
Horizontal = 'horizontal'
}
@Component({
templateUrl: decodeURI(require.toUrl('./tabbedPanel.component.html'))
})
@@ -62,9 +69,9 @@ export default class TabbedPanelComponent extends ContainerBase<TabConfig> imple
setLayout(layout: TabbedPanelLayout): void {
this._panel.options = {
alwaysShowTabs: layout.alwaysShowTabs,
layout: layout.orientation === TabOrientation.Horizontal ? NavigationBarLayout.horizontal : NavigationBarLayout.vertical,
showIcon: layout.showIcon
alwaysShowTabs: layout.alwaysShowTabs ?? false,
layout: (layout.orientation ?? TabOrientation.Horizontal) === TabOrientation.Horizontal ? NavigationBarLayout.horizontal : NavigationBarLayout.vertical,
showIcon: layout.showIcon ?? false
};
}