@beinformed/ui 1.56.1 → 1.56.4
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 +22 -0
- package/esm/hooks/useModularUI.js +20 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +18 -16
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +0 -7
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +0 -7
- 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/redux/_modularui/ModularUISelectors.js +3 -2
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +10 -0
- package/lib/hooks/__tests__/useForm.spec.js.flow +12 -1
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +9 -0
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -0
- package/lib/hooks/useModularUI.js +19 -17
- package/lib/hooks/useModularUI.js.flow +26 -16
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +18 -16
- package/lib/hooks/useModularUIBasic.js.flow +23 -16
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +0 -7
- package/lib/models/concepts/ConceptDetailModel.js.flow +0 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +0 -7
- package/lib/models/concepts/ConceptLinkModel.js.flow +0 -7
- 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/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/redux/_modularui/ModularUISelectors.js +2 -2
- package/lib/redux/_modularui/ModularUISelectors.js.flow +8 -3
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/UseModularUIModel.spec.js +10 -0
- package/src/hooks/__tests__/useForm.spec.js +12 -1
- package/src/hooks/__tests__/useModelCatalog.spec.js +9 -0
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -0
- package/src/hooks/useModularUI.js +26 -16
- package/src/hooks/useModularUIBasic.js +23 -16
- package/src/models/concepts/ConceptDetailModel.js +0 -7
- package/src/models/concepts/ConceptLinkModel.js +0 -7
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/redux/_modularui/ModularUISelectors.js +8 -3
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
9
8
|
var _ResourceModel = _interopRequireDefault(require("../base/ResourceModel"));
|
|
10
9
|
/**
|
|
11
10
|
* Model for concept details, available through modelcatalog
|
|
@@ -15,8 +14,8 @@ class ConceptTypeDetailModel extends _ResourceModel.default {
|
|
|
15
14
|
* The name of the concept type consists of the functional id of the kmt and the functional id of the concept type separated by a #.<br>
|
|
16
15
|
* For example BEI_CaseManagement#Case
|
|
17
16
|
*/
|
|
18
|
-
get
|
|
19
|
-
return this.getData("
|
|
17
|
+
get kmtId() {
|
|
18
|
+
return this.getData("kmtId", "");
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -119,26 +118,10 @@ class ConceptTypeDetailModel extends _ResourceModel.default {
|
|
|
119
118
|
return this.getData("sectionReferenceTypes", []);
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
/**
|
|
123
|
-
*/
|
|
124
|
-
get conceptTypeHierarchy() {
|
|
125
|
-
return this.links.getLinksByGroup("conceptTypeHierarchy");
|
|
126
|
-
}
|
|
127
|
-
|
|
128
121
|
/**
|
|
129
122
|
*/
|
|
130
123
|
isOfConceptType(conceptTypeId) {
|
|
131
|
-
return this.
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
|
|
136
|
-
*/
|
|
137
|
-
hasMetamodelIdInHierarchy(metamodelId) {
|
|
138
|
-
return this.conceptTypeHierarchy?.all.some(link => {
|
|
139
|
-
var _context;
|
|
140
|
-
return (0, _startsWith.default)(_context = link.key).call(_context, metamodelId + "#");
|
|
141
|
-
}) || false;
|
|
124
|
+
return this.selfhref.equals(conceptTypeId);
|
|
142
125
|
}
|
|
143
126
|
}
|
|
144
127
|
var _default = exports.default = ConceptTypeDetailModel;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import ResourceModel from "../base/ResourceModel";
|
|
3
3
|
|
|
4
4
|
import type ModularUIResponse from "../../modularui/ModularUIResponse";
|
|
5
|
-
import type LinkCollection from "../links/LinkCollection";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Model for concept details, available through modelcatalog
|
|
@@ -12,8 +11,8 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
12
11
|
* The name of the concept type consists of the functional id of the kmt and the functional id of the concept type separated by a #.<br>
|
|
13
12
|
* For example BEI_CaseManagement#Case
|
|
14
13
|
*/
|
|
15
|
-
get
|
|
16
|
-
return this.getData("
|
|
14
|
+
get kmtId(): string {
|
|
15
|
+
return this.getData("kmtId", "");
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -119,31 +118,10 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
119
118
|
return this.getData("sectionReferenceTypes", []);
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
/**
|
|
123
|
-
*/
|
|
124
|
-
get conceptTypeHierarchy(): LinkCollection {
|
|
125
|
-
return this.links.getLinksByGroup("conceptTypeHierarchy");
|
|
126
|
-
}
|
|
127
|
-
|
|
128
121
|
/**
|
|
129
122
|
*/
|
|
130
123
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
131
|
-
return (
|
|
132
|
-
this.conceptTypeHierarchy?.hasLinkByKey(conceptTypeId) ||
|
|
133
|
-
this.conceptTypeHierarchy?.hasLinkByHref(conceptTypeId) ||
|
|
134
|
-
this.selfhref.equals(conceptTypeId)
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
|
|
140
|
-
*/
|
|
141
|
-
hasMetamodelIdInHierarchy(metamodelId: string): boolean {
|
|
142
|
-
return (
|
|
143
|
-
this.conceptTypeHierarchy?.all.some((link) =>
|
|
144
|
-
link.key.startsWith(metamodelId + "#"),
|
|
145
|
-
) || false
|
|
146
|
-
);
|
|
124
|
+
return this.selfhref.equals(conceptTypeId);
|
|
147
125
|
}
|
|
148
126
|
}
|
|
149
127
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptTypeDetailModel.js","names":["_ResourceModel","_interopRequireDefault","require","ConceptTypeDetailModel","ResourceModel","
|
|
1
|
+
{"version":3,"file":"ConceptTypeDetailModel.js","names":["_ResourceModel","_interopRequireDefault","require","ConceptTypeDetailModel","ResourceModel","kmtId","getData","type","modelName","isApplicableModel","data","contributions","resourcetype","key","_id","label","modelCategory","isCoreTaxonomy","icon","textColor","backgroundColor","borderColor","labelTypes","propertyTypes","textFragmentTypes","sectionReferenceTypes","isOfConceptType","conceptTypeId","selfhref","equals","_default","exports","default"],"sources":["../../../src/models/concepts/ConceptTypeDetailModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type ModularUIResponse from \"../../modularui/ModularUIResponse\";\n\n/**\n * Model for concept details, available through modelcatalog\n */\nclass ConceptTypeDetailModel extends ResourceModel {\n /**\n * The name of the concept type consists of the functional id of the kmt and the functional id of the concept type separated by a #.<br>\n * For example BEI_CaseManagement#Case\n */\n get kmtId(): string {\n return this.getData(\"kmtId\", \"\");\n }\n\n /**\n */\n get type(): string {\n return \"ConceptTypeDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptTypeDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"ConceptTypeDetail\"\n );\n }\n\n /**\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Get concept type label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Get model category of the concept type\n */\n get modelCategory(): string {\n return this.getData(\"modelCategory\", \"\");\n }\n\n /**\n */\n get isCoreTaxonomy(): boolean {\n return this.getData(\"coreTaxonomy\", \"false\") === \"true\";\n }\n\n /**\n * Get concept type icon\n */\n get icon(): string {\n return this.getData(\"icon\", \"\");\n }\n\n /**\n * Get concept type text color\n */\n get textColor(): string {\n return this.getData(\"textColor\", \"#000\");\n }\n\n /**\n * Get concept type background color\n */\n get backgroundColor(): string {\n return this.getData(\"backgroundColor\", \"#fff\");\n }\n\n /**\n * Get concept line color\n */\n get borderColor(): string {\n return this.getData(\"lineColor\", \"#000\");\n }\n\n /**\n * Get label types\n */\n get labelTypes(): ?Array<Object> {\n return this.data.labelTypes;\n }\n\n /**\n * Get propertyTypes\n */\n get propertyTypes(): Array<Object> {\n return this.getData(\"propertyTypes\", []);\n }\n\n /**\n * Get textFragmentTypes\n */\n get textFragmentTypes(): Array<Object> {\n return this.getData(\"textFragmentTypes\", []);\n }\n\n /**\n * Get sectionReferenceTypes\n */\n get sectionReferenceTypes(): Array<Object> {\n return this.getData(\"sectionReferenceTypes\", []);\n }\n\n /**\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return this.selfhref.equals(conceptTypeId);\n }\n}\n\nexport default ConceptTypeDetailModel;\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACA,MAAMC,sBAAsB,SAASC,sBAAa,CAAC;EACjD;AACF;AACA;AACA;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EAClC;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,mBAAmB;EAC5B;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,wBAAwB;EACjC;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,mBAAmB;EAE3D;;EAEA;AACF;EACE,IAAIC,GAAGA,CAAA,EAAW;IAChB,OAAO,IAAI,CAACH,IAAI,CAACI,GAAG;EACtB;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACT,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EAClC;;EAEA;AACF;AACA;EACE,IAAIU,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAI,CAACV,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIW,cAAcA,CAAA,EAAY;IAC5B,OAAO,IAAI,CAACX,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,KAAK,MAAM;EACzD;;EAEA;AACF;AACA;EACE,IAAIY,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACZ,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EACjC;;EAEA;AACF;AACA;EACE,IAAIa,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACb,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIc,eAAeA,CAAA,EAAW;IAC5B,OAAO,IAAI,CAACd,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC;EAChD;;EAEA;AACF;AACA;EACE,IAAIe,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACf,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIgB,UAAUA,CAAA,EAAmB;IAC/B,OAAO,IAAI,CAACZ,IAAI,CAACY,UAAU;EAC7B;;EAEA;AACF;AACA;EACE,IAAIC,aAAaA,CAAA,EAAkB;IACjC,OAAO,IAAI,CAACjB,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIkB,iBAAiBA,CAAA,EAAkB;IACrC,OAAO,IAAI,CAAClB,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;EAC9C;;EAEA;AACF;AACA;EACE,IAAImB,qBAAqBA,CAAA,EAAkB;IACzC,OAAO,IAAI,CAACnB,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;EAClD;;EAEA;AACF;EACEoB,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAACF,aAAa,CAAC;EAC5C;AACF;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7B,sBAAsB","ignoreList":[]}
|
|
@@ -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
|
});
|
|
@@ -11,7 +11,6 @@ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
|
|
|
11
11
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
12
12
|
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
13
13
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
14
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
|
15
14
|
var _reselect = require("reselect");
|
|
16
15
|
var _objects = require("../../utils/helpers/objects");
|
|
17
16
|
var _Href = _interopRequireDefault(require("../../models/href/Href"));
|
|
@@ -21,6 +20,7 @@ var _ApplicationModel = _interopRequireDefault(require("../../models/application
|
|
|
21
20
|
var _TabModel = _interopRequireDefault(require("../../models/tab/TabModel"));
|
|
22
21
|
var _CaseViewModel = _interopRequireDefault(require("../../models/caseview/CaseViewModel"));
|
|
23
22
|
var _FormModel = _interopRequireDefault(require("../../models/form/FormModel"));
|
|
23
|
+
var _constants = require("../../constants");
|
|
24
24
|
/**
|
|
25
25
|
*/
|
|
26
26
|
const getAllModelsByInstance = (state, instance) => {
|
|
@@ -263,7 +263,7 @@ exports.getModelsByType = getModelsByType;
|
|
|
263
263
|
const getAllFinishedModels = exports.getAllFinishedModels = (0, _reselect.createSelector)(state => state.modularui, modularui => {
|
|
264
264
|
if (modularui) {
|
|
265
265
|
var _context10, _context11;
|
|
266
|
-
return (0, _map.default)(_context10 = (0, _filter.default)(_context11 = (0,
|
|
266
|
+
return (0, _map.default)(_context10 = (0, _filter.default)(_context11 = (0, _keys.default)(modularui)).call(_context11, key => modularui[key] && modularui[key].status === _constants.MODULARUI_STATUS.FINISHED)).call(_context10, key => modularui[key].model);
|
|
267
267
|
}
|
|
268
268
|
return [];
|
|
269
269
|
});
|
|
@@ -16,6 +16,7 @@ import FormModel from "../../models/form/FormModel";
|
|
|
16
16
|
|
|
17
17
|
import type { ReduxState, PreferenceValue } from "../types";
|
|
18
18
|
import type { ModularUIModel } from "../../models/types";
|
|
19
|
+
import { MODULARUI_STATUS } from "../../constants";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
*/
|
|
@@ -308,9 +309,13 @@ export const getAllFinishedModels: (
|
|
|
308
309
|
(state: ReduxState) => state.modularui,
|
|
309
310
|
(modularui): Array<ModularUIModel> => {
|
|
310
311
|
if (modularui) {
|
|
311
|
-
return Object.
|
|
312
|
-
.filter(
|
|
313
|
-
|
|
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);
|
|
314
319
|
}
|
|
315
320
|
return [];
|
|
316
321
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUISelectors.js","names":["_reselect","require","_objects","_Href","_interopRequireDefault","_ContentModel","_ContentTOCModel","_ApplicationModel","_TabModel","_CaseViewModel","_FormModel","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_map","default","_filter","_keys","call","key","model","exports","getFirstModelByInstance","_context3","_find","getActiveModelByInstance","location","getLocation","_context4","_startsWith","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","_context5","findHref","Href","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","_stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","createSelector","_context10","_context11","_values","entry","status"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.values(modularui)\n .filter((entry) => entry.status === \"FINISHED\")\n .map((entry) => entry.model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,gBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,iBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,I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KZ,KAAK,CAACI,SAAS,CAACQ,GAAG,CAAC,CAACC,KAAK,CAAC;EAC7C;EAEA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AADAC,OAAA,CAAAkE,eAAA,GAAAA,eAAA;AAEO,MAAMG,oBAEa,GAAArE,OAAA,CAAAqE,oBAAA,GAAG,IAAAC,wBAAc,EACxCpF,KAAiB,IAAKA,KAAK,CAACI,SAAS,EACrCA,SAAS,IAA4B;EACpC,IAAIA,SAAS,EAAE;IAAA,IAAAiF,UAAA,EAAAC,UAAA;IACb,OAAO,IAAA/E,IAAA,CAAAC,OAAA,EAAA6E,UAAA,OAAA5E,OAAA,CAAAD,OAAA,EAAA8E,UAAA,OAAAC,OAAA,CAAA/E,OAAA,EAAcJ,SAAS,CAAC,EAAAO,IAAA,CAAA2E,UAAA,EACpBE,KAAK,IAAKA,KAAK,CAACC,MAAM,KAAK,UAAU,CAAC,EAAA9E,IAAA,CAAA0E,UAAA,EACzCG,KAAK,IAAKA,KAAK,CAAC3E,KAAK,CAAC;EAChC;EACA,OAAO,EAAE;AACX,CACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModularUISelectors.js","names":["_reselect","require","_objects","_Href","_interopRequireDefault","_ContentModel","_ContentTOCModel","_ApplicationModel","_TabModel","_CaseViewModel","_FormModel","_constants","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_map","default","_filter","_keys","call","key","model","exports","getFirstModelByInstance","_context3","_find","getActiveModelByInstance","location","getLocation","_context4","_startsWith","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","_context5","findHref","Href","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","_stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","createSelector","_context10","_context11","status","MODULARUI_STATUS","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,gBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,iBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,SAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,cAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,UAAA,GAAAN,sBAAA,CAAAH,OAAA;AAIA,IAAAU,UAAA,GAAAV,OAAA;AAEA;AACA;AACO,MAAMW,sBAAsB,GAAGA,CACpCC,KAAiB,EACjBC,QAAkB,KACQ;EAC1B,MAAMC,MAAM,GAAGF,KAAK,EAAEG,IAAI,EAAED,MAAM,IAAI,IAAI;EAC1C,MAAME,SAAS,GAAGJ,KAAK,EAAEI,SAAS;EAElC,IAAIA,SAAS,EAAE;IAAA,IAAAC,QAAA,EAAAC,SAAA;IACb,OAAO,IAAAC,IAAA,CAAAC,OAAA,EAAAH,QAAA,OAAAI,OAAA,CAAAD,OAAA,EAAAF,SAAA,OAAAI,KAAA,CAAAF,OAAA,EAAYJ,SAAS,CAAC,EAAAO,IAAA,CAAAL,SAAA,EAClBM,GAAG,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SAAS,CAACQ,GAAG,CAAC,CAAC2E,MAAM,KAAKC,2BAAgB,CAACC,QAC/C,CAAC,EAAA9E,IAAA,CAAA0E,UAAA,EACKzE,GAAG,IAAKR,SAAS,CAACQ,GAAG,CAAC,CAACC,KAAK,CAAC;EACvC;EACA,OAAO,EAAE;AACX,CACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@ import { Provider } from "react-redux";
|
|
|
4
4
|
import { renderHook } from "@testing-library/react";
|
|
5
5
|
import xhrMock from "xhr-mock";
|
|
6
6
|
|
|
7
|
+
import { useLocation } from "react-router";
|
|
8
|
+
|
|
7
9
|
import {
|
|
8
10
|
useApplication,
|
|
9
11
|
useTab,
|
|
@@ -32,6 +34,11 @@ import {
|
|
|
32
34
|
const middlewares = [thunk];
|
|
33
35
|
const mockStore = configureMockStore(middlewares);
|
|
34
36
|
|
|
37
|
+
jest.mock("react-router", () => ({
|
|
38
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
39
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
40
|
+
}));
|
|
41
|
+
|
|
35
42
|
const JSON_TYPE = "application/json";
|
|
36
43
|
|
|
37
44
|
describe("modularui hooks", () => {
|
|
@@ -83,6 +90,9 @@ describe("modularui hooks", () => {
|
|
|
83
90
|
// replace the real XHR object with the mock XHR object before each test
|
|
84
91
|
// eslint-disable-next-line jest/no-hooks
|
|
85
92
|
beforeEach(() => {
|
|
93
|
+
useLocation.mockReturnValue({
|
|
94
|
+
state: null,
|
|
95
|
+
});
|
|
86
96
|
xhrMock.setup();
|
|
87
97
|
});
|
|
88
98
|
|
|
@@ -3,6 +3,7 @@ import thunk from "redux-thunk";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { renderHook } from "@testing-library/react";
|
|
5
5
|
import xhrMock from "xhr-mock";
|
|
6
|
+
import { useLocation } from "react-router";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
useAttributeSet,
|
|
@@ -19,12 +20,22 @@ import { IllegalArgumentException } from "../../exceptions";
|
|
|
19
20
|
const middlewares = [thunk];
|
|
20
21
|
const mockStore = configureMockStore(middlewares);
|
|
21
22
|
|
|
23
|
+
jest.mock("react-router", () => ({
|
|
24
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
25
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
26
|
+
}));
|
|
27
|
+
|
|
22
28
|
const JSON_TYPE = "application/json";
|
|
23
29
|
|
|
24
30
|
describe("form hooks", () => {
|
|
25
31
|
// replace the real XHR object with the mock XHR object before each test
|
|
26
32
|
// eslint-disable-next-line jest/no-hooks
|
|
27
|
-
beforeEach(() =>
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
useLocation.mockReturnValue({
|
|
35
|
+
state: null,
|
|
36
|
+
});
|
|
37
|
+
xhrMock.setup();
|
|
38
|
+
});
|
|
28
39
|
|
|
29
40
|
// put the real XHR object back and clear the mocks after each test
|
|
30
41
|
// eslint-disable-next-line jest/no-hooks
|
|
@@ -3,6 +3,7 @@ import thunk from "redux-thunk";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { renderHook } from "@testing-library/react";
|
|
5
5
|
import xhrMock from "xhr-mock";
|
|
6
|
+
import { useLocation } from "react-router";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
ConceptIndexModel,
|
|
@@ -26,6 +27,11 @@ import {
|
|
|
26
27
|
const middlewares = [thunk];
|
|
27
28
|
const mockStore = configureMockStore(middlewares);
|
|
28
29
|
|
|
30
|
+
jest.mock("react-router", () => ({
|
|
31
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
32
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
33
|
+
}));
|
|
34
|
+
|
|
29
35
|
const JSON_TYPE = "application/json";
|
|
30
36
|
|
|
31
37
|
describe("modelcatalog hooks", () => {
|
|
@@ -77,6 +83,9 @@ describe("modelcatalog hooks", () => {
|
|
|
77
83
|
// replace the real XHR object with the mock XHR object before each test
|
|
78
84
|
// eslint-disable-next-line jest/no-hooks
|
|
79
85
|
beforeEach(() => {
|
|
86
|
+
useLocation.mockReturnValue({
|
|
87
|
+
state: null,
|
|
88
|
+
});
|
|
80
89
|
xhrMock.setup();
|
|
81
90
|
});
|
|
82
91
|
|
|
@@ -6,16 +6,25 @@ import xhrMock from "xhr-mock";
|
|
|
6
6
|
|
|
7
7
|
import { useModularUIBasic } from "../useModularUIBasic";
|
|
8
8
|
import { ApplicationModel, Href } from "../../models";
|
|
9
|
+
import { useLocation } from "react-router";
|
|
9
10
|
|
|
10
11
|
const middlewares = [thunk];
|
|
11
12
|
const mockStore = configureMockStore(middlewares);
|
|
12
13
|
|
|
14
|
+
jest.mock("react-router", () => ({
|
|
15
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
16
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
17
|
+
}));
|
|
18
|
+
|
|
13
19
|
const JSON_TYPE = "application/json";
|
|
14
20
|
|
|
15
21
|
describe("modularui hooks", () => {
|
|
16
22
|
// replace the real XHR object with the mock XHR object before each test
|
|
17
23
|
// eslint-disable-next-line jest/no-hooks
|
|
18
24
|
beforeEach(() => {
|
|
25
|
+
useLocation.mockReturnValue({
|
|
26
|
+
state: null,
|
|
27
|
+
});
|
|
19
28
|
xhrMock.setup();
|
|
20
29
|
});
|
|
21
30
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useEffect, useRef, useMemo } from "react";
|
|
3
3
|
import { useDispatch, useSelector } from "react-redux";
|
|
4
|
+
import { useLocation } from "react-router";
|
|
4
5
|
|
|
5
6
|
import { HTTP_METHODS } from "../constants";
|
|
6
7
|
import {
|
|
@@ -12,14 +13,17 @@ import useDeepCompareEffect from "./useDeepCompareEffect";
|
|
|
12
13
|
|
|
13
14
|
import { useLocale } from "./useI18n";
|
|
14
15
|
|
|
15
|
-
import
|
|
16
|
+
import Href from "../models/href/Href";
|
|
16
17
|
import type { RequestModularUIOptions } from "../utils";
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
*/
|
|
20
21
|
const useKeyForHook = (modelKey: string, url: string) => {
|
|
21
22
|
const locale = useLocale();
|
|
22
|
-
return
|
|
23
|
+
return useMemo(
|
|
24
|
+
() => `${modelKey}(${url.split("?")[0]})(${locale})`,
|
|
25
|
+
[modelKey, url, locale],
|
|
26
|
+
);
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
/**
|
|
@@ -34,11 +38,17 @@ export const useModularUI = (
|
|
|
34
38
|
},
|
|
35
39
|
): any => {
|
|
36
40
|
const dispatch = useDispatch();
|
|
37
|
-
const href = url?.toString() || "";
|
|
41
|
+
const href = useMemo(() => url?.toString() || "", [url]);
|
|
38
42
|
const key = useKeyForHook(modelKey, href);
|
|
39
43
|
|
|
44
|
+
const location = useLocation();
|
|
45
|
+
const redirectLocation = location.state?.redirectLocation;
|
|
46
|
+
const forceReload =
|
|
47
|
+
redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;
|
|
48
|
+
|
|
40
49
|
const prevOptions = useRef(options);
|
|
41
50
|
const prevHref = useRef(href);
|
|
51
|
+
const prevForceReload = useRef(forceReload);
|
|
42
52
|
|
|
43
53
|
// dispatch loadModularUI
|
|
44
54
|
useDeepCompareEffect(() => {
|
|
@@ -48,25 +58,25 @@ export const useModularUI = (
|
|
|
48
58
|
prevOptions.current.isReload &&
|
|
49
59
|
!options.isReload;
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
const doForceReload = forceReload && !prevForceReload.current;
|
|
62
|
+
|
|
63
|
+
if (href !== "" && (doForceReload || !isOldReload)) {
|
|
52
64
|
dispatch(loadModularUI(key, href, options));
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
prevOptions.current = options;
|
|
56
68
|
prevHref.current = href;
|
|
57
|
-
|
|
69
|
+
prevForceReload.current = forceReload;
|
|
70
|
+
}, [key, href, options, forceReload]);
|
|
58
71
|
|
|
59
|
-
const { removeOnUnmount = false } = options;
|
|
60
72
|
useEffect(() => {
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
if (options.removeOnUnmount) {
|
|
74
|
+
return () => {
|
|
63
75
|
dispatch(removeModelByKey(key));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, [dispatch, key, removeOnUnmount]);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, [dispatch, key, options.removeOnUnmount]);
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
return useSelector(
|
|
70
|
-
return state.modularui[key];
|
|
71
|
-
});
|
|
80
|
+
const selector = useMemo(() => (state) => state.modularui[key], [key]);
|
|
81
|
+
return useSelector(selector);
|
|
72
82
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
2
4
|
import { useModularUI } from "./useModularUI";
|
|
3
5
|
|
|
4
6
|
import { useLocation } from "./useRouter";
|
|
@@ -26,6 +28,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
26
28
|
},
|
|
27
29
|
): T | null => {
|
|
28
30
|
const location = useLocation();
|
|
31
|
+
const memoizedHref = useMemo(() => href.toString(), [href]);
|
|
29
32
|
|
|
30
33
|
const useModularUIOptions = {
|
|
31
34
|
targetModel: undefined,
|
|
@@ -48,25 +51,29 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
// $FlowFixMe[incompatible-call]
|
|
51
|
-
const modularUI = useModularUI(key,
|
|
54
|
+
const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const expectedModels = useMemo(
|
|
57
|
+
() => options.expectedModels ?? [],
|
|
58
|
+
[options.expectedModels],
|
|
59
|
+
);
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
return model.type === expectedModel;
|
|
60
|
-
});
|
|
61
|
+
return useMemo((): T | null => {
|
|
62
|
+
if (modularUI?.model) {
|
|
63
|
+
const { model } = modularUI;
|
|
61
64
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (expectedModels.length > 0) {
|
|
66
|
+
const isCorrectModel = expectedModels.some(
|
|
67
|
+
(expectedModel) => model.type === expectedModel,
|
|
68
|
+
);
|
|
69
|
+
if (!isCorrectModel) {
|
|
70
|
+
console.error(modularUI, "is not of instance", expectedModels);
|
|
71
|
+
throw new IllegalStateException("Resolved model has incorrect type");
|
|
72
|
+
}
|
|
65
73
|
}
|
|
66
|
-
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
return model;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}, [expectedModels, modularUI]);
|
|
72
79
|
};
|
|
@@ -338,11 +338,4 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
338
338
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
339
339
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
340
340
|
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
344
|
-
*/
|
|
345
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
346
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
347
|
-
}
|
|
348
341
|
}
|
|
@@ -168,11 +168,4 @@ export default class ConceptLinkModel
|
|
|
168
168
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
169
169
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
174
|
-
*/
|
|
175
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
176
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
177
|
-
}
|
|
178
171
|
}
|