import { Toolbar, Box, Select, MenuItem, Button, IconButton, Tooltip, useMediaQuery, } from '@mui/material' import { useTheme } from '@mui/material' import { Save, ShowChart, Refresh, RadioButtonChecked, RadioButtonUnchecked } from '@mui/icons-material' import { useI18nStore } from '../../stores/i18n.store' import { useRedisStateStore } from '../../stores/redis-state.store' import { useMainCommandStore } from '../../stores/main-command.store' export default function DatabaseHeader() { const strings = useI18nStore(s => s.strings) const connection = useRedisStateStore(s => s.connection) const currentDatabase = useRedisStateStore(s => s.currentDatabase) const databaseIndexes = useRedisStateStore(s => s.databaseIndexes) const info = useRedisStateStore(s => s.info) const { selectDatabase, save, statistics, refresh } = useMainCommandStore() const muiTheme = useTheme() const isXs = useMediaQuery('(max-width: 599px)') const isWide = useMediaQuery('(min-width: 720px)') const isReadonly = connection?.readonly === true const isCluster = connection?.cluster === true const hasConnection = !!connection const keyspaceDatabases = info?.keyspaceDatabases || {} const hasKeys = (dbIndex: number) => !!keyspaceDatabases[dbIndex] if (!hasConnection) return null return ( {/* Title - hidden on xs */} {!isXs && ( statistics()} sx={{ flex: 1, fontSize: 20, fontWeight: 400, m: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', cursor: 'pointer', textDecoration: 'none', color: 'inherit', }} > {strings?.intention?.main} )} {/* DB selector */} {!isCluster && databaseIndexes.length > 0 && ( DB: )} {/* Save (non-readonly only) */} {!isReadonly && ( isWide ? ( ) : ( save()}> ) )} {/* Statistics */} {isWide ? ( ) : ( statistics()}> )} {/* Refresh */} {isWide ? ( ) : ( refresh()}> )} ) }