-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
association and disassociation of host groups and inventory host groups list. #6559
association and disassociation of host groups and inventory host groups list. #6559
Conversation
Build failed.
|
f2ab381
to
bf4de87
Compare
Build failed.
|
note, this pr fixes #6549 |
bf4de87
to
350a6d6
Compare
Build succeeded.
|
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.
Some small changes and a few questions seeking clarity.
return ( | ||
<Switch> | ||
<Route | ||
key="list" | ||
path="/hosts/:id/groups" | ||
render={() => { | ||
return <HostGroupsList location={location} match={match} />; | ||
return ( | ||
<HostGroupsList host={host} location={location} match={match} /> |
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.
We should probably no longer pass match
and location
in favor of the useLocation() and useParams, in the component that they are needed. Also our new pattern is to wrap the component in <Route>
rather than use the render function.
@@ -15,27 +25,35 @@ const QS_CONFIG = getQSConfig('group', { | |||
order_by: 'name', | |||
}); | |||
|
|||
function HostGroupsList({ i18n, location, match }) { | |||
const [selected, setSelected] = useState([]); | |||
function HostGroupsList({ i18n, location, match, host }) { |
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.
remove location and match from here in favor of useLocation() and useParams()
groups: results, | ||
itemCount: count, | ||
actions: actionsResponse.data.actions, | ||
}; | ||
}, [hostId, location]), // eslint-disable-line react-hooks/exhaustive-deps |
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.
It seems like we can also remove this eslint warning that is disabled
@@ -16,26 +26,33 @@ const QS_CONFIG = getQSConfig('group', { | |||
}); | |||
|
|||
function InventoryHostGroupsList({ i18n, location, match }) { |
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.
use useLocation() and useParams instead of passing location and match as props.
groups: results, | ||
itemCount: count, | ||
actions: actionsResponse.data.actions, | ||
}; | ||
}, [hostId, location]), // eslint-disable-line react-hooks/exhaustive-deps |
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.
You can probably get rid of this es lint warning disable comment.
selected.length > 0 && selected.length === groups.length; | ||
const fetchGroupsToAssociate = useCallback( | ||
params => { | ||
return InventoriesAPI.readGroups( |
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.
Why not use useRequest here?
}; | ||
|
||
const isAllSelected = | ||
selected.length > 0 && selected.length === groups.length; | ||
const fetchGroupsToAssociate = useCallback( |
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.
Why not use useRequest here?
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.
That is because the request is not getting called in this component. On line 95, the function is getting "defined" for later use. fetchGroupsToAssociate
is passed to AssociateModal as the fetchRequest
prop. When the modal opens, fetchRequest
is called within the useRequest
hook to populate the modal list.
@jlmitch5 This same issue is on the Facts tab. I'm happy to create an issue for it to be addressed in a separate PR, or address it in this 1. Let me know which you choose. |
350a6d6
to
f3f441b
Compare
…h hooks where possible in inventories
Build succeeded.
|
f3f441b
to
ce30594
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.
This looks ✨ Thanks for hooking this up.
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.
Good work on this!
Build succeeded.
|
Build succeeded (gate pipeline).
|
link #5908 (this is the association/disassociation part)
--
Note there is a kind of strange thing where if your host is a member of a group as well a member of a child group of that group, and you try to disassociate with the root group, it will still show in the list (because it is still indirectly a member of that group through the child). I checked and this is the same as in the old ui. We could make this work by changing the list's response from /all_groups/ to /groups/ (the latter only shows groups you are directly in. But I'm not sure which we'd want.