Skip to content

Commit

Permalink
Add icons to host bulk actions (theforeman#120)
Browse files Browse the repository at this point in the history
* Add icons to host bulk actions

* update review
  • Loading branch information
stejskalleos authored Jun 20, 2022
1 parent cd55c8e commit f781cd8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/controllers/foreman_bootdisk/disks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ def bootdisk_allowed_actions(host)
title: title,
link: "/bootdisk/disks/#{action}s/#{host.id}",
disabled: disable_full_host ? true : false,
description: disable_full_host ? _('Host is not in build mode') : nil
description: disable_full_host ? _('Host is not in build mode') : nil,
icon: action,
}
end
return allowed unless User.current.allowed_to?({controller: 'foreman_bootdisk/disks', action: 'help'})

allowed.push({
title: _('Boot disk help'),
link: '/bootdisk/disks/help'
link: '/bootdisk/disks/help',
icon: 'help'
})
end
end
Expand Down
21 changes: 21 additions & 0 deletions webpack/src/extensions/host/HostBootdiskButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import React, { useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';

import { DropdownItem, DropdownGroup } from '@patternfly/react-core';
import {
BanIcon,
BuildIcon,
BuilderImageIcon,
OutlinedQuestionCircleIcon,
} from '@patternfly/react-icons';

import { get } from 'foremanReact/redux/API';
import { foremanUrl } from 'foremanReact/common/helpers';
Expand All @@ -23,6 +29,19 @@ const HostBootdiskButtons = () => {
const isLoading = useSelector(selectIsLoading);
const options = useSelector(selectBootdiskOptions);

const iconComponent = icon => {
switch (icon) {
case 'host':
return <BuildIcon />;
case 'full_host':
return <BuilderImageIcon />;
case 'help':
return <OutlinedQuestionCircleIcon />;
default:
return null;
}
};

useEffect(() => {
dispatch(
get({
Expand All @@ -40,6 +59,7 @@ const HostBootdiskButtons = () => {
href={foremanUrl(action.link)}
isDisabled={action.disabled}
description={action.description}
icon={iconComponent(action.icon)}
>
{action.title}
</DropdownItem>
Expand All @@ -55,6 +75,7 @@ const HostBootdiskButtons = () => {
options.architectureName
)}
tooltipProps={{ entryDelay: 0, exitDelay: 0 }}
icon={<BanIcon />}
>
{__('Not available')}
</DropdownItem>
Expand Down

0 comments on commit f781cd8

Please sign in to comment.