import "./Hub.scss"; import * as React from "react"; import * as SDK from "azure-devops-extension-sdk"; import { CommonServiceIds, IHostDialogService, IHostPanelService } from "azure-devops-extension-api"; import { Header, IHeaderCommandBarItem, Page, TitleSize } from "azure-devops-ui/Page"; import { Tab, TabBar, TabSize } from "azure-devops-ui/Tabs"; import { OverviewTab } from "./OverviewTab"; import { NavigationTab } from "./NavigationTab"; import { ExtensionDataTab } from "./ExtensionDataTab"; import { MessagesTab } from "./MessagesTab"; import { showRootComponent } from "../../Common"; interface IHubContentState { selectedTabId: string; headerKicker?: string; useLargeTitle?: boolean; useCompactPivots?: boolean; } class HubContent extends React.Component<{}, IHubContentState> { constructor(props: {}) { super(props); this.state = { selectedTabId: "overview" }; } public componentDidMount() { SDK.init(); } public render(): JSX.Element { const { selectedTabId, headerKicker, useCompactPivots, useLargeTitle } = this.state; return (
{ this.getPageContent() }
); } private onSelectedTabChanged = (newTabId: string) => { this.setState({ selectedTabId: newTabId }) } private getPageContent() { const { selectedTabId } = this.state; if (selectedTabId === "overview") { return ; } else if (selectedTabId === "navigation") { return ; } else if (selectedTabId === "extensionData") { return ; } else if (selectedTabId === "messages") { return ; } } private getCommandBarItems(): IHeaderCommandBarItem[] { return [ { id: "panel", text: "Panel", onActivate: () => { this.onPanelClick() }, iconProps: { iconName: 'Add' }, isPrimary: true, tooltipProps: { content: "Open a panel with custom extension content" } }, { id: "messageDialog", text: "Message", onActivate: () => { this.onMessagePromptClick() }, tooltipProps: { content: "Open a simple message dialog" } }, { id: "customDialog", text: "Custom Dialog", onActivate: () => { this.onCustomPromptClick() }, tooltipProps: { content: "Open a dialog with custom extension content" } } ]; } private async onMessagePromptClick(): Promise { const dialogService = await SDK.getService(CommonServiceIds.HostDialogService); dialogService.openMessageDialog("Use large title?", { showCancel: true, title: "Message dialog", onClose: (result) => { this.setState({ useLargeTitle: result }); } }); } private async onCustomPromptClick(): Promise { const dialogService = await SDK.getService(CommonServiceIds.HostDialogService); dialogService.openCustomDialog(SDK.getExtensionContext().id + ".panel-content", { title: "Custom dialog", configuration: { message: "Use compact pivots?", initialValue: this.state.useCompactPivots }, onClose: (result) => { if (result !== undefined) { this.setState({ useCompactPivots: result }); } } }); } private async onPanelClick(): Promise { const panelService = await SDK.getService(CommonServiceIds.HostPanelService); panelService.openPanel(SDK.getExtensionContext().id + ".panel-content", { title: "My Panel", description: "Description of my panel", configuration: { message: "Show header kicker?", initialValue: !!this.state.headerKicker }, onClose: (result) => { if (result !== undefined) { this.setState({ headerKicker: result ? "This is a kicker" : undefined }); } } }); } } showRootComponent();