diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ReleasePlanChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ReleasePlanChange.tsx index 9f909680df..c3af2824ac 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ReleasePlanChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ReleasePlanChange.tsx @@ -29,41 +29,10 @@ import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useCh import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; import useToast from 'hooks/useToast'; import type { UpdateMilestoneProgressionSchema } from 'openapi'; -import { ReleasePlanProvider } from 'component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanContext.tsx'; import { MilestoneAutomationSection } from 'component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanMilestone/MilestoneAutomationSection.tsx'; import { MilestoneTransitionDisplay } from 'component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanMilestone/MilestoneTransitionDisplay.tsx'; import type { MilestoneStatus } from 'component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanMilestone/ReleasePlanMilestoneStatus.tsx'; -// Indicates that a change is in draft and not yet part of a change request -const PENDING_CHANGE_REQUEST_ID = -1; - -// Helper function to create getPendingProgressionChange for context -const createGetPendingProgressionChange = ( - progressionChanges: (IChangeRequestCreateMilestoneProgression | IChangeRequestUpdateMilestoneProgression | IChangeRequestDeleteMilestoneProgression)[] -) => { - return (sourceMilestoneId: string) => { - const change = progressionChanges.find( - (progressionChange) => - (progressionChange.action === 'updateMilestoneProgression' && - (progressionChange.payload.sourceMilestoneId === sourceMilestoneId || - progressionChange.payload.sourceMilestone === sourceMilestoneId)) || - (progressionChange.action === 'deleteMilestoneProgression' && - (progressionChange.payload.sourceMilestoneId === sourceMilestoneId || - progressionChange.payload.sourceMilestone === sourceMilestoneId)) || - (progressionChange.action === 'createMilestoneProgression' && - progressionChange.payload.sourceMilestone === sourceMilestoneId), - ); - - if (!change) return null; - - return { - action: change.action, - payload: change.payload, - changeRequestId: PENDING_CHANGE_REQUEST_ID, - }; - }; -}; - const StyledTabs = styled(Tabs)(({ theme }) => ({ display: 'flex', flexFlow: 'column', @@ -339,20 +308,7 @@ const CreateMilestoneProgression: FC<{ (milestone) => milestone.id === change.payload.sourceMilestone, ); - // Create a function to get this specific change for the context - const getPendingProgressionChange = (sourceMilestoneId: string) => { - if (sourceMilestoneId === change.payload.sourceMilestone) { - return { - action: change.action, - payload: change.payload, - changeRequestId: -1, - }; - } - return null; - }; - return ( - @@ -422,7 +378,6 @@ const CreateMilestoneProgression: FC<{ /> - ); }; @@ -482,20 +437,7 @@ const UpdateMilestoneProgression: FC<{ (milestone) => milestone.id === change.payload.sourceMilestoneId, ); - // Create a function to get this specific change for the context - const getPendingProgressionChange = (sourceMilestoneId: string) => { - if (sourceMilestoneId === sourceId) { - return { - action: change.action, - payload: change.payload, - changeRequestId: -1, - }; - } - return null; - }; - return ( - @@ -563,7 +505,6 @@ const UpdateMilestoneProgression: FC<{ /> - ); }; @@ -689,11 +630,7 @@ const ConsolidatedProgressionChanges: FC<{ return `${action} automation for ${sourceName}`; }); - // Create a function to get pending progression changes for the context - const getPendingProgressionChange = createGetPendingProgressionChange(progressionChanges); - return ( - @@ -783,7 +720,6 @@ const ConsolidatedProgressionChanges: FC<{ /> - ); }; diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlan.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlan.tsx index 10f7864982..5ed3b60e7e 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlan.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlan.tsx @@ -26,7 +26,6 @@ import type { CreateMilestoneProgressionSchema, UpdateMilestoneProgressionSchema, } from 'openapi'; -import { ReleasePlanProvider } from './ReleasePlanContext.tsx'; import { ReleasePlanMilestoneItem } from './ReleasePlanMilestoneItem/ReleasePlanMilestoneItem.tsx'; const StyledContainer = styled('div')(({ theme }) => ({ @@ -381,10 +380,7 @@ export const ReleasePlan = ({ ); return ( - - + @@ -464,6 +460,5 @@ export const ReleasePlan = ({ /> )} - ); }; diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanContext.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanContext.tsx deleted file mode 100644 index fb3b6b27e9..0000000000 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlanContext.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { createContext, useContext, type ReactNode } from 'react'; - -interface PendingProgressionChange { - action: string; - payload: any; - changeRequestId: number; -} - -interface ReleasePlanContextType { - getPendingProgressionChange: ( - sourceMilestoneId: string, - ) => PendingProgressionChange | null; -} - -const ReleasePlanContext = createContext(null); - -export const useReleasePlanContext = () => { - const context = useContext(ReleasePlanContext); - if (!context) { - // Return a fallback context that returns null for all milestone IDs - // This allows the component to work without the provider (e.g., in change request views) - return { - getPendingProgressionChange: () => null, - }; - } - return context; -}; - -interface ReleasePlanProviderProps { - children: ReactNode; - getPendingProgressionChange: ( - sourceMilestoneId: string, - ) => PendingProgressionChange | null; -} - -export const ReleasePlanProvider = ({ - children, - getPendingProgressionChange, -}: ReleasePlanProviderProps) => { - return ( - - {children} - - ); -};