Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-3144: extract project status into own component. #8823

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};
Loading