From b7f3852ef9019258a68fe73a3f89a32b3514125f Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Wed, 5 Feb 2020 10:45:32 -0800 Subject: [PATCH] move FormSubmitError to inline beside form buttons; add tests --- .../FormActionGroup/FormActionGroup.jsx | 27 ++++++--- .../components/FormField/FormSubmitError.jsx | 22 ++------ .../FormField/FormSubmitError.test.jsx | 55 +++++++++++++++++++ .../Template/shared/JobTemplateForm.jsx | 7 ++- 4 files changed, 85 insertions(+), 26 deletions(-) create mode 100644 awx/ui_next/src/components/FormField/FormSubmitError.test.jsx diff --git a/awx/ui_next/src/components/FormActionGroup/FormActionGroup.jsx b/awx/ui_next/src/components/FormActionGroup/FormActionGroup.jsx index 16c88d8341..7ad011719b 100644 --- a/awx/ui_next/src/components/FormActionGroup/FormActionGroup.jsx +++ b/awx/ui_next/src/components/FormActionGroup/FormActionGroup.jsx @@ -1,9 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; +import styled from 'styled-components'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { ActionGroup as PFActionGroup, Button } from '@patternfly/react-core'; -import styled from 'styled-components'; + +const ErrorMessage = styled('div')` + color: var(--pf-global--danger-color--200); + font-weight: var(--pf-global--FontWeight--bold); +`; const ActionGroup = styled(PFActionGroup)` display: flex; @@ -11,19 +16,25 @@ const ActionGroup = styled(PFActionGroup)` --pf-c-form__group--m-action--MarginTop: 0; .pf-c-form__actions { - display: grid; - gap: 24px; - grid-template-columns: auto auto; - margin: 0; - & > button { margin: 0; } + + & > :not(:first-child) { + margin-left: 24px; + } } `; -const FormActionGroup = ({ onSubmit, submitDisabled, onCancel, i18n }) => ( +const FormActionGroup = ({ + onSubmit, + submitDisabled, + onCancel, + errorMessage, + i18n, +}) => ( + {errorMessage ? {errorMessage} : null}