import React from 'react'; import styled from 'styled-components'; import { FontIcon } from '../icons'; import useTheme from '../theme/useTheme'; import { useCurrentDatabase } from '../utility/globalState'; import { useDatabaseStatus } from '../utility/metadataLoaders'; const Container = styled.div` display: flex; color: ${(props) => props.theme.statusbar_font1}; align-items: stretch; `; const Item = styled.div` padding: 2px 10px; // margin: auto; // flex-grow: 0; `; const ErrorWrapper = styled.span` color: ${(props) => // @ts-ignore props.theme.statusbar_font_red[5]}; `; const InfoWrapper = styled.span` color: ${(props) => // @ts-ignore props.theme.statusbar_font_green[5]}; `; export default function StatusBar() { const { name, connection } = useCurrentDatabase() || {}; const status = useDatabaseStatus(connection ? { conid: connection._id, database: name } : {}); const { displayName, server, user, engine } = connection || {}; const theme = useTheme(); return ( {name && ( {name} )} {(displayName || server) && ( {displayName || server} )} {user && ( {user} )} {connection && status && ( {status.name == 'pending' && ( <> Loading )} {status.name == 'ok' && ( <> {' '} Connected )} {status.name == 'error' && ( <> {' '} Error )} )} {!connection && ( <> Not connected )} ); }