-
-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: selector dropdown for milestone new strategy #8841
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import type { IReleasePlanMilestonePayload } from 'interfaces/releasePlans'; | ||
import type { | ||
IReleasePlanMilestonePayload, | ||
IReleasePlanMilestoneStrategy, | ||
} from 'interfaces/releasePlans'; | ||
import { MilestoneCard } from './MilestoneCard'; | ||
import { styled } from '@mui/material'; | ||
import { Button } from '@mui/material'; | ||
|
@@ -9,7 +12,10 @@ interface IMilestoneListProps { | |
setMilestones: React.Dispatch< | ||
React.SetStateAction<IReleasePlanMilestonePayload[]> | ||
>; | ||
setAddStrategyOpen: (open: boolean) => void; | ||
openAddStrategyForm: ( | ||
index: number, | ||
strategy: IReleasePlanMilestoneStrategy, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is going to be increasingly more difficult to maintain. Maybe we should call it something else. I think this is the |
||
) => void; | ||
errors: { [key: string]: string }; | ||
clearErrors: () => void; | ||
} | ||
|
@@ -22,14 +28,10 @@ const StyledAddMilestoneButton = styled(Button)(({ theme }) => ({ | |
export const MilestoneList = ({ | ||
milestones, | ||
setMilestones, | ||
setAddStrategyOpen, | ||
openAddStrategyForm, | ||
errors, | ||
clearErrors, | ||
}: IMilestoneListProps) => { | ||
const showAddStrategyDialog = (index: number) => { | ||
setAddStrategyOpen(true); | ||
}; | ||
|
||
const milestoneNameChanged = (index: number, name: string) => { | ||
setMilestones((prev) => | ||
prev.map((milestone, i) => | ||
|
@@ -46,7 +48,7 @@ export const MilestoneList = ({ | |
index={index} | ||
milestone={milestone} | ||
milestoneNameChanged={milestoneNameChanged} | ||
showAddStrategyDialog={showAddStrategyDialog} | ||
showAddStrategyDialog={openAddStrategyForm} | ||
errors={errors} | ||
clearErrors={clearErrors} | ||
/> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,89 @@ | ||||||
import { | ||||||
formatStrategyName, | ||||||
getFeatureStrategyIcon, | ||||||
} from 'utils/strategyNames'; | ||||||
import { styled } from '@mui/material'; | ||||||
import type { IStrategy } from 'interfaces/strategy'; | ||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator'; | ||||||
import type { IReleasePlanMilestoneStrategy } from 'interfaces/releasePlans'; | ||||||
import { v4 as uuidv4 } from 'uuid'; | ||||||
import { createFeatureStrategy } from 'utils/createFeatureStrategy'; | ||||||
|
||||||
const StyledIcon = styled('div')(({ theme }) => ({ | ||||||
width: theme.spacing(4), | ||||||
height: 'auto', | ||||||
'& > svg': { | ||||||
// Styling for SVG icons. | ||||||
fill: theme.palette.primary.main, | ||||||
}, | ||||||
'& > div': { | ||||||
// Styling for the Rollout icon. | ||||||
height: theme.spacing(2), | ||||||
marginLeft: '-.75rem', | ||||||
color: theme.palette.primary.main, | ||||||
}, | ||||||
})); | ||||||
|
||||||
const StyledDescription = styled('div')(({ theme }) => ({ | ||||||
fontSize: theme.fontSizes.smallBody, | ||||||
})); | ||||||
|
||||||
const StyledName = styled(StringTruncator)(({ theme }) => ({ | ||||||
fontWeight: theme.fontWeight.bold, | ||||||
})); | ||||||
|
||||||
const StyledCard = styled('div')(({ theme }) => ({ | ||||||
display: 'grid', | ||||||
gridTemplateColumns: '3rem 1fr', | ||||||
width: '20rem', | ||||||
padding: theme.spacing(2), | ||||||
color: 'inherit', | ||||||
textDecoration: 'inherit', | ||||||
lineHeight: 1.25, | ||||||
borderWidth: '1px', | ||||||
borderStyle: 'solid', | ||||||
borderColor: theme.palette.divider, | ||||||
borderRadius: theme.spacing(1), | ||||||
'&:hover, &:focus': { | ||||||
borderColor: theme.palette.primary.main, | ||||||
}, | ||||||
})); | ||||||
|
||||||
interface IMilestoneStrategyMenuCardProps { | ||||||
strategy: IStrategy; | ||||||
strategyClicked: (strategy: IReleasePlanMilestoneStrategy) => void; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
export const MilestoneStrategyMenuCard = ({ | ||||||
strategy, | ||||||
strategyClicked, | ||||||
}: IMilestoneStrategyMenuCardProps) => { | ||||||
const StrategyIcon = getFeatureStrategyIcon(strategy.name); | ||||||
const strategyName = formatStrategyName(strategy.name); | ||||||
return ( | ||||||
<StyledCard | ||||||
onClick={() => { | ||||||
const strat = createFeatureStrategy('', strategy); | ||||||
strategyClicked({ | ||||||
id: uuidv4(), | ||||||
name: strat.name, | ||||||
title: '', | ||||||
constraints: strat.constraints, | ||||||
parameters: strat.parameters, | ||||||
}); | ||||||
}} | ||||||
> | ||||||
<StyledIcon> | ||||||
<StrategyIcon /> | ||||||
</StyledIcon> | ||||||
<div> | ||||||
<StyledName | ||||||
text={strategy.displayName || strategyName} | ||||||
maxWidth='200' | ||||||
maxLength={25} | ||||||
/> | ||||||
<StyledDescription>{strategy.description}</StyledDescription> | ||||||
</div> | ||||||
</StyledCard> | ||||||
); | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { List, ListItem, styled, Typography } from '@mui/material'; | ||
import { MilestoneStrategyMenuCard } from './MilestoneStrategyMenuCard'; | ||
import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies'; | ||
import type { IReleasePlanMilestoneStrategy } from 'interfaces/releasePlans'; | ||
|
||
const StyledTypography = styled(Typography)(({ theme }) => ({ | ||
fontSize: theme.fontSizes.smallBody, | ||
padding: theme.spacing(1, 2), | ||
})); | ||
|
||
interface IMilestoneStrategyMenuCardsProps { | ||
milestoneId: string; | ||
openAddStrategy: ( | ||
milestoneId: string, | ||
strategy: IReleasePlanMilestoneStrategy, | ||
) => void; | ||
} | ||
|
||
export const MilestoneStrategyMenuCards = ({ | ||
milestoneId, | ||
openAddStrategy, | ||
}: IMilestoneStrategyMenuCardsProps) => { | ||
const { strategies } = useStrategies(); | ||
|
||
const preDefinedStrategies = strategies.filter( | ||
(strategy) => !strategy.deprecated && !strategy.editable, | ||
); | ||
|
||
const strategyClicked = (strategy: IReleasePlanMilestoneStrategy) => { | ||
openAddStrategy(milestoneId, strategy); | ||
}; | ||
|
||
return ( | ||
<List dense> | ||
<> | ||
<StyledTypography color='textSecondary'> | ||
Predefined strategy types | ||
</StyledTypography> | ||
{preDefinedStrategies.map((strategy) => ( | ||
<ListItem key={strategy.name}> | ||
<MilestoneStrategyMenuCard | ||
strategy={strategy} | ||
strategyClicked={strategyClicked} | ||
/> | ||
</ListItem> | ||
))} | ||
</> | ||
</List> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary, also going to use uuidv4() to generate an id for milestones