import * as React from "react"; import { IconButton, PrimaryButton } from "office-ui-fabric-react/lib/Button"; import { KeyCodes } from "../../Common/Constants"; import { Subscription } from "knockout"; import ErrorRedIcon from "../../../images/error_red.svg"; import LoadingIndicatorIcon from "../../../images/LoadingIndicator_3Squares.gif"; import Explorer from "../Explorer"; export interface GenericRightPaneProps { container: Explorer; formError: string; formErrorDetail: string; id: string; isExecuting: boolean; onClose: () => void; onSubmit: () => void; submitButtonText: string; title: string; isSubmitButtonHidden?: boolean; } export interface GenericRightPaneState { panelHeight: number; } export class GenericRightPaneComponent extends React.Component { private notificationConsoleSubscription: Subscription; constructor(props: GenericRightPaneProps) { super(props); this.state = { panelHeight: this.getPanelHeight() }; } public componentDidMount(): void { this.notificationConsoleSubscription = this.props.container.isNotificationConsoleExpanded.subscribe(() => { this.setState({ panelHeight: this.getPanelHeight() }); }); this.props.container.isNotificationConsoleExpanded.extend({ rateLimit: 10 }); } public componentWillUnmount(): void { this.notificationConsoleSubscription && this.notificationConsoleSubscription.dispose(); } public render(): JSX.Element { return (
{this.renderPanelHeader()} {this.renderErrorSection()} {this.props.children} {this.renderPanelFooter()}
{this.renderLoadingScreen()}
); } private renderPanelHeader = (): JSX.Element => { return (
{this.props.title}
); }; private renderErrorSection = (): JSX.Element => { return ( ); }; private renderPanelFooter = (): JSX.Element => { return (
); }; private renderLoadingScreen = (): JSX.Element => { return ( ); }; private onKeyDown = (event: React.KeyboardEvent): void => { if (event.keyCode === KeyCodes.Escape) { this.props.onClose(); event.stopPropagation(); } }; private showErrorDetail = (): void => { this.props.container.expandConsole(); }; private getPanelHeight = (): number => { const notificationConsoleElement: HTMLElement = document.getElementById("explorerNotificationConsole"); return window.innerHeight - $(notificationConsoleElement).height(); }; }