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

upcoming: [M3-7614] - Placement Groups Create/Rename Drawers #10106

Merged
merged 21 commits into from
Jan 30, 2024

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Jan 24, 2024

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 🔄

  • Add Drawers, related components and their tests
  • Change affinity type to be an enum (usually a good practice for small, static select options)
  • Rename "update" nomenclature to be "rename" since this is all that drawer does (and likely will do)
  • Code cleanup and tightening

Preview 📷

Create Drawer Rename Drawer
Screenshot 2024-01-29 at 10 06 01 Screenshot 2024-01-29 at 10 05 44

How to test 🧪

Prerequisites

  • Have the "Placement Group" flag and MSW turned on

Verification steps

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@abailly-akamai abailly-akamai self-assigned this Jan 24, 2024
@abailly-akamai abailly-akamai force-pushed the M3-7614 branch 3 times, most recently from af45749 to bc6604c Compare January 26, 2024 22:16
@abailly-akamai abailly-akamai changed the title upcoming: [M3-7614] - Placement Groups Create Drawer upcoming: [M3-7614] - Placement Groups Create/Rename Drawers Jan 28, 2024
compliant: boolean;
linode_ids: number[];
limits: number;
capacity: number;
Copy link
Contributor Author

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

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,
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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 />;
}

Copy link
Contributor Author

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

@abailly-akamai abailly-akamai marked this pull request as ready for review January 29, 2024 16:02
@abailly-akamai abailly-akamai requested a review from a team as a code owner January 29, 2024 16:02
@abailly-akamai abailly-akamai requested review from mjac0bs, jaalah-akamai and carrillo-erik and removed request for a team January 29, 2024 16:02
Copy link

github-actions bot commented Jan 29, 2024

Coverage Report:
Base Coverage: 81.21%
Current Coverage: 81.21%

@jaalah-akamai
Copy link
Contributor

✅ Rename drawer is good
✅ Validation errors look good

I noticed a view issues with create drawer:

  • If I select a region and remove it, I can still submit the form
  • If I choose to create another, Affinity Type is auto-populated
review-vm.mp4

label: value,
value: key as CreatePlacementGroupPayload['affinity_type'],
})
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-01-30 at 09 45 39

wanna cast here so value isn't just a string. a bit stricter

@jaalah-akamai jaalah-akamai added the Add'tl Approval Needed Waiting on another approval! label Jan 30, 2024
Copy link
Contributor

@mjac0bs mjac0bs left a 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.

✅ Creating:
Screenshot 2024-01-30 at 11 30 33 AM

✅ Renaming:
Screenshot 2024-01-30 at 11 31 28 AM

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

@mjac0bs
Copy link
Contributor

mjac0bs commented Jan 30, 2024

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.

@abailly-akamai
Copy link
Contributor Author

@mjac0bs

fixed the "undefined" string on close

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.

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

  • match what was done for the VPC edit drawer
  • eventually add some helper tooltip to the disabled fields and add some context (in which case we may also change the CTA to "edit" and not "rename"

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)

Copy link
Contributor

@mjac0bs mjac0bs left a 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.

Comment on lines 115 to 120
disabled:
!isRenameDrawer &&
numberOfPlacementGroupsCreated &&
maxNumberOfPlacementGroups
? numberOfPlacementGroupsCreated >= maxNumberOfPlacementGroups
: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

A small ❓ : Was disabling the Create button on the landing page, rather than the Create button in the drawer, discussed? Just wondering about that extra click for the user, but maybe it's an intentional choice so that the user can view the drawer.

Screenshot 2024-01-30 at 12 56 46 PM

Copy link
Contributor Author

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.

@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jan 30, 2024
@abailly-akamai abailly-akamai merged commit 3937bc7 into linode:develop Jan 30, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Placement Groups
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants