-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7614] - Placement Groups Create/Rename Drawers #10106
Conversation
af45749
to
bc6604c
Compare
87b98bb
to
bf841f3
Compare
compliant: boolean; | ||
linode_ids: number[]; | ||
limits: number; | ||
capacity: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from updated API specs
} from 'src/utilities/formikErrorUtils'; | ||
|
||
import { PlacementGroupsDrawerContent } from './PlacementGroupsDrawerContent'; | ||
import { MAX_NUMBER_OF_PLACEMENT_GROUPS } from './constants'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is eventually going to be returned by the API
}); | ||
}, | ||
validateOnBlur: false, | ||
validateOnChange: isFormDirty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to implement real time validation once the form has been submitted once and we got validation errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is useful, maybe turning this into a hook?
export const useFormValidateOnChange = () => {
const [isFormDirty, setIsFormDirty] = React.useState<boolean>(false);
const setFormDirty = (value: boolean) => {
setIsFormDirty(value);
};
return { isFormDirty, setFormDirty };
};
I'm open to others input. Perhaps there's a way to utilize formik.dirty
in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the hook idea! gonna add it, and be a little more specific.
dirty in our case is "has been submitted at least once"
formik.dirty
happens with the fist onChange event for any of the fields (which is not what we want)
however it's got formik.submitCount
which we can employ as a param for the hook
if (isLoading) { | ||
return <CircleProgress />; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise "Not Found" was showing instead of our loading state
Coverage Report: ✅ |
✅ Rename drawer is good I noticed a view issues with create drawer:
review-vm.mp4 |
4d414a7
to
e9c132e
Compare
label: value, | ||
value: key as CreatePlacementGroupPayload['affinity_type'], | ||
}) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The submission and payloads look good for creating and renaming a PG. Validation for required fields and label length works in both drawers.
I am seeing, for the briefest of moments, the PG label show "undefined" when closing out of the Rename drawer (via Cancel or X button) without submitting the form.
Screen.Recording.2024-01-30.at.11.32.19.AM.mov
packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.tsx
Outdated
Show resolved
Hide resolved
Follow up question: what's the justification for displaying the disabled Region and Affinity Type fields in the Rename drawer, if those are not editable? That information is available in the table for reference, and it seems cleaner to only have the relevant fields in the Rename drawer; in this case, Label. |
fixed the "undefined" string on close
glad you asked! this has come up before and that's a valid point (and I agree, would make formik types cleaner). the reasoning behind this is to
Frankly this is a bit in flux and I suspect this may change in the next weeks so am not too concerned about it, but I will bring it back up once we get our UX DRI back (will be am easy change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates look good!
As far as the Rename drawer: helpful context, thank you. I'd forgotten we'd done that with VPC, but that seems to diverge from what we've done more of in the past (ex. Linode > Storage > Rename Disk; Volume > Edit). I'd be curious what disabled tooltip text might say other than some version of "You cannot edit this" and how it might be beneficial to the user. In any case, glad you've got eyes on it and the topic has come up.
On a second pass through the code and UI, I checked disabled states and blocked network requests to verify the different error states look good. Overall, LGTM -- just found a couple more typos in tests.
packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.test.tsx
Outdated
Show resolved
Hide resolved
disabled: | ||
!isRenameDrawer && | ||
numberOfPlacementGroupsCreated && | ||
maxNumberOfPlacementGroups | ||
? numberOfPlacementGroupsCreated >= maxNumberOfPlacementGroups | ||
: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair! here's extra context. We still don't know how we are going to get the PG limit. It may be per account, it may be per DC, it may be both... (this came in today) ; to that effect I will leave this as be till we get more clarification but added a comment to move it to the parent as an option.
Description 📝
This PR implements the "Create" & "Rename" Placement Groups drawers. It does a simple abstraction of its shared components to which we pass the formik props and optional placement group data.
I wanted to avoid relying on a "mode" state to have a more robust separation of concern between both drawers and avoid mashing two mutations together. It's a bit more readable and scalable that way, and doesn't part from our existing conventions.
Changes 🔄
Preview 📷
How to test 🧪
Prerequisites
Verification steps
As an Author I have considered 🤔
Check all that apply