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

Harmonize CatalogTable #28449

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Andy2003
Copy link
Contributor

Hey, I just made a Pull Request!

Harmonize CatalogTable by:

  • Show pagination text for OffsetPagination
  • Use same OffsetPaginatedCatalogTable also as fallback if no pagination is set
  • Do not show paging if there is only one page

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@Andy2003 Andy2003 requested review from a team as code owners January 13, 2025 08:38
@Andy2003 Andy2003 requested review from Rugvip and vinzscam January 13, 2025 08:38
@github-actions github-actions bot added the area:catalog Related to the Catalog Project Area label Jan 13, 2025
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Jan 13, 2025

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/plugin-catalog plugins/catalog minor v1.26.1

- Show pagination text for `OffsetPagination`
- Use same `OffsetPaginatedCatalogTable` also as fallback if no pagination is set
- Do not show paging if there is only one page

Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
@Andy2003 Andy2003 force-pushed the bugfix/harmonize-catalog-tables branch from efd1563 to d563f05 Compare January 13, 2025 09:17
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
@Andy2003 Andy2003 requested review from a team and awanlin as code owners January 13, 2025 09:38
@Andy2003 Andy2003 requested a review from benjdlambert January 13, 2025 09:38
@github-actions github-actions bot added area:techdocs Related to the TechDocs Project Area area:kubernetes Related to the Kubernetes Project Area - not deploying Backstage with k8s. search Things related to Search area:scaffolder Everything and all things related to the scaffolder project area area:search labels Jan 13, 2025
@benjdlambert
Copy link
Member

@vinzscam do you wanna have a peek through this? 🙏

return (
<Table<CatalogTableRow>
isLoading={loading}
<OffsetPaginatedCatalogTable
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure using OffsetPaginatedCatalogTable instead of Table is a good idea. Handling pagination properly will be on us and we don't have tests that cover that part. I would keep Table to stay safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are only cursor or offset based tables. Even if paging-mode is not explicitly set, the offset variant is used at the end. The separation, as it was until now, only makes the table behave differently in the case that paging is explicitly activated than if no explicit paging mode is specified.

Copy link
Member

Choose a reason for hiding this comment

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

the Offset table contains some customization to make it work with server side paginated data. The normal <Table /> uses client side paginated data, which behaves differently.

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've tested both with pagination mode offset and none, they behave as expected:

  • offset: server side paging

    image

  • none: client side paging

    image

@Andy2003 Andy2003 requested a review from vinzscam January 16, 2025 12:28
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
Copy link
Member

@vinzscam vinzscam left a comment

Choose a reason for hiding this comment

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

going through the proposed changes one by one:

- Show pagination text for OffsetPagination`

I think this is great

- Use same OffsetPaginatedCatalogTablealso as fallback if no pagination is set

I feel like we should keep things as they are as this won't fix any bug or reduce any complexity. Defining an extra <Table /> in CatalogTable allows us to better split the logic for server side and client side paginated table.

- Do not show paging if there is only one page

if it's possible to change the number of items per page via the UI we should always show the paging information (right now if a user select to display a higher number of items per page than the items that are available, it won't be possible to change the limit anymore).

}}
totalCount={totalItems}
localization={{ pagination: { labelDisplayedRows: '' } }}
{...(clientPagination
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to keep a duplicated <Table /> as it was before as it's make things easier if more things need to be adjusted.

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 disagree, the separation has already led to the CatalogTable behaving differently several times, e.g:

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this led us to miss some common props, but the advantage has been that we have introduced 3 different ways of managing and displaying data without affecting each other. Now we have a more complex OffsetPaginatedCatalogTable that handles server side and client side logic. How can we make sure that this change won't break the existing logic? Also in the future the goal is to sunset the client side paginated table, which is pretty straight forward at the moment as the logic isn't mixed with any of the two new tables.

Copy link
Contributor Author

@Andy2003 Andy2003 Jan 20, 2025

Choose a reason for hiding this comment

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

I agree that this led us to miss some common props, but the advantage has been that we have introduced 3 different ways of managing and displaying data without affecting each other.

I don't see it as an advantage that the server and client-side paging were handled in different places, as explained above, this has led to inconsistencies in the code on several occasions. With my adjustments, the paging behavior is now harmonized and always the same, whether server or client side.

Now we have a more complex OffsetPaginatedCatalogTable that handles server side and client side logic. How can we make sure that this change won't break the existing logic?

It's just an refactoring, that is even reducing the total lines of code. The added "complexity" is just an early return in the hook and a ternary for setting the server side config on the Table. You can simply compare the previous invocation of the client-side-paged table:

image

with the now called code of the OffsetPaginatedCatalogTable

image

the final call of Table is ultimately exactly the same as it was before, with the following adjustments:

Also in the future the goal is to sunset the client side paginated table, which is pretty straight forward at the moment as the logic isn't mixed with any of the two new tables.

It is still easy to remove the client-side paging, because you can explicitly find the paging mode none here (which was not the case before). And in the end you only have to remove clientPagination, which is 2 places in this file, that's it.

…here is only one page available

Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
@Andy2003 Andy2003 requested a review from vinzscam January 20, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area area:kubernetes Related to the Kubernetes Project Area - not deploying Backstage with k8s. area:scaffolder Everything and all things related to the scaffolder project area area:search area:techdocs Related to the TechDocs Project Area search Things related to Search
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants