1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-19 17:52:45 +02:00

refactor: handle more cases

This commit is contained in:
Thomas Heartman 2024-10-15 09:49:44 +02:00
parent 370daf8be4
commit aaf2dbb34a
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
5 changed files with 70 additions and 10 deletions

View File

@ -0,0 +1,29 @@
import { ActionBox } from './ActionBox';
import { NeutralCircleContainer } from './SharedComponents';
import type { PersonalDashboardSchemaProjectOwnersItem } from 'openapi';
import type { FC } from 'react';
import { AvatarGroupFromOwners } from 'component/common/AvatarGroupFromOwners/AvatarGroupFromOwners';
export const AskOwnerToAddYouToTheirProject: FC<{
owners: PersonalDashboardSchemaProjectOwnersItem[];
}> = ({ owners }) => {
return (
<ActionBox
title={
<>
<NeutralCircleContainer>2</NeutralCircleContainer>
Ask a project owner to add you to their project
</>
}
>
{owners.length ? (
<>
<p>Project owners in Unleash:</p>
<AvatarGroupFromOwners users={owners} avatarLimit={9} />
</>
) : (
<p>There are no project owners in Unleash to ask for access.</p>
)}
</ActionBox>
);
};

View File

@ -3,16 +3,7 @@ import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import type { FC } from 'react'; import type { FC } from 'react';
import { ActionBox } from './ActionBox'; import { ActionBox } from './ActionBox';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { NeutralCircleContainer } from './SharedComponents';
const NeutralCircleContainer = styled('span')(({ theme }) => ({
width: '28px',
height: '28px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.palette.neutral.border,
borderRadius: '50%',
}));
const MainCircleContainer = styled(NeutralCircleContainer)(({ theme }) => ({ const MainCircleContainer = styled(NeutralCircleContainer)(({ theme }) => ({
backgroundColor: theme.palette.primary.main, backgroundColor: theme.palette.primary.main,

View File

@ -33,6 +33,8 @@ import { ContactAdmins, DataError } from './ProjectDetailsError';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { ActionBox } from './ActionBox'; import { ActionBox } from './ActionBox';
import { NoProjectsContactAdmin } from './NoProjectsContactAdmin';
import { AskOwnerToAddYouToTheirProject } from './AskOwnerToAddYouToTheirProject';
const ActiveProjectDetails: FC<{ const ActiveProjectDetails: FC<{
project: PersonalDashboardSchemaProjectsItem; project: PersonalDashboardSchemaProjectsItem;
@ -140,6 +142,7 @@ export const MyProjects = forwardRef<
setActiveProject, setActiveProject,
activeProject, activeProject,
admins, admins,
owners,
}, },
ref, ref,
) => { ) => {
@ -158,6 +161,7 @@ export const MyProjects = forwardRef<
const box1Content = () => { const box1Content = () => {
if (state === 'no projects') { if (state === 'no projects') {
return <NoProjectsContactAdmin admins={admins} />;
} }
if (state === 'projects with error') { if (state === 'projects with error') {
@ -185,6 +189,10 @@ export const MyProjects = forwardRef<
}; };
const box2Content = () => { const box2Content = () => {
if (state === 'no projects') {
return <AskOwnerToAddYouToTheirProject owners={owners} />;
}
if (state === 'projects with error') { if (state === 'projects with error') {
return <ContactAdmins admins={admins} />; return <ContactAdmins admins={admins} />;
} }

View File

@ -0,0 +1,22 @@
import { ActionBox } from './ActionBox';
import { YourAdmins } from './YourAdmins';
import { NeutralCircleContainer } from './SharedComponents';
import type { PersonalDashboardSchemaAdminsItem } from 'openapi';
import type { FC } from 'react';
export const NoProjectsContactAdmin: FC<{
admins: PersonalDashboardSchemaAdminsItem[];
}> = ({ admins }) => {
return (
<ActionBox
title={
<>
<NeutralCircleContainer>1</NeutralCircleContainer>
Contact Unleash admin
</>
}
>
<YourAdmins admins={admins} />
</ActionBox>
);
};

View File

@ -130,3 +130,13 @@ export const StyledCardTitle = styled('div')<{ lines?: number }>(
wordBreak: 'break-word', wordBreak: 'break-word',
}), }),
); );
export const NeutralCircleContainer = styled('span')(({ theme }) => ({
width: '28px',
height: '28px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.palette.neutral.border,
borderRadius: '50%',
}));