Skip to content

Commit

Permalink
Refs #36887 - ensure dropdown isn't disabled on host details page
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Nov 3, 2023
1 parent 046bbb6 commit 31e8636
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions webpack/react_app/components/FeaturesDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ import './index.scss';

const FeaturesDropdown = ({ hostId, hostSearch, selectedCount }) => {
const [isOpen, setIsOpen] = useState(false);
const rexFeaturesUrl = hostId
const isSingleHost = !!hostId; // identifies whether we're on the host details or host overview page
const rexFeaturesUrl = isSingleHost
? REX_FEATURES_HOST_URL(hostId)
: ALL_REX_FEATURES_URL;
const { response, status } = useAPI('get', foremanUrl(rexFeaturesUrl));
const dispatch = useDispatch();
// eslint-disable-next-line camelcase
const canRunJob = response?.permissions?.can_run_job;
if (!!hostId && !canRunJob) {
if (isSingleHost && !canRunJob) {
return null;
}

const features = hostId
const features = isSingleHost
? response?.remote_execution_features // eslint-disable-line camelcase
: response?.results;
const dropdownItems = features
Expand All @@ -62,6 +63,8 @@ const FeaturesDropdown = ({ hostId, hostSearch, selectedCount }) => {
</DropdownToggleAction>,
];

const disableDropdown = !isSingleHost && selectedCount === 0;

return (
<Dropdown
ouiaId="schedule-a-job-dropdown"
Expand All @@ -75,7 +78,7 @@ const FeaturesDropdown = ({ hostId, hostSearch, selectedCount }) => {
splitButtonItems={scheduleJob}
toggleVariant="secondary"
onToggle={() => setIsOpen(prev => !prev)}
isDisabled={status === STATUS.PENDING || selectedCount === 0}
isDisabled={status === STATUS.PENDING || disableDropdown}
splitButtonVariant="action"
/>
}
Expand Down

0 comments on commit 31e8636

Please sign in to comment.