1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: Disable Edit constraint when context field was deleted (#4460)

Disable Edit constraint when context field was deleted

Closes:
[1-1208](https://linear.app/unleash/issue/1-1208/if-i-deleted-a-used-context-with-predefined-legal-values)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2023-08-10 15:27:30 +03:00 committed by GitHub
parent ded33a6d81
commit 7d991f3a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { IConstraint } from 'interfaces/strategy';
import { ConstraintAccordionViewHeaderInfo } from './ConstraintAccordionViewHeaderInfo';
import { ConstraintAccordionHeaderActions } from '../../ConstraintAccordionHeaderActions/ConstraintAccordionHeaderActions';
import { styled } from '@mui/system';
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
interface IConstraintAccordionViewHeaderProps {
constraint: IConstraint;
@ -34,6 +35,13 @@ export const ConstraintAccordionViewHeader = ({
expanded,
compact,
}: IConstraintAccordionViewHeaderProps) => {
const { context } = useUnleashContext();
const { contextName } = constraint;
const disableEdit = !context
.map(contextDefinition => contextDefinition.name)
.includes(contextName);
return (
<StyledContainer>
<ConstraintIcon compact={compact} />
@ -46,6 +54,7 @@ export const ConstraintAccordionViewHeader = ({
<ConstraintAccordionHeaderActions
onEdit={onEdit}
onDelete={onDelete}
disableEdit={disableEdit}
/>
</StyledContainer>
);