refactor: add useEnqueueSnackbar with data-test attr
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { ApolloProvider as BaseApolloProvider } from '@apollo/client';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import * as React from 'react';
|
||||
|
||||
import { mutateAndGetClient } from 'graphql/client';
|
||||
import useAuthentication from 'hooks/useAuthentication';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
|
||||
type ApolloProviderProps = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
const ApolloProvider = (props: ApolloProviderProps): React.ReactElement => {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
const authentication = useAuthentication();
|
||||
|
||||
const onError = React.useCallback(
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import * as React from 'react';
|
||||
import { useLazyQuery, useMutation } from '@apollo/client';
|
||||
import Card from '@mui/material/Card';
|
||||
import Box from '@mui/material/Box';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import CircularProgress from '@mui/material/CircularProgress';
|
||||
import CardActionArea from '@mui/material/CardActionArea';
|
||||
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
||||
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
||||
import ErrorIcon from '@mui/icons-material/Error';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
||||
import Box from '@mui/material/Box';
|
||||
import Card from '@mui/material/Card';
|
||||
import CardActionArea from '@mui/material/CardActionArea';
|
||||
import CircularProgress from '@mui/material/CircularProgress';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import { DateTime } from 'luxon';
|
||||
import * as React from 'react';
|
||||
|
||||
import type { IConnection } from '@automatisch/types';
|
||||
import ConnectionContextMenu from 'components/AppConnectionContextMenu';
|
||||
import { DELETE_CONNECTION } from 'graphql/mutations/delete-connection';
|
||||
import { TEST_CONNECTION } from 'graphql/queries/test-connection';
|
||||
import ConnectionContextMenu from 'components/AppConnectionContextMenu';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import { CardContent, Typography } from './style';
|
||||
|
||||
@@ -30,7 +30,7 @@ const countTranslation = (value: React.ReactNode) => (
|
||||
);
|
||||
|
||||
function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
const [verificationVisible, setVerificationVisible] = React.useState(false);
|
||||
const [testConnection, { called: testCalled, loading: testLoading }] =
|
||||
useLazyQuery(TEST_CONNECTION, {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import * as React from 'react';
|
||||
|
||||
import Can from 'components/Can';
|
||||
import ConfirmationDialog from 'components/ConfirmationDialog';
|
||||
@@ -22,7 +22,7 @@ export default function DeleteRoleButton(props: DeleteRoleButtonProps) {
|
||||
refetchQueries: ['GetRoles'],
|
||||
});
|
||||
const formatMessage = useFormatMessage();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
|
||||
const handleConfirm = React.useCallback(async () => {
|
||||
try {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import * as React from 'react';
|
||||
|
||||
import ConfirmationDialog from 'components/ConfirmationDialog';
|
||||
import { DELETE_USER } from 'graphql/mutations/delete-user.ee';
|
||||
@@ -20,7 +20,7 @@ export default function DeleteUserButton(props: DeleteUserButtonProps) {
|
||||
refetchQueries: ['GetUsers'],
|
||||
});
|
||||
const formatMessage = useFormatMessage();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
|
||||
const handleConfirm = React.useCallback(async () => {
|
||||
try {
|
||||
|
@@ -1,15 +1,15 @@
|
||||
import * as React from 'react';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Menu from '@mui/material/Menu';
|
||||
import type { PopoverProps } from '@mui/material/Popover';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import type { PopoverProps } from '@mui/material/Popover';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import * as React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import Can from 'components/Can';
|
||||
import * as URLS from 'config/urls';
|
||||
import { DELETE_FLOW } from 'graphql/mutations/delete-flow';
|
||||
import { DUPLICATE_FLOW } from 'graphql/mutations/duplicate-flow';
|
||||
import * as URLS from 'config/urls';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
|
||||
type ContextMenuProps = {
|
||||
@@ -22,14 +22,11 @@ export default function ContextMenu(
|
||||
props: ContextMenuProps
|
||||
): React.ReactElement {
|
||||
const { flowId, onClose, anchorEl } = props;
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
const [deleteFlow] = useMutation(DELETE_FLOW);
|
||||
const [duplicateFlow] = useMutation(
|
||||
DUPLICATE_FLOW,
|
||||
{
|
||||
refetchQueries: ['GetFlows'],
|
||||
}
|
||||
);
|
||||
const [duplicateFlow] = useMutation(DUPLICATE_FLOW, {
|
||||
refetchQueries: ['GetFlows'],
|
||||
});
|
||||
const formatMessage = useFormatMessage();
|
||||
|
||||
const onFlowDuplicate = React.useCallback(async () => {
|
||||
@@ -75,11 +72,7 @@ export default function ContextMenu(
|
||||
>
|
||||
<Can I="read" a="Flow" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
disabled={!allowed}
|
||||
component={Link}
|
||||
to={URLS.FLOW(flowId)}
|
||||
>
|
||||
<MenuItem disabled={!allowed} component={Link} to={URLS.FLOW(flowId)}>
|
||||
{formatMessage('flow.view')}
|
||||
</MenuItem>
|
||||
)}
|
||||
@@ -87,10 +80,7 @@ export default function ContextMenu(
|
||||
|
||||
<Can I="create" a="Flow" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
disabled={!allowed}
|
||||
onClick={onFlowDuplicate}
|
||||
>
|
||||
<MenuItem disabled={!allowed} onClick={onFlowDuplicate}>
|
||||
{formatMessage('flow.duplicate')}
|
||||
</MenuItem>
|
||||
)}
|
||||
@@ -98,10 +88,7 @@ export default function ContextMenu(
|
||||
|
||||
<Can I="delete" a="Flow" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
disabled={!allowed}
|
||||
onClick={onFlowDelete}
|
||||
>
|
||||
<MenuItem disabled={!allowed} onClick={onFlowDelete}>
|
||||
{formatMessage('flow.delete')}
|
||||
</MenuItem>
|
||||
)}
|
||||
|
@@ -1,18 +1,18 @@
|
||||
import * as React from 'react';
|
||||
import { useSearchParams, useNavigate } from 'react-router-dom';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
import LoadingButton from '@mui/lab/LoadingButton';
|
||||
import Paper from '@mui/material/Paper';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import LoadingButton from '@mui/lab/LoadingButton';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import * as React from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import * as yup from 'yup';
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
|
||||
import * as URLS from 'config/urls';
|
||||
import Form from 'components/Form';
|
||||
import TextField from 'components/TextField';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import * as URLS from 'config/urls';
|
||||
import { RESET_PASSWORD } from 'graphql/mutations/reset-password.ee';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
|
||||
const validationSchema = yup.object().shape({
|
||||
password: yup.string().required('resetPasswordForm.mandatoryInput'),
|
||||
@@ -23,7 +23,7 @@ const validationSchema = yup.object().shape({
|
||||
});
|
||||
|
||||
export default function ResetPasswordForm() {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
const formatMessage = useFormatMessage();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
@@ -41,7 +41,9 @@ export default function ResetPasswordForm() {
|
||||
},
|
||||
});
|
||||
|
||||
enqueueSnackbar(formatMessage('resetPasswordForm.passwordUpdated'), { variant: 'success' });
|
||||
enqueueSnackbar(formatMessage('resetPasswordForm.passwordUpdated'), {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
navigate(URLS.LOGIN);
|
||||
};
|
||||
@@ -78,14 +80,18 @@ export default function ResetPasswordForm() {
|
||||
helperText={
|
||||
touchedFields.password && errors?.password?.message
|
||||
? formatMessage(errors?.password?.message as string, {
|
||||
inputName: formatMessage('resetPasswordForm.passwordFieldLabel'),
|
||||
inputName: formatMessage(
|
||||
'resetPasswordForm.passwordFieldLabel'
|
||||
),
|
||||
})
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label={formatMessage('resetPasswordForm.confirmPasswordFieldLabel')}
|
||||
label={formatMessage(
|
||||
'resetPasswordForm.confirmPasswordFieldLabel'
|
||||
)}
|
||||
name="confirmPassword"
|
||||
fullWidth
|
||||
margin="dense"
|
||||
|
Reference in New Issue
Block a user