Sha256: d0086b126ddce8fb06bb3523a38cd2ab5e82c12528b15ea30045c078bd92ac16

Contents?: true

Size: 1.4 KB

Versions: 10

Compression:

Stored size: 1.4 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { FieldLevelHelp } from 'patternfly-react';

import TextButtonField from './TextButtonField';
import ButtonTooltip from './ButtonTooltip';

const SyncSettingField = ({ setting, resetField, disabled, syncType }) => {
  const label = settingObj => `${settingObj.fullName} `;

  const fieldSelector = settingObj => {
    if (settingObj.settingsType === 'boolean') {
      return 'checkbox';
    }

    if (settingObj.selection.length !== 0) {
      return 'select';
    }

    return 'text';
  };

  const tooltipContent = (
    <div
      dangerouslySetInnerHTML={{
        __html: setting.description,
      }}
    />
  );

  return (
    <TextButtonField
      name={`${syncType}.${setting.name}`}
      label={label(setting)}
      blank={{}}
      item={setting}
      buttonText={<ButtonTooltip tooltipId={setting.name} />}
      buttonAction={resetField(`${syncType}.${setting.name}`, setting.value)}
      fieldSelector={fieldSelector}
      disabled={disabled}
      fieldRequired={setting.required}
      tooltipHelp={<FieldLevelHelp content={tooltipContent} />}
    >
      {setting.value}
    </TextButtonField>
  );
};

SyncSettingField.propTypes = {
  setting: PropTypes.object.isRequired,
  resetField: PropTypes.func.isRequired,
  disabled: PropTypes.bool.isRequired,
  syncType: PropTypes.string.isRequired,
};

export default SyncSettingField;

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_templates-9.3.3 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.3.2 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.3.1 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.3.0 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.2.0 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.1.0 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.0.2 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.0.1 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-9.0.0 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-8.0.0 webpack/components/NewTemplateSync/components/SyncSettingField.js