From 7d991f3a5696e47c5e12caf4a85939dd036a0f11 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Thu, 10 Aug 2023 15:27:30 +0300 Subject: [PATCH] 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 --- .../ConstraintAccordionViewHeader.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionView/ConstraintAccordionViewHeader/ConstraintAccordionViewHeader.tsx b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionView/ConstraintAccordionViewHeader/ConstraintAccordionViewHeader.tsx index 7e1d3f84d7..c272df5286 100644 --- a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionView/ConstraintAccordionViewHeader/ConstraintAccordionViewHeader.tsx +++ b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionView/ConstraintAccordionViewHeader/ConstraintAccordionViewHeader.tsx @@ -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 ( @@ -46,6 +54,7 @@ export const ConstraintAccordionViewHeader = ({ );