-
Notifications
You must be signed in to change notification settings - Fork 43
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
✨ Add client-side pagination to Archetypes table #1370
Conversation
Signed-off-by: Mike Turley <mike.turley@alum.cs.umass.edu>
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #1370 +/- ##
=======================================
Coverage 41.43% 41.43%
=======================================
Files 137 137
Lines 4279 4279
Branches 1026 1026
=======================================
Hits 1773 1773
Misses 2418 2418
Partials 88 88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Ok, that's just far too straight forward to add client side pagination like that.
Part of #1264, see [checklist here](#1264 (comment)). The Duplicate action is a cross between create and edit: a "create new archetype" form is opened, but its fields are all prefilled as if we are editing an existing archetype. The prefilled name has an appended " (duplicate)" suffix on it. Just for fun, in case a user duplicates the same archetype multiple times without touching the default name, we check to see if the new default name is taken and use " (duplicate N)" as the suffix, with N incrementing until we get a name that isn't taken. This is probably unnecessary, but I found it annoying that the "name must be unique" error didn't appear until I touched the field, so this makes sure that case never comes up. Because ArchetypeForm already had the logic for prefilling the form for editing, all we needed to do was pass in an `archetype` and an `isDuplicating` boolean which slightly changes the behavior: * When validating that the name is unique, we don't treat the archetype being duplicated as the "current item", so it is not an exception to that validation like it needs to be when editing (if you input the same name of the item you're editing that's valid, but not so for duplicating). * We have the default name behavior with the suffix as described above. * Normally the submit button is disabled if the form isn't dirty, but the prefilled form with a generated name is valid for submission, so we allow a non-dirty form to be submitted when `isDuplicating` is true. This way you can rapid-fire duplicating things without touching the form if you so desire (useful for testing the pagination in #1370 😄) * The submit button says "Create", and on submit we create instead of updating. --------- Signed-off-by: Mike Turley <mike.turley@alum.cs.umass.edu> Co-authored-by: Ian Bolton <ibolton@redhat.com>
Thanks @sjd78 ! I honestly believe most table stuff can be that straightforward with the right abstraction. I've seen so many tables in products become a mess of repeated and confusing boilerplate, and the success so far we've had with the table-controls stuff gives me hope. |
Part of #1264, see checklist here.