From 1fcda5584b4e3cc646f5e41f3bffe8f36814c632 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Mon, 25 Oct 2021 11:18:15 -0700 Subject: [PATCH] Fixed error message on timeout --- .../src/main/resources/i18n/messages.properties | 1 + ui/src/app/metadata/view/MetadataWizard.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 4c22a97ff..632916239 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -597,6 +597,7 @@ message.invalid-signing=Unless the response or the assertions are signed, SAML s message.session-timeout-heading=Session timed out message.session-timeout-body=Your session has timed out. Please login again. +message.session-timeout=An error has occurred while saving. Your session may have timed out. tooltip.entity-id=Entity ID tooltip.service-provider-name=Service Provider Name (Dashboard Display Only) diff --git a/ui/src/app/metadata/view/MetadataWizard.js b/ui/src/app/metadata/view/MetadataWizard.js index 4a4b4b5c7..6ba534ffd 100644 --- a/ui/src/app/metadata/view/MetadataWizard.js +++ b/ui/src/app/metadata/view/MetadataWizard.js @@ -7,10 +7,12 @@ import { Wizard } from '../wizard/Wizard'; import { useMetadataEntity } from '../hooks/api'; import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications'; import { Prompt, useHistory } from 'react-router'; +import { useTranslator } from '../../i18n/hooks'; export function MetadataWizard ({type, data, onCallback}) { const history = useHistory(); + const translator = useTranslator(); const { post, loading, response } = useMetadataEntity(type === 'source' ? 'source' : 'provider'); @@ -19,15 +21,21 @@ export function MetadataWizard ({type, data, onCallback}) { const [blocking, setBlocking] = React.useState(false); async function save(metadata) { - console.log(metadata); await post('', metadata); if (response.ok) { setBlocking(false); history.push(`/dashboard/metadata/manager/${type === 'source' ? 'resolvers' : 'providers'}`); } else { - const { errorCode, errorMessage, cause } = response.data; + let msg; + if (response.status) { + const { errorCode, errorMessage, cause } = response.data; + msg = `${errorCode}: ${errorMessage} ${cause ? `-${cause}` : ''}`; + } else { + msg = translator('message.session-timeout'); + } + notificationDispatch(createNotificationAction( - `${errorCode}: ${errorMessage} ${cause ? `-${cause}` : ''}`, + msg, NotificationTypes.ERROR )); }