Sha256: 14d93010db1edc8c2cc5b6562545cd6e02a9f07c229dd8cbd47432a2a7db83ef
Contents?: true
Size: 1.59 KB
Versions: 7
Compression:
Stored size: 1.59 KB
Contents
import React from 'react'; import { ListView, Tooltip, OverlayTrigger } from 'patternfly-react'; import classNames from 'classnames'; import { translate as __ } from 'foremanReact/common/I18n'; import AnsibleRoleActionButton from './AnsibleRoleActionButton'; import '../AnsibleRolesSwitcher.scss'; const AnsibleRole = ({ role, icon, onClick, resourceName, index }) => { const text = resourceName === 'hostgroup' ? __('This Ansible role is inherited from parent host group') : __('This Ansible role is inherited from host group'); const tooltip = ( <Tooltip id={role.id}> <span>{text}</span> </Tooltip> ); const clickHandler = (onClickFn, ansibleRole) => event => { event.preventDefault(); onClickFn(ansibleRole); }; const headingText = (name, idx) => idx || idx === 0 ? `${idx + 1}. ${name}` : name; const listItem = (click = undefined) => ( <ListView.Item id={role.id} className={classNames('listViewItem--listItemVariants', { 'ansible-role-disabled': role.inherited, 'ansible-role-movable': !role.inherited, })} heading={headingText(role.name, index)} actions={ role.inherited ? ( '' ) : ( <AnsibleRoleActionButton icon={icon} role={role} /> ) } stacked onClick={typeof click === 'function' ? click(onClick, role) : click} /> ); if (role.inherited) { return ( <OverlayTrigger overlay={tooltip} placement="top"> {listItem()} </OverlayTrigger> ); } return listItem(clickHandler); }; export default AnsibleRole;
Version data entries
7 entries across 7 versions & 1 rubygems