Skip to content

Commit

Permalink
Fixed issue with contention and reloading data
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 2, 2021
1 parent d6e9d3e commit 31b3f72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const BaseProviderDefinition = {
...changes,
metadataFilters: [
...changes.metadataFilters.filter((filter, filterName) => {

if (filter['@type'] === 'RequiredValidUntil') {
if (!filter.maxValidityInterval || filter.maxValidityInterval === "") {
return false;
Expand Down
15 changes: 9 additions & 6 deletions ui/src/app/metadata/editor/MetadataEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ export function MetadataEditor ({ restore, current, reload }) {
.then(() => {
gotoDetail({ refresh: true });
})
.catch((err, notification) => {
notificationDispatch(notification || createNotificationAction(`${err.errorCode} - ${translator(err.errorMessage)}`, NotificationTypes.ERROR));
.catch((err) => {
notificationDispatch(
createNotificationAction(`${err.errorCode > 1 ? `${err.errorCode} - ` : ''} ${translator(err.errorMessage)}`, err.errorCode === 1 ? NotificationTypes.INFO : NotificationTypes.ERROR)
);
if (err.errorCode === 1) {
setTimeout(() => {
window.location.reload();
}, 500);
}
});
};

Expand Down Expand Up @@ -83,10 +90,6 @@ export function MetadataEditor ({ restore, current, reload }) {

const canFilter = restore ? false : FilterableProviders.indexOf(definition.type) > -1;

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

return (
<div className="container-fluid p-3">
<Prompt
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/metadata/hooks/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import useFetch from 'use-http';

import API_BASE_PATH from '../../App.constant';
import { createNotificationAction, NotificationTypes } from '../../notifications/hoc/Notifications';
import { useContentionDispatcher, openContentionModalAction } from '../contention/ContentionContext';

import {MetadataFilterTypes} from '../domain/filter';
Expand Down Expand Up @@ -114,7 +113,7 @@ export function useMetadataUpdater (path, current, cancel) {
resolve(await update(p, resolution));
}, (err) => {
cancel && cancel();
reject(err, createNotificationAction(`Updated data with latest changes`, NotificationTypes.INFO));
reject({ errorCode: 1, errorMessage: 'Updated data with latest changes - Reloading' });
}));
});
}
Expand Down

0 comments on commit 31b3f72

Please sign in to comment.