-
-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: release plan template milestone UI listing strategies (#8933)
- Loading branch information
Showing
9 changed files
with
585 additions
and
150 deletions.
There are no files selected for viewing
378 changes: 306 additions & 72 deletions
378
frontend/src/component/releases/ReleasePlanTemplate/MilestoneCard.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
frontend/src/component/releases/ReleasePlanTemplate/MilestoneStrategyDraggableItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import type { IReleasePlanMilestoneStrategy } from 'interfaces/releasePlans'; | ||
import { type DragEventHandler, type RefObject, useRef } from 'react'; | ||
import { Box, IconButton } from '@mui/material'; | ||
import Edit from '@mui/icons-material/Edit'; | ||
import Delete from '@mui/icons-material/DeleteOutlined'; | ||
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator'; | ||
import { MilestoneStrategyItem } from './MilestoneStrategyItem'; | ||
|
||
interface IMilestoneStrategyDraggableItemProps { | ||
strategy: Omit<IReleasePlanMilestoneStrategy, 'milestoneId'>; | ||
index: number; | ||
isDragging?: boolean; | ||
onDragStartRef: ( | ||
ref: RefObject<HTMLDivElement>, | ||
index: number, | ||
) => DragEventHandler<HTMLButtonElement>; | ||
onDragOver: ( | ||
ref: RefObject<HTMLDivElement>, | ||
index: number, | ||
) => DragEventHandler<HTMLDivElement>; | ||
onDragEnd: () => void; | ||
onDeleteClick: () => void; | ||
onEditClick: () => void; | ||
} | ||
|
||
export const MilestoneStrategyDraggableItem = ({ | ||
strategy, | ||
index, | ||
isDragging, | ||
onDragStartRef, | ||
onDragOver, | ||
onDragEnd, | ||
onDeleteClick, | ||
onEditClick, | ||
}: IMilestoneStrategyDraggableItemProps) => { | ||
const ref = useRef<HTMLDivElement>(null); | ||
return ( | ||
<Box | ||
key={strategy.id} | ||
ref={ref} | ||
onDragOver={onDragOver(ref, index)} | ||
sx={{ opacity: isDragging ? '0.5' : '1' }} | ||
> | ||
{index > 0 && <StrategySeparator text='OR' />} | ||
<MilestoneStrategyItem | ||
strategy={strategy} | ||
onDragStart={onDragStartRef(ref, index)} | ||
onDragEnd={onDragEnd} | ||
actions={ | ||
<> | ||
<IconButton title='Edit strategy' onClick={onEditClick}> | ||
<Edit /> | ||
</IconButton> | ||
<IconButton | ||
title='Remove release plan' | ||
onClick={onDeleteClick} | ||
> | ||
<Delete /> | ||
</IconButton> | ||
</> | ||
} | ||
/> | ||
</Box> | ||
); | ||
}; |
99 changes: 99 additions & 0 deletions
99
frontend/src/component/releases/ReleasePlanTemplate/MilestoneStrategyItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Box, IconButton, styled } from '@mui/material'; | ||
import SplitPreviewSlider from 'component/feature/StrategyTypes/SplitPreviewSlider/SplitPreviewSlider'; | ||
import { | ||
formatStrategyName, | ||
getFeatureStrategyIcon, | ||
} from 'utils/strategyNames'; | ||
import type { IFeatureStrategy } from 'interfaces/strategy'; | ||
import { StrategyExecution } from 'component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/StrategyExecution/StrategyExecution'; | ||
import type { DragEventHandler, ReactNode } from 'react'; | ||
import DragIndicator from '@mui/icons-material/DragIndicator'; | ||
|
||
const StyledStrategy = styled('div')(({ theme }) => ({ | ||
background: theme.palette.background.paper, | ||
})); | ||
|
||
const DragIcon = styled(IconButton)({ | ||
padding: 0, | ||
cursor: 'inherit', | ||
transition: 'color 0.2s ease-in-out', | ||
}); | ||
|
||
const StyledHeader = styled('div', { | ||
shouldForwardProp: (prop) => prop !== 'draggable', | ||
})<{ draggable: boolean }>(({ theme, draggable }) => ({ | ||
display: 'flex', | ||
padding: theme.spacing(2), | ||
gap: theme.spacing(1), | ||
alignItems: 'center', | ||
color: theme.palette.text.primary, | ||
'& > svg': { | ||
fill: theme.palette.action.disabled, | ||
}, | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
})); | ||
|
||
const StyledStrategyExecution = styled('div')(({ theme }) => ({ | ||
padding: theme.spacing(2), | ||
})); | ||
|
||
interface IReleasePlanMilestoneStrategyProps { | ||
strategy: IFeatureStrategy; | ||
onDragStart?: DragEventHandler<HTMLButtonElement>; | ||
onDragEnd?: DragEventHandler<HTMLButtonElement>; | ||
actions?: ReactNode; | ||
} | ||
|
||
export const MilestoneStrategyItem = ({ | ||
strategy, | ||
onDragStart, | ||
onDragEnd, | ||
actions, | ||
}: IReleasePlanMilestoneStrategyProps) => { | ||
const Icon = getFeatureStrategyIcon(strategy.strategyName); | ||
|
||
return ( | ||
<StyledStrategy> | ||
<StyledHeader draggable={Boolean(onDragStart)}> | ||
<DragIcon | ||
draggable | ||
disableRipple | ||
size='small' | ||
onDragStart={onDragStart} | ||
onDragEnd={onDragEnd} | ||
sx={{ cursor: 'move' }} | ||
> | ||
<DragIndicator | ||
titleAccess='Drag to reorder' | ||
cursor='grab' | ||
sx={{ color: 'action.active' }} | ||
/> | ||
</DragIcon> | ||
<Icon /> | ||
{`${formatStrategyName(String(strategy.strategyName))}${strategy.title ? `: ${strategy.title}` : ''}`} | ||
<Box | ||
sx={{ | ||
marginLeft: 'auto', | ||
display: 'flex', | ||
minHeight: (theme) => theme.spacing(6), | ||
alignItems: 'center', | ||
}} | ||
> | ||
{actions} | ||
</Box> | ||
</StyledHeader> | ||
<StyledStrategyExecution> | ||
<StrategyExecution strategy={strategy} /> | ||
{strategy.variants && | ||
strategy.variants.length > 0 && | ||
(strategy.disabled ? ( | ||
<Box sx={{ opacity: '0.5' }}> | ||
<SplitPreviewSlider variants={strategy.variants} /> | ||
</Box> | ||
) : ( | ||
<SplitPreviewSlider variants={strategy.variants} /> | ||
))} | ||
</StyledStrategyExecution> | ||
</StyledStrategy> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.