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

✨ Add client-side pagination to Archetypes table #1370

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

mturley
Copy link
Collaborator

@mturley mturley commented Sep 15, 2023

Part of #1264, see checklist here.

Signed-off-by: Mike Turley <mike.turley@alum.cs.umass.edu>
@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (3feb39a) 41.43% compared to head (cffee81) 41.43%.

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           
Flag Coverage Δ
client 41.43% <ø> (ø)
server ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

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

mturley added a commit that referenced this pull request Sep 18, 2023
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>
@mturley mturley merged commit 063e16a into konveyor:main Sep 18, 2023
6 checks passed
@mturley mturley deleted the archetypes-pagination branch September 18, 2023 19:15
@mturley
Copy link
Collaborator Author

mturley commented Sep 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants