Skip to content

Commit

Permalink
fix(GoalCriteria): hide action dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Jul 19, 2023
1 parent 0827d8b commit b5e00cc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/GoalCriteria/GoalCriteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const criteriaGuard = (props: GoalCriteriaItemProps): props is CriteriaAsGoalPro

type CriteriaActionItem = {
label: string;
onClick: () => void;
handler: () => void;
color?: string;
icon: React.ReactNode;
};
Expand Down Expand Up @@ -293,20 +293,24 @@ const GoalCriteriaItem: React.FC<GoalCriteriaItemProps> = memo((props) => {
actions.push({
label: tr('Create as goal'),
icon: <IconTargetOutline size="xxs" />,
onClick: onConvertToGoal,
handler: onConvertToGoal,
});
}

actions.push({
label: tr('Delete'),
icon: <IconXCircleSolid size="xxs" />,
color: danger0,
onClick: onRemove,
handler: onRemove,
});

return actions;
}, [canEdit, onRemove, props, onConvertToGoal]);

const handleChange = useCallback((val: CriteriaActionItem) => {
val.handler();
}, []);

return (
<StyledTableRow>
{criteriaGuard(props) ? (
Expand Down Expand Up @@ -342,12 +346,13 @@ const GoalCriteriaItem: React.FC<GoalCriteriaItemProps> = memo((props) => {
<ContentItem>
{nullable(availableActions, (actions) => (
<Dropdown
onChange={handleChange}
renderTrigger={({ onClick }) => <IconMoreVerticalOutline size="xs" onClick={onClick} />}
items={actions}
renderItem={(props) => (
<MenuItem
key={props.index}
onClick={props.item.onClick}
onClick={props.onClick}
icon={props.item.icon}
ghost
color={props.item.color}
Expand Down

0 comments on commit b5e00cc

Please sign in to comment.