From af50fc2fd3d6340c066d949081c3d51f45149ead Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 10 Oct 2023 10:36:13 +0200 Subject: [PATCH] feat: visualize dependencies managment in change requests (#4978) --- .../ChangeRequest/ChangeRequest.tsx | 1 + .../Changes/Change/DependencyChange.tsx | 66 +++++++++++++++++++ .../Changes/Change/FeatureChange.tsx | 13 +++- .../changeRequest/changeRequest.types.ts | 23 ++++++- 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 frontend/src/component/changeRequest/ChangeRequest/Changes/Change/DependencyChange.tsx diff --git a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx index 4f9156eaaf3d..d78d01954c14 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx @@ -76,6 +76,7 @@ export const ChangeRequest: VFC = ({ changeRequest={changeRequest} change={change} feature={feature} + onNavigate={onNavigate} /> ))} {feature.defaultChange ? ( diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/DependencyChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/DependencyChange.tsx new file mode 100644 index 000000000000..ec26d868740c --- /dev/null +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/DependencyChange.tsx @@ -0,0 +1,66 @@ +import { ReactNode, VFC } from 'react'; +import { Box, styled, Typography } from '@mui/material'; +import { + IChangeRequestAddDependency, + IChangeRequestDeleteDependency, +} from 'component/changeRequest/changeRequest.types'; +import { Link } from 'react-router-dom'; +import { ChangeItemWrapper } from './StrategyChange'; + +const StyledLink = styled(Link)(({ theme }) => ({ + maxWidth: '100%', + textDecoration: 'none', + '&:hover, &:focus': { + textDecoration: 'underline', + }, +})); + +const AddDependencyWrapper = styled(Box)(({ theme }) => ({ + display: 'flex', + alignItems: 'center', + gap: theme.spacing(1), +})); + +export const DependencyChange: VFC<{ + actions?: ReactNode; + change: IChangeRequestAddDependency | IChangeRequestDeleteDependency; + projectId: string; + onNavigate?: () => void; +}> = ({ actions, change, projectId, onNavigate }) => { + return ( + <> + {change.action === 'addDependency' && ( + <> + + + + + Adding dependency: + + + {change.payload.feature} + + + {actions} + + + )} + {change.action === 'deleteDependency' && ( + + + ({ + color: theme.palette.error.main, + })} + > + - Deleting dependencies + + + {actions} + + )} + + ); +}; diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx index 42886b30a0fd..eab19b99afce 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx @@ -12,6 +12,7 @@ import { StrategyChange } from './StrategyChange'; import { VariantPatch } from './VariantPatch/VariantPatch'; import { EnvironmentStrategyExecutionOrder } from './EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder'; import { ArchiveFeatureChange } from './ArchiveFeatureChange'; +import { DependencyChange } from './DependencyChange'; const StyledSingleChangeBox = styled(Box, { shouldForwardProp: (prop: string) => !prop.startsWith('$'), @@ -61,7 +62,8 @@ export const FeatureChange: FC<{ changeRequest: IChangeRequest; change: IFeatureChange; feature: IChangeRequestFeature; -}> = ({ index, change, feature, changeRequest, actions }) => { + onNavigate?: () => void; +}> = ({ index, change, feature, changeRequest, actions, onNavigate }) => { const lastIndex = feature.defaultChange ? feature.changes.length + 1 : feature.changes.length; @@ -85,6 +87,15 @@ export const FeatureChange: FC<{ /> ({ padding: theme.spacing(3) })}> + {(change.action === 'addDependency' || + change.action === 'deleteDependency') && ( + + )} {change.action === 'updateEnabled' && (