Skip to content

Commit

Permalink
chore: small misc improvements in release plans
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Nov 27, 2024
1 parent eaca09b commit dd24785
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,20 @@ import { ReleasePlanRemoveDialog } from './ReleasePlanRemoveDialog';
import { ReleasePlanMilestone } from './ReleasePlanMilestone';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

const StyledContainer = styled('div', {
shouldForwardProp: (prop) => prop !== 'disabled',
})<{ disabled?: boolean }>(({ theme, disabled }) => ({
const StyledContainer = styled('div')(({ theme }) => ({
padding: theme.spacing(2),
borderRadius: theme.shape.borderRadiusMedium,
border: `1px solid ${theme.palette.divider}`,
'& + &': {
marginTop: theme.spacing(2),
},
background: disabled
? theme.palette.envAccordion.disabled
: theme.palette.background.paper,
background: theme.palette.background.paper,
}));

const StyledHeader = styled('div', {
shouldForwardProp: (prop) => prop !== 'disabled',
})<{ disabled?: boolean }>(({ theme, disabled }) => ({
const StyledHeader = styled('div')(({ theme }) => ({
display: 'flex',
justifyContent: 'space-between',
color: disabled ? theme.palette.text.secondary : theme.palette.text.primary,
color: theme.palette.text.primary,
}));

const StyledHeaderTitleContainer = styled('div')(({ theme }) => ({
Expand Down Expand Up @@ -132,14 +126,13 @@ export const ReleasePlan = ({ plan }: IReleasePlanProps) => {
}
};

const disabled = !activeMilestoneId;
const activeIndex = milestones.findIndex(
(milestone) => milestone.id === activeMilestoneId,
);

return (
<StyledContainer disabled={disabled}>
<StyledHeader disabled={disabled}>
<StyledContainer>
<StyledHeader>
<StyledHeaderTitleContainer>
<StyledHeaderTitleLabel>
Release plan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const StyledAccordionSummary = styled(AccordionSummary)({
'& .MuiAccordionSummary-content': {
justifyContent: 'space-between',
alignItems: 'center',
minHeight: '30px',
},
});

Expand Down Expand Up @@ -101,6 +102,19 @@ export const ReleasePlanMilestone = ({
? 'Restart'
: 'Start';

if (!milestone.strategies.length) {
return (
<StyledAccordion status={status} sx={{ pointerEvents: 'none' }}>
<StyledAccordionSummary>
<StyledTitleContainer>
<StyledTitle>{milestone.name}</StyledTitle>
</StyledTitleContainer>
<StyledSecondaryLabel>No strategies</StyledSecondaryLabel>
</StyledAccordionSummary>
</StyledAccordion>
);
}

return (
<StyledAccordion status={status}>
<StyledAccordionSummary expandIcon={<ExpandMore />}>
Expand Down Expand Up @@ -128,7 +142,11 @@ export const ReleasePlanMilestone = ({
/>
</StyledStatus>
</StyledTitleContainer>
<StyledSecondaryLabel>View strategies</StyledSecondaryLabel>
<StyledSecondaryLabel>
{milestone.strategies.length === 1
? 'View strategy'
: `View ${milestone.strategies.length} strategies`}
</StyledSecondaryLabel>
</StyledAccordionSummary>
<StyledAccordionDetails>
{milestone.strategies.map((strategy, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { ReactComponent as ReleaseTemplateIcon } from 'assets/img/releaseTemplat
import { styled, Typography } from '@mui/material';
import { ReleasePlanTemplateCardMenu } from './ReleasePlanTemplateCardMenu';
import { useNavigate } from 'react-router-dom';
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar';
import useUserInfo from 'hooks/api/getters/useUserInfo/useUserInfo';

const StyledTemplateCard = styled('aside')(({ theme }) => ({
height: '100%',
cursor: 'pointer',
'&:hover': {
transition: 'background-color 0.2s ease-in-out',
backgroundColor: theme.palette.neutral.light,
Expand Down Expand Up @@ -45,6 +48,12 @@ const StyledCreatedBy = styled(Typography)(({ theme }) => ({
display: 'flex',
alignItems: 'center',
marginRight: 'auto',
gap: theme.spacing(1),
}));

const StyledCreatedByAvatar = styled(UserAvatar)(({ theme }) => ({
width: theme.spacing(3),
height: theme.spacing(3),
}));

const StyledMenu = styled('div')(({ theme }) => ({
Expand All @@ -63,6 +72,7 @@ export const ReleasePlanTemplateCard = ({
const onClick = () => {
navigate(`/release-management/edit/${template.id}`);
};
const { user: createdBy } = useUserInfo(`${template.createdByUserId}`);

return (
<StyledTemplateCard onClick={onClick}>
Expand All @@ -75,7 +85,7 @@ export const ReleasePlanTemplateCard = ({
<div>{template.name}</div>
<StyledDiv>
<StyledCreatedBy>
Created by {template.createdByUserId}
Created by <StyledCreatedByAvatar user={createdBy} />
</StyledCreatedBy>
<StyledMenu
onClick={(e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CreateReleasePlanTemplate = () => {
type: 'success',
title: 'Release plan template created',
});
navigate(`/release-management/edit/${template.id}`);
navigate('/release-management');
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const EditReleasePlanTemplate = () => {
type: 'success',
title: 'Release plan template updated',
});
navigate('/release-management');
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));
}
Expand Down

0 comments on commit dd24785

Please sign in to comment.