This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): drawer. replace statuses pie with inline indicator
- Loading branch information
Showing
5 changed files
with
60 additions
and
65 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
38 changes: 38 additions & 0 deletions
38
packages/ui/src/components/Drawer/Queues/QueueStatusesIndicator.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,38 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import type { JobStatus } from '@/typings/gql'; | ||
import { useJobStatusesPalette } from '@/components/JobStatusChip/hooks'; | ||
import { MathUtils } from '@/services/math-utils'; | ||
import sum from 'lodash/sum'; | ||
import { useMemo } from 'react'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: 'flex', | ||
height: 3, | ||
overflow: 'hidden', | ||
marginTop: theme.spacing(0.5), | ||
}, | ||
})); | ||
|
||
type TProps = { | ||
count: { status: JobStatus; count: number }[]; | ||
}; | ||
export default function QueueStatusesIndicator({ count }: TProps) { | ||
const cls = useStyles(); | ||
const palette = useJobStatusesPalette(); | ||
const mapped = useMemo(() => { | ||
const allJobsCount = sum(count.map(({ count }) => count)); | ||
return count.map(({ count, status }) => ({ | ||
width: MathUtils.mapNumberToPercent(count, 0, allJobsCount) + '%', | ||
color: palette[status], | ||
})); | ||
}, [palette, count]); | ||
return ( | ||
<div className={cls.root}> | ||
{mapped.map(({ width, color }, idx) => ( | ||
<div style={{ width, backgroundColor: color }} key={idx} /> | ||
))} | ||
</div> | ||
); | ||
} |
29 changes: 0 additions & 29 deletions
29
packages/ui/src/components/Drawer/Queues/QueueStatusesPie.tsx
This file was deleted.
Oops, something went wrong.
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