1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: human readable project names in insight charts (#7686)

This commit is contained in:
Mateusz Kwasniewski 2024-07-29 11:52:14 +02:00 committed by GitHub
parent 1cd1f982ee
commit 94588c12d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ import type { InstanceInsightsSchema } from 'openapi';
import { useProjectColor } from './useProjectColor';
import { useTheme } from '@mui/material';
import type { GroupedDataByProject } from './useGroupedProjectTrends';
import useProjects from 'hooks/api/getters/useProjects/useProjects';
type ProjectFlagTrends = InstanceInsightsSchema['projectFlagTrends'];
@ -11,13 +12,17 @@ export const useProjectChartData = (
) => {
const theme = useTheme();
const getProjectColor = useProjectColor();
const { projects } = useProjects();
const projectNames = new Map(
projects.map((project) => [project.id, project.name]),
);
const data = useMemo(() => {
const datasets = Object.entries(projectFlagTrends).map(
([project, trends]) => {
const color = getProjectColor(project);
return {
label: project,
label: projectNames.get(project) || project,
data: trends,
borderColor: color,
backgroundColor: color,