Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

andreas-unleash
Copy link
Contributor

Disable Edit constraint when context field was deleted

Closes: 1-1208

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
@vercel
Copy link

vercel bot commented Aug 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2023 0:10am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Aug 10, 2023 0:10am

const { contextName } = constraint;

const disableEdit = !context
.map(contextDefinition => contextDefinition.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(contextDefinition => contextDefinition.name)
.map(({name}) => name)

Another concise way to do

@@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dots

@@ -34,6 +35,13 @@ export const ConstraintAccordionViewHeader = ({
expanded,
compact,
}: IConstraintAccordionViewHeaderProps) => {
const { context } = useUnleashContext();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could create useContextFieldExists('name') hook

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
…ld_was_deleted

# Conflicts:
#	frontend/cypress/integration/import/import.spec.ts
@andreas-unleash andreas-unleash merged commit 7d991f3 into main Aug 10, 2023
15 checks passed
@andreas-unleash andreas-unleash deleted the fix/disable_edit_constraint_when_context_field_was_deleted branch August 10, 2023 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants