webpack/components/NewTemplateSync/components/SyncSettingField.js in foreman_templates-7.0.7 vs webpack/components/NewTemplateSync/components/SyncSettingField.js in foreman_templates-8.0.0
- old
+ new
@@ -3,11 +3,11 @@
import { FieldLevelHelp } from 'patternfly-react';
import TextButtonField from './TextButtonField';
import ButtonTooltip from './ButtonTooltip';
-const SyncSettingField = ({ setting, resetField, disabled }) => {
+const SyncSettingField = ({ setting, resetField, disabled, syncType }) => {
const label = settingObj => `${settingObj.fullName} `;
const fieldSelector = settingObj => {
if (settingObj.settingsType === 'boolean') {
return 'checkbox';
@@ -18,36 +18,29 @@
}
return 'text';
};
- const handleReset = (settingName, settingValue) => {
- resetField(settingName, settingValue);
- };
-
const tooltipContent = (
<div
dangerouslySetInnerHTML={{
__html: setting.description,
}}
/>
);
return (
<TextButtonField
- name={setting.name}
+ name={`${syncType}.${setting.name}`}
label={label(setting)}
blank={{}}
item={setting}
- buttonAttrs={{
- buttonText: <ButtonTooltip tooltipId={setting.name} />,
- buttonAction: () => handleReset(setting.name, setting.value),
- }}
+ buttonText={<ButtonTooltip tooltipId={setting.name} />}
+ buttonAction={resetField(`${syncType}.${setting.name}`, setting.value)}
fieldSelector={fieldSelector}
disabled={disabled}
fieldRequired={setting.required}
- validate={setting.validate}
tooltipHelp={<FieldLevelHelp content={tooltipContent} />}
>
{setting.value}
</TextButtonField>
);
@@ -55,8 +48,9 @@
SyncSettingField.propTypes = {
setting: PropTypes.object.isRequired,
resetField: PropTypes.func.isRequired,
disabled: PropTypes.bool.isRequired,
+ syncType: PropTypes.string.isRequired,
};
export default SyncSettingField;