Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-2193 (pull request #559)
Browse files Browse the repository at this point in the history
Fixed issue with contention modal

Approved-by: Bill Smith
Approved-by: Jonathan Johnson
  • Loading branch information
rmathis authored and Jonathan Johnson committed Nov 1, 2021
2 parents 807f85c + 80b3e59 commit 1cf5abc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function Metadata () {
</MetadataDetail>
} />
<Route path={`${path}/edit/:section`} render={() =>
<MetadataEdit />
<MetadataEdit reload={reload} />
} />
<Route path={`${path}/restore/:versionId/:section`} exact render={() =>
<MetadataConfirmRestore />
Expand Down
14 changes: 8 additions & 6 deletions ui/src/app/metadata/editor/MetadataEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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))
});
};

Expand All @@ -74,7 +73,6 @@ export function MetadataEditor ({ current }) {
history.push(path);
setBlocking(resetBlock);
});
// setBlocking(resetBlock);
};

const [blocking, setBlocking] = React.useState(false);
Expand All @@ -85,6 +83,10 @@ export function MetadataEditor ({ current }) {

const canFilter = FilterableProviders.indexOf(definition.type) > -1;

React.useEffect(() => {
dispatch(setFormDataAction(current));
}, [current, dispatch])

return (
<div className="container-fluid p-3">
<Prompt
Expand Down
7 changes: 4 additions & 3 deletions ui/src/app/metadata/hooks/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function useMetadataFilterTypes () {
return MetadataFilterTypes;
}

export function useMetadataUpdater (path, current) {
export function useMetadataUpdater (path, current, cancel) {
const { request, put, get, error, response, ...props } = useFetch(path, {
cachePolicy: 'no-cache'
});
Expand All @@ -111,8 +111,9 @@ export function useMetadataUpdater (path, current) {
return new Promise((resolve, reject) => {
dispatch(openContentionModalAction(current, latest, body, async (resolution) => {
resolve(await update(p, resolution));
}, () => {
reject();
}, (err) => {
cancel && cancel();
reject(err);
}));
});
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/view/MetadataEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<MetadataForm initial={base}>
<MetadataEditor current={base} />
<MetadataEditor current={base} reload={reload} />
</MetadataForm>
);
}

0 comments on commit 1cf5abc

Please sign in to comment.