import React, { useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { DropdownItem, DropdownGroup } from '@patternfly/react-core';
import { get } from 'foremanReact/redux/API';
import { foremanUrl } from 'foremanReact/common/helpers';
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
import Loading from 'foremanReact/components/Loading';
import { HOST_BOOTDISK_BUTTONS_REQUEST_KEY } from '../constants';
import {
selectHostId,
selectIsLoading,
selectBootdiskOptions,
} from './HostBootdiskButtonsSelectors';
const HostBootdiskButtons = () => {
const dispatch = useDispatch();
const hostId = useSelector(selectHostId);
const isLoading = useSelector(selectIsLoading);
const options = useSelector(selectBootdiskOptions);
useEffect(() => {
dispatch(
get({
key: HOST_BOOTDISK_BUTTONS_REQUEST_KEY,
url: foremanUrl(`/bootdisk/disks/bootdisk_options/${hostId}`),
})
);
}, [dispatch, hostId]);
let content = null;
if (options.bootdiskDownloadable) {
content = options.actions.map((action, i) => (
{action.title}
));
} else {
content = (
{__('Not available')}
);
}
return (
{isLoading ? : content}
);
};
export default HostBootdiskButtons;