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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deboer-tim
requested review from
jeffmaury and
feloy
and removed request for
a team
November 27, 2023 21:14
benoitf
reviewed
Nov 28, 2023
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
force-pushed
the
table-col-map
branch
from
November 30, 2023 03:40
6c6daff
to
e98ce24
Compare
Merged
Tests never ran, so I rebased on main and force pushed. |
benoitf
reviewed
Nov 30, 2023
benoitf
approved these changes
Nov 30, 2023
Signed-off-by: Tim deBoer <git@tdeboer.ca>
cdrage
approved these changes
Dec 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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