Sha256: 843da36267d59f573fd409b8f6d56eff385462b6e724a17ff277123234545407

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 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 }) => {
  const label = settingObj => `${settingObj.fullName} `;

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

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

    return 'text';
  };

  const handleReset = (settingName, settingValue) => {
    resetField(settingName, settingValue);
  };

  return (
    <TextButtonField
      name={setting.name}
      label={label(setting)}
      blank={{}}
      item={setting}
      buttonAttrs={{
        buttonText: <ButtonTooltip tooltipId={setting.name} />,
        buttonAction: () => handleReset(setting.name, setting.value),
      }}
      fieldSelector={fieldSelector}
      disabled={disabled}
      fieldRequired={setting.required}
      validate={setting.validate}
      tooltipHelp={<FieldLevelHelp content={setting.description} />}
    >
      {setting.value}
    </TextButtonField>
  );
};

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

export default SyncSettingField;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_templates-7.0.4 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-7.0.3 webpack/components/NewTemplateSync/components/SyncSettingField.js
foreman_templates-7.0.2 webpack/components/NewTemplateSync/components/SyncSettingField.js