Skip to content

Commit

Permalink
1-3144: extract project status into own component.
Browse files Browse the repository at this point in the history
This way, we don't need to reload the entire project page just to
open/close it.
  • Loading branch information
thomasheartman committed Nov 21, 2024
1 parent 52a456a commit 0bf45d2
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions frontend/src/component/project/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ const ProjectStatusButton = styled(Button)(({ theme }) => ({
},
}));

const ProjectStatusSvgWithMargin = styled(ProjectStatusSvg)(({ theme }) => ({
marginLeft: theme.spacing(0.5),
}));

const ProjectStatus = () => {
const [projectStatusOpen, setProjectStatusOpen] = useState(false);
return (
<>
<ProjectStatusButton
onClick={() => setProjectStatusOpen(true)}
startIcon={<ProjectStatusSvgWithMargin />}
data-loading-project
>
Project status
</ProjectStatusButton>
<ProjectStatusModal
open={projectStatusOpen}
close={() => setProjectStatusOpen(false)}
/>
</>
);
};

export const Project = () => {
const projectId = useRequiredPathParam('projectId');
const { trackEvent } = usePlausibleTracker();
Expand All @@ -133,7 +156,6 @@ export const Project = () => {
const projectName = project?.name || projectId;
const { favorite, unfavorite } = useFavoriteProjectsApi();
const simplifyProjectOverview = useUiFlag('simplifyProjectOverview');
const [projectStatusOpen, setProjectStatusOpen] = useState(false);

const [showDelDialog, setShowDelDialog] = useState(false);

Expand Down Expand Up @@ -297,15 +319,7 @@ export const Project = () => {
</PermissionIconButton>
}
/>
{simplifyProjectOverview && (
<ProjectStatusButton
onClick={() => setProjectStatusOpen(true)}
startIcon={<ProjectStatusSvg />}
data-loading-project
>
Project status
</ProjectStatusButton>
)}
{simplifyProjectOverview && <ProjectStatus />}
</StyledDiv>
</StyledTopRow>
</StyledInnerContainer>
Expand Down Expand Up @@ -428,10 +442,6 @@ export const Project = () => {
setOpen={setModalOpen}
project={projectId}
/>
<ProjectStatusModal
open={projectStatusOpen}
close={() => setProjectStatusOpen(false)}
/>
</div>
);
};

0 comments on commit 0bf45d2

Please sign in to comment.