Merge pull request #2271 from automatisch/AUT-1389

feat: add error snackbar on failed app authentication
This commit is contained in:
Ali BARIN
2025-01-17 12:05:43 +01:00
committed by GitHub
3 changed files with 17 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import InputCreator from 'components/InputCreator';
import * as URLS from 'config/urls'; import * as URLS from 'config/urls';
import useAuthenticateApp from 'hooks/useAuthenticateApp.ee'; import useAuthenticateApp from 'hooks/useAuthenticateApp.ee';
import useFormatMessage from 'hooks/useFormatMessage'; import useFormatMessage from 'hooks/useFormatMessage';
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
import { generateExternalLink } from 'helpers/translationValues'; import { generateExternalLink } from 'helpers/translationValues';
import { Form } from './style'; import { Form } from './style';
import useAppAuth from 'hooks/useAppAuth'; import useAppAuth from 'hooks/useAppAuth';
@@ -39,6 +40,7 @@ function AddAppConnection(props) {
useShared: !!oauthClientId, useShared: !!oauthClientId,
}); });
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const enqueueSnackbar = useEnqueueSnackbar();
React.useEffect(function relayProviderData() { React.useEffect(function relayProviderData() {
if (window.opener) { if (window.opener) {
@@ -58,8 +60,14 @@ function AddAppConnection(props) {
if (!authenticate) return; if (!authenticate) return;
const asyncAuthenticate = async () => { const asyncAuthenticate = async () => {
await authenticate(); try {
navigate(URLS.APP_CONNECTIONS(key)); await authenticate();
navigate(URLS.APP_CONNECTIONS(key));
} catch (error) {
enqueueSnackbar(error?.message || formatMessage('genericError'), {
variant: 'error',
});
}
}; };
asyncAuthenticate(); asyncAuthenticate();

View File

@@ -23,6 +23,7 @@ import { useQueryClient } from '@tanstack/react-query';
import useAppConnections from 'hooks/useAppConnections'; import useAppConnections from 'hooks/useAppConnections';
import useTestConnection from 'hooks/useTestConnection'; import useTestConnection from 'hooks/useTestConnection';
import useOAuthClients from 'hooks/useOAuthClients'; import useOAuthClients from 'hooks/useOAuthClients';
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
const ADD_CONNECTION_VALUE = 'ADD_CONNECTION'; const ADD_CONNECTION_VALUE = 'ADD_CONNECTION';
const ADD_SHARED_CONNECTION_VALUE = 'ADD_SHARED_CONNECTION'; const ADD_SHARED_CONNECTION_VALUE = 'ADD_SHARED_CONNECTION';
@@ -55,6 +56,7 @@ function ChooseConnectionSubstep(props) {
React.useState(false); React.useState(false);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { data: appOAuthClients } = useOAuthClients(application.key); const { data: appOAuthClients } = useOAuthClients(application.key);
const enqueueSnackbar = useEnqueueSnackbar();
const { authenticate } = useAuthenticateApp({ const { authenticate } = useAuthenticateApp({
appKey: application.key, appKey: application.key,
@@ -156,8 +158,10 @@ function ChooseConnectionSubstep(props) {
}, },
}); });
} }
} catch (err) { } catch (error) {
// void enqueueSnackbar(error?.message || formatMessage('genericError'), {
variant: 'error',
});
} finally { } finally {
setShowAddSharedConnectionDialog(false); setShowAddSharedConnectionDialog(false);
} }

View File

@@ -1,6 +1,7 @@
{ {
"brandText": "Automatisch", "brandText": "Automatisch",
"searchPlaceholder": "Search", "searchPlaceholder": "Search",
"genericError": "Something went wrong. Please try again.",
"accountDropdownMenu.settings": "Settings", "accountDropdownMenu.settings": "Settings",
"accountDropdownMenu.adminSettings": "Admin", "accountDropdownMenu.adminSettings": "Admin",
"accountDropdownMenu.logout": "Logout", "accountDropdownMenu.logout": "Logout",