From 4140d330dc060d4979072fd221019099b32b86d4 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Mon, 30 Nov 2020 15:15:35 +0100 Subject: [PATCH] F #3951: Change list layout (#502) --- .../components/Dialogs/DialogConfirmation.js | 4 +- .../client/components/Dialogs/DialogForm.js | 4 +- .../components/FormControl/SubmitButton.js | 32 +++++--- .../client/components/FormStepper/Stepper.js | 4 +- .../components/List/ListHeader/index.js | 76 +++++++++++-------- .../components/List/ListHeader/styles.js | 26 +++++-- .../src/client/containers/Login/Form.js | 4 +- .../src/client/containers/Providers/index.js | 4 +- .../src/client/containers/Provisions/index.js | 4 +- .../client/containers/TestApi/ResponseForm.js | 4 +- 10 files changed, 97 insertions(+), 65 deletions(-) diff --git a/src/fireedge/src/client/components/Dialogs/DialogConfirmation.js b/src/fireedge/src/client/components/Dialogs/DialogConfirmation.js index aadd3d06a4..da00d5397d 100644 --- a/src/fireedge/src/client/components/Dialogs/DialogConfirmation.js +++ b/src/fireedge/src/client/components/Dialogs/DialogConfirmation.js @@ -10,7 +10,7 @@ import { DialogActions } from '@material-ui/core' -import ButtonSubmit from 'client/components/FormControl/SubmitButton' +import SubmitButton from 'client/components/FormControl/SubmitButton' import { Tr } from 'client/components/HOC' import { T } from 'client/constants' @@ -60,7 +60,7 @@ const DialogConfirmation = memo( )} {handleAccept && ( - )} {onSubmit && ( - ({ } })) -const ButtonComponent = ({ fab, children, ...props }) => fab ? ( - {children} +const ButtonComponent = ({ icon, children, ...props }) => icon ? ( + + {children} + ) : ( - ) ButtonComponent.propTypes = { - fab: PropTypes.bool, + icon: PropTypes.bool, children: PropTypes.any } const SubmitButton = React.memo( - ({ isSubmitting, label, fab, ...props }) => { + ({ isSubmitting, label, ...props }) => { const classes = useStyles() return ( {isSubmitting && } @@ -46,15 +48,21 @@ const SubmitButton = React.memo( ) SubmitButton.propTypes = { - fab: PropTypes.bool, + icon: PropTypes.bool, + label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), isSubmitting: PropTypes.bool, - label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]) + className: PropTypes.string, + color: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary']), + size: PropTypes.oneOf(['large', 'medium', 'small']) } SubmitButton.defaultProps = { - fab: false, + icon: false, + label: undefined, isSubmitting: false, - label: undefined + className: undefined, + color: 'primary', + variant: 'contained' } export default SubmitButton diff --git a/src/fireedge/src/client/components/FormStepper/Stepper.js b/src/fireedge/src/client/components/FormStepper/Stepper.js index 2033dcec9f..31eada2263 100644 --- a/src/fireedge/src/client/components/FormStepper/Stepper.js +++ b/src/fireedge/src/client/components/FormStepper/Stepper.js @@ -11,7 +11,7 @@ import { } from '@material-ui/core' import { makeStyles, fade } from '@material-ui/core/styles' -import ButtonSubmit from 'client/components/FormControl/SubmitButton' +import SubmitButton from 'client/components/FormControl/SubmitButton' import { Tr } from 'client/components/HOC' import { T } from 'client/constants' @@ -57,7 +57,7 @@ const CustomStepper = ({ - { @@ -20,30 +23,40 @@ const ListHeader = memo(({ const { handleChange } = searchProps return ( - - {hasReloadButton && ( - } {...reloadButtonProps} /> - )} - {title && ( - - {Tr(title)} - - )} - {hasSearch && ( - - - + + + + {!!(hasReloadButton || reloadButtonProps) && ( + } {...reloadButtonProps} /> + )} + {!!(hasAddButton || addButtonProps) && ( + } {...addButtonProps} /> + )} + + {!!(hasSearch || searchProps) && ( + + + + + - + )} + + + {title && ( + + + {Tr(title)} + )} @@ -58,6 +71,11 @@ ListHeader.propTypes = { onClick: PropTypes.func, isSubmitting: PropTypes.bool }), + hasAddButton: PropTypes.bool, + addButtonProps: PropTypes.shape({ + onClick: PropTypes.func, + isSubmitting: PropTypes.bool + }), hasSearch: PropTypes.bool, searchProps: PropTypes.shape({ query: PropTypes.string, @@ -68,14 +86,10 @@ ListHeader.propTypes = { ListHeader.defaultProps = { title: undefined, hasReloadButton: false, - reloadButtonProps: { - onClick: undefined, - isSubmitting: false - }, - searchProps: { - query: undefined, - handleChange: undefined - } + reloadButtonProps: undefined, + hasAddButton: false, + addButtonProps: undefined, + searchProps: undefined } ListHeader.displayName = 'ListHeader' diff --git a/src/fireedge/src/client/components/List/ListHeader/styles.js b/src/fireedge/src/client/components/List/ListHeader/styles.js index f6f47c6bed..ce688b7414 100644 --- a/src/fireedge/src/client/components/List/ListHeader/styles.js +++ b/src/fireedge/src/client/components/List/ListHeader/styles.js @@ -2,13 +2,27 @@ import { makeStyles, fade } from '@material-ui/core' export default makeStyles(theme => ({ root: { - display: 'flex', - alignItems: 'center', - flexWrap: 'wrap' + padding: theme.spacing(2, 3) }, title: { - marginLeft: theme.spacing(1), - flexGrow: 1 + padding: theme.spacing(2), + borderBottom: '1px solid #e5e5e5' + }, + titleText: { + letterSpacing: 0.1, + fontWeight: 500 + }, + actions: { + display: 'flex', + alignItems: 'center', + flexWrap: 'wrap', + borderBottom: '1px solid #e5e5e5' + }, + buttons: { + flexGrow: 1, + [theme.breakpoints.only('xs')]: { + borderBottom: '1px solid #e5e5e5' + } }, search: { position: 'relative', @@ -17,7 +31,7 @@ export default makeStyles(theme => ({ '&:hover': { backgroundColor: fade(theme.palette.primary.main, 0.25) }, - margin: theme.spacing(3, 0), + margin: theme.spacing(1, 0), width: '100%', [theme.breakpoints.up('sm')]: { marginLeft: theme.spacing(1), diff --git a/src/fireedge/src/client/containers/Login/Form.js b/src/fireedge/src/client/containers/Login/Form.js index d84d705803..8c46be9017 100644 --- a/src/fireedge/src/client/containers/Login/Form.js +++ b/src/fireedge/src/client/containers/Login/Form.js @@ -8,7 +8,7 @@ import { yupResolver } from '@hookform/resolvers' import loginStyles from 'client/containers/Login/styles' -import ButtonSubmit from 'client/components/FormControl/SubmitButton' +import SubmitButton from 'client/components/FormControl/SubmitButton' import FormWithSchema from 'client/components/Forms/FormWithSchema' import { Tr } from 'client/components/HOC' import { T } from 'client/constants' @@ -48,7 +48,7 @@ const Form = ({ onBack, onSubmit, resolver, fields, error, isLoading, transition {Tr(T.Back)} )} - fetchRequest(undefined, { reload: true }), isSubmitting: Boolean(loading || reloading) }} - hasSearch + addButtonProps={{ onClick: () => history.push(PATH.PROVIDERS.CREATE) }} searchProps={{ handleChange }} /> @@ -51,7 +50,6 @@ function Providers () { history.push(PATH.PROVIDERS.CREATE)} CardComponent={ProvisionCard} cardsProps={({ value: { ID, NAME } }) => ({ isProvider: true, diff --git a/src/fireedge/src/client/containers/Provisions/index.js b/src/fireedge/src/client/containers/Provisions/index.js index 916dff7d5c..9b5b276a71 100644 --- a/src/fireedge/src/client/containers/Provisions/index.js +++ b/src/fireedge/src/client/containers/Provisions/index.js @@ -35,12 +35,11 @@ function Provisions () { fetchRequest(undefined, { reload: true }), isSubmitting: Boolean(loading || reloading) }} - hasSearch + addButtonProps={{ onClick: () => history.push(PATH.PROVISIONS.CREATE) }} searchProps={{ handleChange }} /> @@ -50,7 +49,6 @@ function Provisions () { 0 && loading} - handleCreate={() => history.push(PATH.PROVISIONS.CREATE)} CardComponent={ProvisionCard} cardsProps={({ value: { ID, NAME } }) => ({ handleClick: () => setShowDialog({ diff --git a/src/fireedge/src/client/containers/TestApi/ResponseForm.js b/src/fireedge/src/client/containers/TestApi/ResponseForm.js index 0c52d63205..afe6dfc2b8 100644 --- a/src/fireedge/src/client/containers/TestApi/ResponseForm.js +++ b/src/fireedge/src/client/containers/TestApi/ResponseForm.js @@ -10,7 +10,7 @@ import { Checkbox } from '@material-ui/core' -import ButtonSubmit from 'client/components/FormControl/SubmitButton' +import SubmitButton from 'client/components/FormControl/SubmitButton' import { requestData, requestParams } from 'client/utils' const ResponseForm = ({ @@ -77,7 +77,7 @@ const ResponseForm = ({ ))} - +