diff --git a/src/fireedge/src/client/components/Cards/ApplicationCard.js b/src/fireedge/src/client/components/Cards/ApplicationCard.js index a94bd35577..c41b1e38c3 100644 --- a/src/fireedge/src/client/components/Cards/ApplicationCard.js +++ b/src/fireedge/src/client/components/Cards/ApplicationCard.js @@ -4,10 +4,7 @@ import PropTypes from 'prop-types' import { makeStyles, Box, - Fade, Button, - Card, - CardHeader, CardContent, CardActions, Chip @@ -16,29 +13,12 @@ import FileIcon from '@material-ui/icons/Description' import { Tr } from 'client/components/HOC' import { APPLICATION_STATES } from 'client/constants/states' +import SelectCard from './SelectCard' const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - flexGrow: 1 - }, - subheader: { - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'initial', - display: '-webkit-box', - lineClamp: 2, - boxOrient: 'vertical' - }, content: { display: 'flex', - gap: theme.typography.pxToRem(12) + gap: theme.spacing(1) } })) @@ -51,49 +31,33 @@ const ApplicationCard = memo( const stateInfo = APPLICATION_STATES[state] return ( - - - } - className={classes.header} - classes={{ content: classes.headerContent }} - title={`${ID} - ${NAME}`} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - title: NAME - }} - subheader={description} - subheaderTypographyProps={{ - variant: 'body2', - noWrap: true, - className: classes.subheader, - title: description - }} - /> - - - - - - - {handleShow && ( - - )} - {handleRemove && ( - - )} - - - + } + title={`${ID} - ${NAME}`} + subheader={description} + > + + + + + + + {handleShow && ( + + )} + {handleRemove && ( + + )} + + ) } ) diff --git a/src/fireedge/src/client/components/Cards/ApplicationTemplateCard.js b/src/fireedge/src/client/components/Cards/ApplicationTemplateCard.js index cbfccfc2a4..95041d1070 100644 --- a/src/fireedge/src/client/components/Cards/ApplicationTemplateCard.js +++ b/src/fireedge/src/client/components/Cards/ApplicationTemplateCard.js @@ -4,11 +4,8 @@ import PropTypes from 'prop-types' import { makeStyles, Box, - Fade, Badge, Button, - Card, - CardHeader, CardContent, CardActions } from '@material-ui/core' @@ -17,32 +14,13 @@ import VideogameAssetIcon from '@material-ui/icons/VideogameAsset' import AccountTreeIcon from '@material-ui/icons/AccountTree' import { Tr } from 'client/components/HOC' +import SelectCard from './SelectCard' const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - flexGrow: 1 - }, - subheader: { - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'initial', - display: '-webkit-box', - lineClamp: 2, - boxOrient: 'vertical' - }, badgesWrapper: { display: 'flex', gap: theme.typography.pxToRem(12) - }, - badge: {}, - icon: {} + } })) const ApplicationTemplateCard = memo( @@ -57,74 +35,73 @@ const ApplicationTemplateCard = memo( const badgePosition = { vertical: 'top', horizontal: 'right' } return ( - - - } - className={classes.header} - classes={{ content: classes.headerContent }} - title={NAME} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - title: NAME - }} - subheader={description} - subheaderTypographyProps={{ - variant: 'body2', - noWrap: true, - className: classes.subheader, - title: description - }} - /> - - - - - - - - - - - - {handleEdit && ( - - )} - {handleDeploy && ( - - )} - {handleShow && ( - - )} - {handleRemove && ( - - )} - - - + } + title={NAME} + subheader={description} + > + + + + + + + + + + + + {handleEdit && ( + + )} + {handleDeploy && ( + + )} + {handleShow && ( + + )} + {handleRemove && ( + + )} + + ) } ) diff --git a/src/fireedge/src/client/components/Cards/ClusterCard.js b/src/fireedge/src/client/components/Cards/ClusterCard.js index 7e228ab8d0..c944dd971b 100644 --- a/src/fireedge/src/client/components/Cards/ClusterCard.js +++ b/src/fireedge/src/client/components/Cards/ClusterCard.js @@ -1,7 +1,7 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { makeStyles, Badge, Box } from '@material-ui/core' +import { makeStyles, Badge, Box, CardContent } from '@material-ui/core' import StorageIcon from '@material-ui/icons/Storage' import VideogameAssetIcon from '@material-ui/icons/VideogameAsset' import AccountTreeIcon from '@material-ui/icons/AccountTree' @@ -35,38 +35,40 @@ const ClusterCard = memo( isSelected={isSelected} handleClick={handleClick} > - - - - - - - - - - - + + + + + + + + + + + + + ) }, diff --git a/src/fireedge/src/client/components/Cards/LocationCard.js b/src/fireedge/src/client/components/Cards/LocationCard.js index 70a9e3eebb..2c6c119e16 100644 --- a/src/fireedge/src/client/components/Cards/LocationCard.js +++ b/src/fireedge/src/client/components/Cards/LocationCard.js @@ -1,80 +1,31 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import clsx from 'clsx' -import { - makeStyles, - Fade, - Card, - CardHeader, - CardActionArea, - CardContent, - Typography -} from '@material-ui/core' +import { CardContent, Typography } from '@material-ui/core' import ProvidersIcon from '@material-ui/icons/Public' -const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - minHeight: 140 - }, - selected: { - color: theme.palette.primary.contrastText, - backgroundColor: theme.palette.primary.main, - '& $badge': { - color: theme.palette.primary.main, - backgroundColor: theme.palette.common.white - } - }, - actionArea: { - height: '100%', - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - width: '100%' - }, - content: { - width: '100%', - flexGrow: 1 - } -})) +import SelectCard from './SelectCard' const LocationCard = memo( ({ value, isSelected, handleClick }) => { - const classes = useStyles() const { key, properties } = value return ( - - - - } - className={classes.header} - title={key} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - title: key - }} - /> - {properties && - {Object.entries(properties)?.map(([pKey, pVal]) => ( - - {pKey}{` - ${pVal}`} - - ))} - } - - - + } + isSelected={isSelected} + handleClick={handleClick} + > + + {properties && Object.entries(properties) + ?.map(([pKey, pVal]) => ( + + {pKey}{` - ${pVal}`} + + ))} + + ) }, (prev, next) => prev.isSelected === next.isSelected diff --git a/src/fireedge/src/client/components/Cards/NetworkCard.js b/src/fireedge/src/client/components/Cards/NetworkCard.js index 213b2c90d2..3c91f73733 100644 --- a/src/fireedge/src/client/components/Cards/NetworkCard.js +++ b/src/fireedge/src/client/components/Cards/NetworkCard.js @@ -1,88 +1,59 @@ -import React from 'react' +import React, { memo } from 'react' import PropTypes from 'prop-types' -import { - makeStyles, - Card, - Button, - CardHeader, - CardActions, - Fade -} from '@material-ui/core' +import { Button, CardActions } from '@material-ui/core' import { Tr } from 'client/components/HOC' +import SelectCard from './SelectCard' -const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - flexGrow: 1 - }, - subheader: { - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'initial', - display: '-webkit-box', - lineClamp: 2, - boxOrient: 'vertical' - }, - remove: { - backgroundColor: theme.palette.error.dark - } -})) +const NetworkCard = memo(({ + value, + isSelected, + handleClick, + handleEdit, + handleClone, + handleRemove +}) => { + const { mandatory, name, description } = value -const NetworkCard = React.memo( - ({ value, handleEdit, handleClone, handleRemove }) => { - const classes = useStyles() - const { mandatory, name, description } = value - - return ( - - - - - {handleEdit && ( - - )} - {handleClone && ( - - )} - {handleRemove && ( - - )} - - - - ) - } + return ( + + + {handleEdit && ( + + )} + {handleClone && ( + + )} + {handleRemove && ( + + )} + + + ) +} ) NetworkCard.propTypes = { @@ -94,6 +65,8 @@ NetworkCard.propTypes = { id: PropTypes.string, extra: PropTypes.string }), + isSelected: PropTypes.bool, + handleClick: PropTypes.func, handleEdit: PropTypes.func, handleClone: PropTypes.func, handleRemove: PropTypes.func @@ -101,6 +74,8 @@ NetworkCard.propTypes = { NetworkCard.defaultProps = { value: {}, + isSelected: false, + handleClick: undefined, handleEdit: undefined, handleClone: undefined, handleRemove: undefined diff --git a/src/fireedge/src/client/components/Cards/ProviderCard.js b/src/fireedge/src/client/components/Cards/ProviderCard.js index c6b82e47f1..2139c09e9b 100644 --- a/src/fireedge/src/client/components/Cards/ProviderCard.js +++ b/src/fireedge/src/client/components/Cards/ProviderCard.js @@ -1,68 +1,36 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { - makeStyles, - Fade, - Button, - Card, - CardHeader, - CardActions -} from '@material-ui/core' +import { Button, CardActions } from '@material-ui/core' import FileIcon from '@material-ui/icons/Description' import { Tr } from 'client/components/HOC' - -const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - flexGrow: 1 - }, - content: { - display: 'flex', - gap: theme.typography.pxToRem(12) - } -})) +import SelectCard from './SelectCard' const ProviderCard = memo( ({ value, handleShow, handleRemove }) => { - const classes = useStyles() const { ID, NAME } = value return ( - - - } - className={classes.header} - classes={{ content: classes.headerContent }} - title={`${ID} - ${NAME}`} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - title: NAME - }} - /> - - {handleShow && ( - - )} - {handleRemove && ( - - )} - - - + }> + + {handleShow && ( + + )} + {handleRemove && ( + + )} + + ) } ) diff --git a/src/fireedge/src/client/components/Cards/ProviderTemplateCard.js b/src/fireedge/src/client/components/Cards/ProviderTemplateCard.js index e14447b758..a91fc91809 100644 --- a/src/fireedge/src/client/components/Cards/ProviderTemplateCard.js +++ b/src/fireedge/src/client/components/Cards/ProviderTemplateCard.js @@ -1,51 +1,19 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { - makeStyles, Fade, Card, CardHeader, CardActionArea -} from '@material-ui/core' import FileIcon from '@material-ui/icons/Description' - -const useStyles = makeStyles(() => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - actionArea: { - height: '100%' - }, - headerContent: { - overflowX: 'hidden' - } -})) +import SelectCard from './SelectCard' const ProviderTemplateCard = memo( ({ value, handleClick }) => { - const classes = useStyles() const { name } = value return ( - - - - } - classes={{ content: classes.headerContent }} - title={name} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - title: name - }} - /> - - - + } + /> ) } ) diff --git a/src/fireedge/src/client/components/Cards/SelectCard.js b/src/fireedge/src/client/components/Cards/SelectCard.js index 6cf30a0a24..a5c6c7526f 100644 --- a/src/fireedge/src/client/components/Cards/SelectCard.js +++ b/src/fireedge/src/client/components/Cards/SelectCard.js @@ -2,10 +2,11 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' import clsx from 'clsx' -import { Card, CardActionArea, CardContent, CardHeader, Fade, makeStyles } from '@material-ui/core' +import { Card, CardActionArea, CardHeader, Fade, makeStyles } from '@material-ui/core' import { Skeleton } from '@material-ui/lab' import useNearScreen from 'client/hooks/useNearScreen' +import ConditionalWrap from 'client/components/HOC/ConditionalWrap' const useStyles = makeStyles(theme => ({ root: { @@ -17,6 +18,9 @@ const useStyles = makeStyles(theme => ({ '& .badge': { color: theme.palette.primary.main, backgroundColor: theme.palette.common.white + }, + '& $subheader': { + color: 'inherit' } }, actionArea: { @@ -26,53 +30,100 @@ const useStyles = makeStyles(theme => ({ }, headerContent: { overflowX: 'hidden' + }, + subheader: { + overflow: 'hidden', + textOverflow: 'ellipsis', + whiteSpace: 'initial', + display: '-webkit-box', + lineClamp: 2, + boxOrient: 'vertical' } })) -const SelectCard = memo( - ({ title, icon, isSelected, handleClick, children }) => { - const classes = useStyles() - const { isNearScreen, fromRef } = useNearScreen({ - distance: '100px' - }) +const SelectCard = memo(({ + title, + subheader, + icon, + isSelected, + handleClick, + cardProps, + observerOff, + children +}) => { + const classes = useStyles() + const { isNearScreen, fromRef } = useNearScreen({ + distance: '100px' + }) - return ( -
- {isNearScreen ? ( - - - - - {children && {children}} - - - - ) : ( - - )} -
- ) - }, - (prev, next) => prev.isSelected === next.isSelected -) + return ( +
{children}
}> + {observerOff || isNearScreen ? ( + + + + + {children} + + } + > + + {children} + + + + ) : ( + + )} +
+ ) +}) SelectCard.propTypes = { title: PropTypes.oneOfType([ PropTypes.string, PropTypes.object ]), - icon: PropTypes.object, + subheader: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.object + ]), + icon: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.object + ]), isSelected: PropTypes.bool, handleClick: PropTypes.func, + cardProps: PropTypes.object, + observerOff: PropTypes.bool, children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node, @@ -82,9 +133,12 @@ SelectCard.propTypes = { SelectCard.defaultProps = { title: undefined, + subheader: undefined, icon: undefined, isSelected: false, - handleClick: () => undefined, + handleClick: undefined, + cardProps: undefined, + observerOff: false, children: undefined } diff --git a/src/fireedge/src/client/components/Cards/TierCard.js b/src/fireedge/src/client/components/Cards/TierCard.js index bb7372776f..d640efb4eb 100644 --- a/src/fireedge/src/client/components/Cards/TierCard.js +++ b/src/fireedge/src/client/components/Cards/TierCard.js @@ -1,88 +1,47 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { - makeStyles, - Card, - Button, - CardHeader, - CardActions, - Badge -} from '@material-ui/core' +import { Button, CardActions, Badge } from '@material-ui/core' import DesktopWindowsIcon from '@material-ui/icons/DesktopWindows' import { Tr } from 'client/components/HOC' - -const useStyles = makeStyles(() => ({ - root: { - height: '100%', - minHeight: 140, - display: 'flex', - flexDirection: 'column' - }, - header: { - overflowX: 'hidden', - flexGrow: 1 - }, - headerContent: {}, - title: { - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'initial', - display: '-webkit-box', - lineClamp: 2, - boxOrient: 'vertical' - } -})) +import SelectCard from './SelectCard' const TierCard = memo( - ({ value, handleEdit, handleClone, handleRemove, cardProps }) => { - const classes = useStyles() + ({ value, handleEdit, handleRemove, cardProps }) => { const { name, cardinality } = value return ( - - - - - } - className={classes.header} - classes={{ content: classes.headerContent }} - title={name} - titleTypographyProps={{ - variant: 'body2', - noWrap: true, - className: classes.title, - title: name - }} - /> + + + + } + title={name} + cardProps={cardProps} + > {handleEdit && ( )} - {handleClone && ( - - )} {handleRemove && ( )} - +
) } ) @@ -96,7 +55,6 @@ TierCard.propTypes = { ]) }), handleEdit: PropTypes.func, - handleClone: PropTypes.func, handleRemove: PropTypes.func, cardProps: PropTypes.object } @@ -104,7 +62,6 @@ TierCard.propTypes = { TierCard.defaultProps = { value: {}, handleEdit: undefined, - handleClone: undefined, handleRemove: undefined, cardProps: undefined } diff --git a/src/fireedge/src/client/components/FormStepper/MobileStepper.js b/src/fireedge/src/client/components/FormStepper/MobileStepper.js index 014413bf0e..1708b34173 100644 --- a/src/fireedge/src/client/components/FormStepper/MobileStepper.js +++ b/src/fireedge/src/client/components/FormStepper/MobileStepper.js @@ -11,7 +11,6 @@ const useStyles = makeStyles(theme => ({ root: { position: 'sticky', top: -15, - backdropFilter: 'blur(5px)', background: fade(theme.palette.primary.main, 0.65), zIndex: theme.zIndex.mobileStepper, margin: theme.spacing(2, 0) diff --git a/src/fireedge/src/client/components/FormStepper/Stepper.js b/src/fireedge/src/client/components/FormStepper/Stepper.js index c65cbc2182..1d77bd15cf 100644 --- a/src/fireedge/src/client/components/FormStepper/Stepper.js +++ b/src/fireedge/src/client/components/FormStepper/Stepper.js @@ -2,7 +2,6 @@ import React from 'react' import PropTypes from 'prop-types' import { - styled, Button, Stepper, Step, @@ -10,19 +9,21 @@ import { Box, Typography } from '@material-ui/core' +import { makeStyles, fade } from '@material-ui/core/styles' import ButtonSubmit from 'client/components/FormControl/SubmitButton' import { Finish, Back, Next } from 'client/constants/translates' import { Tr } from 'client/components/HOC' -const StickyStepper = styled(Stepper)({ - position: 'sticky', - top: -15, - minHeight: 100, - backdropFilter: 'blur(5px)', - background: '#fafafa9c', - zIndex: 1 -}) +const useStyles = makeStyles(theme => ({ + root: { + position: 'sticky', + top: -15, + minHeight: 100, + background: fade(theme.palette.background.default, 0.65), + zIndex: theme.zIndex.mobileStepper + } +})) const CustomStepper = ({ steps, @@ -33,35 +34,39 @@ const CustomStepper = ({ handleBack, errors, isSubmitting -}) => ( - <> - - {steps?.map(({ id, label }) => ( - - - {errors[id]?.message} - - } - >{label} - - ))} - - - - - - -) +}) => { + const classes = useStyles() + + return ( + <> + + {steps?.map(({ id, label }) => ( + + + {errors[id]?.message} + + } + >{label} + + ))} + + + + + + + ) +} CustomStepper.propTypes = { steps: PropTypes.arrayOf( diff --git a/src/fireedge/src/client/components/HOC/ConditionalWrap.js b/src/fireedge/src/client/components/HOC/ConditionalWrap.js new file mode 100644 index 0000000000..122646c547 --- /dev/null +++ b/src/fireedge/src/client/components/HOC/ConditionalWrap.js @@ -0,0 +1,4 @@ +import React from 'react' + +export default ({ condition, children, wrap }) => + condition ? React.cloneElement(wrap(children)) : children diff --git a/src/fireedge/src/client/components/HOC/Translate.js b/src/fireedge/src/client/components/HOC/Translate.js index 5abdfb67f6..ef40faf404 100644 --- a/src/fireedge/src/client/components/HOC/Translate.js +++ b/src/fireedge/src/client/components/HOC/Translate.js @@ -126,6 +126,7 @@ const SelectTranslate = () => {