1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
This commit is contained in:
andreas-unleash 2022-07-25 09:30:04 +03:00
parent 9a13c5c489
commit 70e8df83b5
2 changed files with 12 additions and 5 deletions

View File

@ -147,7 +147,7 @@ export const ConstraintAccordionEditHeader = ({
</p> </p>
} }
/> />
<ConstraintAccordionHeaderActions onDelete={onDelete} /> <ConstraintAccordionHeaderActions onDelete={onDelete} disableEdit/>
</div> </div>
); );
}; };

View File

@ -2,15 +2,20 @@ import React from 'react';
import { IconButton, Tooltip } from '@mui/material'; import { IconButton, Tooltip } from '@mui/material';
import { Delete, Edit } from '@mui/icons-material'; import { Delete, Edit } from '@mui/icons-material';
import { useStyles } from '../ConstraintAccordion.styles'; import { useStyles } from '../ConstraintAccordion.styles';
import {ConditionallyRender} from "../../ConditionallyRender/ConditionallyRender";
interface ConstraintAccordionHeaderActionsProps { interface ConstraintAccordionHeaderActionsProps {
onDelete?: () => void; onDelete?: () => void;
onEdit?: () => void; onEdit?: () => void;
disableEdit?: boolean;
disableDelete?: boolean
} }
export const ConstraintAccordionHeaderActions = ({ export const ConstraintAccordionHeaderActions = ({
onEdit, onEdit,
onDelete, onDelete,
disableDelete = false,
disableEdit = false
}: ConstraintAccordionHeaderActionsProps) => { }: ConstraintAccordionHeaderActionsProps) => {
const { classes: styles } = useStyles(); const { classes: styles } = useStyles();
const onEditClick = const onEditClick =
@ -29,24 +34,26 @@ export const ConstraintAccordionHeaderActions = ({
return ( return (
<div className={styles.headerActions}> <div className={styles.headerActions}>
<ConditionallyRender condition={Boolean(onEditClick) && !disableEdit} show={
<Tooltip title="Edit constraint" arrow> <Tooltip title="Edit constraint" arrow>
<IconButton <IconButton
type="button" type="button"
onClick={onEditClick} onClick={onEditClick}
disabled={!Boolean(onEditClick)} disabled={disableEdit}
> >
<Edit /> <Edit />
</IconButton> </IconButton>
</Tooltip> </Tooltip>} />
<ConditionallyRender condition={Boolean(onDeleteClick) && !disableDelete} show={
<Tooltip title="Delete constraint" arrow> <Tooltip title="Delete constraint" arrow>
<IconButton <IconButton
type="button" type="button"
onClick={onDeleteClick} onClick={onDeleteClick}
disabled={!Boolean(onDeleteClick)} disabled={disableDelete}
> >
<Delete /> <Delete />
</IconButton> </IconButton>
</Tooltip> </Tooltip>} />
</div> </div>
); );
}; };