Skip to content

Commit 3447b03

Browse files
Fix(1-3564)/hide project owner if system (#9686)
Hides owner avatars in cases where the owner type is "system". Touches dashboard and project card owners. Back when all projects required owners, we introduced the new project cards that have the owner listed in the footer. Because, theoretically, you weren’t allowed to create projects without owners, the only project that should ever be without an owner was the default project. So we thought it made sense to say that it was owned by the system. But now that owners are optional, that doesn't necessarily make sense anymore. As such, we'll just hide their avatars to begin with. <img width="726" alt="image" src="https://github.com/user-attachments/assets/950cd909-c891-48f1-9ef7-fd74922a5990" /> <img width="1497" alt="image" src="https://github.com/user-attachments/assets/f4d213f5-febb-46f8-89f0-899e77652e07" /> Because the components expected the avatars to be there, we now need to set an explicit min-height on them, so that they don't collapse. Luckily, we can use the default avatar height (and also force that so that they change in tandem) and use that in both places.
1 parent 4344c94 commit 3447b03

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

frontend/src/component/personalDashboard/RoleAndOwnerInfo.tsx

+27-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ type Props = {
99
owners: ProjectSchemaOwners;
1010
};
1111

12+
const avatarHeight = 3.5;
13+
1214
const Wrapper = styled('div')(({ theme }) => ({
1315
width: '100%',
1416
display: 'flex',
@@ -21,6 +23,7 @@ const InfoSection = styled('div')(({ theme }) => ({
2123
display: 'flex',
2224
gap: theme.spacing(1),
2325
alignItems: 'center',
26+
minHeight: theme.spacing(avatarHeight),
2427
}));
2528

2629
const Roles = styled('ul')(({ theme }) => ({
@@ -43,13 +46,17 @@ const RoleBadge = styled(Badge)({
4346
whitespace: 'nowrap',
4447
});
4548

46-
const StyledAvatarGroup = styled(AvatarGroupFromOwners)({
49+
const StyledAvatarGroup = styled(AvatarGroupFromOwners)(({ theme }) => ({
4750
width: 'max-content',
48-
});
51+
height: theme.spacing(avatarHeight),
52+
}));
4953

5054
export const RoleAndOwnerInfo = ({ roles, owners }: Props) => {
5155
const firstRoles = roles.slice(0, 3);
5256
const extraRoles = roles.slice(3);
57+
const ownersWithoutSystem = owners.filter(
58+
(owner) => owner.ownerType !== 'system',
59+
);
5360
return (
5461
<Wrapper data-loading>
5562
<InfoSection>
@@ -104,16 +111,24 @@ export const RoleAndOwnerInfo = ({ roles, owners }: Props) => {
104111
)}
105112
</InfoSection>
106113
<InfoSection>
107-
<Typography
108-
variant='body1'
109-
component='h4'
110-
sx={{
111-
whiteSpace: 'nowrap',
112-
}}
113-
>
114-
Project owner{owners.length > 1 ? 's' : ''}
115-
</Typography>
116-
<StyledAvatarGroup users={owners} avatarLimit={3} />
114+
{ownersWithoutSystem.length > 0 ? (
115+
<>
116+
<Typography
117+
variant='body1'
118+
component='h4'
119+
sx={{
120+
whiteSpace: 'nowrap',
121+
}}
122+
>
123+
Project owner
124+
{ownersWithoutSystem.length > 1 ? 's' : ''}
125+
</Typography>
126+
<StyledAvatarGroup
127+
users={ownersWithoutSystem as ProjectSchemaOwners}
128+
avatarLimit={3}
129+
/>
130+
</>
131+
) : null}
117132
</InfoSection>
118133
</Wrapper>
119134
);

frontend/src/component/project/ProjectCard/ProjectCardFooter/ProjectCardFooter.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ProjectOwners,
66
type IProjectOwnersProps,
77
} from './ProjectOwners/ProjectOwners';
8+
import type { ProjectSchemaOwners } from 'openapi';
89

910
interface IProjectCardFooterProps {
1011
id?: string;
@@ -24,6 +25,8 @@ const StyledFooter = styled(Box)<{ disabled: boolean }>(
2425
alignItems: 'center',
2526
justifyContent: 'space-between',
2627
borderTop: `1px solid ${theme.palette.divider}`,
28+
paddingInline: theme.spacing(2),
29+
paddingBlock: theme.spacing(1.5),
2730
}),
2831
);
2932

@@ -32,9 +35,16 @@ export const ProjectCardFooter: FC<IProjectCardFooterProps> = ({
3235
owners,
3336
disabled = false,
3437
}) => {
38+
const ownersWithoutSystem = owners?.filter(
39+
(owner) => owner.ownerType !== 'system',
40+
);
3541
return (
3642
<StyledFooter disabled={disabled}>
37-
{owners ? <ProjectOwners owners={owners} /> : null}
43+
{ownersWithoutSystem ? (
44+
<ProjectOwners
45+
owners={ownersWithoutSystem as ProjectSchemaOwners}
46+
/>
47+
) : null}
3848
{children}
3949
</StyledFooter>
4050
);

frontend/src/component/project/ProjectCard/ProjectCardFooter/ProjectOwners/ProjectOwners.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ const StyledHeader = styled('span')(({ theme }) => ({
4545
marginRight: 'auto',
4646
}));
4747

48+
const AvatarHeight = 3.5;
4849
const StyledWrapper = styled('div')(({ theme }) => ({
49-
padding: theme.spacing(1.5, 0, 1.5, 2),
5050
display: 'flex',
5151
alignItems: 'center',
52+
minHeight: theme.spacing(AvatarHeight),
5253
}));
5354

5455
const StyledAvatarComponent = styled(AvatarComponent)(({ theme }) => ({
5556
cursor: 'default',
57+
height: theme.spacing(AvatarHeight),
5658
}));
5759

5860
const getOwnerName = (owner?: ProjectSchemaOwners[number]) => {

0 commit comments

Comments
 (0)