From 31e8636897320d09090f97766497597e8aac158e Mon Sep 17 00:00:00 2001 From: Jeremy Lenz Date: Fri, 3 Nov 2023 12:07:05 -0400 Subject: [PATCH] Refs #36887 - ensure dropdown isn't disabled on host details page --- .../react_app/components/FeaturesDropdown/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/webpack/react_app/components/FeaturesDropdown/index.js b/webpack/react_app/components/FeaturesDropdown/index.js index 8ca244777..82f0cc490 100644 --- a/webpack/react_app/components/FeaturesDropdown/index.js +++ b/webpack/react_app/components/FeaturesDropdown/index.js @@ -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 @@ -62,6 +63,8 @@ const FeaturesDropdown = ({ hostId, hostSearch, selectedCount }) => { , ]; + const disableDropdown = !isSingleHost && selectedCount === 0; + return ( { splitButtonItems={scheduleJob} toggleVariant="secondary" onToggle={() => setIsOpen(prev => !prev)} - isDisabled={status === STATUS.PENDING || selectedCount === 0} + isDisabled={status === STATUS.PENDING || disableDropdown} splitButtonVariant="action" /> }