mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat(site): show metadata stale data (#8745)
This commit is contained in:
@ -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",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -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),
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user