From 80b3e59e6d4ed9bdd06dde3418fb4d9bfb7475bb Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Tue, 26 Oct 2021 11:32:32 -0700 Subject: [PATCH] Fixed issue with contention modal --- .../src/main/resources/i18n/messages.properties | 1 + ui/src/app/metadata/Metadata.js | 2 +- ui/src/app/metadata/editor/MetadataEditor.js | 14 ++++++++------ ui/src/app/metadata/hooks/api.js | 7 ++++--- ui/src/app/metadata/view/MetadataEdit.js | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 4c22a97ff..b43c52d50 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -69,6 +69,7 @@ action.groups=Groups action.source-group=Group action.enable=Enable action.disable=Disable +action.get-latest=Get latest changes action.add-new-role=Add new role action.roles=Roles diff --git a/ui/src/app/metadata/Metadata.js b/ui/src/app/metadata/Metadata.js index 81cd1e35a..20fec9021 100644 --- a/ui/src/app/metadata/Metadata.js +++ b/ui/src/app/metadata/Metadata.js @@ -49,7 +49,7 @@ export function Metadata () { } /> - + } /> diff --git a/ui/src/app/metadata/editor/MetadataEditor.js b/ui/src/app/metadata/editor/MetadataEditor.js index 0c8757d97..8cbec6770 100644 --- a/ui/src/app/metadata/editor/MetadataEditor.js +++ b/ui/src/app/metadata/editor/MetadataEditor.js @@ -21,14 +21,14 @@ import { checkChanges } from '../hooks/utility'; import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications'; import { useUserGroup } from '../../core/user/UserContext'; -export function MetadataEditor ({ current }) { +export function MetadataEditor ({ current, reload }) { const translator = useTranslator(); const group = useUserGroup(); const { type, id, section } = useParams(); - const { update, loading } = useMetadataUpdater(`${ API_BASE_PATH }${getMetadataPath(type)}`, current); + const { update, loading } = useMetadataUpdater(`${ API_BASE_PATH }${getMetadataPath(type)}`, current, reload); const notificationDispatch = useNotificationDispatcher(); @@ -51,9 +51,8 @@ export function MetadataEditor ({ current }) { .then(() => { gotoDetail({ refresh: true }); }) - .catch(err => { - // window.location.reload(); - notificationDispatch(createNotificationAction(`${err.errorCode} - ${translator(err.errorMessage)}`, NotificationTypes.ERROR)) + .catch((err) => { + notificationDispatch(createNotificationAction(`Updated data with latest changes`, NotificationTypes.INFO)) }); }; @@ -74,7 +73,6 @@ export function MetadataEditor ({ current }) { history.push(path); setBlocking(resetBlock); }); - // setBlocking(resetBlock); }; const [blocking, setBlocking] = React.useState(false); @@ -85,6 +83,10 @@ export function MetadataEditor ({ current }) { const canFilter = FilterableProviders.indexOf(definition.type) > -1; + React.useEffect(() => { + dispatch(setFormDataAction(current)); + }, [current, dispatch]) + return (
{ dispatch(openContentionModalAction(current, latest, body, async (resolution) => { resolve(await update(p, resolution)); - }, () => { - reject(); + }, (err) => { + cancel && cancel(); + reject(err); })); }); } diff --git a/ui/src/app/metadata/view/MetadataEdit.js b/ui/src/app/metadata/view/MetadataEdit.js index 45d326312..6fcabd933 100644 --- a/ui/src/app/metadata/view/MetadataEdit.js +++ b/ui/src/app/metadata/view/MetadataEdit.js @@ -3,13 +3,13 @@ import { MetadataForm } from '../hoc/MetadataFormContext'; import { MetadataEditor } from '../editor/MetadataEditor'; import { useMetadataObject } from '../hoc/MetadataSelector'; -export function MetadataEdit() { +export function MetadataEdit({reload}) { const base = useMetadataObject(); return ( - + ); } \ No newline at end of file