Skip to content

Commit d193e4d

Browse files
authored
Merge pull request #269 from rvsia/allowDisableSubmitPf4
fix(pf4): allow to use disableSubmit
2 parents 9a61001 + e2b7bf4 commit d193e4d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

packages/pf4-component-mapper/src/form-fields/layout-components.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { layoutComponents } from '@data-driven-forms/react-form-renderer';
44
import { Form, Button, ActionGroup, TextContent, Text, TextVariants } from '@patternfly/react-core';
55
import './layout-components-styles.scss';
66

7-
const ButtonLayout = ({ label, bsStyle, children, ...props }) =>
8-
<Button variant={ bsStyle || 'secondary' } { ...props }>
7+
const ButtonLayout = ({ label, bsStyle, children, disabled, ...props }) =>
8+
<Button variant={ bsStyle || 'secondary' } isDisabled={ disabled } { ...props }>
99
{ label }{ children }
1010
</Button>;
1111

1212
ButtonLayout.propTypes = {
1313
label: PropTypes.string.isRequired,
1414
bsStyle: PropTypes.string,
15+
disabled: PropTypes.bool,
1516
children: PropTypes.oneOfType([
1617
PropTypes.arrayOf(PropTypes.node),
1718
PropTypes.node,

packages/pf4-component-mapper/src/tests/field-array/__snapshots__/field-array.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ exports[`FieldArray should render array field correctly 1`] = `
679679
"Submit",
680680
undefined,
681681
],
682-
"disabled": undefined,
682+
"isDisabled": undefined,
683683
"onClick": [Function],
684684
"type": "button",
685685
"variant": "primary",

packages/pf4-component-mapper/src/tests/layout-components.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@ describe('Layout mapper', () => {
2121
expect(mount(layoutMapper[layoutComponents.TITLE]({})).find(TextContent)).toHaveLength(1);
2222
expect(mount(layoutMapper[layoutComponents.TITLE]({})).find(Text)).toHaveLength(1);
2323
});
24+
25+
it('should return PF4 Button disabled', () => {
26+
const wrapper = mount(layoutMapper[layoutComponents.BUTTON]({ disabled: true }));
27+
28+
expect(wrapper.find(Button)).toHaveLength(1);
29+
expect(wrapper.find(Button).props().isDisabled).toEqual(true);
30+
});
2431
});

0 commit comments

Comments
 (0)