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