mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-06 07:04:45 +09:00
1 parent
4bec4df31e
commit
4140d330dc
10 files changed
+97
-65
No files matched your search
@@ -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(
|
||||
</Button>
|
||||
)}
|
||||
{handleAccept && (
|
||||
<ButtonSubmit
|
||||
<SubmitButton
|
||||
data-cy="dg-accept-button"
|
||||
onClick={handleAccept}
|
||||
label={Tr(T.Accept)}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { useForm, FormProvider } from 'react-hook-form'
|
||||
import { yupResolver } from '@hookform/resolvers'
|
||||
|
||||
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'
|
||||
|
||||
@@ -61,7 +61,7 @@ const DialogForm = memo(
|
||||
</Button>
|
||||
)}
|
||||
{onSubmit && (
|
||||
<ButtonSubmit
|
||||
<SubmitButton
|
||||
data-cy="dg-form-submit-button"
|
||||
isSubmitting={methods.formState.isSubmitting}
|
||||
onClick={methods.handleSubmit(onSubmit)}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import * as React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { makeStyles, CircularProgress, Button, Fab } from '@material-ui/core'
|
||||
import {
|
||||
makeStyles, CircularProgress, Button, Fab, IconButton
|
||||
} from '@material-ui/core'
|
||||
import { Tr } from 'client/components/HOC'
|
||||
import { T } from 'client/constants'
|
||||
|
||||
@@ -12,29 +14,29 @@ const useStyles = makeStyles(() => ({
|
||||
}
|
||||
}))
|
||||
|
||||
const ButtonComponent = ({ fab, children, ...props }) => fab ? (
|
||||
<Fab color="primary" size="small" {...props}>{children}</Fab>
|
||||
const ButtonComponent = ({ icon, children, ...props }) => icon ? (
|
||||
<IconButton {...props}>
|
||||
{children}
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button color="primary" type="submit" variant="contained" {...props}>
|
||||
<Button type="submit" variant="contained" {...props}>
|
||||
{children}
|
||||
</Button>
|
||||
)
|
||||
|
||||
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 (
|
||||
<ButtonComponent
|
||||
color="primary"
|
||||
className={classes.root}
|
||||
disabled={isSubmitting}
|
||||
fab={fab}
|
||||
{...props}
|
||||
>
|
||||
{isSubmitting && <CircularProgress size={24} />}
|
||||
@@ -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
|
||||
@@ -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 = ({
|
||||
<Button onClick={handleBack} disabled={disabledBack}>
|
||||
{Tr(T.Back)}
|
||||
</Button>
|
||||
<ButtonSubmit
|
||||
<SubmitButton
|
||||
data-cy="stepper-next-button"
|
||||
onClick={handleNext}
|
||||
isSubmitting={isSubmitting}
|
||||
|
||||
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types'
|
||||
import { Box, Typography, InputBase } from '@material-ui/core'
|
||||
import SearchIcon from '@material-ui/icons/Search'
|
||||
import RefreshIcon from '@material-ui/icons/Autorenew'
|
||||
import AddIcon from '@material-ui/icons/Add'
|
||||
|
||||
import SubmitButton from 'client/components/FormControl/SubmitButton'
|
||||
import listHeaderStyles from 'client/components/List/ListHeader/styles'
|
||||
@@ -13,6 +14,8 @@ const ListHeader = memo(({
|
||||
title,
|
||||
hasReloadButton,
|
||||
reloadButtonProps,
|
||||
hasAddButton,
|
||||
addButtonProps,
|
||||
hasSearch,
|
||||
searchProps
|
||||
}) => {
|
||||
@@ -20,30 +23,40 @@ const ListHeader = memo(({
|
||||
const { handleChange } = searchProps
|
||||
|
||||
return (
|
||||
<Box p={3} className={classes.root}>
|
||||
{hasReloadButton && (
|
||||
<SubmitButton fab label={<RefreshIcon />} {...reloadButtonProps} />
|
||||
)}
|
||||
{title && (
|
||||
<Typography variant="h5" className={classes.title}>
|
||||
{Tr(title)}
|
||||
</Typography>
|
||||
)}
|
||||
{hasSearch && (
|
||||
<Box className={classes.search}>
|
||||
<Box className={classes.searchIcon}>
|
||||
<SearchIcon />
|
||||
<Box className={classes.root}>
|
||||
<Box className={classes.actions}>
|
||||
<Box className={classes.buttons}>
|
||||
{!!(hasReloadButton || reloadButtonProps) && (
|
||||
<SubmitButton icon label={<RefreshIcon />} {...reloadButtonProps} />
|
||||
)}
|
||||
{!!(hasAddButton || addButtonProps) && (
|
||||
<SubmitButton icon label={<AddIcon />} {...addButtonProps} />
|
||||
)}
|
||||
</Box>
|
||||
{!!(hasSearch || searchProps) && (
|
||||
<Box className={classes.search}>
|
||||
<Box className={classes.searchIcon}>
|
||||
<SearchIcon />
|
||||
</Box>
|
||||
<InputBase
|
||||
type="search"
|
||||
onChange={handleChange}
|
||||
fullWidth
|
||||
placeholder="Search..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
<InputBase
|
||||
type="search"
|
||||
onChange={handleChange}
|
||||
fullWidth
|
||||
placeholder="Search..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{title && (
|
||||
<Box className={classes.title}>
|
||||
<Typography variant="h5" className={classes.titleText}>
|
||||
{Tr(title)}
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
@@ -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'
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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)}
|
||||
</Button>
|
||||
)}
|
||||
<ButtonSubmit
|
||||
<SubmitButton
|
||||
data-cy="login-button"
|
||||
isSubmitting={isLoading}
|
||||
label={onBack ? Tr(T.Next) : Tr(T.SignIn)}
|
||||
|
||||
@@ -36,12 +36,11 @@ function Providers () {
|
||||
<Container disableGutters>
|
||||
<ListHeader
|
||||
title={T.Providers}
|
||||
hasReloadButton
|
||||
reloadButtonProps={{
|
||||
onClick: () => fetchRequest(undefined, { reload: true }),
|
||||
isSubmitting: Boolean(loading || reloading)
|
||||
}}
|
||||
hasSearch
|
||||
addButtonProps={{ onClick: () => history.push(PATH.PROVIDERS.CREATE) }}
|
||||
searchProps={{ handleChange }}
|
||||
/>
|
||||
<Box p={3}>
|
||||
@@ -51,7 +50,6 @@ function Providers () {
|
||||
<ListCards
|
||||
list={result ?? providers}
|
||||
isLoading={providers.length === 0 && loading}
|
||||
handleCreate={() => history.push(PATH.PROVIDERS.CREATE)}
|
||||
CardComponent={ProvisionCard}
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
isProvider: true,
|
||||
|
||||
@@ -35,12 +35,11 @@ function Provisions () {
|
||||
<Container disableGutters>
|
||||
<ListHeader
|
||||
title={T.Provisions}
|
||||
hasReloadButton
|
||||
reloadButtonProps={{
|
||||
onClick: () => fetchRequest(undefined, { reload: true }),
|
||||
isSubmitting: Boolean(loading || reloading)
|
||||
}}
|
||||
hasSearch
|
||||
addButtonProps={{ onClick: () => history.push(PATH.PROVISIONS.CREATE) }}
|
||||
searchProps={{ handleChange }}
|
||||
/>
|
||||
<Box p={3}>
|
||||
@@ -50,7 +49,6 @@ function Provisions () {
|
||||
<ListCards
|
||||
list={result ?? provisions}
|
||||
isLoading={provisions.length > 0 && loading}
|
||||
handleCreate={() => history.push(PATH.PROVISIONS.CREATE)}
|
||||
CardComponent={ProvisionCard}
|
||||
cardsProps={({ value: { ID, NAME } }) => ({
|
||||
handleClick: () => setShowDialog({
|
||||
|
||||
@@ -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 = ({
|
||||
</Grid>
|
||||
))}
|
||||
<Grid item xs={12}>
|
||||
<ButtonSubmit isSubmitting={formState.isSubmitting} />
|
||||
<SubmitButton isSubmitting={formState.isSubmitting} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user