Fixes #35835 - Hide provisioning cards for unmanaged hosts
Unmanaged hosts do not have provisioning so the cards shouldn't be shown.
In addition to this it also moves away from using the hostname in the API URL and instead uses the host ID. Host IDs are stable while a host can be renamed. Application code should never use the names in URLs.
I should mention I wasn't able to test this out yet (don't have a development environment with a compatible nodejs version).
Issues: #35835
Before I fix the lint issues: is this actually something we should filter out at the card registry level?
is this actually something we should filter out at the card registry level?
Or at what level instead?
Right now this PR filters it out at the card level. Perhaps the registry could/should be enhanced to do the filtering? Basically accept a function that takes hostDetails and returns a boolean.
Im not sure what the benefit of that will be, and this way makes it clear on the card level why isnt it shown which is nice.
I don't think it is clear. It gives the impression the fields can be set, but they can't. At a database level the fields don't exist. If anything, the whole card should be grayed out to make it clear it's not applicable.
Why does the current state of the pr gives the impression the fields can be set?
I'm reviving this PR. In the mean time I learned a bit more.
We have a Host::Managed object, which has a boolean managed. If managed is set to false, you are not able to provision it. Yesterday we discussed that provisionable is a better name.
We also have a way to change it between the two: https://github.com/theforeman/foreman/blob/555c3d0f4de32b72cf11aab6c7099aeee38f17ff/app/views/hosts/edit.html.erb#L5-L7
Perhaps instead of hiding the whole section, we can instead show the "Manage host" button with some instructions?
You can also see some fields are conditionally present: https://github.com/theforeman/foreman/blob/555c3d0f4de32b72cf11aab6c7099aeee38f17ff/app/views/hosts/_form.html.erb#L13-L18 https://github.com/theforeman/foreman/blob/555c3d0f4de32b72cf11aab6c7099aeee38f17ff/app/views/hosts/_form.html.erb#L106
Looking at it, that's just the compute resource and OS: https://github.com/theforeman/foreman/blob/develop/app/views/hosts/_unattended.html.erb
Looking more at it, I think you can import hosts from compute resources and they end up as unmanaged hosts. That workflow then doesn't make a lot of sense.