@beinformed/ui 1.20.2 → 1.20.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/constants/Constants.js +0 -15
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/constants/Settings.js +6 -0
  5. package/esm/constants/Settings.js.map +1 -1
  6. package/esm/hooks/useAuthentication.js +41 -5
  7. package/esm/hooks/useAuthentication.js.map +1 -1
  8. package/esm/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  9. package/esm/i18n/translations/beinformed_error_messages_en.nl.js.map +1 -1
  10. package/esm/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  11. package/esm/i18n/translations/beinformed_error_messages_nl.nl.js.map +1 -1
  12. package/esm/models/application/ApplicationModel.js +6 -1
  13. package/esm/models/application/ApplicationModel.js.map +1 -1
  14. package/esm/models/form/FormModel.js +7 -6
  15. package/esm/models/form/FormModel.js.map +1 -1
  16. package/esm/redux/_modularui/actions.js +1 -1
  17. package/esm/redux/_modularui/actions.js.map +1 -1
  18. package/esm/redux/actions/Authorization.js +5 -9
  19. package/esm/redux/actions/Authorization.js.map +1 -1
  20. package/esm/redux/actions/Error.js +3 -1
  21. package/esm/redux/actions/Error.js.map +1 -1
  22. package/esm/redux/actions/SignIn.js +7 -0
  23. package/esm/redux/actions/SignIn.js.map +1 -1
  24. package/esm/redux/index.js +3 -1
  25. package/esm/redux/index.js.map +1 -1
  26. package/esm/redux/selectors/index.js +2 -0
  27. package/esm/redux/selectors/index.js.map +1 -0
  28. package/esm/redux/types.js.map +1 -1
  29. package/lib/constants/Constants.js +2 -20
  30. package/lib/constants/Constants.js.flow +0 -15
  31. package/lib/constants/Constants.js.map +1 -1
  32. package/lib/constants/Settings.js +6 -0
  33. package/lib/constants/Settings.js.flow +9 -0
  34. package/lib/constants/Settings.js.map +1 -1
  35. package/lib/hooks/useAuthentication.js +49 -5
  36. package/lib/hooks/useAuthentication.js.flow +42 -3
  37. package/lib/hooks/useAuthentication.js.map +1 -1
  38. package/lib/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  39. package/lib/i18n/translations/beinformed_error_messages_en.nl.js.flow +3 -2
  40. package/lib/i18n/translations/beinformed_error_messages_en.nl.js.map +1 -1
  41. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  42. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js.flow +4 -3
  43. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js.map +1 -1
  44. package/lib/models/application/ApplicationModel.js +7 -1
  45. package/lib/models/application/ApplicationModel.js.flow +7 -1
  46. package/lib/models/application/ApplicationModel.js.map +1 -1
  47. package/lib/models/form/FormModel.js +7 -7
  48. package/lib/models/form/FormModel.js.flow +2 -3
  49. package/lib/models/form/FormModel.js.map +1 -1
  50. package/lib/redux/_modularui/actions.js +1 -1
  51. package/lib/redux/_modularui/actions.js.flow +1 -4
  52. package/lib/redux/_modularui/actions.js.map +1 -1
  53. package/lib/redux/actions/Authorization.js +7 -12
  54. package/lib/redux/actions/Authorization.js.flow +4 -16
  55. package/lib/redux/actions/Authorization.js.map +1 -1
  56. package/lib/redux/actions/Error.js +4 -1
  57. package/lib/redux/actions/Error.js.flow +3 -1
  58. package/lib/redux/actions/Error.js.map +1 -1
  59. package/lib/redux/actions/SignIn.js +12 -2
  60. package/lib/redux/actions/SignIn.js.flow +11 -2
  61. package/lib/redux/actions/SignIn.js.map +1 -1
  62. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +4 -18
  63. package/lib/redux/index.js +14 -0
  64. package/lib/redux/index.js.flow +3 -0
  65. package/lib/redux/index.js.map +1 -1
  66. package/lib/redux/selectors/index.js +21 -0
  67. package/lib/redux/selectors/index.js.flow +2 -0
  68. package/lib/redux/selectors/index.js.map +1 -0
  69. package/lib/redux/types.js.flow +2 -2
  70. package/lib/redux/types.js.map +1 -1
  71. package/package.json +19 -18
  72. package/src/constants/Constants.js +0 -15
  73. package/src/constants/Settings.js +9 -0
  74. package/src/hooks/useAuthentication.js +42 -3
  75. package/src/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  76. package/src/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  77. package/src/models/application/ApplicationModel.js +7 -1
  78. package/src/models/form/FormModel.js +2 -3
  79. package/src/redux/_modularui/actions.js +1 -4
  80. package/src/redux/actions/Authorization.js +4 -16
  81. package/src/redux/actions/Error.js +3 -1
  82. package/src/redux/actions/SignIn.js +11 -2
  83. package/src/redux/actions/__tests__/Authorization.spec.js +4 -18
  84. package/src/redux/index.js +3 -0
  85. package/src/redux/selectors/index.js +2 -0
  86. package/src/redux/types.js +2 -2
@@ -1,7 +1,6 @@
1
1
  // @flow
2
2
  import flattenDeep from "lodash/flattenDeep";
3
3
  import deepmerge from "deepmerge";
4
- import { get } from "lodash";
5
4
 
6
5
  import { has } from "../../utils/helpers/objects";
7
6
 
@@ -156,11 +155,11 @@ class FormModel extends ResourceModel {
156
155
  ): string | null {
157
156
  // cancel button labels are defined on the form
158
157
  if (buttonType === "cancel") {
159
- return get(this.buttonLabels, "cancel", null);
158
+ return this.buttonLabels?.cancel ?? null;
160
159
  }
161
160
 
162
161
  // all other form related button labels are defined on the object
163
- return get(this.currentFormObject?.buttonLabels, buttonType, null);
162
+ return this.currentFormObject?.buttonLabels?.[buttonType] ?? null;
164
163
  }
165
164
 
166
165
  /**
@@ -116,10 +116,7 @@ export const loadModel = (
116
116
  return {
117
117
  type: "NO_ACTION",
118
118
  };
119
- } else if (
120
- errorResponse.isResourceNotFoundAfterReload ||
121
- errorResponse.isInvalidUsername
122
- ) {
119
+ } else if (errorResponse.isResourceNotFoundAfterReload) {
123
120
  return removeModelByKey(key);
124
121
  }
125
122
 
@@ -1,11 +1,8 @@
1
1
  // @flow
2
- import { LOGIN_PATH, NOTIFICATION_TYPES } from "../../constants/Constants";
3
-
4
2
  import ErrorResponse from "../../models/error/ErrorResponse";
5
3
 
6
4
  import { replace } from "../_router/actions";
7
5
  import { logoutSuccess } from "./SignOut";
8
- import { showNotification } from "./Notification";
9
6
 
10
7
  import Cache from "../../utils/browser/Cache";
11
8
 
@@ -16,6 +13,7 @@ import { reloadApplication } from "./Application";
16
13
  import { getSetting } from "../../constants";
17
14
 
18
15
  import type { ThunkAction } from "../types";
16
+ import { sendAuthenticationError } from "./SignIn";
19
17
 
20
18
  /**
21
19
  */
@@ -40,28 +38,18 @@ export const handleUnauthorized =
40
38
  dispatch(reloadApplication());
41
39
  }
42
40
 
43
- // set logged auth
41
+ // set logged out
44
42
  dispatch(logoutSuccess());
45
43
 
46
44
  Cache.removeItem("auth");
47
45
 
48
46
  if (errorResponse.isInvalidUsername) {
49
- const WARNING_TIMEOUT = 4000;
50
- dispatch(
51
- showNotification(
52
- NOTIFICATION_TYPES.WARNING,
53
- {
54
- id: errorResponse.id,
55
- defaultMessage: errorResponse.message,
56
- },
57
- null,
58
- WARNING_TIMEOUT
59
- )
60
- );
47
+ dispatch(sendAuthenticationError(errorResponse.message));
61
48
  }
62
49
 
63
50
  // add current location as from location before redirect
64
51
  const location = getState().router.location;
52
+ const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
65
53
  if (location?.pathname !== LOGIN_PATH) {
66
54
  const locationFrom = location?.state?.from;
67
55
  return dispatch(
@@ -1,5 +1,6 @@
1
1
  // @flow
2
- import { LOGOUT_PATH, IS_SERVER } from "../../constants/Constants";
2
+ import { IS_SERVER } from "../../constants/Constants";
3
+ import { getSetting } from "../../constants/Settings";
3
4
 
4
5
  import ErrorResponse from "../../models/error/ErrorResponse";
5
6
 
@@ -39,6 +40,7 @@ const defaultErrorResponseHandler: DefaultErrorResponseHandler =
39
40
  }
40
41
 
41
42
  if (error.isBlocked || error.isConcurrentUser) {
43
+ const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
42
44
  dispatch(push(LOGOUT_PATH));
43
45
  }
44
46
 
@@ -9,7 +9,7 @@ import { push } from "../_router/actions";
9
9
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
10
10
 
11
11
  import type {
12
- LoginFailedAction,
12
+ SendAuthenticationErrorAction,
13
13
  ResetAuthErrorsAction,
14
14
  LoginSuccessAction,
15
15
  ThunkAction,
@@ -18,7 +18,16 @@ import type {
18
18
  /**
19
19
  * Send login failed action
20
20
  */
21
- export const loginFailed = (errorMessage: string): LoginFailedAction => ({
21
+ export const loginFailed = (
22
+ errorMessage: string
23
+ ): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);
24
+
25
+ /**
26
+ * Send authentication error action
27
+ */
28
+ export const sendAuthenticationError = (
29
+ errorMessage: string
30
+ ): SendAuthenticationErrorAction => ({
22
31
  type: "AUTHENTICATION_ERROR",
23
32
  payload: errorMessage,
24
33
  });
@@ -60,15 +60,8 @@ describe("authorization actions", () => {
60
60
  type: "AUTHENTICATION_LOGOUT",
61
61
  },
62
62
  {
63
- type: "SHOW_NOTIFICATION",
64
- payload: {
65
- error: null,
66
- message: {
67
- defaultMessage: "Error.Authentication.InvalidUsername",
68
- id: "Error.Authentication.InvalidUsername",
69
- },
70
- type: "WARNING",
71
- },
63
+ type: "AUTHENTICATION_ERROR",
64
+ payload: "Error.Authentication.InvalidUsername",
72
65
  },
73
66
  {
74
67
  type: "ROUTER/REPLACE",
@@ -114,15 +107,8 @@ describe("authorization actions", () => {
114
107
  type: "AUTHENTICATION_LOGOUT",
115
108
  },
116
109
  {
117
- type: "SHOW_NOTIFICATION",
118
- payload: {
119
- error: null,
120
- message: {
121
- defaultMessage: "Error.Authentication.InvalidUsername",
122
- id: "Error.Authentication.InvalidUsername",
123
- },
124
- type: "WARNING",
125
- },
110
+ type: "AUTHENTICATION_ERROR",
111
+ payload: "Error.Authentication.InvalidUsername",
126
112
  },
127
113
  {
128
114
  type: "ROUTER/REPLACE",
@@ -21,4 +21,7 @@ export * from "./connectors/index";
21
21
  // REDUCERS
22
22
  export * from "./reducers/index";
23
23
 
24
+ // SELECTORS
25
+ export * from "./selectors/index";
26
+
24
27
  export type * from "./types";
@@ -0,0 +1,2 @@
1
+ // @flow
2
+ export * from "./i18n";
@@ -103,7 +103,7 @@ export type UpdateProgressAction = {
103
103
  payload: { percentComplete: number },
104
104
  };
105
105
 
106
- export type LoginFailedAction = {
106
+ export type SendAuthenticationErrorAction = {
107
107
  type: "AUTHENTICATION_ERROR",
108
108
  payload: string,
109
109
  };
@@ -151,8 +151,8 @@ export type ReduxAction =
151
151
  | FinishProgressAction
152
152
  | ResetProgressAction
153
153
  | UpdateProgressAction
154
- | LoginFailedAction
155
154
  | ResetAuthErrorsAction
155
+ | SendAuthenticationErrorAction
156
156
  | LoginSuccessAction
157
157
  | ChangePasswordAction
158
158
  | LogoutSuccessAction