Sha256: 0b783d8655b63022013065947185c8f02e1336e4ce90c84b368e3af629c38bf7

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

import React from 'react';
import EllipsisWithTooltip from 'react-ellipsis-with-tooltip';
import PropTypes from 'prop-types';

import InfoItem from './InfoItem';
import { itemIteratorId } from './helpers';

const StringInfoItem = ({
  template,
  attr,
  tooltipText,
  translate,
  mapAttr,
  elipsed,
}) => {
  const inner = (
    <span>
      {translate ? __(mapAttr(template, attr)) : mapAttr(template, attr)}
    </span>
  );
  const innerContent = elipsed ? (
    <EllipsisWithTooltip placement="top">{inner}</EllipsisWithTooltip>
  ) : (
    inner
  );

  return (
    <InfoItem itemId={itemIteratorId(template, attr)} tooltipText={tooltipText}>
      {innerContent}
    </InfoItem>
  );
};

StringInfoItem.propTypes = {
  template: PropTypes.object.isRequired,
  attr: PropTypes.string.isRequired,
  tooltipText: PropTypes.string,
  translate: PropTypes.bool,
  mapAttr: PropTypes.func,
  elipsed: PropTypes.bool,
};

StringInfoItem.defaultProps = {
  translate: false,
  mapAttr: (template, attr) => template[attr],
  elipsed: false,
  tooltipText: undefined,
};

export default StringInfoItem;

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_templates-9.2.0 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-9.1.0 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-9.0.2 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-9.0.1 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-9.0.0 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.7 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-8.0.0 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.6 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.5 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.4 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.3 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
foreman_templates-7.0.2 webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js