import * as React from "react"; import { NavBarProps, NavBarState } from "./interfaces"; import { EStopButton } from "../devices/components/e_stop_btn"; import { Session } from "../session"; import { Row, Col } from "../ui/index"; import { getPathArray } from "../history"; import { updatePageInfo } from "../util"; import { SyncButton } from "./sync_button"; import { NavLinks } from "./nav_links"; import { TickerList } from "./ticker_list"; import { AdditionalMenu } from "./additional_menu"; import { MobileMenu } from "./mobile_menu"; import { Popover, Position } from "@blueprintjs/core"; import { ErrorBoundary } from "../error_boundary"; import { RunTour } from "../help/tour"; import { t } from "../i18next_wrapper"; import { Connectivity } from "../devices/connectivity/connectivity"; import { connectivityData } from "../devices/connectivity/generate_data"; import { DiagnosisSaucer } from "../devices/connectivity/diagnosis"; import { maybeSetTimezone } from "../devices/timezones/guess_timezone"; import { BooleanSetting } from "../session_keys"; import { ReadOnlyIcon } from "../read_only_mode"; export class NavBar extends React.Component> { state: NavBarState = { mobileMenuOpen: false, tickerListOpen: false, accountMenuOpen: false }; componentDidMount = () => { const { device } = this.props; device && maybeSetTimezone(this.props.dispatch, device); } logout = () => Session.clear(); toggle = (key: keyof NavBarState) => () => this.setState({ [key]: !this.state[key] }); close = (key: keyof NavBarState) => () => this.setState({ [key]: false }); ReadOnlyStatus = () => SyncButton = () => EstopButton = () => AccountMenu = () => { const hasName = this.props.user?.body.name; const firstName = hasName ? `${hasName.split(" ")[0].slice(0, 9)} ▾` : `${t("Menu")} ▾`; return
{firstName}
{AdditionalMenu({ logout: this.logout, close: this.close })}
; } ConnectionStatus = () => { const data = connectivityData({ bot: this.props.bot, device: this.props.device }); return
; } AppNavLinks = () => { const { close } = this; const { mobileMenuOpen } = this.state; const { alertCount } = this.props; return
{MobileMenu({ close, mobileMenuOpen, alertCount })} {NavLinks({ close, alertCount })}
; } render() { /** Change document meta title on every route change. */ updatePageInfo(getPathArray()[2] || ""); const { toggle } = this; const { tickerListOpen } = this.state; const { logs, timeSettings, getConfigValue } = this.props; const tickerListProps = { logs, tickerListOpen, toggle, timeSettings, getConfigValue }; return
; } }