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:
parent
51ff54497e
commit
8fbb149b9b
@ -36,12 +36,6 @@ const StyledAddAutomationButton = styled(Button)(({ theme }) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const StyledAddAutomationContainer = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: theme.spacing(1),
|
||||
}));
|
||||
|
||||
interface MilestoneAutomationProps {
|
||||
milestone: IReleasePlanMilestone;
|
||||
status: MilestoneStatus;
|
||||
@ -82,20 +76,14 @@ export const MilestoneAutomation = ({
|
||||
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 =
|
||||
!isOriginallyEmpty &&
|
||||
pendingProgressionChange?.action === 'changeMilestoneProgression';
|
||||
const hasPendingDelete =
|
||||
pendingProgressionChange?.action === 'deleteMilestoneProgression';
|
||||
|
||||
const badge = hasPendingDelete ? (
|
||||
<Badge color='error'>Deleted in draft</Badge>
|
||||
) : hasPendingChange || hasPendingCreate ? (
|
||||
) : hasPendingChange ? (
|
||||
<Badge color='warning'>Modified in draft</Badge>
|
||||
) : undefined;
|
||||
|
||||
@ -121,18 +109,13 @@ export const MilestoneAutomation = ({
|
||||
badge={badge}
|
||||
/>
|
||||
) : (
|
||||
<StyledAddAutomationContainer>
|
||||
<StyledAddAutomationButton
|
||||
onClick={onOpenProgressionForm}
|
||||
color='primary'
|
||||
startIcon={<Add />}
|
||||
>
|
||||
Add automation
|
||||
</StyledAddAutomationButton>
|
||||
{hasPendingCreate && (
|
||||
<Badge color='warning'>Modified in draft</Badge>
|
||||
)}
|
||||
</StyledAddAutomationContainer>
|
||||
<StyledAddAutomationButton
|
||||
onClick={onOpenProgressionForm}
|
||||
color='primary'
|
||||
startIcon={<Add />}
|
||||
>
|
||||
Add automation
|
||||
</StyledAddAutomationButton>
|
||||
)}
|
||||
</MilestoneAutomationSection>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user