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

View file

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