feat(site): show metadata stale data (#8745)

This commit is contained in:
Bruno Quaresma
2023-07-26 15:41:07 -03:00
committed by GitHub
parent 9ffbdc6696
commit b5dec61cd5
2 changed files with 27 additions and 20 deletions

View File

@ -57,7 +57,7 @@ Example.args = {
{ {
result: { result: {
...resultDefaults, ...resultDefaults,
value: "cant see it", value: "stale value",
age: 300, age: 300,
}, },
description: { description: {
@ -76,18 +76,7 @@ Example.args = {
description: { description: {
...descriptionDefaults, ...descriptionDefaults,
display_name: "Error", display_name: "Error",
}, key: "error",
},
{
result: {
...resultDefaults,
value: "oops",
error: "fatal error",
},
description: {
...descriptionDefaults,
display_name: "Error",
key: "stale",
}, },
}, },
{ {

View File

@ -6,6 +6,8 @@ import dayjs from "dayjs"
import { createContext, FC, useContext, useEffect, useState } from "react" import { createContext, FC, useContext, useEffect, useState } from "react"
import Skeleton from "@mui/material/Skeleton" import Skeleton from "@mui/material/Skeleton"
import { MONOSPACE_FONT_FAMILY } from "theme/constants" import { MONOSPACE_FONT_FAMILY } from "theme/constants"
import { combineClasses } from "utils/combineClasses"
import Tooltip from "@mui/material/Tooltip"
type ItemStatus = "stale" | "valid" | "loading" type ItemStatus = "stale" | "valid" | "loading"
@ -44,22 +46,33 @@ const MetadataItem: FC<{ item: WorkspaceAgentMetadata }> = ({ item }) => {
// users that what's shown is real. If times aren't correctly synced this // users that what's shown is real. If times aren't correctly synced this
// could be buggy. But, how common is that anyways? // could be buggy. But, how common is that anyways?
const value = const value =
status === "stale" || status === "loading" ? ( status === "loading" ? (
<Skeleton <Skeleton
width={65} width={65}
height={12} height={12}
variant="text" variant="text"
className={styles.skeleton} className={styles.skeleton}
/> />
) : status === "stale" ? (
<Tooltip title="This data is stale and no longer up to date">
<div
className={combineClasses([
styles.metadataValue,
styles.metadataStale,
])}
>
{item.result.value}
</div>
</Tooltip>
) : ( ) : (
<div <div
className={ className={combineClasses([
styles.metadataValue + styles.metadataValue,
" " +
(item.result.error.length === 0 item.result.error.length === 0
? styles.metadataValueSuccess ? styles.metadataValueSuccess
: styles.metadataValueError) : styles.metadataValueError,
} ])}
> >
{item.result.value} {item.result.value}
</div> </div>
@ -226,6 +239,11 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.error.main, color: theme.palette.error.main,
}, },
metadataStale: {
color: theme.palette.text.disabled,
cursor: "pointer",
},
skeleton: { skeleton: {
marginTop: theme.spacing(0.5), marginTop: theme.spacing(0.5),
}, },