-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align aggregate counts for job statuses
On the Lookout UI, when grouping is enabled for the jobs table, change how counts for different statuses are displayed, so that they are aligned and are less visually noisy. This change is in response to user feedback.
- Loading branch information
Maurice Yap
authored and
GitHub Enterprise
committed
Jan 6, 2025
1 parent
6e5c1eb
commit d1a7ffd
Showing
14 changed files
with
282 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
internal/lookout/ui/src/components/lookoutV2/JobGroupStateCounts.module.css
This file was deleted.
Oops, something went wrong.
69 changes: 42 additions & 27 deletions
69
internal/lookout/ui/src/components/lookoutV2/JobGroupStateCounts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
import { Chip, Tooltip, Typography } from "@mui/material" | ||
import { Chip, styled, Tooltip } from "@mui/material" | ||
|
||
import styles from "./JobGroupStateCounts.module.css" | ||
import { JobState, jobStateColors, jobStateIcons } from "../../models/lookoutV2Models" | ||
import { JobState, jobStateColors } from "../../models/lookoutV2Models" | ||
import { formatJobState } from "../../utils/jobsTableFormatters" | ||
|
||
const CountsContainer = styled("div")({ | ||
display: "grid", | ||
gridAutoColumns: "minmax(0, 1fr)", | ||
gridAutoFlow: "column", | ||
textAlign: "center", | ||
}) | ||
|
||
const StateCountChip = styled(Chip)({ | ||
width: "100%", | ||
borderRadius: 0, | ||
|
||
"& .MuiChip-label": { | ||
overflow: "visible", | ||
}, | ||
}) | ||
|
||
interface JobGroupStateCountsProps { | ||
jobStatesToDisplay?: JobState[] | ||
stateCounts: Partial<Record<JobState, number>> | ||
} | ||
|
||
export const JobGroupStateCounts = ({ stateCounts }: JobGroupStateCountsProps) => ( | ||
<div className={styles.container}> | ||
{Object.values(JobState) | ||
.flatMap( | ||
(jobState) => (jobState in stateCounts ? [[jobState, stateCounts[jobState]]] : []) as [JobState, number][], | ||
) | ||
.map(([_jobState, count]) => { | ||
const jobState = _jobState as JobState | ||
const Icon = jobStateIcons[jobState] | ||
return ( | ||
<Tooltip key={jobState} title={formatJobState(jobState)}> | ||
<Chip | ||
size="small" | ||
variant="outlined" | ||
label={ | ||
<Typography fontSize="inherit" color="text.primary" fontWeight="medium"> | ||
{count.toString()} | ||
</Typography> | ||
} | ||
color={jobStateColors[jobState]} | ||
icon={<Icon />} | ||
/> | ||
export const JobGroupStateCounts = ({ | ||
stateCounts, | ||
jobStatesToDisplay = Object.values(JobState), | ||
}: JobGroupStateCountsProps) => ( | ||
<CountsContainer> | ||
{Object.values(JobState).map((_jobState) => { | ||
const jobState = _jobState as JobState | ||
const count = stateCounts[jobState] ?? 0 | ||
return ( | ||
jobStatesToDisplay.includes(jobState) && ( | ||
<Tooltip key={jobState} title={`${formatJobState(jobState)} (${count.toString()})`}> | ||
<div> | ||
<StateCountChip | ||
size="small" | ||
variant="shaded" | ||
label={count.toString()} | ||
color={jobStateColors[jobState]} | ||
disabled={count === 0} | ||
/> | ||
</div> | ||
</Tooltip> | ||
) | ||
})} | ||
</div> | ||
) | ||
})} | ||
</CountsContainer> | ||
) |
35 changes: 35 additions & 0 deletions
35
internal/lookout/ui/src/components/lookoutV2/JobGroupStateCountsColumnHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { styled, Tooltip } from "@mui/material" | ||
|
||
import { JobState, jobStateColors, jobStateIcons } from "../../models/lookoutV2Models" | ||
import { formatJobState } from "../../utils/jobsTableFormatters" | ||
|
||
const OuterContainer = styled("div")({ | ||
display: "grid", | ||
gridAutoColumns: "minmax(0, 1fr)", | ||
gridAutoFlow: "column", | ||
textAlign: "center", | ||
}) | ||
|
||
export interface JobGroupStateCountsColumnHeaderProps { | ||
jobStatesToDisplay?: JobState[] | ||
} | ||
|
||
export const JobGroupStateCountsColumnHeader = ({ | ||
jobStatesToDisplay = Object.values(JobState), | ||
}: JobGroupStateCountsColumnHeaderProps) => ( | ||
<OuterContainer> | ||
{Object.values(JobState).map((_jobState) => { | ||
const jobState = _jobState as JobState | ||
const Icon = jobStateIcons[jobState] | ||
return ( | ||
jobStatesToDisplay.includes(jobState) && ( | ||
<Tooltip key={jobState} title={formatJobState(jobState)} placement="top"> | ||
<div> | ||
<Icon fontSize="inherit" color={jobStateColors[jobState]} /> | ||
</div> | ||
</Tooltip> | ||
) | ||
) | ||
})} | ||
</OuterContainer> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.