diff --git a/src/fireedge/src/client/components/Cards/ApplicationNetworkCard.js b/src/fireedge/src/client/components/Cards/ApplicationNetworkCard.js new file mode 100644 index 0000000000..9c521532b0 --- /dev/null +++ b/src/fireedge/src/client/components/Cards/ApplicationNetworkCard.js @@ -0,0 +1,86 @@ +import React, { memo } from 'react' +import PropTypes from 'prop-types' + +import { Button, CardActions } from '@material-ui/core' + +import { Tr } from 'client/components/HOC' +import SelectCard from 'client/components/Cards/SelectCard' + +const ApplicationNetworkCard = memo(({ + value, + isSelected, + handleClick, + handleEdit, + handleClone, + handleRemove +}) => { + const { mandatory, name, description } = value + + return ( + + + {handleEdit && ( + + )} + {handleClone && ( + + )} + {handleRemove && ( + + )} + + + ) +} +) + +ApplicationNetworkCard.propTypes = { + value: PropTypes.shape({ + mandatory: PropTypes.bool, + name: PropTypes.string.isRequired, + description: PropTypes.string, + type: PropTypes.string, + id: PropTypes.string, + extra: PropTypes.string + }), + isSelected: PropTypes.bool, + handleClick: PropTypes.func, + handleEdit: PropTypes.func, + handleClone: PropTypes.func, + handleRemove: PropTypes.func +} + +ApplicationNetworkCard.defaultProps = { + value: {}, + isSelected: false, + handleClick: undefined, + handleEdit: undefined, + handleClone: undefined, + handleRemove: undefined +} + +ApplicationNetworkCard.displayName = 'ApplicationNetworkCard' + +export default ApplicationNetworkCard diff --git a/src/fireedge/src/client/components/Cards/DatastoreCard.js b/src/fireedge/src/client/components/Cards/DatastoreCard.js index 002949d44d..fcba5e1d16 100644 --- a/src/fireedge/src/client/components/Cards/DatastoreCard.js +++ b/src/fireedge/src/client/components/Cards/DatastoreCard.js @@ -13,7 +13,7 @@ const useStyles = makeStyles(() => ({ })) const DatastoreCard = memo( - ({ value, isSelected, handleClick }) => { + ({ value, isSelected, handleClick, actions }) => { const { ID, NAME, TYPE, STATE } = value const type = Datastore.TYPES[TYPE] const state = Datastore.STATES[STATE] @@ -25,7 +25,7 @@ const DatastoreCard = memo( return ( } title={( @@ -37,6 +37,7 @@ const DatastoreCard = memo( cardHeaderProps={{ disableTypography: true }} isSelected={isSelected} handleClick={handleClick} + actions={actions} /> ) }, @@ -51,13 +52,24 @@ DatastoreCard.propTypes = { STATE: PropTypes.string }), isSelected: PropTypes.bool, - handleClick: PropTypes.func + handleClick: PropTypes.func, + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ) } DatastoreCard.defaultProps = { value: {}, isSelected: false, - handleClick: undefined + handleClick: undefined, + actions: undefined } DatastoreCard.displayName = 'DatastoreCard' diff --git a/src/fireedge/src/client/components/Cards/HostCard.js b/src/fireedge/src/client/components/Cards/HostCard.js index 196be53073..a60f8807c3 100644 --- a/src/fireedge/src/client/components/Cards/HostCard.js +++ b/src/fireedge/src/client/components/Cards/HostCard.js @@ -1,7 +1,7 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { makeStyles, Chip } from '@material-ui/core' +import { makeStyles, Chip, Box, Typography } from '@material-ui/core' import { VideogameAsset as HostIcon } from '@material-ui/icons' import SelectCard from 'client/components/Cards/SelectCard' @@ -13,9 +13,10 @@ const useStyles = makeStyles(() => ({ })) const HostCard = memo( - ({ value, isSelected, handleClick }) => { - const { ID, NAME, STATE } = value + ({ value, isSelected, handleClick, actions }) => { + const { ID, NAME, STATE, IM_MAD: imMad, VM_MAD: vmMad } = value const state = Host.STATES[STATE] + const mad = imMad === vmMad ? imMad : `${imMad}/${vmMad}` const classes = useStyles({ stateColor: state.color }) @@ -24,12 +25,20 @@ const HostCard = memo( return ( } - title={`${ID} - ${NAME}`} - subheader={renderChip({ label: state.name, className: classes.state })} + title={( + + {`${ID} - ${NAME}`} + {renderChip({ label: mad })} + + )} + subheader={ + renderChip({ label: state.name, className: classes.state }) + } isSelected={isSelected} handleClick={handleClick} + actions={actions} /> ) }, @@ -41,16 +50,29 @@ HostCard.propTypes = { ID: PropTypes.string.isRequired, NAME: PropTypes.string.isRequired, TYPE: PropTypes.string, - STATE: PropTypes.string + STATE: PropTypes.string, + IM_MAD: PropTypes.string, + VM_MAD: PropTypes.string }), isSelected: PropTypes.bool, - handleClick: PropTypes.func + handleClick: PropTypes.func, + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ) } HostCard.defaultProps = { value: {}, isSelected: false, - handleClick: undefined + handleClick: undefined, + actions: undefined } HostCard.displayName = 'HostCard' diff --git a/src/fireedge/src/client/components/Cards/NetworkCard.js b/src/fireedge/src/client/components/Cards/NetworkCard.js index baa2743cff..6806e5e690 100644 --- a/src/fireedge/src/client/components/Cards/NetworkCard.js +++ b/src/fireedge/src/client/components/Cards/NetworkCard.js @@ -1,84 +1,53 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { Button, CardActions } from '@material-ui/core' - -import { Tr } from 'client/components/HOC' +import { AccountTree as NetworkIcon } from '@material-ui/icons' import SelectCard from 'client/components/Cards/SelectCard' -const NetworkCard = memo(({ - value, - isSelected, - handleClick, - handleEdit, - handleClone, - handleRemove -}) => { - const { mandatory, name, description } = value +const NetworkCard = memo( + ({ value, isSelected, handleClick, actions }) => { + const { ID, NAME } = value - return ( - - - {handleEdit && ( - - )} - {handleClone && ( - - )} - {handleRemove && ( - - )} - - - ) -} + return ( + } + title={`${ID} - ${NAME}`} + isSelected={isSelected} + handleClick={handleClick} + actions={actions} + /> + ) + }, + (prev, next) => prev.isSelected === next.isSelected ) NetworkCard.propTypes = { value: PropTypes.shape({ - mandatory: PropTypes.bool, - name: PropTypes.string.isRequired, - description: PropTypes.string, - type: PropTypes.string, - id: PropTypes.string, - extra: PropTypes.string + ID: PropTypes.string.isRequired, + NAME: PropTypes.string.isRequired, + TYPE: PropTypes.string, + STATE: PropTypes.string }), isSelected: PropTypes.bool, handleClick: PropTypes.func, - handleEdit: PropTypes.func, - handleClone: PropTypes.func, - handleRemove: PropTypes.func + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ) } NetworkCard.defaultProps = { value: {}, isSelected: false, handleClick: undefined, - handleEdit: undefined, - handleClone: undefined, - handleRemove: undefined + actions: undefined } NetworkCard.displayName = 'NetworkCard' diff --git a/src/fireedge/src/client/components/Cards/ProviderCard.js b/src/fireedge/src/client/components/Cards/ProviderCard.js index 02f6015085..9ef8db161a 100644 --- a/src/fireedge/src/client/components/Cards/ProviderCard.js +++ b/src/fireedge/src/client/components/Cards/ProviderCard.js @@ -1,56 +1,41 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { CardActions, IconButton } from '@material-ui/core' import TemplateIcon from '@material-ui/icons/Description' -import InfoIcon from '@material-ui/icons/Info' -import EditIcon from '@material-ui/icons/Build' -import DeleteIcon from '@material-ui/icons/Delete' - import SelectCard from 'client/components/Cards/SelectCard' -const ProviderCard = memo( - ({ value, handleShow, handleEdit, handleDelete }) => { - const { ID, NAME } = value +const ProviderCard = memo(({ value, actions }) => { + const { ID, NAME } = value - const renderAction = ({ handleClick, icon: Icon, iconColor }) => - handleClick && ( - - - - ) - - return ( - }> - - {renderAction({ - handleClick: handleShow, - icon: InfoIcon, - iconColor: 'primary' - })} - {renderAction({ handleClick: handleEdit, icon: EditIcon })} - {renderAction({ handleClick: handleDelete, icon: DeleteIcon })} - - - ) - } -) + return ( + } + actions={actions} + /> + ) +}) ProviderCard.propTypes = { value: PropTypes.shape({ ID: PropTypes.string.isRequired, NAME: PropTypes.string.isRequired }), - handleShow: PropTypes.func, - handleEdit: PropTypes.func, - handleDelete: PropTypes.func + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ) } ProviderCard.defaultProps = { value: {}, - handleShow: undefined, - handleEdit: undefined, - handleDelete: undefined + actions: undefined } ProviderCard.displayName = 'ProviderCard' diff --git a/src/fireedge/src/client/components/Cards/ProvisionCard.js b/src/fireedge/src/client/components/Cards/ProvisionCard.js index b95c414e13..97c53c0fdf 100644 --- a/src/fireedge/src/client/components/Cards/ProvisionCard.js +++ b/src/fireedge/src/client/components/Cards/ProvisionCard.js @@ -1,56 +1,41 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { CardActions, IconButton } from '@material-ui/core' import ProvisionIcon from '@material-ui/icons/Cloud' -import InfoIcon from '@material-ui/icons/Info' -import EditIcon from '@material-ui/icons/Build' -import DeleteIcon from '@material-ui/icons/Delete' - import SelectCard from 'client/components/Cards/SelectCard' -const ProvisionCard = memo( - ({ value, handleShow, handleEdit, handleDelete }) => { - const { ID, NAME } = value +const ProvisionCard = memo(({ value, actions }) => { + const { ID, NAME } = value - const renderAction = ({ handleClick, icon: Icon, iconColor }) => - handleClick && ( - - - - ) - - return ( - }> - - {renderAction({ - handleClick: handleShow, - icon: InfoIcon, - iconColor: 'primary' - })} - {renderAction({ handleClick: handleEdit, icon: EditIcon })} - {renderAction({ handleClick: handleDelete, icon: DeleteIcon })} - - - ) - } -) + return ( + } + actions={actions} + /> + ) +}) ProvisionCard.propTypes = { value: PropTypes.shape({ ID: PropTypes.string.isRequired, NAME: PropTypes.string.isRequired }), - handleShow: PropTypes.func, - handleEdit: PropTypes.func, - handleDelete: PropTypes.func + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ) } ProvisionCard.defaultProps = { value: {}, - handleShow: undefined, - handleEdit: undefined, - handleDelete: undefined + actions: undefined } ProvisionCard.displayName = 'ProvisionCard' diff --git a/src/fireedge/src/client/components/Cards/SelectCard.js b/src/fireedge/src/client/components/Cards/SelectCard.js index 7231bb1e41..33311f9f41 100644 --- a/src/fireedge/src/client/components/Cards/SelectCard.js +++ b/src/fireedge/src/client/components/Cards/SelectCard.js @@ -1,17 +1,17 @@ import React, { memo } from 'react' import PropTypes from 'prop-types' - import clsx from 'clsx' -import { Card, CardActionArea, CardHeader, Fade, makeStyles } from '@material-ui/core' + +import { + makeStyles, Card, CardActionArea, CardHeader, CardActions, IconButton +} 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: { - height: '100%' - }, + root: { height: '100%' }, selected: { color: theme.palette.primary.contrastText, backgroundColor: theme.palette.primary.main, @@ -37,11 +37,14 @@ const useStyles = makeStyles(theme => ({ display: '-webkit-box', lineClamp: 2, boxOrient: 'vertical' - } + }, + actionsIcon: { margin: theme.spacing(1) } })) const SelectCard = memo(({ stylesProps, + action, + actions, icon, title, subheader, @@ -57,6 +60,12 @@ const SelectCard = memo(({ distance: '100px' }) + const renderAction = ({ handleClick, icon: Icon, iconColor, cy }) => ( + + + + ) + return ( {children} + {actions?.length > 0 && ( + + {actions?.map(action => renderAction(action))} + + )} ) : ( @@ -113,6 +128,21 @@ const SelectCard = memo(({ SelectCard.propTypes = { stylesProps: PropTypes.object, + action: PropTypes.node, + actions: PropTypes.arrayOf( + PropTypes.shape({ + handleClick: PropTypes.func.isRequired, + icon: PropTypes.object.isRequired, + iconColor: PropTypes.oneOf([ + 'inherit', 'primary', 'secondary', 'action', 'error', 'disabled' + ]), + cy: PropTypes.string + }) + ), + icon: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.object + ]), title: PropTypes.oneOfType([ PropTypes.string, PropTypes.object @@ -121,10 +151,6 @@ SelectCard.propTypes = { PropTypes.string, PropTypes.object ]), - icon: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.object - ]), cardHeaderProps: PropTypes.shape({ titleTypographyProps: PropTypes.object, subheaderTypographyProps: PropTypes.object @@ -142,9 +168,11 @@ SelectCard.propTypes = { SelectCard.defaultProps = { stylesProps: undefined, + action: undefined, + actions: undefined, + icon: undefined, title: undefined, subheader: undefined, - icon: undefined, cardHeaderProps: undefined, isSelected: false, handleClick: undefined, diff --git a/src/fireedge/src/client/components/Cards/index.js b/src/fireedge/src/client/components/Cards/index.js index ea86f18c04..babda1b4ec 100644 --- a/src/fireedge/src/client/components/Cards/index.js +++ b/src/fireedge/src/client/components/Cards/index.js @@ -7,6 +7,7 @@ import EmptyCard from 'client/components/Cards/EmptyCard' import SelectCard from 'client/components/Cards/SelectCard' import ApplicationTemplateCard from 'client/components/Cards/ApplicationTemplateCard' import ApplicationCard from 'client/components/Cards/ApplicationCard' +import ApplicationNetworkCard from 'client/components/Cards/ApplicationNetworkCard' import PolicyCard from 'client/components/Cards/PolicyCard' import ProviderTemplateCard from 'client/components/Cards/ProviderTemplateCard' import ProviderCard from 'client/components/Cards/ProviderCard' @@ -23,6 +24,7 @@ export { SelectCard, ApplicationTemplateCard, ApplicationCard, + ApplicationNetworkCard, PolicyCard, ProviderTemplateCard, ProviderCard, diff --git a/src/fireedge/src/client/constants/index.js b/src/fireedge/src/client/constants/index.js index aef7d5a309..fd99f121d6 100644 --- a/src/fireedge/src/client/constants/index.js +++ b/src/fireedge/src/client/constants/index.js @@ -56,3 +56,8 @@ export { INPUT_TYPES, REQUEST_ACTIONS } + +export * as T from 'client/constants/translates' +export * from 'client/constants/flow' +export * from 'client/constants/states' +export * from 'client/constants/provision' diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js index 3d1e636c12..88d42e5dbb 100644 --- a/src/fireedge/src/client/constants/translates.js +++ b/src/fireedge/src/client/constants/translates.js @@ -40,6 +40,7 @@ module.exports = { ProvidersLabel: 'Providers', ProvisionLabel: 'Provision', ProvisionsLabel: 'Provisions', + ClustersLabel: 'Clusters', /* tabs */ Information: 'Information', diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Networking/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Networking/index.js index fa2228ac87..7f16151ac4 100644 --- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Networking/index.js +++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Networking/index.js @@ -7,7 +7,7 @@ import useListForm from 'client/hooks/useListForm' import FormWithSchema from 'client/components/Forms/FormWithSchema' import ListCards from 'client/components/List/ListCards' import { DialogForm } from 'client/components/Dialogs' -import { NetworkCard } from 'client/components/Cards' +import { ApplicationNetworkCard } from 'client/components/Cards' import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers' import { FORM_FIELDS, NETWORK_FORM_SCHEMA, STEP_FORM_SCHEMA } from './schema' @@ -44,7 +44,7 @@ const Networks = () => ({ <> { handleEdit() setShowDialog(true) diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Networks/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Networks/index.js index f6489605b8..5cb33b7f9d 100644 --- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Networks/index.js +++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Networks/index.js @@ -2,7 +2,7 @@ import React, { useCallback, useContext } from 'react' import useListForm from 'client/hooks/useListForm' import ListCards from 'client/components/List/ListCards' -import { NetworkCard } from 'client/components/Cards' +import { ApplicationNetworkCard } from 'client/components/Cards' import { STEP_ID as NETWORKING } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking' import { Context } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers' @@ -25,7 +25,7 @@ const Networks = () => ({ return ( { const isSelected = data?.some(selected => selected === id) diff --git a/src/fireedge/src/client/containers/Providers/index.js b/src/fireedge/src/client/containers/Providers/index.js index 656b88d4f3..6788c34f6a 100644 --- a/src/fireedge/src/client/containers/Providers/index.js +++ b/src/fireedge/src/client/containers/Providers/index.js @@ -3,6 +3,9 @@ import React, { useState, useEffect } from 'react' import { useHistory } from 'react-router-dom' import { Container, Box, Typography, Divider } from '@material-ui/core' import RefreshIcon from '@material-ui/icons/Autorenew' +import InfoIcon from '@material-ui/icons/Info' +import EditIcon from '@material-ui/icons/Build' +import DeleteIcon from '@material-ui/icons/Delete' import { PATH } from 'client/router/provision' import useProvision from 'client/hooks/useProvision' @@ -55,21 +58,36 @@ function Providers () { isLoading={providers.length === 0 && loading} handleCreate={() => history.push(PATH.PROVIDERS.CREATE)} CardComponent={ProviderCard} - cardsProps={({ value }) => ({ - handleEdit: () => - history.push(PATH.PROVIDERS.EDIT.replace(':id', value.ID)), - handleShow: () => setShowDialog({ - id: value.ID, - title: `(ID: ${value.ID}) ${value.NAME}` - }), - handleDelete: () => setShowDialog({ - id: value.ID, - title: `DELETE provider - (ID: ${value.ID}) ${value.NAME}`, - handleAccept: () => { - deleteProvider({ id: value.ID }) - setShowDialog(false) + cardsProps={({ value: { ID, NAME } }) => ({ + actions: [ + { + handleClick: () => setShowDialog({ + id: ID, + title: `(ID: ${ID}) ${NAME}` + }), + icon: InfoIcon, + iconColor: 'primary', + cy: `provider-info-${ID}` + }, + { + handleClick: () => + history.push(PATH.PROVIDERS.EDIT.replace(':id', ID)), + icon: EditIcon, + cy: `provider-edit-${ID}` + }, + { + handleClick: () => setShowDialog({ + id: ID, + title: `DELETE provider - (ID: ${ID}) ${NAME}`, + handleAccept: () => { + deleteProvider({ id: ID }) + setShowDialog(false) + } + }), + icon: DeleteIcon, + cy: `provider-delete-${ID}` } - }) + ] })} breakpoints={{ xs: 12, sm: 6, md: 4 }} /> diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/clusters.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/clusters.js deleted file mode 100644 index 8135223006..0000000000 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/clusters.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { memo, useEffect } from 'react' -import PropTypes from 'prop-types' - -import useFetchAll from 'client/hooks/useFetchAll' -import useOpennebula from 'client/hooks/useOpennebula' -import ListCards from 'client/components/List/ListCards' -import { ClusterCard } from 'client/components/Cards' - -const Clusters = memo(({ hidden, data }) => { - const { - clusters - } = data?.TEMPLATE?.PROVISION_BODY?.provision?.infrastructure - - const { getCluster } = useOpennebula() - const { data: list, fetchRequestAll, loading } = useFetchAll() - - useEffect(() => { - if (!list && !hidden) { - const reqs = clusters?.map(({ id }) => getCluster({ id })) - fetchRequestAll(reqs) - } - }, [hidden]) - - return ( - - ) -}, (prev, next) => prev.hidden === next.hiddfen) - -Clusters.propTypes = { - data: PropTypes.object.isRequired, - hidden: PropTypes.bool -} - -Clusters.defaultProps = { - data: {}, - hidden: true -} - -Clusters.displayName = 'Clusters' - -export default Clusters diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js index bcdf0c40c5..5fe851cd71 100644 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js +++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js @@ -1,6 +1,8 @@ import React, { memo, useEffect } from 'react' import PropTypes from 'prop-types' +import DeleteIcon from '@material-ui/icons/Delete' + import useFetchAll from 'client/hooks/useFetchAll' import useOpennebula from 'client/hooks/useOpennebula' import ListCards from 'client/components/List/ListCards' @@ -26,6 +28,13 @@ const Datastores = memo(({ hidden, data }) => { list={list} isLoading={loading} CardComponent={DatastoreCard} + cardsProps={({ value: { ID } }) => ({ + actions: [{ + handleClick: () => undefined, + icon: DeleteIcon, + cy: `provision-datastore-delete-${ID}` + }] + })} displayEmpty breakpoints={{ xs: 12, md: 6 }} /> diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js index 2fbfda15c4..2b75cae6a6 100644 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js +++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js @@ -1,6 +1,9 @@ import React, { memo, useEffect } from 'react' import PropTypes from 'prop-types' +import DeleteIcon from '@material-ui/icons/Delete' +import ConfigureIcon from '@material-ui/icons/Build' + import useFetchAll from 'client/hooks/useFetchAll' import useOpennebula from 'client/hooks/useOpennebula' import ListCards from 'client/components/List/ListCards' @@ -26,6 +29,20 @@ const Hosts = memo(({ hidden, data }) => { list={list} isLoading={loading} CardComponent={HostCard} + cardsProps={({ value: { ID } }) => ({ + actions: [ + { + handleClick: () => undefined, + icon: ConfigureIcon, + cy: `provision-host-configure-${ID}` + }, + { + handleClick: () => undefined, + icon: DeleteIcon, + cy: `provision-host-delete-${ID}` + } + ] + })} displayEmpty breakpoints={{ xs: 12, md: 6 }} /> diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js index 55b04a6d13..0b154e3461 100644 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js +++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js @@ -3,20 +3,17 @@ import PropTypes from 'prop-types' import { AppBar, Tabs, Tab, Box } from '@material-ui/core' import InfoIcon from '@material-ui/icons/Info' -import ClusterIcon from '@material-ui/icons/Storage' import DatastoreIcon from '@material-ui/icons/FolderOpen' import NetworkIcon from '@material-ui/icons/AccountTree' import HostIcon from '@material-ui/icons/VideogameAsset' import InfoTab from 'client/containers/Provisions/DialogInfo/info' -import ClustersTab from 'client/containers/Provisions/DialogInfo/clusters' import DatastoresTab from 'client/containers/Provisions/DialogInfo/datastores' import NetworksTab from 'client/containers/Provisions/DialogInfo/networks' import HostsTab from 'client/containers/Provisions/DialogInfo/hosts' const TABS = [ { name: 'info', icon: InfoIcon, content: InfoTab }, - { name: 'clusters', icon: ClusterIcon, content: ClustersTab }, { name: 'datastores', icon: DatastoreIcon, content: DatastoresTab }, { name: 'networks', icon: NetworkIcon, content: NetworksTab }, { name: 'hosts', icon: HostIcon, content: HostsTab } diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js index fd57f82908..54a19ca411 100644 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js +++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js @@ -6,24 +6,8 @@ import { CheckBox, CheckBoxOutlineBlank } from '@material-ui/icons' import clsx from 'clsx' import useStyles from 'client/containers/Provisions/DialogInfo/styles' -import { PROVISIONS_STATES } from 'client/constants/provision' import { Tr } from 'client/components/HOC' -import { - Information, - Name, - Description, - ProviderLabel, - StartTime, - Permissions, - Use, - Manage, - Admin, - Ownership, - Owner, - Group, - Other, - State -} from 'client/constants/translates' +import { T, PROVISIONS_STATES } from 'client/constants' const Info = memo(({ data }) => { const classes = useStyles() @@ -33,9 +17,11 @@ const Info = memo(({ data }) => { description, name, provider: providerName, - start_time: time + start_time: time, + provision: { infrastructure = {} } } = TEMPLATE?.PROVISION_BODY + const { id: clusterId, name: clusterName } = infrastructure?.clusters?.[0] const stateInfo = PROVISIONS_STATES[state] const isChecked = checked => @@ -47,7 +33,7 @@ const Info = memo(({ data }) => { - {Tr(Information)} + {Tr(T.Information)} @@ -55,25 +41,29 @@ const Info = memo(({ data }) => { {ID} - {Tr(Name)} + {Tr(T.Name)} {name} - {Tr(Description)} + {Tr(T.Description)} {description} - {Tr(ProviderLabel)} + {Tr(T.ProviderLabel)} {providerName} - {Tr(StartTime)} + {Tr(T.ClustersLabel)} + {`${clusterId} - ${clusterName}`} + + + {Tr(T.StartTime)} {new Date(time * 1000).toLocaleString()} - {Tr(State)} + {Tr(T.State)} { - {Tr(Permissions)} - {Tr(Use)} - {Tr(Manage)} - {Tr(Admin)} + {Tr(T.Permissions)} + {Tr(T.Use)} + {Tr(T.Manage)} + {Tr(T.Admin)} - {Tr(Owner)} + {Tr(T.Owner)} {isChecked(PERMISSIONS.OWNER_U)} {isChecked(PERMISSIONS.OWNER_M)} {isChecked(PERMISSIONS.OWNER_A)} - {Tr(Group)} + {Tr(T.Group)} {isChecked(PERMISSIONS.GROUP_U)} {isChecked(PERMISSIONS.GROUP_M)} {isChecked(PERMISSIONS.GROUP_A)} - {Tr(Other)} + {Tr(T.Other)} {isChecked(PERMISSIONS.OTHER_U)} {isChecked(PERMISSIONS.OTHER_M)} {isChecked(PERMISSIONS.OTHER_A)} @@ -116,15 +106,15 @@ const Info = memo(({ data }) => { - {Tr(Ownership)} + {Tr(T.Ownership)} - {Tr(Owner)} + {Tr(T.Owner)} {UNAME} - {Tr(Group)} + {Tr(T.Group)} {GNAME} diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js index 725594334f..ef4ef57771 100644 --- a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js +++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js @@ -1,10 +1,12 @@ import React, { memo, useEffect } from 'react' import PropTypes from 'prop-types' +import DeleteIcon from '@material-ui/icons/Delete' + import useFetchAll from 'client/hooks/useFetchAll' import useOpennebula from 'client/hooks/useOpennebula' import ListCards from 'client/components/List/ListCards' -import { SelectCard } from 'client/components/Cards' +import { NetworkCard } from 'client/components/Cards' const Networks = memo(({ hidden, data }) => { const { @@ -25,10 +27,13 @@ const Networks = memo(({ hidden, data }) => { ({ - title: `${ID} - ${NAME}`, - stylesProps: { minHeight: 75 } + CardComponent={NetworkCard} + cardsProps={({ value: { ID } }) => ({ + actions: [{ + handleClick: () => undefined, + icon: DeleteIcon, + cy: `provision-vnet-delete-${ID}` + }] })} displayEmpty breakpoints={{ xs: 12, md: 6 }} diff --git a/src/fireedge/src/client/containers/Provisions/index.js b/src/fireedge/src/client/containers/Provisions/index.js index 1f1408a5d5..d7eac5f781 100644 --- a/src/fireedge/src/client/containers/Provisions/index.js +++ b/src/fireedge/src/client/containers/Provisions/index.js @@ -3,6 +3,8 @@ import React, { useState, useEffect, createElement } from 'react' import { useHistory } from 'react-router-dom' import { Container, Box, Typography, Divider } from '@material-ui/core' import RefreshIcon from '@material-ui/icons/Autorenew' +import InfoIcon from '@material-ui/icons/Info' +import DeleteIcon from '@material-ui/icons/Delete' import { PATH } from 'client/router/provision' import useProvision from 'client/hooks/useProvision' @@ -57,21 +59,32 @@ function Provisions () { isLoading={provisions.length === 0 && loading} handleCreate={() => history.push(PATH.PROVISIONS.CREATE)} CardComponent={ProvisionCard} - cardsProps={({ value }) => ({ - handleShow: () => setShowDialog({ - id: value.ID, - title: `(ID: ${value.ID}) ${value.NAME}`, - content: DialogInfo - }), - handleDelete: () => setShowDialog({ - id: value.ID, - title: `DELETE provider - (ID: ${value.ID}) ${value.NAME}`, - handleAccept: () => { - deleteProvision({ id: value.ID }) - setShowDialog(false) + cardsProps={({ value: { ID, NAME } }) => ({ + actions: [ + { + handleClick: () => setShowDialog({ + id: ID, + title: `(ID: ${ID}) ${NAME}`, + content: DialogInfo + }), + icon: InfoIcon, + iconColor: 'primary', + cy: `provision-info-${ID}` }, - content: DialogInfo - }) + { + handleClick: () => setShowDialog({ + id: ID, + title: `DELETE provision - (ID: ${ID}) ${NAME}`, + handleAccept: () => { + deleteProvision({ id: ID }) + setShowDialog(false) + }, + content: DialogInfo + }), + icon: DeleteIcon, + cy: `provision-delete-${ID}` + } + ] })} breakpoints={{ xs: 12, sm: 6, md: 4 }} />