mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-10 01:19:53 +01:00
fix: simplify pending changes
This commit is contained in:
parent
dcd191298c
commit
64d5727c45
@ -10,6 +10,7 @@ import { MilestoneAutomationSection } from '../ReleasePlanMilestone/MilestoneAut
|
||||
import { MilestoneTransitionDisplay } from '../ReleasePlanMilestone/MilestoneTransitionDisplay.tsx';
|
||||
import type { MilestoneStatus } from '../ReleasePlanMilestone/ReleasePlanMilestoneStatus.tsx';
|
||||
import { MilestoneProgressionForm } from '../MilestoneProgressionForm/MilestoneProgressionForm.tsx';
|
||||
import type { PendingProgressionChange } from './ReleasePlanMilestoneItem';
|
||||
|
||||
const StyledAddAutomationButton = styled(Button)(({ theme }) => ({
|
||||
textTransform: 'none',
|
||||
@ -53,9 +54,7 @@ interface MilestoneAutomationProps {
|
||||
readonly: boolean | undefined;
|
||||
isProgressionFormOpen: boolean;
|
||||
effectiveTransitionCondition: IReleasePlanMilestone['transitionCondition'];
|
||||
hasPendingCreate: boolean;
|
||||
hasPendingUpdate: boolean;
|
||||
hasPendingDelete: boolean;
|
||||
pendingProgressionChange: PendingProgressionChange | null;
|
||||
onOpenProgressionForm: () => void;
|
||||
onCloseProgressionForm: () => void;
|
||||
onCreateProgression: (
|
||||
@ -76,9 +75,7 @@ export const MilestoneAutomation = ({
|
||||
readonly,
|
||||
isProgressionFormOpen,
|
||||
effectiveTransitionCondition,
|
||||
hasPendingCreate,
|
||||
hasPendingUpdate,
|
||||
hasPendingDelete,
|
||||
pendingProgressionChange,
|
||||
onOpenProgressionForm,
|
||||
onCloseProgressionForm,
|
||||
onCreateProgression,
|
||||
@ -92,6 +89,13 @@ export const MilestoneAutomation = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
const hasPendingCreate =
|
||||
pendingProgressionChange?.action === 'createMilestoneProgression';
|
||||
const hasPendingUpdate =
|
||||
pendingProgressionChange?.action === 'updateMilestoneProgression';
|
||||
const hasPendingDelete =
|
||||
pendingProgressionChange?.action === 'deleteMilestoneProgression';
|
||||
|
||||
return (
|
||||
<MilestoneAutomationSection status={status}>
|
||||
{isProgressionFormOpen ? (
|
||||
|
||||
@ -168,12 +168,8 @@ export const ReleasePlanMilestoneItem = ({
|
||||
environmentIsDisabled,
|
||||
);
|
||||
|
||||
const {
|
||||
hasPendingCreate,
|
||||
hasPendingUpdate,
|
||||
hasPendingDelete,
|
||||
effectiveTransitionCondition,
|
||||
} = usePendingProgressionChanges(milestone, getPendingProgressionChange);
|
||||
const { pendingProgressionChange, effectiveTransitionCondition } =
|
||||
usePendingProgressionChanges(milestone, getPendingProgressionChange);
|
||||
|
||||
const automationSection = (
|
||||
<MilestoneAutomation
|
||||
@ -185,9 +181,7 @@ export const ReleasePlanMilestoneItem = ({
|
||||
readonly={readonly}
|
||||
isProgressionFormOpen={isProgressionFormOpen}
|
||||
effectiveTransitionCondition={effectiveTransitionCondition}
|
||||
hasPendingCreate={hasPendingCreate}
|
||||
hasPendingUpdate={hasPendingUpdate}
|
||||
hasPendingDelete={hasPendingDelete}
|
||||
pendingProgressionChange={pendingProgressionChange}
|
||||
onOpenProgressionForm={handleOpenProgressionForm}
|
||||
onCloseProgressionForm={handleCloseProgressionForm}
|
||||
onCreateProgression={handleCreateProgression}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import type { IReleasePlanMilestone } from 'interfaces/releasePlans';
|
||||
import type { IReleasePlanMilestoneItemProps } from './ReleasePlanMilestoneItem';
|
||||
import type {
|
||||
IReleasePlanMilestoneItemProps,
|
||||
PendingProgressionChange,
|
||||
} from './ReleasePlanMilestoneItem';
|
||||
|
||||
interface PendingProgressionChangeResult {
|
||||
hasPendingCreate: boolean;
|
||||
hasPendingUpdate: boolean;
|
||||
hasPendingDelete: boolean;
|
||||
pendingProgressionChange: PendingProgressionChange | null;
|
||||
effectiveTransitionCondition: IReleasePlanMilestone['transitionCondition'];
|
||||
}
|
||||
|
||||
@ -14,13 +15,6 @@ export const usePendingProgressionChanges = (
|
||||
): PendingProgressionChangeResult => {
|
||||
const pendingProgressionChange = getPendingProgressionChange(milestone.id);
|
||||
|
||||
const hasPendingCreate =
|
||||
pendingProgressionChange?.action === 'createMilestoneProgression';
|
||||
const hasPendingUpdate =
|
||||
pendingProgressionChange?.action === 'updateMilestoneProgression';
|
||||
const hasPendingDelete =
|
||||
pendingProgressionChange?.action === 'deleteMilestoneProgression';
|
||||
|
||||
// Determine effective transition condition (use pending create if exists)
|
||||
let effectiveTransitionCondition = milestone.transitionCondition;
|
||||
if (
|
||||
@ -33,9 +27,7 @@ export const usePendingProgressionChanges = (
|
||||
}
|
||||
|
||||
return {
|
||||
hasPendingCreate,
|
||||
hasPendingUpdate,
|
||||
hasPendingDelete,
|
||||
pendingProgressionChange,
|
||||
effectiveTransitionCondition,
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user