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 component injection tokens #7754

Merged
merged 20 commits into from
May 26, 2023
Merged

Table component injection tokens #7754

merged 20 commits into from
May 26, 2023

Conversation

aleksfront
Copy link
Contributor

No description provided.

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@aleksfront aleksfront added the enhancement New feature or request label May 23, 2023
@aleksfront aleksfront requested a review from ixrock May 23, 2023 12:06
@aleksfront aleksfront requested a review from a team as a code owner May 23, 2023 12:06
@aleksfront aleksfront requested review from Nokel81 and removed request for a team May 23, 2023 12:06
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
ixrock
ixrock previously approved these changes May 23, 2023
packages/table/index.ts Outdated Show resolved Hide resolved
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@aleksfront aleksfront added this to the 6.6.0 milestone May 24, 2023
@aleksfront aleksfront requested a review from ixrock May 24, 2023 10:04
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Comment on lines +8 to +14
export const tableFeature = getFeature({
id: "core-table-feature",

register: (di) => {
di.register(tableComponentInjectable);
},
});
Copy link
Member

@ixrock ixrock May 25, 2023

Choose a reason for hiding this comment

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

Can you remind me (mostly for learning purpose) why do we need to make it as a feature?
(instead of simple some injection token re-use from some package, e.g. import {cystomTableToken} from "@k8slens/item-list")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, it seems to be an architectural decision. If we utilize an injection token in the core and there are two "users" of this token registered, an error will occur. Only one injection token consumer is allowed. However, by incorporating a feature within the open-lens package, we can easily separate features to determine their visibility in all lens variations. Additionally, the feature is beneficial when dealing with multiple injection tokens that need to be registered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jansav @Iku-turso A good chance to clarify the question and correct me.

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, the feature is beneficial when dealing with multiple injection tokens that need to be registered.

Can't get it.. why not di.injectMany(customTableToken)? And decide which one to use..
This is simple & perfect for plain component injections/replacement).

Copy link
Contributor

Choose a reason for hiding this comment

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

Feature is a group of injectables which are registered and deregistered at once. The idea is that everything related to the feature can be in separate npm package called @k8slens/some-feature which then exports someFeature. Now that open-lens (or any of the applications) registers someFeature with registerFeature, the feature is added.

--

This case seems to have been built in a way that we expect a single implementation of tableComponentInjectionToken to be around. This makes sense, because there should be only one of them. However, the important part here is that implementation tableComponentInjectable should be under open-lens and not under core. Therefore it's only registered in the open-lens and not in any other application which is built on top of core package. In this way di.inject(tableComponentInjectionToken) will be enough. Feature is not needed here because the "open-lens" implementation of table can be moved under open-lens and we're fine with stuff under there being registered individually.

@aleksfront @ixrock

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@aleksfront aleksfront added chore and removed enhancement New feature or request labels May 25, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@aleksfront aleksfront requested a review from ixrock May 26, 2023 06:45
@aleksfront aleksfront merged commit 1ffdb6c into master May 26, 2023
@aleksfront aleksfront deleted the table-injection-tokens branch May 26, 2023 10:32
@Nokel81 Nokel81 modified the milestones: 6.6.0, 6.5.0 May 26, 2023
@Nokel81 Nokel81 mentioned this pull request May 26, 2023
@@ -0,0 +1,15 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this under open-lens package and import Table from @k8slens/core. Add export if it's not exported yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

4 participants