1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00

refactor: simplify badge logic for draft automations

Remove unnecessary distinction between create and update for badge display.
Both cases just need to show "Modified in draft" when there's a pending
changeMilestoneProgression action.

Also remove unused StyledAddAutomationContainer and badge next to "Add
automation" button since pending creates now show the display component
instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FredrikOseberg 2025-10-24 09:18:39 +02:00
parent 51ff54497e
commit 8fbb149b9b
No known key found for this signature in database
GPG Key ID: 282FD8A6D8F9BCF0

View File

@ -36,12 +36,6 @@ const StyledAddAutomationButton = styled(Button)(({ theme }) => ({
}, },
})); }));
const StyledAddAutomationContainer = styled('div')(({ theme }) => ({
display: 'flex',
alignItems: 'center',
gap: theme.spacing(1),
}));
interface MilestoneAutomationProps { interface MilestoneAutomationProps {
milestone: IReleasePlanMilestone; milestone: IReleasePlanMilestone;
status: MilestoneStatus; status: MilestoneStatus;
@ -82,20 +76,14 @@ export const MilestoneAutomation = ({
return null; return null;
} }
// When milestone has no original transitionCondition but has a pending changeMilestoneProgression, it's a create
const isOriginallyEmpty = !milestone.transitionCondition;
const hasPendingCreate =
isOriginallyEmpty &&
pendingProgressionChange?.action === 'changeMilestoneProgression';
const hasPendingChange = const hasPendingChange =
!isOriginallyEmpty &&
pendingProgressionChange?.action === 'changeMilestoneProgression'; pendingProgressionChange?.action === 'changeMilestoneProgression';
const hasPendingDelete = const hasPendingDelete =
pendingProgressionChange?.action === 'deleteMilestoneProgression'; pendingProgressionChange?.action === 'deleteMilestoneProgression';
const badge = hasPendingDelete ? ( const badge = hasPendingDelete ? (
<Badge color='error'>Deleted in draft</Badge> <Badge color='error'>Deleted in draft</Badge>
) : hasPendingChange || hasPendingCreate ? ( ) : hasPendingChange ? (
<Badge color='warning'>Modified in draft</Badge> <Badge color='warning'>Modified in draft</Badge>
) : undefined; ) : undefined;
@ -121,7 +109,6 @@ export const MilestoneAutomation = ({
badge={badge} badge={badge}
/> />
) : ( ) : (
<StyledAddAutomationContainer>
<StyledAddAutomationButton <StyledAddAutomationButton
onClick={onOpenProgressionForm} onClick={onOpenProgressionForm}
color='primary' color='primary'
@ -129,10 +116,6 @@ export const MilestoneAutomation = ({
> >
Add automation Add automation
</StyledAddAutomationButton> </StyledAddAutomationButton>
{hasPendingCreate && (
<Badge color='warning'>Modified in draft</Badge>
)}
</StyledAddAutomationContainer>
)} )}
</MilestoneAutomationSection> </MilestoneAutomationSection>
); );