diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index b43c52d50..36bf6ddfb 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -598,6 +598,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 )); } diff --git a/ui/src/app/metadata/wizard/MetadataSourceWizard.js b/ui/src/app/metadata/wizard/MetadataSourceWizard.js index 364d74421..66e75e32b 100644 --- a/ui/src/app/metadata/wizard/MetadataSourceWizard.js +++ b/ui/src/app/metadata/wizard/MetadataSourceWizard.js @@ -12,16 +12,15 @@ import { useMetadataDefinitionContext, useMetadataSchemaContext, useMetadataDefi import { useMetadataFormDispatcher, setFormDataAction, setFormErrorAction, useMetadataFormData, useMetadataFormErrors } from '../hoc/MetadataFormContext'; import { MetadataConfiguration } from '../component/MetadataConfiguration'; import { Configuration } from '../hoc/Configuration'; -import { useMetadataEntity, useMetadataSources } from '../hooks/api'; +import { useMetadataSources } from '../hooks/api'; import Translate from '../../i18n/components/translate'; import { checkChanges } from '../hooks/utility'; import { useUserGroup } from '../../core/user/UserContext'; -export function MetadataSourceWizard ({ onShowNav, onSave, block }) { +export function MetadataSourceWizard ({ onShowNav, onSave, block, loading }) { - const { loading } = useMetadataEntity('source'); const group = useUserGroup(); const { data } = useMetadataSources({ @@ -61,6 +60,8 @@ export function MetadataSourceWizard ({ onShowNav, onSave, block }) { const validator = useMetadataDefinitionValidator(data, null, group); const warnings = definition.warnings && definition.warnings(metadata); + React.useEffect(() => console.log(loading), [loading]); + return ( <>