Skip to content

Commit

Permalink
Refs #36789 - respect permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Oct 4, 2023
1 parent ee15098 commit 4e799e6
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions webpack/components/extensions/HostDetails/ActionsBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ 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);
const dispatch = useDispatch();
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: {
Expand Down Expand Up @@ -45,15 +50,18 @@ const HostActionsBar = () => {
>
{__('Legacy content host UI')}
</DropdownItem>
<DropdownSeparator key="separator" ouiaId="katello-separator" />,
<DropdownItem
ouiaId="katello-refresh-applicability"
key="katello-refresh-applicability"
onClick={handleRefreshApplicabilityClick}
icon={<RedoIcon />}
>
{__('Refresh applicability')}
</DropdownItem>
<DropdownSeparator key="separator" ouiaId="katello-separator" />
{showRecalculate && (
<DropdownItem
ouiaId="katello-refresh-applicability"
key="katello-refresh-applicability"
onClick={handleRefreshApplicabilityClick}
icon={<RedoIcon />}
>
{__('Refresh applicability')}
</DropdownItem>
)
}
<DropdownItem
ouiaId="katello-change-host-content-source"
key="katello-change-host-content-source"
Expand Down

0 comments on commit 4e799e6

Please sign in to comment.