2024-03-27 14:30:01 +01:00
|
|
|
|
import { type FC, useEffect, useState } from 'react';
|
2023-01-18 10:10:41 +01:00
|
|
|
|
import { Box, styled } from '@mui/material';
|
2021-10-01 12:15:02 +02:00
|
|
|
|
import ProjectInfo from './ProjectInfo/ProjectInfo';
|
2022-08-04 13:57:25 +02:00
|
|
|
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
2023-01-27 13:13:41 +01:00
|
|
|
|
import { ProjectStats } from './ProjectStats/ProjectStats';
|
2024-01-31 08:22:26 +01:00
|
|
|
|
import { ProjectFeatureToggles } from './PaginatedProjectFeatureToggles/ProjectFeatureToggles';
|
|
|
|
|
import useProjectOverview, {
|
|
|
|
|
useProjectOverviewNameOrId,
|
|
|
|
|
} from 'hooks/api/getters/useProjectOverview/useProjectOverview';
|
|
|
|
|
import { usePageTitle } from 'hooks/usePageTitle';
|
|
|
|
|
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
2024-03-22 12:09:31 +01:00
|
|
|
|
import { useUiFlag } from 'hooks/useUiFlag';
|
2024-03-25 14:02:06 +01:00
|
|
|
|
import { ProjectOverviewChangeRequests } from './ProjectOverviewChangeRequests';
|
2024-03-27 14:30:01 +01:00
|
|
|
|
import { useFeedback } from '../../feedbackNew/useFeedback';
|
2024-03-27 13:30:31 +01:00
|
|
|
|
import { OldProjectFeatureToggles } from './PaginatedProjectFeatureToggles/OldProjectFeatureToggles';
|
2023-11-10 14:16:31 +01:00
|
|
|
|
|
2022-08-04 13:57:25 +02:00
|
|
|
|
const refreshInterval = 15 * 1000;
|
2021-10-01 12:15:02 +02:00
|
|
|
|
|
2023-01-03 16:15:22 +01:00
|
|
|
|
const StyledContainer = styled('div')(({ theme }) => ({
|
|
|
|
|
display: 'flex',
|
2023-12-01 15:53:05 +01:00
|
|
|
|
gap: theme.spacing(2),
|
2023-01-03 16:15:22 +01:00
|
|
|
|
[theme.breakpoints.down('md')]: {
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
},
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const StyledProjectToggles = styled('div')(() => ({
|
|
|
|
|
width: '100%',
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
}));
|
|
|
|
|
|
2023-12-01 15:53:05 +01:00
|
|
|
|
const StyledContentContainer = styled(Box)(({ theme }) => ({
|
2023-01-18 10:10:41 +01:00
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
2023-12-01 15:53:05 +01:00
|
|
|
|
gap: theme.spacing(2),
|
2023-01-18 10:10:41 +01:00
|
|
|
|
width: '100%',
|
2023-01-25 14:03:36 +01:00
|
|
|
|
minWidth: 0,
|
2023-01-18 10:10:41 +01:00
|
|
|
|
}));
|
|
|
|
|
|
2024-01-31 08:22:26 +01:00
|
|
|
|
const ProjectOverview: FC<{
|
2023-11-24 17:50:58 +01:00
|
|
|
|
storageKey?: string;
|
2023-12-19 16:24:43 +01:00
|
|
|
|
}> = ({ storageKey = 'project-overview-v2' }) => {
|
2024-03-22 12:09:31 +01:00
|
|
|
|
const projectOverviewRefactor = useUiFlag('projectOverviewRefactor');
|
2024-03-25 14:02:06 +01:00
|
|
|
|
|
|
|
|
|
if (projectOverviewRefactor) {
|
|
|
|
|
return <NewProjectOverview storageKey={storageKey} />;
|
|
|
|
|
} else {
|
|
|
|
|
return <OldProjectOverview storageKey={storageKey} />;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const OldProjectOverview: FC<{
|
|
|
|
|
storageKey?: string;
|
|
|
|
|
}> = ({ storageKey = 'project-overview-v2' }) => {
|
2023-11-01 12:05:42 +01:00
|
|
|
|
const projectId = useRequiredPathParam('projectId');
|
2024-01-31 08:22:26 +01:00
|
|
|
|
const projectName = useProjectOverviewNameOrId(projectId);
|
2023-12-01 19:00:35 +01:00
|
|
|
|
const { project } = useProjectOverview(projectId, {
|
2023-11-01 12:05:42 +01:00
|
|
|
|
refreshInterval,
|
|
|
|
|
});
|
2024-01-31 08:22:26 +01:00
|
|
|
|
usePageTitle(`Project overview – ${projectName}`);
|
|
|
|
|
const { setLastViewed } = useLastViewedProject();
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setLastViewed(projectId);
|
|
|
|
|
}, [projectId, setLastViewed]);
|
2023-11-08 13:19:40 +01:00
|
|
|
|
|
2023-12-01 19:00:35 +01:00
|
|
|
|
const {
|
|
|
|
|
members,
|
|
|
|
|
featureTypeCounts,
|
|
|
|
|
health,
|
|
|
|
|
description,
|
|
|
|
|
environments,
|
|
|
|
|
stats,
|
|
|
|
|
} = project;
|
2023-11-08 10:12:42 +01:00
|
|
|
|
|
2023-11-01 12:05:42 +01:00
|
|
|
|
return (
|
2023-11-24 17:50:58 +01:00
|
|
|
|
<StyledContainer key={projectId}>
|
2024-03-25 14:02:06 +01:00
|
|
|
|
<ProjectInfo
|
|
|
|
|
id={projectId}
|
|
|
|
|
description={description}
|
|
|
|
|
memberCount={members}
|
|
|
|
|
health={health}
|
|
|
|
|
featureTypeCounts={featureTypeCounts}
|
|
|
|
|
stats={stats}
|
2023-11-01 12:05:42 +01:00
|
|
|
|
/>
|
2024-03-22 12:09:31 +01:00
|
|
|
|
|
2023-11-01 12:05:42 +01:00
|
|
|
|
<StyledContentContainer>
|
2024-03-25 14:02:06 +01:00
|
|
|
|
<ProjectStats stats={project.stats} />
|
|
|
|
|
|
|
|
|
|
<StyledProjectToggles>
|
2024-03-27 13:30:31 +01:00
|
|
|
|
<OldProjectFeatureToggles
|
|
|
|
|
environments={project.environments.map(
|
2024-03-25 14:02:06 +01:00
|
|
|
|
(environment) => environment.environment,
|
|
|
|
|
)}
|
|
|
|
|
refreshInterval={refreshInterval}
|
|
|
|
|
storageKey={storageKey}
|
|
|
|
|
/>
|
|
|
|
|
</StyledProjectToggles>
|
|
|
|
|
</StyledContentContainer>
|
|
|
|
|
</StyledContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-27 14:30:01 +01:00
|
|
|
|
const useDelayedFeedbackPrompt = () => {
|
|
|
|
|
const { openFeedback, hasSubmittedFeedback } = useFeedback(
|
|
|
|
|
'newProjectOverview',
|
|
|
|
|
'manual',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const [seenFeedback, setSeenFeedback] = useState(false);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
if (!seenFeedback && !hasSubmittedFeedback) {
|
|
|
|
|
openFeedback({
|
|
|
|
|
title: 'How easy was it to work with the project overview in Unleash?',
|
|
|
|
|
positiveLabel:
|
|
|
|
|
'What do you like most about the updated project overview?',
|
|
|
|
|
areasForImprovementsLabel:
|
|
|
|
|
'What improvements are needed in the project overview?',
|
|
|
|
|
});
|
|
|
|
|
setSeenFeedback(true);
|
|
|
|
|
}
|
|
|
|
|
}, 30000);
|
|
|
|
|
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}, [hasSubmittedFeedback, openFeedback, seenFeedback]);
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-25 14:02:06 +01:00
|
|
|
|
const NewProjectOverview: FC<{
|
|
|
|
|
storageKey?: string;
|
|
|
|
|
}> = ({ storageKey = 'project-overview-v2' }) => {
|
|
|
|
|
const projectId = useRequiredPathParam('projectId');
|
|
|
|
|
const projectName = useProjectOverviewNameOrId(projectId);
|
|
|
|
|
|
|
|
|
|
const { project } = useProjectOverview(projectId, {
|
|
|
|
|
refreshInterval,
|
|
|
|
|
});
|
2024-03-27 14:30:01 +01:00
|
|
|
|
useDelayedFeedbackPrompt();
|
2024-03-25 14:02:06 +01:00
|
|
|
|
|
|
|
|
|
usePageTitle(`Project overview – ${projectName}`);
|
|
|
|
|
const { setLastViewed } = useLastViewedProject();
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setLastViewed(projectId);
|
|
|
|
|
}, [projectId, setLastViewed]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<StyledContainer key={projectId}>
|
|
|
|
|
<StyledContentContainer>
|
|
|
|
|
<ProjectOverviewChangeRequests project={projectId} />
|
2024-03-22 12:09:31 +01:00
|
|
|
|
|
2023-11-01 12:05:42 +01:00
|
|
|
|
<StyledProjectToggles>
|
2024-01-31 08:22:26 +01:00
|
|
|
|
<ProjectFeatureToggles
|
2024-03-25 14:02:06 +01:00
|
|
|
|
environments={project.environments.map(
|
|
|
|
|
(environment) => environment.environment,
|
|
|
|
|
)}
|
2023-12-04 17:04:28 +01:00
|
|
|
|
refreshInterval={refreshInterval}
|
|
|
|
|
storageKey={storageKey}
|
2023-11-08 10:12:42 +01:00
|
|
|
|
/>
|
2023-11-01 12:05:42 +01:00
|
|
|
|
</StyledProjectToggles>
|
|
|
|
|
</StyledContentContainer>
|
|
|
|
|
</StyledContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-01 12:15:02 +02:00
|
|
|
|
export default ProjectOverview;
|