Skip to content

Commit

Permalink
Merge pull request #7003 from skateman/ddf-button-labels
Browse files Browse the repository at this point in the history
Merge default button labels properly with the custom ones in DDF
  • Loading branch information
mzazrivec authored Apr 28, 2020
2 parents 158ca6f + a0175ca commit b063402
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/javascript/forms/data-driven-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ Validators.messages = {
required: __('Required'),
};

const buttonLabels = {
submitLabel: __('Save'),
resetLabel: __('Reset'),
cancelLabel: __('Cancel'),
};

const MiqFormRenderer = ({
className, setPristine, onStateUpdate, formFieldsMapper, ...props
className, setPristine, onStateUpdate, formFieldsMapper, buttonsLabels, ...props
}) => (
<FormRender
formFieldsMapper={formFieldsMapper}
Expand All @@ -39,7 +33,12 @@ const MiqFormRenderer = ({
onStateUpdate(formOptions);
}
}}
{...buttonLabels}
buttonsLabels={{
submitLabel: __('Save'),
resetLabel: __('Reset'),
cancelLabel: __('Cancel'),
...buttonsLabels,
}}
{...props}
/>
);
Expand All @@ -49,12 +48,14 @@ MiqFormRenderer.propTypes = {
onStateUpdate: PropTypes.func,
setPristine: PropTypes.func.isRequired,
formFieldsMapper: PropTypes.any,
buttonsLabels: PropTypes.any,
};

MiqFormRenderer.defaultProps = {
className: 'form-react',
onStateUpdate: undefined,
formFieldsMapper: defaultFormFieldsMapper,
buttonsLabels: {},
};

const mapDispatchToProps = dispatch => bindActionCreators({ setPristine }, dispatch);
Expand Down

0 comments on commit b063402

Please sign in to comment.