From c45d558352a30611d66a99598ae478fc107483df Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 10 Jun 2025 13:29:28 +0200 Subject: [PATCH] remove legacy code usage --- .../common/SegmentItem/SegmentItem.tsx | 145 ------------------ .../FeatureStrategySegmentList.tsx | 2 +- .../FeatureOverviewSegment.tsx | 6 +- .../ConstraintExecutionWithoutResults.tsx | 16 +- .../SegmentExecutionWithoutResult.tsx | 2 +- .../MilestoneStrategySegmentList.tsx | 2 +- 6 files changed, 12 insertions(+), 161 deletions(-) delete mode 100644 frontend/src/component/common/SegmentItem/SegmentItem.tsx diff --git a/frontend/src/component/common/SegmentItem/SegmentItem.tsx b/frontend/src/component/common/SegmentItem/SegmentItem.tsx deleted file mode 100644 index ff7666d9fb..0000000000 --- a/frontend/src/component/common/SegmentItem/SegmentItem.tsx +++ /dev/null @@ -1,145 +0,0 @@ -import { useId, useMemo, useState, type FC } from 'react'; -import { Link } from 'react-router-dom'; -import type { ISegment } from 'interfaces/segment'; -import { - Accordion, - AccordionDetails, - AccordionSummary, - Button, - styled, -} from '@mui/material'; -import { StrategyEvaluationItem } from 'component/common/ConstraintsList/StrategyEvaluationItem/StrategyEvaluationItem'; -import { objectId } from 'utils/objectId'; -import { - ConstraintListItem, - ConstraintsList, -} from 'component/common/ConstraintsList/ConstraintsList'; -import { ConstraintAccordionView } from '../NewConstraintAccordion/ConstraintAccordionView/ConstraintAccordionView.tsx'; - -type SegmentItemProps = { - segment: Partial; - isExpanded?: boolean; - disabled?: boolean | null; - constraintList?: JSX.Element; - headerContent?: JSX.Element; -}; - -const StyledConstraintListItem = styled(ConstraintListItem)(() => ({ - padding: 0, -})); - -const StyledAccordion = styled(Accordion)(() => ({ - boxShadow: 'none', - margin: 0, - padding: 0, - '::before': { - // MUI separator between accordions - display: 'none', - }, -})); - -const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({ - fontSize: theme.typography.body2.fontSize, - minHeight: 'unset', - ':focus-within': { - backgroundColor: 'inherit', - }, -})); - -const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({ - padding: theme.spacing(0.5, 3, 2.5), -})); - -const StyledLink = styled(Link)(({ theme }) => ({ - textDecoration: 'none', - paddingRight: theme.spacing(0.5), - '&:hover': { - textDecoration: 'underline', - }, -})); - -const StyledActionsContainer = styled('div')(({ theme }) => ({ - display: 'flex', - alignItems: 'center', - marginLeft: 'auto', -})); - -const StyledButton = styled(Button)(({ theme }) => ({ - fontSize: theme.typography.body2.fontSize, -})); - -const StyledNoConstraintsText = styled('p')(({ theme }) => ({ - fontSize: theme.typography.body2.fontSize, - color: theme.palette.text.secondary, -})); - -export const SegmentItem: FC = ({ - segment, - isExpanded, - headerContent, - constraintList, -}) => { - const [isOpen, setIsOpen] = useState(isExpanded || false); - const segmentDetailsId = useId(); - - const constraints = useMemo(() => { - if (constraintList) { - return constraintList; - } - - if (segment.constraints?.length) { - return ( - - {segment.constraints.map((constraint, index) => ( - - ))} - - ); - } - - return ( - - This segment has no constraints. - - ); - }, [constraintList, segment.constraints]); - - return ( - - - - - - {segment.name} - - - {headerContent ? headerContent : null} - {!isExpanded ? ( - - setIsOpen((value) => !value)} - > - {isOpen ? 'Close preview' : 'Preview'} - - - ) : null} - - {constraints} - - - ); -}; diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentList.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentList.tsx index 7ca101d208..f02aff596c 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentList.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentList.tsx @@ -3,8 +3,8 @@ import { Fragment, useState } from 'react'; import type { ISegment } from 'interfaces/segment'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { FeatureStrategySegmentChip } from 'component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentChip'; -import { SegmentItem } from 'component/common/SegmentItem/LegacySegmentItem'; import { styled } from '@mui/material'; +import { SegmentItem } from 'component/common/SegmentItem/SegmentItem'; interface IFeatureStrategySegmentListProps { segments: ISegment[]; diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewSegment/FeatureOverviewSegment.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewSegment/FeatureOverviewSegment.tsx index 73f3a0e43c..4f90f03d9a 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewSegment/FeatureOverviewSegment.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewSegment/FeatureOverviewSegment.tsx @@ -1,8 +1,8 @@ import { Fragment } from 'react'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { StrategySeparator } from 'component/common/StrategySeparator/LegacyStrategySeparator'; -import { SegmentItem } from 'component/common/SegmentItem/LegacySegmentItem'; import type { ISegment } from 'interfaces/segment'; +import { SegmentItem } from 'component/common/SegmentItem/SegmentItem'; +import { ConstraintSeparator } from 'component/common/ConstraintsList/ConstraintSeparator/ConstraintSeparator'; interface IFeatureOverviewSegmentProps { segments?: ISegment[]; @@ -23,7 +23,7 @@ export const FeatureOverviewSegment = ({ 0} - show={} + show={} /> diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/ConstraintExecution/ConstraintExecutionWithoutResults.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/ConstraintExecution/ConstraintExecutionWithoutResults.tsx index f0c279f76c..7b334bd0ce 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/ConstraintExecution/ConstraintExecutionWithoutResults.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/ConstraintExecution/ConstraintExecutionWithoutResults.tsx @@ -1,10 +1,10 @@ -import { Fragment, type VFC } from 'react'; +import { type FC, Fragment } from 'react'; import type { PlaygroundConstraintSchema } from 'openapi'; import { objectId } from 'utils/objectId'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { StrategySeparator } from 'component/common/StrategySeparator/LegacyStrategySeparator'; import { styled } from '@mui/material'; -import { ConstraintAccordionView } from 'component/common/LegacyConstraintAccordion/ConstraintAccordionView/ConstraintAccordionView'; +import { ConstraintAccordionView } from 'component/common/NewConstraintAccordion/ConstraintAccordionView/ConstraintAccordionView'; +import { ConstraintSeparator } from 'component/common/ConstraintsList/ConstraintSeparator/ConstraintSeparator'; interface IConstraintExecutionWithoutResultsProps { constraints?: PlaygroundConstraintSchema[]; @@ -16,7 +16,7 @@ export const ConstraintExecutionWrapper = styled('div')(() => ({ flexDirection: 'column', })); -export const ConstraintExecutionWithoutResults: VFC< +export const ConstraintExecutionWithoutResults: FC< IConstraintExecutionWithoutResultsProps > = ({ constraints }) => { if (!constraints) return null; @@ -27,13 +27,9 @@ export const ConstraintExecutionWithoutResults: VFC< 0} - show={} - /> - } /> + ))} diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/SegmentExecution/SegmentExecutionWithoutResult.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/SegmentExecution/SegmentExecutionWithoutResult.tsx index b153208840..b25691b59c 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/SegmentExecution/SegmentExecutionWithoutResult.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/PlaygroundStrategyExecution/SegmentExecution/SegmentExecutionWithoutResult.tsx @@ -2,8 +2,8 @@ import { Fragment, type VFC } from 'react'; import type { PlaygroundSegmentSchema } from 'openapi'; import { StrategySeparator } from 'component/common/StrategySeparator/LegacyStrategySeparator'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { SegmentItem } from 'component/common/SegmentItem/LegacySegmentItem'; import { ConstraintExecutionWithoutResults } from '../ConstraintExecution/ConstraintExecutionWithoutResults.tsx'; +import { SegmentItem } from 'component/common/SegmentItem/SegmentItem.tsx'; interface ISegmentExecutionWithoutResultProps { segments?: PlaygroundSegmentSchema[]; diff --git a/frontend/src/component/releases/ReleasePlanTemplate/TemplateForm/MilestoneStrategy/MilestoneStrategySegmentList.tsx b/frontend/src/component/releases/ReleasePlanTemplate/TemplateForm/MilestoneStrategy/MilestoneStrategySegmentList.tsx index 5323c51a1e..418f3baa63 100644 --- a/frontend/src/component/releases/ReleasePlanTemplate/TemplateForm/MilestoneStrategy/MilestoneStrategySegmentList.tsx +++ b/frontend/src/component/releases/ReleasePlanTemplate/TemplateForm/MilestoneStrategy/MilestoneStrategySegmentList.tsx @@ -2,8 +2,8 @@ import { Fragment, useState } from 'react'; import type { ISegment } from 'interfaces/segment'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { FeatureStrategySegmentChip } from 'component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegmentChip'; -import { SegmentItem } from 'component/common/SegmentItem/LegacySegmentItem'; import { styled } from '@mui/material'; +import { SegmentItem } from 'component/common/SegmentItem/SegmentItem'; const StyledList = styled('div')(({ theme }) => ({ display: 'flex',