Adding showButtons prop to InfoPanel

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2020-10-07 13:20:09 +03:00
1 parent 9f3056d706
commit c8a83ce1fa
1 file changed
+7 -5
+7 -5
View File
@@ -23,7 +23,7 @@ interface OptionalProps {
submitLabel?: ReactNode;
submittingMessage?: ReactNode;
disableSubmit?: boolean;
showSubmit?: boolean;
showButtons?: boolean
showSubmitClose?: boolean;
showInlineInfo?: boolean;
showNotifications?: boolean;
@@ -34,7 +34,7 @@ export class InfoPanel extends Component<Props> {
static defaultProps: OptionalProps = {
submitLabel: <Trans>Submit</Trans>,
submittingMessage: <Trans>Submitting..</Trans>,
showSubmit: true,
showButtons: true,
showSubmitClose: true,
showInlineInfo: true,
showNotifications: true,
@@ -89,7 +89,7 @@ export class InfoPanel extends Component<Props> {
}
render() {
const { className, controls, submitLabel, disableSubmit, error, submittingMessage, showSubmit, showSubmitClose } = this.props;
const { className, controls, submitLabel, disableSubmit, error, submittingMessage, showButtons, showSubmitClose } = this.props;
const { submit, close, submitAndClose, waiting } = this;
const isDisabled = !!(disableSubmit || waiting || error);
return (
@@ -100,8 +100,9 @@ export class InfoPanel extends Component<Props> {
<div className="info flex gaps align-center">
{waiting ? <><Spinner /> {submittingMessage}</> : this.renderErrorIcon()}
</div>
{showButtons && (
<>
<Button plain label={<Trans>Cancel</Trans>} onClick={close} />
{showSubmit && (
<Button
active
outlined={showSubmitClose}
@@ -110,7 +111,6 @@ export class InfoPanel extends Component<Props> {
onClick={submit}
disabled={isDisabled}
/>
)}
{showSubmitClose && (
<Button
primary active
@@ -119,6 +119,8 @@ export class InfoPanel extends Component<Props> {
disabled={isDisabled}
/>
)}
</>
)}
</div>
);
}