1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/project/Project/ProjectOverview.tsx
Tymoteusz Czech f82ae354eb
fix: project features table initial state (#4843)
When loading don't keep initial state, but recalculate if after proper
data is present. (issue 1-1432)
2023-09-27 08:37:25 +00:00

75 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect } from 'react';
import useProject, {
useProjectNameOrId,
} from 'hooks/api/getters/useProject/useProject';
import { Box, styled } from '@mui/material';
import { ProjectFeatureToggles } from './ProjectFeatureToggles/ProjectFeatureToggles';
import ProjectInfo from './ProjectInfo/ProjectInfo';
import { usePageTitle } from 'hooks/usePageTitle';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { useLastViewedProject } from 'hooks/useLastViewedProject';
import { ProjectStats } from './ProjectStats/ProjectStats';
const refreshInterval = 15 * 1000;
const StyledContainer = styled('div')(({ theme }) => ({
display: 'flex',
[theme.breakpoints.down('md')]: {
flexDirection: 'column',
},
}));
const StyledProjectToggles = styled('div')(() => ({
width: '100%',
minWidth: 0,
}));
const StyledContentContainer = styled(Box)(() => ({
display: 'flex',
flexDirection: 'column',
width: '100%',
minWidth: 0,
}));
const ProjectOverview = () => {
const projectId = useRequiredPathParam('projectId');
const projectName = useProjectNameOrId(projectId);
const { project, loading } = useProject(projectId, {
refreshInterval,
});
const { members, features, health, description, environments, stats } =
project;
usePageTitle(`Project overview ${projectName}`);
const { setLastViewed } = useLastViewedProject();
useEffect(() => {
setLastViewed(projectId);
}, [projectId, setLastViewed]);
return (
<StyledContainer>
<ProjectInfo
id={projectId}
description={description}
memberCount={members}
health={health}
features={features}
stats={stats}
/>
<StyledContentContainer>
<ProjectStats stats={project.stats} />
<StyledProjectToggles>
<ProjectFeatureToggles
key={loading ? 'loading' : 'ready'}
features={features}
environments={environments}
loading={loading}
/>
</StyledProjectToggles>
</StyledContentContainer>
</StyledContainer>
);
};
export default ProjectOverview;