diff --git a/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx b/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx index e208686ab5..66bbbc634a 100644 --- a/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx +++ b/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx @@ -116,7 +116,7 @@ class SelectResourceStep extends React.Component { name={item[displayKey]} label={item[displayKey]} onSelect={() => onRowClick(item)} - onDeselect={() => {}} + onDeselect={() => onRowClick(item)} /> )} renderToolbar={props => } diff --git a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx index 2ca4fe86ab..8f402ead06 100644 --- a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx +++ b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Link, withRouter } from 'react-router-dom'; +import { Link, useHistory, useParams, useLocation } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Host } from '@types'; @@ -14,9 +14,27 @@ import DeleteButton from '@components/DeleteButton'; import Switch from '@components/Switch'; import { HostsAPI } from '@api'; -function HostDetail({ host, history, match, i18n, onUpdateHost }) { - const { created, description, id, modified, name, summary_fields } = host; +function HostDetail({ host, i18n, onUpdateHost }) { + const { + created, + description, + id, + modified, + name, + enabled, + summary_fields: { + inventory, + recent_jobs, + kind, + created_by, + modified_by, + user_capabilities, + }, + } = host; + const history = useHistory(); + const { pathname } = useLocation(); + const { id: inventoryId, hostId: inventoryHostId } = useParams(); const [isLoading, setIsloading] = useState(false); const [deletionError, setDeletionError] = useState(false); const [toggleLoading, setToggleLoading] = useState(false); @@ -25,8 +43,8 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { const handleHostToggle = async () => { setToggleLoading(true); try { - const { data } = await HostsAPI.update(host.id, { - enabled: !host.enabled, + const { data } = await HostsAPI.update(id, { + enabled: !enabled, }); onUpdateHost(data); } catch (err) { @@ -39,9 +57,9 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { const handleHostDelete = async () => { setIsloading(true); try { - await HostsAPI.destroy(host.id); + await HostsAPI.destroy(id); setIsloading(false); - history.push(`/inventories/inventory/${match.params.id}/hosts`); + history.push(`/inventories/inventory/${inventoryId}/hosts`); } catch (err) { setDeletionError(err); } @@ -68,7 +86,7 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { title={i18n._(t`Error!`)} onClose={() => setDeletionError(false)} > - {i18n._(t`Failed to delete ${host.name}.`)} + {i18n._(t`Failed to delete ${name}.`)} ); @@ -76,12 +94,12 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { return ( handleHostToggle()} aria-label={i18n._(t`Toggle Host`)} /> @@ -89,22 +107,20 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { } + value={} label={i18n._(t`Activity`)} /> - {summary_fields.inventory && ( + {inventory && ( - {summary_fields.inventory.name} + {inventory.name} } /> @@ -112,11 +128,11 @@ function HostDetail({ host, history, match, i18n, onUpdateHost }) { - {summary_fields.user_capabilities && - summary_fields.user_capabilities.edit && ( - - )} - {summary_fields.user_capabilities && - summary_fields.user_capabilities.delete && ( - handleHostDelete()} - modalTitle={i18n._(t`Delete Host`)} - name={host.name} - /> - )} + {user_capabilities && user_capabilities.edit && ( + + )} + {user_capabilities && user_capabilities.delete && ( + handleHostDelete()} + modalTitle={i18n._(t`Delete Host`)} + name={host.name} + /> + )} ); @@ -157,4 +171,4 @@ HostDetail.propTypes = { host: Host.isRequired, }; -export default withI18n()(withRouter(HostDetail)); +export default withI18n()(HostDetail);