Fixed when the empty message should appear

This commit is contained in:
José Oliveira 2021-02-04 13:44:29 +00:00 committed by Josh Harvey
parent d2fd305329
commit 037f383540
2 changed files with 30 additions and 35 deletions

View file

@ -16,7 +16,7 @@ import {
TableBody, TableBody,
TableCell TableCell
} from 'src/components/table' } from 'src/components/table'
import { Info3 } from 'src/components/typography' import { Info3, H4 } from 'src/components/typography'
import styles from './Logs.styles' import styles from './Logs.styles'
@ -74,7 +74,7 @@ const Logs = () => {
const { data: machineResponse } = useQuery(GET_MACHINES) const { data: machineResponse } = useQuery(GET_MACHINES)
const { data: logsResponse } = useQuery(GET_MACHINE_LOGS, { const { data: logsResponse, loading } = useQuery(GET_MACHINE_LOGS, {
variables: { deviceId, limit: NUM_LOG_RESULTS }, variables: { deviceId, limit: NUM_LOG_RESULTS },
skip: !selected, skip: !selected,
onCompleted: () => setSaveMessage('') onCompleted: () => setSaveMessage('')
@ -123,10 +123,6 @@ const Logs = () => {
<TableHeader className={classes.fillColumn} /> <TableHeader className={classes.fillColumn} />
</TableRow> </TableRow>
</TableHead> </TableHead>
{logsResponse &&
(!logsResponse.machineLogs.length ? (
<p>{'No activity so far'}</p>
) : (
<TableBody> <TableBody>
{logsResponse && {logsResponse &&
logsResponse.machineLogs.map((log, idx) => ( logsResponse.machineLogs.map((log, idx) => (
@ -137,8 +133,9 @@ const Logs = () => {
</TableRow> </TableRow>
))} ))}
</TableBody> </TableBody>
))}
</Table> </Table>
{loading && <H4>{'Loading...'}</H4>}
{!loading && !logsResponse && <H4>{'No activity so far'}</H4>}
</div> </div>
</div> </div>
</> </>

View file

@ -17,7 +17,7 @@ import {
TableBody, TableBody,
TableCell TableCell
} from 'src/components/table' } from 'src/components/table'
import { Info3 } from 'src/components/typography' import { Info3, H4 } from 'src/components/typography'
import typographyStyles from 'src/components/typography/styles' import typographyStyles from 'src/components/typography/styles'
import { offColor } from 'src/styling/variables' import { offColor } from 'src/styling/variables'
import { startCase } from 'src/utils/string' import { startCase } from 'src/utils/string'
@ -91,7 +91,7 @@ const Logs = () => {
const [saveMessage, setSaveMessage] = useState(null) const [saveMessage, setSaveMessage] = useState(null)
const [logLevel, setLogLevel] = useState(SHOW_ALL) const [logLevel, setLogLevel] = useState(SHOW_ALL)
const { data } = useQuery(GET_DATA, { const { data, loading } = useQuery(GET_DATA, {
onCompleted: () => setSaveMessage(''), onCompleted: () => setSaveMessage(''),
variables: { variables: {
limit: NUM_LOG_RESULTS limit: NUM_LOG_RESULTS
@ -174,9 +174,6 @@ const Logs = () => {
</TableHead> </TableHead>
<TableBody> <TableBody>
{data && {data &&
(!data.serverLogs.length ? (
<p>{'No activity so far'} </p>
) : (
data.serverLogs data.serverLogs
.filter( .filter(
log => log =>
@ -188,10 +185,11 @@ const Logs = () => {
<TableCell>{log.logLevel}</TableCell> <TableCell>{log.logLevel}</TableCell>
<TableCell>{log.message}</TableCell> <TableCell>{log.message}</TableCell>
</TableRow> </TableRow>
))
))} ))}
</TableBody> </TableBody>
</Table> </Table>
{loading && <H4>{'Loading...'}</H4>}
{!loading && !data && <H4>{'No activity so far'}</H4>}
</div> </div>
</div> </div>
</> </>