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
Fixes #34320 - Hide Katello tabs & cards on new host detail page when host is unregistered #9942
Conversation
Issues: #34320 |
a5c11b7
to
91527c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @jeremylenz! 👍
Tabs are registered with slot&fill which uses a registry for registering new fills, how about leveraging this runtime mechanism for unregistering a tab (fill)?
We use this helper to register a core's tab in runtime -
https://github.com/theforeman/foreman/blob/develop/webpack/assets/javascripts/react_app/components/HostDetails/Tabs/index.js#L7
We can leverage the slot's registry and create a helper for unregistering a specific tab directly from the registry.
@amirfefer I did try unregistering, but ran into some problems which I can't remember now. I think it was something to do with the tab unregistering itself. I guess I will look into it again.. 🤔 |
In TracesTab I added if (hostIsNotRegistered({ hostDetails })) {
SlotsRegistry.remove('host-details-page-tabs', 'Traces');
return null;
} But this didn't work because the tab itself was still there; it just didn't render any content inside it. Also, after a few seconds I got this console error
|
I also tried to use the Redux action if (hostIsNotRegistered({ hostDetails })) {
// SlotsRegistry.remove('host-details-page-tabs', 'Traces');
dispatch(unregisterFillComponent('host-details-page-tabs', 'Traces'));
return null;
} and I got
|
I also tried to unregister the tab from ErrataOverviewCard:
I think the problem is that there's simply no good place to put this code in Katello. That's why I think my solution of passing the function to Foreman is pretty clean and the best way to go. @amirfefer thoughts? |
91527c8
to
a05532c
Compare
rebased |
Works well for me only oddity I saw was #<Katello::Host::ContentFacet:0x00000000182b5850
id: 1,
host_id: 1,
uuid: nil,
content_view_id: 1,
lifecycle_environment_id: 1,
kickstart_repository_id: nil,
content_source_id: nil,
installable_security_errata_count: 0,
installable_enhancement_errata_count: 0,
installable_bugfix_errata_count: 0,
applicable_rpm_count: 1,
upgradable_rpm_count: 0,
applicable_module_stream_count: 0,
upgradable_module_stream_count: 0,
applicable_deb_count: 0,
upgradable_deb_count: 0> |
Unregistering slot/fills seems complicated, require deeper changes in foreman and has potential for breaking other things. You approach seems much less invasive, cleaner and easier to maintain. APJ :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well for me. APJ
[test katello] |
d22c4e3
to
ccefae1
Compare
Refs #34320 - add & fix tests
ccefae1
to
0c3f1e2
Compare
rebased |
… host is unregistered (Katello#9942) * Fixes #34320 - update errata applicability when unregistering * Refs #34320 - Hide Katello tabs Refs #34320 - add & fix tests
… host is unregistered (Katello#9942) * Fixes #34320 - update errata applicability when unregistering * Refs #34320 - Hide Katello tabs Refs #34320 - add & fix tests
… host is unregistered (#9942) * Fixes #34320 - update errata applicability when unregistering * Refs #34320 - Hide Katello tabs Refs #34320 - add & fix tests
… host is unregistered (Katello#9942) * Fixes #34320 - update errata applicability when unregistering * Refs #34320 - Hide Katello tabs Refs #34320 - add & fix tests (cherry picked from commit f4f19c1)
…for unregistered host Fixes #34320 - Hide Katello tabs & cards on new host detail page when host is unregistered (Katello#9942) * Fixes #34320 - update errata applicability when unregistering * Refs #34320 - Hide Katello tabs Refs #34320 - add & fix tests (cherry picked from commit d5059d5)
What are the changes introduced in this pull request?
We need to allow Katello to hide its tabs and cards from the new host detail page.
Adds new helper functions
hostIsNotRegistered
andhostIsRegistered
Check if host is registered and if not, hide Errata and Content View overview cards
Also hide Content, Traces, and Repository sets tabs for non-registered hosts. The way it works is as follows:
hideTab
, that is sent to Foreman. This allows us to pass a function to Foreman which Foreman will then call with the host details when setting up the page.hideTab
returns true for that tab, Foreman will hide the tab from the host details page.hostIsNotRegistered
as thehideTab
function here, but other functions could be used for other slots in the future.Also, recalculates errata counts on the host when unregistering to ensure they're properly cleared out.
Considerations taken when implementing this change?
Hiding cards I can do from Katello, but I found that changing Foreman code is the only clean way to hide an entire tab.
I found that passing the
hideTab
function to Foreman is a good way to keep Katello code in Katello and Foreman code in Foreman. This way Katello can be the one that cares about why we're hiding the tab, and Foreman doesn't have to touch such ugliness as subscription facets 😱.What are the testing steps for this pull request?
Apply the Foreman change: Refs #34442 - Allow plugins to hide tabs on new host detail page theforeman/foreman#9104
Reload the host detail page and verify:
Reregister the host and verify that