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

Table column mapping and reuse #5011

Merged
merged 3 commits into from Dec 1, 2023
Merged

Table column mapping and reuse #5011

merged 3 commits into from Dec 1, 2023

Conversation

deboer-tim
Copy link
Collaborator

What does this PR do?

It has come up a couple times so I thought I should make a proposal for how I think we should share column renderers between tables. IMHO we have three cases:

  1. Type-specific column rendering like Image name. These should continue to be type-specific as today.
  2. Generic columns that really just need to (e.g.) render a string in a certain way.
  3. The middle ground where it's a little more complex, or maybe you need to render a couple properties.

This PR adds a simple type-mapping function to directly support #2, and applies it to VolumeList.

For the middle ground, I think we're going to have convenient cases where objects used in two tables have the same property types & names (e.g. { id: string, some-prop: number}) and we can just render those, and other cases where maybe the renderer should use another type (e.g. Condition) or one of the objects has a different property name. Again, this PR provides a simple way for tables to do whatever mapping is required.

Based on top of #5005 assuming that would merge soon.

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

Fixes #5002. We would share more columns as we add other tables that would use them.

How to test this PR?

yarn test:renderer

@deboer-tim deboer-tim requested review from benoitf and a team as code owners November 27, 2023 21:14
@deboer-tim deboer-tim requested review from jeffmaury and feloy and removed request for a team November 27, 2023 21:14
packages/renderer/src/lib/table/SimpleColumn.svelte Outdated Show resolved Hide resolved
packages/renderer/src/lib/table/table.ts Outdated Show resolved Hide resolved
packages/renderer/src/lib/table/TestTable.svelte Outdated Show resolved Hide resolved
It has come up a couple times so I thought I should make a proposal for how I
think we should share column renderers between tables. IMHO we have three cases:
1. Type-specific column rendering like Image name. These should continue to be
   type-specific as today.
2. Generic columns that really just need to (e.g.) render a string in a certain
   way.
3. The middle ground where it's a little more complex, or maybe you need to
   render a couple properties.

This commit adds a simple type-mapping function to directly support #2, and
applies it to VolumeList.

For the middle ground, I think we're going to have convenient cases where objects
used in two tables have the same property types & names (e.g. { id: string,
some-prop: number}) and we can just render those, and other cases where maybe the
renderer should use another type (e.g. Condition) or one of the objects has a
different property name. Again, this commit provides a simple way for tables to
do whatever mapping is required.

Based on top of #5005 assuming that would merge soon.

Fixes #5002. We would share more columns as we add other tables that would
use them.

Signed-off-by: Tim deBoer <git@tdeboer.ca>
Responding to PR feedback:
- Changes SimpleColumn object type to string.
- Uses a generic parameter default to provide typing to Column renderMapping.
  The second type parameter on Column defaults to the original type, but if
  you set it then the renderMapping must convert to that type.

Signed-off-by: Tim deBoer <git@tdeboer.ca>
@deboer-tim
Copy link
Collaborator Author

Tests never ran, so I rebased on main and force pushed.

Signed-off-by: Tim deBoer <git@tdeboer.ca>
@cdrage cdrage merged commit 2ddf121 into main Dec 1, 2023
9 checks passed
@cdrage cdrage deleted the table-col-map branch December 1, 2023 03:41
@podman-desktop-bot podman-desktop-bot added this to the 1.6.0 milestone Dec 1, 2023
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.

Improve table column sharing
5 participants