Skip to content

Commit a65d183

Browse files
committed
Fixes #38470 - deprecate forms/Form.js
1 parent c9d6db8 commit a65d183

File tree

1 file changed

+29
-18
lines changed
  • webpack/assets/javascripts/react_app/components/common/forms

1 file changed

+29
-18
lines changed

webpack/assets/javascripts/react_app/components/common/forms/Form.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { Alert } from 'patternfly-react';
44

55
import { noop } from '../../../common/helpers';
66
import AlertBody from '../Alert/AlertBody';
77
import Actions from './Actions';
88
import { translate as __ } from '../../../../react_app/common/I18n';
9+
import { deprecate } from '../../../common/DeprecationService';
910

1011
const Form = ({
1112
className,
@@ -17,23 +18,33 @@ const Form = ({
1718
disabled,
1819
submitting,
1920
errorTitle,
20-
}) => (
21-
<form className={className} onSubmit={onSubmit}>
22-
{error && (
23-
<Alert className="base in fade" type={error.severity || 'danger'}>
24-
<AlertBody title={errorTitle}>
25-
{error.errorMsgs.length === 1 ? (
26-
<span>{error.errorMsgs[0]}</span>
27-
) : (
28-
error.errorMsgs.map((e, idx) => <li key={idx}>{e}</li>)
29-
)}
30-
</AlertBody>
31-
</Alert>
32-
)}
33-
{children}
34-
<Actions onCancel={onCancel} disabled={disabled} submitting={submitting} />
35-
</form>
36-
);
21+
}) => {
22+
useEffect(() => {
23+
deprecate('Form', 'Form from @patternfly/react-core', '3.20');
24+
}, []);
25+
26+
return (
27+
<form className={className} onSubmit={onSubmit}>
28+
{error && (
29+
<Alert className="base in fade" type={error.severity || 'danger'}>
30+
<AlertBody title={errorTitle}>
31+
{error.errorMsgs.length === 1 ? (
32+
<span>{error.errorMsgs[0]}</span>
33+
) : (
34+
error.errorMsgs.map((e, idx) => <li key={idx}>{e}</li>)
35+
)}
36+
</AlertBody>
37+
</Alert>
38+
)}
39+
{children}
40+
<Actions
41+
onCancel={onCancel}
42+
disabled={disabled}
43+
submitting={submitting}
44+
/>
45+
</form>
46+
);
47+
};
3748

3849
Form.propTypes = {
3950
children: PropTypes.node,

0 commit comments

Comments
 (0)