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

79 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-01-25 14:03:36 +01:00
import { useEffect } from 'react';
import useProject, {
useProjectNameOrId,
} from 'hooks/api/getters/useProject/useProject';
import { Box, styled } from '@mui/material';
2022-02-28 17:20:47 +01:00
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 { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
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%',
2023-01-25 14:03:36 +01:00
minWidth: 0,
}));
const ProjectOverview = () => {
const projectId = useRequiredPathParam('projectId');
const projectName = useProjectNameOrId(projectId);
const { project, loading } = useProject(projectId, {
refreshInterval,
});
const { members, features, health, description, environments } = project;
usePageTitle(`Project overview ${projectName}`);
const { setLastViewed } = useLastViewedProject();
const { uiConfig } = useUiConfig();
2023-01-31 11:06:45 +01:00
console.log({ project });
useEffect(() => {
setLastViewed(projectId);
}, [projectId, setLastViewed]);
return (
<StyledContainer>
2022-12-07 12:52:17 +01:00
<ProjectInfo
id={projectId}
description={description}
memberCount={members}
health={health}
features={features}
2022-12-07 12:52:17 +01:00
/>
<StyledContentContainer>
<ConditionallyRender
condition={Boolean(uiConfig?.flags.newProjectOverview)}
show={<ProjectStats stats={project.stats} />}
/>
<StyledProjectToggles>
<ProjectFeatureToggles
features={features}
environments={environments}
loading={loading}
/>
</StyledProjectToggles>
</StyledContentContainer>
</StyledContainer>
);
};
export default ProjectOverview;