Sha256: b41b9fc2f6d770f29e161690e934e44c5c05857b11bcc3e6353f8eb246ae6ba9

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

import React from 'react';
import { ListView, Tooltip, OverlayTrigger } from 'patternfly-react';
import classNames from 'classnames';

import AnsibleRoleActionButton from './AnsibleRoleActionButton';
import '../AnsibleRolesSwitcher.scss';

const AnsibleRole = ({ role, icon, onClick, resourceName }) => {
  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 listItem = (click = undefined) => (
    <ListView.Item
      id={role.id}
      className={classNames('listViewItem--listItemVariants', {
        'ansible-role-disabled': role.inherited,
        'ansible-role-movable': !role.inherited,
      })}
      heading={role.name}
      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

12 entries across 12 versions & 1 rubygems

Version Path
foreman_ansible-3.0.9 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.8 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.7 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.6 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.5 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.4 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.3 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-2.3.4 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.2 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.1 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-3.0.0 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
foreman_ansible-2.3.3 webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js