Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { Alert } from 'patternfly-react';

import { noop } from '../../../common/helpers';
import AlertBody from '../Alert/AlertBody';
import Actions from './Actions';
import { translate as __ } from '../../../../react_app/common/I18n';
import { deprecate } from '../../../common/DeprecationService';

const Form = ({
className,
Expand All @@ -17,23 +18,33 @@ const Form = ({
disabled,
submitting,
errorTitle,
}) => (
<form className={className} onSubmit={onSubmit}>
{error && (
<Alert className="base in fade" type={error.severity || 'danger'}>
<AlertBody title={errorTitle}>
{error.errorMsgs.length === 1 ? (
<span>{error.errorMsgs[0]}</span>
) : (
error.errorMsgs.map((e, idx) => <li key={idx}>{e}</li>)
)}
</AlertBody>
</Alert>
)}
{children}
<Actions onCancel={onCancel} disabled={disabled} submitting={submitting} />
</form>
);
}) => {
useEffect(() => {
deprecate('Form', 'Form from @patternfly/react-core', '3.20');
}, []);

return (
<form className={className} onSubmit={onSubmit}>
{error && (
<Alert className="base in fade" type={error.severity || 'danger'}>
<AlertBody title={errorTitle}>
{error.errorMsgs.length === 1 ? (
<span>{error.errorMsgs[0]}</span>
) : (
error.errorMsgs.map((e, idx) => <li key={idx}>{e}</li>)
)}
</AlertBody>
</Alert>
)}
{children}
<Actions
onCancel={onCancel}
disabled={disabled}
submitting={submitting}
/>
</form>
);
};

Form.propTypes = {
children: PropTypes.node,
Expand Down
Loading