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