@beinformed/ui 1.57.0-contextpath.1 → 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 +53 -0
- package/esm/constants/Settings.js +10 -2
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useModularUI.js +19 -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/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/connectors/PanelRenderer.js +0 -2
- package/esm/redux/connectors/PanelRenderer.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 +18 -17
- package/lib/hooks/useModularUI.js.flow +25 -15
- 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/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/__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/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 +25 -15
- 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/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/__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/repositoryResource.js +8 -6
|
@@ -19,30 +19,13 @@ describe("conceptTypeDetailModel", () => {
|
|
|
19
19
|
expect(conceptTypeDetail.backgroundColor).toBe("#FFFF3C");
|
|
20
20
|
expect(conceptTypeDetail.borderColor).toBe("#000000");
|
|
21
21
|
|
|
22
|
-
expect(conceptTypeDetail.conceptTypeHierarchy.length).toBe(2);
|
|
23
22
|
expect(
|
|
24
23
|
conceptTypeDetail.isOfConceptType(
|
|
25
|
-
"
|
|
24
|
+
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Advice%20and%20request%20business%20scenarios.bixml/ScenarioStep_Advice",
|
|
26
25
|
),
|
|
27
26
|
).toBe(true);
|
|
28
|
-
expect(
|
|
29
|
-
conceptTypeDetail.isOfConceptType("BusinessScenarios#ScenarioStep"),
|
|
30
|
-
).toBe(true);
|
|
31
27
|
expect(conceptTypeDetail.isOfConceptType("BEI_CaseManagement#Case")).toBe(
|
|
32
28
|
false,
|
|
33
29
|
);
|
|
34
|
-
|
|
35
|
-
expect(
|
|
36
|
-
conceptTypeDetail.isOfConceptType(
|
|
37
|
-
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Business%20scenarios.bixml/ScenarioStep",
|
|
38
|
-
),
|
|
39
|
-
).toBe(true);
|
|
40
|
-
|
|
41
|
-
expect(
|
|
42
|
-
conceptTypeDetail.hasMetamodelIdInHierarchy("BusinessScenarios"),
|
|
43
|
-
).toBe(true);
|
|
44
|
-
expect(
|
|
45
|
-
conceptTypeDetail.hasMetamodelIdInHierarchy("BEI_CaseManagement"),
|
|
46
|
-
).toBe(false);
|
|
47
30
|
});
|
|
48
31
|
});
|
|
@@ -8,6 +8,7 @@ import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
|
8
8
|
import LinkCollection from "../links/LinkCollection";
|
|
9
9
|
|
|
10
10
|
import type { ModularUIModel, IModelWithChildModels } from "../types";
|
|
11
|
+
import { getBasePath } from "../../constants";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Link to a concept
|
|
@@ -20,13 +21,22 @@ export default class ContentLinkModel
|
|
|
20
21
|
_entryDate: ?ISO_DATE;
|
|
21
22
|
_contentType: ContentTypeModel | null = null;
|
|
22
23
|
_items: Array<ContentLinkModel>;
|
|
24
|
+
_origin: string = "";
|
|
25
|
+
_contextPath: string = getBasePath();
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
*/
|
|
26
|
-
constructor(
|
|
29
|
+
constructor(
|
|
30
|
+
data: Object,
|
|
31
|
+
entryDate: ?ISO_DATE = null,
|
|
32
|
+
origin?: string,
|
|
33
|
+
contextPath?: string,
|
|
34
|
+
) {
|
|
27
35
|
super(data, {});
|
|
28
36
|
|
|
29
37
|
this._entryDate = entryDate;
|
|
38
|
+
this._origin = origin || "";
|
|
39
|
+
this._contextPath = contextPath || getBasePath();
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
/**
|
|
@@ -102,9 +112,12 @@ export default class ContentLinkModel
|
|
|
102
112
|
/**
|
|
103
113
|
*/
|
|
104
114
|
createEncodedHref(): Href {
|
|
105
|
-
// TODO SBO: origin and context
|
|
106
115
|
const startURI = "/content/";
|
|
107
|
-
const selfHref = new Href(
|
|
116
|
+
const selfHref = new Href(
|
|
117
|
+
this.data._links.self.href,
|
|
118
|
+
this._origin,
|
|
119
|
+
this._contextPath,
|
|
120
|
+
);
|
|
108
121
|
const href = selfHref.path;
|
|
109
122
|
|
|
110
123
|
const section = this.data.section;
|
|
@@ -140,11 +153,13 @@ export default class ContentLinkModel
|
|
|
140
153
|
*/
|
|
141
154
|
get links(): LinkCollection {
|
|
142
155
|
if (!this._links) {
|
|
143
|
-
// TODO SBO: origin and context
|
|
144
156
|
this._links = new LinkCollection(
|
|
145
157
|
Array.isArray(this.data._links)
|
|
146
158
|
? this.data._links[0]
|
|
147
159
|
: this.data._links,
|
|
160
|
+
null,
|
|
161
|
+
this._origin,
|
|
162
|
+
this._contextPath,
|
|
148
163
|
);
|
|
149
164
|
}
|
|
150
165
|
|
|
@@ -8,6 +8,7 @@ import LinkModel from "../links/LinkModel";
|
|
|
8
8
|
|
|
9
9
|
import type Href from "../href/Href";
|
|
10
10
|
import { retrieveText } from "../../utils";
|
|
11
|
+
import { getBasePath } from "../../constants";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
*/
|
|
@@ -15,11 +16,20 @@ class SectionModel extends BaseModel {
|
|
|
15
16
|
_entryDate: ISO_DATE | null;
|
|
16
17
|
_selflink: ?LinkModel;
|
|
17
18
|
_childSections: Array<SectionModel>;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
_origin: string = "";
|
|
20
|
+
_contextPath: string = getBasePath();
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
data: Object,
|
|
24
|
+
entryDate: ISO_DATE | null,
|
|
25
|
+
origin?: string,
|
|
26
|
+
contextPath?: string,
|
|
27
|
+
) {
|
|
20
28
|
super(data, {});
|
|
21
29
|
|
|
22
30
|
this._entryDate = entryDate;
|
|
31
|
+
this._origin = origin || "";
|
|
32
|
+
this._contextPath = contextPath || getBasePath();
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
/**
|
|
@@ -32,8 +42,12 @@ class SectionModel extends BaseModel {
|
|
|
32
42
|
*/
|
|
33
43
|
get selflink(): LinkModel {
|
|
34
44
|
if (!this._selflink) {
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
this._selflink = new LinkModel(
|
|
46
|
+
this.data._links?.self,
|
|
47
|
+
null,
|
|
48
|
+
this._origin,
|
|
49
|
+
this._contextPath,
|
|
50
|
+
);
|
|
37
51
|
}
|
|
38
52
|
return this._selflink;
|
|
39
53
|
}
|
|
@@ -111,6 +125,8 @@ class SectionModel extends BaseModel {
|
|
|
111
125
|
_links: childSection._links,
|
|
112
126
|
},
|
|
113
127
|
this.entryDate,
|
|
128
|
+
this._origin,
|
|
129
|
+
this._contextPath,
|
|
114
130
|
),
|
|
115
131
|
)
|
|
116
132
|
: [];
|
|
@@ -128,6 +144,8 @@ class SectionModel extends BaseModel {
|
|
|
128
144
|
_links: this.data._links,
|
|
129
145
|
},
|
|
130
146
|
this.entryDate,
|
|
147
|
+
this._origin,
|
|
148
|
+
this._contextPath,
|
|
131
149
|
);
|
|
132
150
|
}
|
|
133
151
|
|
|
@@ -138,7 +156,15 @@ class SectionModel extends BaseModel {
|
|
|
138
156
|
if (!this._childSections && this.data.childSections) {
|
|
139
157
|
this._childSections = this.data.childSections
|
|
140
158
|
.filter((childSection) => "body" in childSection)
|
|
141
|
-
.map(
|
|
159
|
+
.map(
|
|
160
|
+
(childSection) =>
|
|
161
|
+
new SectionModel(
|
|
162
|
+
childSection,
|
|
163
|
+
this.entryDate,
|
|
164
|
+
this._origin,
|
|
165
|
+
this._contextPath,
|
|
166
|
+
),
|
|
167
|
+
);
|
|
142
168
|
}
|
|
143
169
|
return this._childSections || [];
|
|
144
170
|
}
|
|
@@ -3,6 +3,7 @@ import Href from "../href/Href";
|
|
|
3
3
|
|
|
4
4
|
import type { MessageParameters } from "../../i18n/types";
|
|
5
5
|
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
6
|
+
import { getBasePath } from "../../constants";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*/
|
|
@@ -33,12 +34,23 @@ export default class ErrorResponse {
|
|
|
33
34
|
_error: Object;
|
|
34
35
|
_connectKey: ?string;
|
|
35
36
|
|
|
37
|
+
_origin: string = "";
|
|
38
|
+
_contextPath: string = getBasePath();
|
|
39
|
+
|
|
36
40
|
/**
|
|
37
41
|
* Construct ErrorResponse
|
|
38
42
|
*/
|
|
39
|
-
constructor(
|
|
43
|
+
constructor(
|
|
44
|
+
data: Object,
|
|
45
|
+
connectKey?: string,
|
|
46
|
+
origin?: string,
|
|
47
|
+
contextPath?: string,
|
|
48
|
+
) {
|
|
40
49
|
this._error = data;
|
|
41
50
|
this._connectKey = connectKey;
|
|
51
|
+
|
|
52
|
+
this._origin = origin || "";
|
|
53
|
+
this._contextPath = contextPath || getBasePath();
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
/**
|
|
@@ -53,6 +65,18 @@ export default class ErrorResponse {
|
|
|
53
65
|
return this._connectKey;
|
|
54
66
|
}
|
|
55
67
|
|
|
68
|
+
/**
|
|
69
|
+
*/
|
|
70
|
+
get origin(): string {
|
|
71
|
+
return this._origin;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*/
|
|
76
|
+
get contextPath(): string {
|
|
77
|
+
return this._contextPath;
|
|
78
|
+
}
|
|
79
|
+
|
|
56
80
|
/**
|
|
57
81
|
* Return error information
|
|
58
82
|
*/
|
|
@@ -161,9 +185,13 @@ export default class ErrorResponse {
|
|
|
161
185
|
* Return response error redirect href
|
|
162
186
|
*/
|
|
163
187
|
get redirectHref(): Href {
|
|
164
|
-
// TODO SBO: origin and context
|
|
165
188
|
if (this.response.redirect?.href) {
|
|
166
|
-
return new Href(
|
|
189
|
+
return new Href(
|
|
190
|
+
this.response.redirect?.href,
|
|
191
|
+
"",
|
|
192
|
+
this.origin,
|
|
193
|
+
this.contextPath,
|
|
194
|
+
);
|
|
167
195
|
}
|
|
168
196
|
return new Href();
|
|
169
197
|
}
|
|
@@ -291,8 +319,9 @@ export default class ErrorResponse {
|
|
|
291
319
|
* Get response url
|
|
292
320
|
*/
|
|
293
321
|
get changePasswordHref(): ?Href {
|
|
294
|
-
|
|
295
|
-
|
|
322
|
+
return this.properties.redirect
|
|
323
|
+
? new Href(this.properties.redirect, "", this.origin, this.contextPath)
|
|
324
|
+
: null;
|
|
296
325
|
}
|
|
297
326
|
|
|
298
327
|
/**
|
|
@@ -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,
|
|
@@ -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",
|
|
@@ -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
|
};
|