@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.
- package/CHANGELOG.md +63 -0
- package/esm/constants/Settings.js +10 -2
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useModularUI.js +24 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +52 -41
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +1 -8
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +8 -9
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +3 -1
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +9 -3
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +10 -4
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +10 -6
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +20 -5
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/href/Href.js +21 -4
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/list/ListItemCollection.js +1 -1
- package/esm/models/list/ListItemCollection.js.map +1 -1
- package/esm/modularui/CaptchaRequest.js +12 -3
- package/esm/modularui/CaptchaRequest.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/UploadRequest.js +7 -3
- package/esm/modularui/UploadRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +11 -9
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +2 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +7 -6
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +11 -6
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +0 -2
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +0 -2
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/esm/utils/helpers/repositoryResource.js +6 -5
- package/esm/utils/helpers/repositoryResource.js.map +1 -1
- package/lib/constants/Settings.js +10 -2
- package/lib/constants/Settings.js.flow +8 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
- package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
- package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
- package/lib/hooks/useModularUI.js +23 -17
- package/lib/hooks/useModularUI.js.flow +31 -16
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +52 -41
- package/lib/hooks/useModularUIBasic.js.flow +66 -50
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +1 -8
- package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +8 -9
- package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +3 -1
- package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +9 -3
- package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
- package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/models/content/ContentLinkModel.js +9 -4
- package/lib/models/content/ContentLinkModel.js.flow +19 -4
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +10 -6
- package/lib/models/content/SectionModel.js.flow +31 -5
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +20 -5
- package/lib/models/error/ErrorResponse.js.flow +34 -5
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/href/Href.js +21 -4
- package/lib/models/href/Href.js.flow +21 -4
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
- package/lib/models/list/ListItemCollection.js +1 -1
- package/lib/models/list/ListItemCollection.js.flow +2 -0
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/modularui/CaptchaRequest.js +11 -2
- package/lib/modularui/CaptchaRequest.js.flow +17 -3
- package/lib/modularui/CaptchaRequest.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -1
- package/lib/modularui/ModularUIRequest.js.flow +3 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/UploadRequest.js +6 -2
- package/lib/modularui/UploadRequest.js.flow +12 -2
- package/lib/modularui/UploadRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +11 -9
- package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +2 -1
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +5 -6
- package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
- package/lib/redux/_modularui/types.js.flow +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +10 -5
- package/lib/redux/actions/Application.js.flow +16 -5
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
- package/lib/redux/connectors/PanelRenderer.js +0 -2
- package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +0 -2
- package/lib/utils/helpers/checkResource.js.flow +0 -2
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/lib/utils/helpers/repositoryResource.js +6 -5
- package/lib/utils/helpers/repositoryResource.js.flow +8 -6
- package/lib/utils/helpers/repositoryResource.js.map +1 -1
- package/package.json +18 -18
- package/src/constants/Settings.js +8 -2
- package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
- package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
- package/src/hooks/__tests__/useForm.spec.js +14 -12
- package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
- package/src/hooks/__tests__/useModels.spec.js +3 -12
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
- package/src/hooks/useModularUI.js +31 -16
- package/src/hooks/useModularUIBasic.js +66 -50
- package/src/models/concepts/ConceptDetailModel.js +2 -7
- package/src/models/concepts/ConceptIndexModel.js +7 -1
- package/src/models/concepts/ConceptLinkModel.js +14 -9
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/SourceReferenceCollection.js +8 -1
- package/src/models/concepts/SourceReferenceModel.js +19 -3
- package/src/models/concepts/__mock__/conceptindex.js +15 -0
- package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
- package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/models/content/ContentLinkModel.js +19 -4
- package/src/models/content/SectionModel.js +31 -5
- package/src/models/error/ErrorResponse.js +34 -5
- package/src/models/href/Href.js +21 -4
- package/src/models/href/__tests__/Href.spec.js +9 -3
- package/src/models/list/ListItemCollection.js +2 -0
- package/src/modularui/CaptchaRequest.js +17 -3
- package/src/modularui/ModularUIRequest.js +3 -1
- package/src/modularui/UploadRequest.js +12 -2
- package/src/redux/_modularui/ModularUIActions.js +20 -10
- package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/ModularUISelectors.js +22 -10
- package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
- package/src/redux/_modularui/types.js +1 -0
- package/src/redux/actions/Application.js +16 -5
- package/src/redux/actions/__tests__/Application.spec.js +1 -8
- package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
- package/src/redux/connectors/PanelRenderer.js +0 -1
- package/src/utils/helpers/checkResource.js +0 -2
- 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:
|
|
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:
|
|
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:
|
|
177
|
+
state: {
|
|
178
|
+
contextPath: "/BeInformed",
|
|
179
|
+
},
|
|
174
180
|
});
|
|
175
181
|
});
|
|
176
182
|
});
|
|
@@ -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(
|
|
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(
|
|
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
|
-
|
|
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((
|
|
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))
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import {
|
|
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
|
-
)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
.
|
|
308
|
-
|
|
309
|
-
|
|
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,
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
loadModularUI,
|
|
4
4
|
removeModelByKey,
|
|
5
5
|
} from "../_modularui/ModularUIActions";
|
|
6
|
-
import {
|
|
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
|
|
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
|
-
|
|
22
|
-
const modelKey = `application(/)(${getLocale(getState())})`;
|
|
33
|
+
const modelKey = `application(/)(${getLocale(state)})`;
|
|
23
34
|
return dispatch(
|
|
24
|
-
loadModularUI(modelKey,
|
|
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",
|
|
@@ -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 = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 `${
|
|
18
|
+
return `${origin}${contextPath}${resourceUrl}`;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
return `${
|
|
21
|
+
return `${origin}${contextPath}${RESOURCE_PATH}${resourceUrl}`;
|
|
20
22
|
};
|