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: prevent deleting the last variable variant on the ui #2964

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

sighphyre
Copy link
Member

This blocks the UI from allowing you to attempt to delete the last fixed variant in environment variants, this was previously possible, but the UI catch an error and then never make a request. For bonus points this removes the problematic try catch, which allows the error message to bubble correctly to the handler

@vercel
Copy link

vercel bot commented Jan 23, 2023

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

Name Status Preview Comments Updated
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 24, 2023 at 6:29AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
unleash-docs ⬜️ Ignored (Inspect) Jan 24, 2023 at 6:29AM (UTC)

return { patch: [], error: formatUnknownError(error) };
}
const updatedNewVariants = updateWeight(newVariants, 1000);
return { patch: createPatch(variants, updatedNewVariants) };
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows the error to bubble back to the caller, which gives us a nice pretty error message. This should be prevented by the other changes for this error path but other cases can also cause failures, in which case an error message would be pretty cool

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

Awesome 😎

@@ -130,6 +131,23 @@ export const EnvironmentVariantsTable = ({
[]
);

const isProtectedVariant = (variant: IFeatureVariant): boolean => {
const isVariable = variant.weightType === 'variable';
Copy link
Member

Choose a reason for hiding this comment

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

I think we have some weight type constants around somewhere if you'd like to use those instead of a literal string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah point, shot.

He wasn't exposed, so he got a new home in constants for reusing

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

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

G!

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