orc-shared 1.6.0-dev.3 → 1.6.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/globalErrorMessages.js +67 -0
- package/dist/actions/makeApiAction.js +1 -1
- package/dist/buildStore.js +3 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.js +133 -0
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.js +78 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +2 -2
- package/dist/components/MaterialUI/Inputs/InputBase.js +1 -1
- package/dist/components/MaterialUI/hocs/withDeferredPopper.js +1 -1
- package/dist/components/Routing/SubPage.js +6 -7
- package/dist/components/Scope/useScopeConfirmationModalState.js +1 -1
- package/dist/hooks/useDispatchWithErrorHandling.js +106 -0
- package/dist/hooks/useNotificationRequestState.js +2 -2
- package/dist/reducers/globalErrorMessages.js +79 -0
- package/dist/selectors/authentication.js +2 -2
- package/dist/selectors/globalErrorMessages.js +58 -0
- package/dist/selectors/metadata.js +1 -1
- package/dist/utils/responseProcessingHelper.js +86 -0
- package/package.json +4 -2
- package/src/actions/globalErrorMessages.js +12 -0
- package/src/actions/globalErrorMessages.test.js +21 -0
- package/src/buildStore.js +2 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.js +92 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.test.js +444 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.js +12 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.test.js +85 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +1 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +2 -2
- package/src/components/Routing/SubPage.js +0 -1
- package/src/hooks/useDispatchWithErrorHandling.js +57 -0
- package/src/hooks/useDispatchWithErrorHandling.test.js +230 -0
- package/src/reducers/globalErrorMessages.js +25 -0
- package/src/reducers/globalErrorMessages.test.js +66 -0
- package/src/selectors/globalErrorMessages.js +11 -0
- package/src/selectors/globalErrorMessages.test.js +25 -0
- package/src/utils/responseProcessingHelper.js +41 -0
- package/src/utils/responseProcessingHelper.test.js +182 -0
|
@@ -68,8 +68,8 @@ var useNotificationRequestState = function useNotificationRequestState(_ref) {
|
|
|
68
68
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
69
|
}, [formatMessage, successAction, successMessageId, successMessageValues]);
|
|
70
70
|
var onError = (0, _react.useCallback)(function (errorResponse) {
|
|
71
|
-
var _errorResponse$respon, _errorResponse$respon2
|
|
72
|
-
var errorMessage = (_errorResponse$respon = errorResponse == null
|
|
71
|
+
var _errorResponse$respon, _errorResponse$respon2;
|
|
72
|
+
var errorMessage = (_errorResponse$respon = errorResponse == null || (_errorResponse$respon2 = errorResponse.response) == null || (_errorResponse$respon2 = _errorResponse$respon2.responseStatus) == null ? void 0 : _errorResponse$respon2.message) != null ? _errorResponse$respon : null;
|
|
73
73
|
var message = formatMessage(errorMessageId, _objectSpread(_objectSpread({}, errorMessageValues), {}, {
|
|
74
74
|
errorMessage: errorMessage != null ? errorMessage : formatMessage(_sharedMessages.default.errorUnknown)
|
|
75
75
|
}));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
6
|
+
var _globalErrorMessages = require("../actions/globalErrorMessages");
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
(function () {
|
|
9
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
10
|
+
enterModule && enterModule(module);
|
|
11
|
+
})();
|
|
12
|
+
(function () {
|
|
13
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
14
|
+
enterModule && enterModule(module);
|
|
15
|
+
})();
|
|
16
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var initialState = _immutable.default.fromJS({
|
|
23
|
+
dialog: {
|
|
24
|
+
errorMessages: []
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var globalErrorMessages = function globalErrorMessages(state, action) {
|
|
28
|
+
if (state === void 0) {
|
|
29
|
+
state = initialState;
|
|
30
|
+
}
|
|
31
|
+
switch (action.type) {
|
|
32
|
+
case _globalErrorMessages.PUSH_GLOBAL_ERROR_MESSAGE:
|
|
33
|
+
{
|
|
34
|
+
var newMsgs = state.getIn(["dialog", "errorMessages"]).push(_immutable.default.fromJS(action.payload));
|
|
35
|
+
return state.setIn(["dialog", "errorMessages"], newMsgs);
|
|
36
|
+
}
|
|
37
|
+
case _globalErrorMessages.POP_GLOBAL_ERROR_MESSAGE:
|
|
38
|
+
{
|
|
39
|
+
var _newMsgs = state.getIn(["dialog", "errorMessages"]).shift();
|
|
40
|
+
return state.setIn(["dialog", "errorMessages"], _newMsgs);
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
return state;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var _default = globalErrorMessages;
|
|
47
|
+
var _default2 = _default;
|
|
48
|
+
var _default3 = _default2;
|
|
49
|
+
exports.default = _default3;
|
|
50
|
+
;
|
|
51
|
+
(function () {
|
|
52
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
53
|
+
if (!reactHotLoader) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
57
|
+
reactHotLoader.register(globalErrorMessages, "globalErrorMessages", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
58
|
+
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
59
|
+
})();
|
|
60
|
+
;
|
|
61
|
+
(function () {
|
|
62
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
63
|
+
leaveModule && leaveModule(module);
|
|
64
|
+
})();
|
|
65
|
+
;
|
|
66
|
+
(function () {
|
|
67
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
68
|
+
if (!reactHotLoader) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
72
|
+
reactHotLoader.register(globalErrorMessages, "globalErrorMessages", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
73
|
+
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/reducers/globalErrorMessages.js");
|
|
74
|
+
})();
|
|
75
|
+
;
|
|
76
|
+
(function () {
|
|
77
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
78
|
+
leaveModule && leaveModule(module);
|
|
79
|
+
})();
|
|
@@ -41,8 +41,8 @@ var hasRolePermissions = function hasRolePermissions(appRolesClaims, scopeId, ro
|
|
|
41
41
|
if (appRolesClaims != null && scopeId != null) {
|
|
42
42
|
var allowed = !!appRolesClaims.getIn(["*", role]) || !!appRolesClaims.getIn([scopeId, role]);
|
|
43
43
|
if (!allowed) {
|
|
44
|
-
var _scopes$get$toJS$pare, _scopes$get
|
|
45
|
-
var parentScopeId = (_scopes$get$toJS$pare = (_scopes$get = scopes.get(scopeId)) == null
|
|
44
|
+
var _scopes$get$toJS$pare, _scopes$get;
|
|
45
|
+
var parentScopeId = (_scopes$get$toJS$pare = (_scopes$get = scopes.get(scopeId)) == null || (_scopes$get = _scopes$get.toJS()) == null ? void 0 : _scopes$get.parentScopeId) != null ? _scopes$get$toJS$pare : null;
|
|
46
46
|
return hasRolePermissions(appRolesClaims, parentScopeId, role, scopes);
|
|
47
47
|
}
|
|
48
48
|
return allowed;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.firstDialogErrorMessageSelector = void 0;
|
|
5
|
+
var _reselect = require("reselect");
|
|
6
|
+
(function () {
|
|
7
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
8
|
+
enterModule && enterModule(module);
|
|
9
|
+
})();
|
|
10
|
+
(function () {
|
|
11
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
12
|
+
enterModule && enterModule(module);
|
|
13
|
+
})();
|
|
14
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var globalMsgData = function globalMsgData(state) {
|
|
21
|
+
return state.get("globalErrorMessages");
|
|
22
|
+
};
|
|
23
|
+
var firstDialogErrorMessageSelector = (0, _reselect.createSelector)(globalMsgData, function (data) {
|
|
24
|
+
var msgs = data.getIn(["dialog", "errorMessages"]);
|
|
25
|
+
if (msgs.size === 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return msgs.first().toJS();
|
|
29
|
+
});
|
|
30
|
+
exports.firstDialogErrorMessageSelector = firstDialogErrorMessageSelector;
|
|
31
|
+
;
|
|
32
|
+
(function () {
|
|
33
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
34
|
+
if (!reactHotLoader) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
reactHotLoader.register(globalMsgData, "globalMsgData", "/home/vsts/work/1/s/src/selectors/globalErrorMessages.js");
|
|
38
|
+
reactHotLoader.register(firstDialogErrorMessageSelector, "firstDialogErrorMessageSelector", "/home/vsts/work/1/s/src/selectors/globalErrorMessages.js");
|
|
39
|
+
})();
|
|
40
|
+
;
|
|
41
|
+
(function () {
|
|
42
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
43
|
+
leaveModule && leaveModule(module);
|
|
44
|
+
})();
|
|
45
|
+
;
|
|
46
|
+
(function () {
|
|
47
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
48
|
+
if (!reactHotLoader) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
reactHotLoader.register(globalMsgData, "globalMsgData", "/home/vsts/work/1/s/src/selectors/globalErrorMessages.js");
|
|
52
|
+
reactHotLoader.register(firstDialogErrorMessageSelector, "firstDialogErrorMessageSelector", "/home/vsts/work/1/s/src/selectors/globalErrorMessages.js");
|
|
53
|
+
})();
|
|
54
|
+
;
|
|
55
|
+
(function () {
|
|
56
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
57
|
+
leaveModule && leaveModule(module);
|
|
58
|
+
})();
|
|
@@ -369,7 +369,7 @@ var resolveProductPropertyValue = function resolveProductPropertyValue(property,
|
|
|
369
369
|
case "Lookup":
|
|
370
370
|
var lookupName = (_property$lookupDefin = property.lookupDefinition) == null ? void 0 : _property$lookupDefin.lookupName;
|
|
371
371
|
var lookup = lookups == null ? void 0 : lookups.get(lookupName);
|
|
372
|
-
var lookupValue = lookup == null
|
|
372
|
+
var lookupValue = lookup == null || (_lookup$get = lookup.get("values")) == null ? void 0 : _lookup$get.get(propertyValue);
|
|
373
373
|
return (0, _localizationHelper.getLocalization)(lookupValue == null ? void 0 : lookupValue.get("displayName"), locale, lookupValue == null ? void 0 : lookupValue.get("value"));
|
|
374
374
|
default:
|
|
375
375
|
return propertyValue;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.extractStandardErrorMessagesFromResponse = void 0;
|
|
5
|
+
(function () {
|
|
6
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
7
|
+
enterModule && enterModule(module);
|
|
8
|
+
})();
|
|
9
|
+
(function () {
|
|
10
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
11
|
+
enterModule && enterModule(module);
|
|
12
|
+
})();
|
|
13
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
14
|
+
return a;
|
|
15
|
+
};
|
|
16
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var extractStandardErrorMessagesFromResponse = function extractStandardErrorMessagesFromResponse(response, validationLookupModule, validationLookupName) {
|
|
20
|
+
var hasErrors = false;
|
|
21
|
+
var messages = [];
|
|
22
|
+
if (response != null && response.error) {
|
|
23
|
+
var _response$payload, _response$payload3;
|
|
24
|
+
hasErrors = true;
|
|
25
|
+
if (((_response$payload = response.payload) == null ? void 0 : _response$payload.status) === 422) {
|
|
26
|
+
var _response$payload2;
|
|
27
|
+
if ((_response$payload2 = response.payload) != null && (_response$payload2 = _response$payload2.response) != null && _response$payload2.failures) {
|
|
28
|
+
// uses structure from our .Net ValidationFailuresExceptionHandler
|
|
29
|
+
response.payload.response.failures.forEach(function (failure) {
|
|
30
|
+
if (failure.errorCode) {
|
|
31
|
+
messages.push({
|
|
32
|
+
message: failure.errorMessage,
|
|
33
|
+
lookupModule: validationLookupModule,
|
|
34
|
+
lookupName: validationLookupName,
|
|
35
|
+
lookupKey: failure.errorCode
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
} else if (((_response$payload3 = response.payload) == null ? void 0 : _response$payload3.status) === 500) {
|
|
41
|
+
var _response$payload4;
|
|
42
|
+
if ((_response$payload4 = response.payload) != null && (_response$payload4 = _response$payload4.response) != null && _response$payload4.errors) {
|
|
43
|
+
// uses structure from our .Net OrckestraExceptionErrorHandler
|
|
44
|
+
response.payload.response.errors.forEach(function (err) {
|
|
45
|
+
messages.push({
|
|
46
|
+
message: err.message,
|
|
47
|
+
lookupModule: err.lookupModule,
|
|
48
|
+
lookupName: err.lookupName,
|
|
49
|
+
lookupKey: err.lookupKey
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
hasErrors: hasErrors,
|
|
57
|
+
messages: messages
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.extractStandardErrorMessagesFromResponse = extractStandardErrorMessagesFromResponse;
|
|
61
|
+
;
|
|
62
|
+
(function () {
|
|
63
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
64
|
+
if (!reactHotLoader) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
reactHotLoader.register(extractStandardErrorMessagesFromResponse, "extractStandardErrorMessagesFromResponse", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
68
|
+
})();
|
|
69
|
+
;
|
|
70
|
+
(function () {
|
|
71
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
72
|
+
leaveModule && leaveModule(module);
|
|
73
|
+
})();
|
|
74
|
+
;
|
|
75
|
+
(function () {
|
|
76
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
77
|
+
if (!reactHotLoader) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
reactHotLoader.register(extractStandardErrorMessagesFromResponse, "extractStandardErrorMessagesFromResponse", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
81
|
+
})();
|
|
82
|
+
;
|
|
83
|
+
(function () {
|
|
84
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
85
|
+
leaveModule && leaveModule(module);
|
|
86
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "1.6.0-dev.
|
|
3
|
+
"version": "1.6.0-dev.5",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
"cultureIso": "fr-CA"
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
|
-
"devDependencies": {
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@testing-library/react": "^10.4.9"
|
|
52
|
+
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"orc-scripts": "1.7.0-dev.1"
|
|
53
55
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const PUSH_GLOBAL_ERROR_MESSAGE = "PUSH_GLOBAL_ERROR_MESSAGE";
|
|
2
|
+
|
|
3
|
+
export const pushGlobalErrorMessage = msg => ({
|
|
4
|
+
type: PUSH_GLOBAL_ERROR_MESSAGE,
|
|
5
|
+
payload: msg,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const POP_GLOBAL_ERROR_MESSAGE = "POP_GLOBAL_ERROR_MESSAGE";
|
|
9
|
+
|
|
10
|
+
export const popGlobalErrorMessage = () => ({
|
|
11
|
+
type: POP_GLOBAL_ERROR_MESSAGE,
|
|
12
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
POP_GLOBAL_ERROR_MESSAGE,
|
|
3
|
+
popGlobalErrorMessage,
|
|
4
|
+
PUSH_GLOBAL_ERROR_MESSAGE,
|
|
5
|
+
pushGlobalErrorMessage,
|
|
6
|
+
} from "./globalErrorMessages";
|
|
7
|
+
|
|
8
|
+
describe("pushGlobalErrorMessage", () => {
|
|
9
|
+
it("create action with message", () =>
|
|
10
|
+
expect(pushGlobalErrorMessage, "when called with", [{ custom: "message" }], "to equal", {
|
|
11
|
+
type: PUSH_GLOBAL_ERROR_MESSAGE,
|
|
12
|
+
payload: { custom: "message" },
|
|
13
|
+
}));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("popGlobalErrorMessage", () => {
|
|
17
|
+
it("create action", () =>
|
|
18
|
+
expect(popGlobalErrorMessage, "when called with", [], "to equal", {
|
|
19
|
+
type: POP_GLOBAL_ERROR_MESSAGE,
|
|
20
|
+
}));
|
|
21
|
+
});
|
package/src/buildStore.js
CHANGED
|
@@ -21,6 +21,7 @@ import modulesReducer from "./reducers/modules";
|
|
|
21
21
|
import metadataReducer from "./reducers/metadata";
|
|
22
22
|
import requestStatesReducer from "./reducers/requestStates";
|
|
23
23
|
import tasksReducer from "./reducers/tasks";
|
|
24
|
+
import globalErrorMessagesReducer from "./reducers/globalErrorMessages";
|
|
24
25
|
|
|
25
26
|
window.BUILD_ID = BUILD_ID;
|
|
26
27
|
window.BUILD_NUMBER = BUILD_NUMBER;
|
|
@@ -67,6 +68,7 @@ const buildStore = (reducers, devOptions = {}) => {
|
|
|
67
68
|
metadata: metadataReducer,
|
|
68
69
|
requestStates: requestStatesReducer,
|
|
69
70
|
tasks: tasksReducer,
|
|
71
|
+
globalErrorMessages: globalErrorMessagesReducer,
|
|
70
72
|
});
|
|
71
73
|
const rootReducer = buildReducer(reducers);
|
|
72
74
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
4
|
+
import sharedMessages from "../../../../sharedMessages";
|
|
5
|
+
import Grid from "@material-ui/core/Grid";
|
|
6
|
+
import ListItemText from "@material-ui/core/ListItemText";
|
|
7
|
+
import List from "@material-ui/core/List";
|
|
8
|
+
import ListItem from "@material-ui/core/ListItem";
|
|
9
|
+
import ListItemIcon from "@material-ui/core/ListItemIcon";
|
|
10
|
+
import LookupDisplayValue from "./LookupDisplayValue";
|
|
11
|
+
import ActionModal from "./ActionModal";
|
|
12
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
13
|
+
import { firstDialogErrorMessageSelector } from "../../../../selectors/globalErrorMessages";
|
|
14
|
+
import { popGlobalErrorMessage } from "../../../../actions/globalErrorMessages";
|
|
15
|
+
|
|
16
|
+
const useStyles = makeStyles(theme => ({
|
|
17
|
+
grid: {
|
|
18
|
+
maxHeight: "40vh",
|
|
19
|
+
overflowY: "auto",
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const GlobalErrorMessagesModal = ({ children }) => {
|
|
24
|
+
const classes = useStyles();
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
const dispatch = useDispatch();
|
|
27
|
+
|
|
28
|
+
const msg = useSelector(firstDialogErrorMessageSelector);
|
|
29
|
+
|
|
30
|
+
if (msg === null) {
|
|
31
|
+
return <>{children}</>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const closeCallback = () => {
|
|
35
|
+
dispatch(popGlobalErrorMessage());
|
|
36
|
+
};
|
|
37
|
+
const actions = [{ label: sharedMessages.close, isPrimary: true, handler: closeCallback }];
|
|
38
|
+
|
|
39
|
+
let content = (
|
|
40
|
+
<Grid container spacing={2} className={classes.grid}>
|
|
41
|
+
<Grid container item spacing={0}>
|
|
42
|
+
{msg.description && (
|
|
43
|
+
<Grid item xs={12}>
|
|
44
|
+
{msg.description}
|
|
45
|
+
</Grid>
|
|
46
|
+
)}
|
|
47
|
+
|
|
48
|
+
{msg.messages?.length > 0 && (
|
|
49
|
+
<Grid item xs={12}>
|
|
50
|
+
<List className={classes.root}>
|
|
51
|
+
{msg.messages.map((msg, index) => {
|
|
52
|
+
const hasLookup = msg.lookupModule && msg.lookupName && msg.lookupKey;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ListItem key={index}>
|
|
56
|
+
<ListItemIcon>●</ListItemIcon>
|
|
57
|
+
<ListItemText>
|
|
58
|
+
{hasLookup && (
|
|
59
|
+
<LookupDisplayValue
|
|
60
|
+
moduleName={msg.lookupModule}
|
|
61
|
+
lookupName={msg.lookupName}
|
|
62
|
+
lookupKey={msg.lookupKey}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
{!hasLookup && msg.message}
|
|
66
|
+
</ListItemText>
|
|
67
|
+
</ListItem>
|
|
68
|
+
);
|
|
69
|
+
})}
|
|
70
|
+
</List>
|
|
71
|
+
</Grid>
|
|
72
|
+
)}
|
|
73
|
+
</Grid>
|
|
74
|
+
</Grid>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
{children}
|
|
80
|
+
{
|
|
81
|
+
<ActionModal
|
|
82
|
+
title={msg.title || formatMessage(sharedMessages.error)}
|
|
83
|
+
message={content}
|
|
84
|
+
open={true}
|
|
85
|
+
actions={actions}
|
|
86
|
+
/>
|
|
87
|
+
}
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default GlobalErrorMessagesModal;
|