From 4e799e6276f106a1c774aa4c08ced470eb17a030 Mon Sep 17 00:00:00 2001 From: Jeremy Lenz Date: Wed, 4 Oct 2023 13:56:35 -0400 Subject: [PATCH] Refs #36789 - respect permissions --- .../HostDetails/ActionsBar/index.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/webpack/components/extensions/HostDetails/ActionsBar/index.js b/webpack/components/extensions/HostDetails/ActionsBar/index.js index 1d2e74993fa..a7fc601d766 100644 --- a/webpack/components/extensions/HostDetails/ActionsBar/index.js +++ b/webpack/components/extensions/HostDetails/ActionsBar/index.js @@ -11,6 +11,7 @@ import { foremanUrl } from 'foremanReact/common/helpers'; import { selectHostDetails } from '../HostDetailsSelectors'; import { useRexJobPolling } from '../Tabs/RemoteExecutionHooks'; import { runSubmanRepos } from '../Cards/ContentViewDetailsCard/HostContentViewActions'; +import { hasRequiredPermissions as can, userPermissionsFromHostDetails } from '../hostDetailsHelpers'; const HostActionsBar = () => { const hostDetails = useSelector(selectHostDetails); @@ -18,6 +19,10 @@ const HostActionsBar = () => { const hostname = hostDetails?.name; const { onKebabToggle } = useContext(ForemanActionsBarContext); + const recalculateApplicability = ['edit_hosts', 'create_job_invocations']; + const showRecalculate = + can(recalculateApplicability, userPermissionsFromHostDetails({ hostDetails })); + const refreshHostDetails = () => dispatch({ type: 'API_GET', payload: { @@ -45,15 +50,18 @@ const HostActionsBar = () => { > {__('Legacy content host UI')} - , - } - > - {__('Refresh applicability')} - + + {showRecalculate && ( + } + > + {__('Refresh applicability')} + + ) + }