import * as classNames from "classnames"; import { observer } from "mobx-react"; import * as React from "react"; import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react"; import { AppState, injectState } from "@app/state"; import { ConnectionState as ConState } from "@common/sprinklersRpc"; import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from "."; import "./DeviceView.scss"; const ConnectionState = observer(({ connectionState, className }: { connectionState: ConState, className?: string }) => { const connected = connectionState.isConnected; const classes = classNames({ connectionState: true, connected: connected === true, disconnected: connected === false, unknown: connected === null, }, className); let connectionText: string; let iconName: SemanticICONS = "unlinkify"; if (connected) { connectionText = "Connected"; iconName = "linkify"; } else if (connected === null) { connectionText = "Unknown"; iconName = "question"; } else if (connectionState.noPermission) { connectionText = "No permission for this device"; iconName = "ban"; } else if (connectionState.serverToBroker) { connectionText = "Device Disconnected"; } else if (connectionState.clientToServer) { connectionText = "Broker Disconnected"; } else { connectionText = "Server Disconnected"; } return (