Sha256: 772e39822f0161a1de1c61c56cb7de5b0b8440a05a1fb0b1ae8449b6c8f97fad
Contents?: true
Size: 1.82 KB
Versions: 16
Compression:
Stored size: 1.82 KB
Contents
import React from 'react'; import { upperFirst } from 'lodash'; import PropTypes from 'prop-types'; import SyncSettingField from './SyncSettingField'; const SyncSettingsFields = ({ importSettings, exportSettings, syncType, resetField, formProps: { isSubmitting }, }) => { const addRequiredToSetting = setting => setting.name === 'repo' ? setting.merge({ required: true, }) : setting; const modifyDescription = (setting, type) => { if (setting.description) { let split = setting.description.split('. '); if (setting.name === 'repo' && type !== 'export') { split = split.slice(0, split.length - 1); } split = split.join('.<br>'); return setting.set('description', split); } return setting; }; const specializeDescription = (setting, type) => setting.set( 'description', upperFirst(setting.description.replace(/import\/export/i, type)) ); const settingsAry = syncType === 'import' ? importSettings : exportSettings; return ( <React.Fragment> {settingsAry .map(addRequiredToSetting) .map(setting => modifyDescription(setting, syncType)) .map(setting => specializeDescription(setting, syncType)) .map(setting => ( <SyncSettingField setting={setting} syncType={syncType} key={setting.name} disabled={isSubmitting} resetField={resetField} /> ))} </React.Fragment> ); }; SyncSettingsFields.propTypes = { importSettings: PropTypes.array.isRequired, exportSettings: PropTypes.array.isRequired, syncType: PropTypes.string.isRequired, resetField: PropTypes.func.isRequired, formProps: PropTypes.object, }; SyncSettingsFields.defaultProps = { formProps: {}, }; export default SyncSettingsFields;
Version data entries
16 entries across 16 versions & 1 rubygems