@beinformed/ui 1.57.0-contextpath.0 → 1.57.0

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 (185) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/esm/constants/Settings.js +10 -2
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/hooks/useModularUI.js +24 -18
  5. package/esm/hooks/useModularUI.js.map +1 -1
  6. package/esm/hooks/useModularUIBasic.js +52 -41
  7. package/esm/hooks/useModularUIBasic.js.map +1 -1
  8. package/esm/models/concepts/ConceptDetailModel.js +1 -8
  9. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  10. package/esm/models/concepts/ConceptIndexModel.js +1 -1
  11. package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
  12. package/esm/models/concepts/ConceptLinkModel.js +8 -9
  13. package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
  14. package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
  15. package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  16. package/esm/models/concepts/SourceReferenceCollection.js +3 -1
  17. package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
  18. package/esm/models/concepts/SourceReferenceModel.js +9 -3
  19. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  20. package/esm/models/content/ContentLinkModel.js +10 -4
  21. package/esm/models/content/ContentLinkModel.js.map +1 -1
  22. package/esm/models/content/SectionModel.js +10 -6
  23. package/esm/models/content/SectionModel.js.map +1 -1
  24. package/esm/models/error/ErrorResponse.js +20 -5
  25. package/esm/models/error/ErrorResponse.js.map +1 -1
  26. package/esm/models/href/Href.js +21 -4
  27. package/esm/models/href/Href.js.map +1 -1
  28. package/esm/models/list/ListItemCollection.js +1 -1
  29. package/esm/models/list/ListItemCollection.js.map +1 -1
  30. package/esm/modularui/CaptchaRequest.js +12 -3
  31. package/esm/modularui/CaptchaRequest.js.map +1 -1
  32. package/esm/modularui/ModularUIRequest.js +1 -1
  33. package/esm/modularui/ModularUIRequest.js.map +1 -1
  34. package/esm/modularui/UploadRequest.js +7 -3
  35. package/esm/modularui/UploadRequest.js.map +1 -1
  36. package/esm/redux/_modularui/ModularUIActions.js +11 -9
  37. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  38. package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
  39. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  40. package/esm/redux/_modularui/ModularUIReducer.js +2 -1
  41. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  42. package/esm/redux/_modularui/ModularUISelectors.js +7 -6
  43. package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
  44. package/esm/redux/_modularui/types.js.map +1 -1
  45. package/esm/redux/actions/Application.js +11 -6
  46. package/esm/redux/actions/Application.js.map +1 -1
  47. package/esm/redux/connectors/PanelRenderer.js +0 -2
  48. package/esm/redux/connectors/PanelRenderer.js.map +1 -1
  49. package/esm/utils/helpers/checkResource.js +0 -2
  50. package/esm/utils/helpers/checkResource.js.map +1 -1
  51. package/esm/utils/helpers/repositoryResource.js +6 -5
  52. package/esm/utils/helpers/repositoryResource.js.map +1 -1
  53. package/lib/constants/Settings.js +10 -2
  54. package/lib/constants/Settings.js.flow +8 -2
  55. package/lib/constants/Settings.js.map +1 -1
  56. package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
  57. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
  58. package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
  59. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
  60. package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
  61. package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
  62. package/lib/hooks/useModularUI.js +23 -17
  63. package/lib/hooks/useModularUI.js.flow +31 -16
  64. package/lib/hooks/useModularUI.js.map +1 -1
  65. package/lib/hooks/useModularUIBasic.js +52 -41
  66. package/lib/hooks/useModularUIBasic.js.flow +66 -50
  67. package/lib/hooks/useModularUIBasic.js.map +1 -1
  68. package/lib/models/concepts/ConceptDetailModel.js +1 -8
  69. package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
  70. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  71. package/lib/models/concepts/ConceptIndexModel.js +1 -1
  72. package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
  73. package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
  74. package/lib/models/concepts/ConceptLinkModel.js +8 -9
  75. package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
  76. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  77. package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
  78. package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
  79. package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  80. package/lib/models/concepts/SourceReferenceCollection.js +3 -1
  81. package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
  82. package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
  83. package/lib/models/concepts/SourceReferenceModel.js +9 -3
  84. package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
  85. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  86. package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
  87. package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
  88. package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
  89. package/lib/models/content/ContentLinkModel.js +9 -4
  90. package/lib/models/content/ContentLinkModel.js.flow +19 -4
  91. package/lib/models/content/ContentLinkModel.js.map +1 -1
  92. package/lib/models/content/SectionModel.js +10 -6
  93. package/lib/models/content/SectionModel.js.flow +31 -5
  94. package/lib/models/content/SectionModel.js.map +1 -1
  95. package/lib/models/error/ErrorResponse.js +20 -5
  96. package/lib/models/error/ErrorResponse.js.flow +34 -5
  97. package/lib/models/error/ErrorResponse.js.map +1 -1
  98. package/lib/models/href/Href.js +21 -4
  99. package/lib/models/href/Href.js.flow +21 -4
  100. package/lib/models/href/Href.js.map +1 -1
  101. package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
  102. package/lib/models/list/ListItemCollection.js +1 -1
  103. package/lib/models/list/ListItemCollection.js.flow +2 -0
  104. package/lib/models/list/ListItemCollection.js.map +1 -1
  105. package/lib/modularui/CaptchaRequest.js +11 -2
  106. package/lib/modularui/CaptchaRequest.js.flow +17 -3
  107. package/lib/modularui/CaptchaRequest.js.map +1 -1
  108. package/lib/modularui/ModularUIRequest.js +1 -1
  109. package/lib/modularui/ModularUIRequest.js.flow +3 -1
  110. package/lib/modularui/ModularUIRequest.js.map +1 -1
  111. package/lib/modularui/UploadRequest.js +6 -2
  112. package/lib/modularui/UploadRequest.js.flow +12 -2
  113. package/lib/modularui/UploadRequest.js.map +1 -1
  114. package/lib/redux/_modularui/ModularUIActions.js +11 -9
  115. package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
  116. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  117. package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
  118. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
  119. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  120. package/lib/redux/_modularui/ModularUIReducer.js +2 -1
  121. package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
  122. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  123. package/lib/redux/_modularui/ModularUISelectors.js +5 -6
  124. package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
  125. package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
  126. package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
  127. package/lib/redux/_modularui/types.js.flow +1 -0
  128. package/lib/redux/_modularui/types.js.map +1 -1
  129. package/lib/redux/actions/Application.js +10 -5
  130. package/lib/redux/actions/Application.js.flow +16 -5
  131. package/lib/redux/actions/Application.js.map +1 -1
  132. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
  133. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
  134. package/lib/redux/connectors/PanelRenderer.js +0 -2
  135. package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
  136. package/lib/redux/connectors/PanelRenderer.js.map +1 -1
  137. package/lib/utils/helpers/checkResource.js +0 -2
  138. package/lib/utils/helpers/checkResource.js.flow +0 -2
  139. package/lib/utils/helpers/checkResource.js.map +1 -1
  140. package/lib/utils/helpers/repositoryResource.js +6 -5
  141. package/lib/utils/helpers/repositoryResource.js.flow +8 -6
  142. package/lib/utils/helpers/repositoryResource.js.map +1 -1
  143. package/package.json +18 -18
  144. package/src/constants/Settings.js +8 -2
  145. package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
  146. package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
  147. package/src/hooks/__tests__/useForm.spec.js +14 -12
  148. package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
  149. package/src/hooks/__tests__/useModels.spec.js +3 -12
  150. package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
  151. package/src/hooks/useModularUI.js +31 -16
  152. package/src/hooks/useModularUIBasic.js +66 -50
  153. package/src/models/concepts/ConceptDetailModel.js +2 -7
  154. package/src/models/concepts/ConceptIndexModel.js +7 -1
  155. package/src/models/concepts/ConceptLinkModel.js +14 -9
  156. package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
  157. package/src/models/concepts/SourceReferenceCollection.js +8 -1
  158. package/src/models/concepts/SourceReferenceModel.js +19 -3
  159. package/src/models/concepts/__mock__/conceptindex.js +15 -0
  160. package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
  161. package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
  162. package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
  163. package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
  164. package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
  165. package/src/models/content/ContentLinkModel.js +19 -4
  166. package/src/models/content/SectionModel.js +31 -5
  167. package/src/models/error/ErrorResponse.js +34 -5
  168. package/src/models/href/Href.js +21 -4
  169. package/src/models/href/__tests__/Href.spec.js +9 -3
  170. package/src/models/list/ListItemCollection.js +2 -0
  171. package/src/modularui/CaptchaRequest.js +17 -3
  172. package/src/modularui/ModularUIRequest.js +3 -1
  173. package/src/modularui/UploadRequest.js +12 -2
  174. package/src/redux/_modularui/ModularUIActions.js +20 -10
  175. package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
  176. package/src/redux/_modularui/ModularUIReducer.js +1 -0
  177. package/src/redux/_modularui/ModularUISelectors.js +22 -10
  178. package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
  179. package/src/redux/_modularui/types.js +1 -0
  180. package/src/redux/actions/Application.js +16 -5
  181. package/src/redux/actions/__tests__/Application.spec.js +1 -8
  182. package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
  183. package/src/redux/connectors/PanelRenderer.js +0 -1
  184. package/src/utils/helpers/checkResource.js +0 -2
  185. package/src/utils/helpers/repositoryResource.js +8 -6
@@ -151,7 +151,9 @@ describe("href spec", () => {
151
151
  hash: "",
152
152
  pathname: "/BeInformed",
153
153
  search: "",
154
- state: null,
154
+ state: {
155
+ contextPath: "/BeInformed",
156
+ },
155
157
  });
156
158
 
157
159
  const listHref = new Href("/BeInformed/list");
@@ -161,7 +163,9 @@ describe("href spec", () => {
161
163
  hash: "",
162
164
  pathname: "/BeInformed/list",
163
165
  search: "",
164
- state: null,
166
+ state: {
167
+ contextPath: "/BeInformed",
168
+ },
165
169
  });
166
170
 
167
171
  const listHrefFromHref = new Href(listHref);
@@ -170,7 +174,9 @@ describe("href spec", () => {
170
174
  hash: "",
171
175
  pathname: "/BeInformed/list",
172
176
  search: "",
173
- state: null,
177
+ state: {
178
+ contextPath: "/BeInformed",
179
+ },
174
180
  });
175
181
  });
176
182
  });
@@ -36,6 +36,8 @@ class ListItemCollection extends BaseCollection<ListItemModel> {
36
36
  key,
37
37
  listitemData,
38
38
  listitemContributions,
39
+ list.origin,
40
+ list.contextPath,
39
41
  );
40
42
  });
41
43
 
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import xhr from "../utils/fetch/xhr";
3
- import { getCaptchaPath, HTTP_METHODS } from "../constants";
3
+ import { getBasePath, getCaptchaPath, HTTP_METHODS } from "../constants";
4
4
 
5
5
  type CaptchaInitialResponse = {
6
6
  tokenId: string,
@@ -25,11 +25,25 @@ type CaptchaResponse = {
25
25
  error: { id: string } | null,
26
26
  };
27
27
 
28
+ type CaptchaRequestOptions = {
29
+ origin?: string,
30
+ contextPath?: string,
31
+ };
32
+
28
33
  /**
29
34
  */
30
35
  class CaptchaRequest {
31
36
  _tokenId: string;
32
37
  _image: string;
38
+ _origin: string = "";
39
+ _contextPath: string = getBasePath();
40
+
41
+ /**
42
+ */
43
+ CaptchaRequest(options?: CaptchaRequestOptions) {
44
+ this._origin = options?.origin || "";
45
+ this._contextPath = options?.contextPath || getBasePath();
46
+ }
33
47
 
34
48
  /**
35
49
  */
@@ -55,7 +69,7 @@ class CaptchaRequest {
55
69
  */
56
70
  init(): Promise<CaptchaResponse> {
57
71
  return xhr({
58
- url: getCaptchaPath(),
72
+ url: getCaptchaPath(this._contextPath, this._origin),
59
73
  }).then((response) => this.captchaResponse(response));
60
74
  }
61
75
 
@@ -64,7 +78,7 @@ class CaptchaRequest {
64
78
  */
65
79
  send(answer?: string): Promise<CaptchaResponse> {
66
80
  return xhr({
67
- url: getCaptchaPath(),
81
+ url: getCaptchaPath(this._contextPath, this._origin),
68
82
  method: HTTP_METHODS.POST,
69
83
  data: {
70
84
  tokenId: this._tokenId ?? "",
@@ -724,7 +724,9 @@ class ModularUIRequest {
724
724
  reason,
725
725
  );
726
726
  }
727
- errorChildModels.push(new ErrorResponse(reason));
727
+ errorChildModels.push(
728
+ new ErrorResponse(reason, "", this.origin, this.contextPath),
729
+ );
728
730
  } else {
729
731
  resolvedChildModels.push(childModel.value);
730
732
  }
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import { getUploadPath, HTTP_METHODS } from "../constants";
2
+ import { getBasePath, getUploadPath, HTTP_METHODS } from "../constants";
3
3
 
4
4
  import xhr from "../utils/fetch/xhr";
5
5
 
@@ -11,6 +11,11 @@ import ErrorModel from "../models/error/ErrorModel";
11
11
 
12
12
  type ProgressHandler = (file: File, uploadInfo: Object) => void;
13
13
 
14
+ type UploadRequestOptions = {
15
+ origin?: string,
16
+ contextPath?: string,
17
+ };
18
+
14
19
  type UploadResponse = {
15
20
  token: string,
16
21
  };
@@ -25,6 +30,8 @@ class UploadRequest {
25
30
  acceptedFiles: Array<string>,
26
31
  };
27
32
  _progressHandler: ProgressHandler;
33
+ _origin: string = "";
34
+ _contextPath: string = getBasePath();
28
35
 
29
36
  constructor(
30
37
  uploadConstraints: {
@@ -33,9 +40,12 @@ class UploadRequest {
33
40
  acceptedFiles: Array<string>,
34
41
  },
35
42
  progressHandler: ProgressHandler,
43
+ options?: UploadRequestOptions,
36
44
  ) {
37
45
  this._uploadConstraints = uploadConstraints;
38
46
  this._progressHandler = progressHandler;
47
+ this._origin = options?.origin || "";
48
+ this._contextPath = options?.contextPath || getBasePath();
39
49
  }
40
50
 
41
51
  /**
@@ -102,7 +112,7 @@ class UploadRequest {
102
112
  }
103
113
 
104
114
  return xhr({
105
- url: getUploadPath(),
115
+ url: getUploadPath(this._contextPath, this._origin),
106
116
  method: HTTP_METHODS.POST,
107
117
  headers: {
108
118
  "Content-Type": file.type,
@@ -109,6 +109,7 @@ export const loadModel = (
109
109
  ): ModularUIAction => ({
110
110
  type: "MODULARUI/FETCH",
111
111
  payload: {
112
+ key,
112
113
  origin: options?.origin,
113
114
  contextPath: options?.contextPath,
114
115
  href:
@@ -129,7 +130,12 @@ export const loadModel = (
129
130
  /**
130
131
  */
131
132
  errorAction: (error) => {
132
- const errorResponse = new ErrorResponse(error, key);
133
+ const errorResponse = new ErrorResponse(
134
+ error,
135
+ key,
136
+ options?.origin,
137
+ options?.contextPath,
138
+ );
133
139
  if (errorResponse.isChangePassword) {
134
140
  return {
135
141
  type: "NO_ACTION",
@@ -151,20 +157,24 @@ export const loadModularUI =
151
157
  href: Href | string,
152
158
  options?: RequestModularUIOptions,
153
159
  ): ThunkAction =>
154
- (dispatch: Dispatch) => {
155
- dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
160
+ (dispatch: Dispatch, getState) => {
161
+ const modularuiStore = getState()?.modularui;
162
+ if (
163
+ modularuiStore &&
164
+ modularuiStore[key]?.status === MODULARUI_STATUS.LOADING
165
+ ) {
166
+ // don't create duplicate requests during loading
167
+ return dispatch({
168
+ type: "NO_ACTION",
169
+ });
170
+ }
171
+
156
172
  dispatch(startProgress());
157
173
 
158
174
  const loadModelPromise = dispatch(loadModel(key, href, options));
159
175
 
160
176
  return Promise.resolve(loadModelPromise)
161
- .then((response) => {
162
- if (response?.type === "FINISH_PROGRESS") {
163
- dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));
164
- }
165
-
166
- return dispatch(finishProgress());
167
- })
177
+ .then(() => dispatch(finishProgress()))
168
178
  .catch((error) => dispatch(handleError(error)));
169
179
  };
170
180
 
@@ -1,11 +1,12 @@
1
1
  // @flow
2
2
  import ModularUIRequest from "../../modularui/ModularUIRequest";
3
- import { HTTP_METHODS } from "../../constants/Constants";
3
+ import { HTTP_METHODS, MODULARUI_STATUS } from "../../constants/Constants";
4
4
 
5
5
  import { startProgress, finishProgress } from "../actions/ProgressIndicator";
6
-
7
6
  import { handleError } from "../actions/Error";
8
7
 
8
+ import { updateStatus } from "./ModularUIActions";
9
+
9
10
  import type { Middleware, MiddlewareAPI } from "redux";
10
11
  import type {
11
12
  ReduxAction,
@@ -127,11 +128,13 @@ const handleFetch = (
127
128
  ) => {
128
129
  dispatch(startProgress());
129
130
 
130
- const { successAction, errorAction, ...requestOptions } = action.payload;
131
+ const { key, successAction, errorAction, ...requestOptions } = action.payload;
131
132
  requestOptions.locale = locale;
132
133
 
133
134
  const modularuiRequest = createRequest(requestOptions);
134
135
 
136
+ dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
137
+
135
138
  return modularuiRequest
136
139
  .fetch()
137
140
  .then((model) => responseHandler(next, dispatch, successAction, model))
@@ -46,6 +46,7 @@ const setModel = (
46
46
  ...state[key],
47
47
  model,
48
48
  lastModification: Date.now(),
49
+ status: MODULARUI_STATUS.FINISHED,
49
50
  },
50
51
  };
51
52
  }
@@ -1,5 +1,9 @@
1
1
  // @flow
2
- import { createSelectorCreator, defaultMemoize } from "reselect";
2
+ import {
3
+ createSelector,
4
+ createSelectorCreator,
5
+ defaultMemoize,
6
+ } from "reselect";
3
7
  import { has } from "../../utils/helpers/objects";
4
8
 
5
9
  import Href from "../../models/href/Href";
@@ -12,6 +16,7 @@ import FormModel from "../../models/form/FormModel";
12
16
 
13
17
  import type { ReduxState, PreferenceValue } from "../types";
14
18
  import type { ModularUIModel } from "../../models/types";
19
+ import { MODULARUI_STATUS } from "../../constants";
15
20
 
16
21
  /**
17
22
  */
@@ -298,13 +303,20 @@ export const getModelsByType = (
298
303
 
299
304
  /**
300
305
  */
301
- export const getAllFinishedModels = (
306
+ export const getAllFinishedModels: (
302
307
  state: ReduxState,
303
- ): Array<ModularUIModel> => {
304
- if (state && state.modularui) {
305
- return Object.values(state.modularui)
306
- .filter((entry) => entry.status === "FINISHED")
307
- .map((entry) => entry.model);
308
- }
309
- return [];
310
- };
308
+ ) => Array<ModularUIModel> = createSelector(
309
+ (state: ReduxState) => state.modularui,
310
+ (modularui): Array<ModularUIModel> => {
311
+ if (modularui) {
312
+ return Object.keys(modularui)
313
+ .filter(
314
+ (key) =>
315
+ modularui[key] &&
316
+ modularui[key].status === MODULARUI_STATUS.FINISHED,
317
+ )
318
+ .map((key) => modularui[key].model);
319
+ }
320
+ return [];
321
+ },
322
+ );
@@ -134,16 +134,13 @@ describe("modularui actions", () => {
134
134
  await store.dispatch(loadModularUI("application", "/", {}));
135
135
 
136
136
  expect(store.getActions()).toStrictEqual([
137
- {
138
- type: "MODULARUI/STATUS",
139
- payload: { key: "application", status: MODULARUI_STATUS.LOADING },
140
- },
141
137
  {
142
138
  type: "START_PROGRESS",
143
139
  },
144
140
  {
145
141
  type: "MODULARUI/FETCH",
146
142
  payload: expect.objectContaining({
143
+ key: "application",
147
144
  href: new Href("/"),
148
145
  method: HTTP_METHODS.GET,
149
146
  data: undefined,
@@ -65,6 +65,7 @@ export type ErrorAction = (
65
65
  export type ModularUIAction = {
66
66
  type: "MODULARUI/FETCH",
67
67
  payload: {
68
+ key: string,
68
69
  origin?: string,
69
70
  contextPath?: string,
70
71
  href: Href,
@@ -3,7 +3,10 @@ import {
3
3
  loadModularUI,
4
4
  removeModelByKey,
5
5
  } from "../_modularui/ModularUIActions";
6
- import { allKeysByHref } from "../_modularui/ModularUISelectors";
6
+ import {
7
+ allKeysByHref,
8
+ getApplication,
9
+ } from "../_modularui/ModularUISelectors";
7
10
  import { ApplicationModel, Href } from "../../models";
8
11
  import { getLocale } from "../selectors/i18n";
9
12
 
@@ -13,15 +16,23 @@ import type { Dispatch, GetState, ThunkAction } from "../types";
13
16
  */
14
17
  export const reloadApplication =
15
18
  (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {
16
- const allKeys = allKeysByHref(getState(), "/");
19
+ const state = getState();
20
+
21
+ let applicationHref = new Href("/", "Application");
22
+ const application = getApplication(state);
23
+ if (application) {
24
+ applicationHref.contextPath = application.contextPath;
25
+ applicationHref.origin = application.origin;
26
+ }
27
+
28
+ const allKeys = allKeysByHref(state, applicationHref);
17
29
  for (const key of allKeys) {
18
30
  dispatch(removeModelByKey(key));
19
31
  }
20
32
 
21
- // TODO SBO: origin and context
22
- const modelKey = `application(/)(${getLocale(getState())})`;
33
+ const modelKey = `application(/)(${getLocale(state)})`;
23
34
  return dispatch(
24
- loadModularUI(modelKey, new Href("/", "Application"), {
35
+ loadModularUI(modelKey, applicationHref, {
25
36
  targetModel: ApplicationModel,
26
37
  }),
27
38
  );
@@ -16,14 +16,11 @@ describe("application actions", () => {
16
16
  await store.dispatch(reloadApplication());
17
17
 
18
18
  expect(store.getActions()).toStrictEqual([
19
- {
20
- type: "MODULARUI/STATUS",
21
- payload: { key: "application(/)(en)", status: "LOADING" },
22
- },
23
19
  { type: "START_PROGRESS" },
24
20
  expect.objectContaining({
25
21
  type: "MODULARUI/FETCH",
26
22
  payload: expect.objectContaining({
23
+ key: "application(/)(en)",
27
24
  href: new Href("/", "Application"),
28
25
  }),
29
26
  }),
@@ -43,10 +40,6 @@ describe("application actions", () => {
43
40
  type: "MODULARUI/REMOVE_KEY",
44
41
  payload: "/",
45
42
  },
46
- {
47
- type: "MODULARUI/STATUS",
48
- payload: { key: "application(/)(en)", status: "LOADING" },
49
- },
50
43
  { type: "START_PROGRESS" },
51
44
  expect.objectContaining({
52
45
  type: "MODULARUI/FETCH",
@@ -43,10 +43,6 @@ describe("authorization actions", () => {
43
43
  type: "MODULARUI/REMOVE_KEY",
44
44
  payload: "/",
45
45
  },
46
- {
47
- type: "MODULARUI/STATUS",
48
- payload: { key: "application(/)(en)", status: "LOADING" },
49
- },
50
46
  {
51
47
  type: "START_PROGRESS",
52
48
  },
@@ -15,7 +15,6 @@ export const connectPanel: ModularUIConnector = modularui(
15
15
  );
16
16
  }
17
17
 
18
- // TODO SBO: origin and context?
19
18
  const panelHref = href ? new Href(href) : new Href(match.url);
20
19
 
21
20
  if (match && match.isExact) {
@@ -9,7 +9,6 @@ import Href from "../../models/href/Href";
9
9
  * @returns {boolean}
10
10
  */
11
11
  export const resourceExists = (url: string | Href): boolean => {
12
- // TODO SBO: origin and context?
13
12
  const fullUrl = new Href(url).absolutehref;
14
13
 
15
14
  const xhr = new XMLHttpRequest();
@@ -29,7 +28,6 @@ export const resourceExists = (url: string | Href): boolean => {
29
28
  * @returns {boolean}
30
29
  */
31
30
  export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
32
- // TODO SBO: origin and context?
33
31
  const fullUrl = new Href(url).absolutehref;
34
32
 
35
33
  const xhr = new XMLHttpRequest();
@@ -5,16 +5,18 @@ import { getBasePath, RESOURCE_PATH } from "../../constants";
5
5
  * Creates an url to a resource in the Be Informed repository
6
6
  * Only possible when serving using the UI Servlet of Be Informed
7
7
  */
8
- export const getRepositoryResourceUrl = (resourceUrl: string): string => {
9
- const basePath = getBasePath();
10
-
11
- if (resourceUrl.startsWith(basePath)) {
8
+ export const getRepositoryResourceUrl = (
9
+ resourceUrl: string,
10
+ contextPath: string = getBasePath(),
11
+ origin: string = "",
12
+ ): string => {
13
+ if (resourceUrl.startsWith(origin + contextPath)) {
12
14
  return resourceUrl;
13
15
  }
14
16
 
15
17
  if (resourceUrl.startsWith(RESOURCE_PATH)) {
16
- return `${basePath}${resourceUrl}`;
18
+ return `${origin}${contextPath}${resourceUrl}`;
17
19
  }
18
20
 
19
- return `${basePath}${RESOURCE_PATH}${resourceUrl}`;
21
+ return `${origin}${contextPath}${RESOURCE_PATH}${resourceUrl}`;
20
22
  };