@beinformed/ui 1.13.5 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/esm/constants/Settings.js +4 -0
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/models/concepts/BusinessScenarioModel.js +25 -6
  5. package/esm/models/concepts/BusinessScenarioModel.js.map +1 -1
  6. package/esm/models/href/Href.js.map +1 -1
  7. package/esm/react-server/renderSSRComplete.js +3 -1
  8. package/esm/react-server/renderSSRComplete.js.map +1 -1
  9. package/esm/redux/actions/Authorization.js +2 -1
  10. package/esm/redux/actions/Authorization.js.map +1 -1
  11. package/esm/utils/helpers/checkResourceExists.js +23 -0
  12. package/esm/utils/helpers/checkResourceExists.js.map +1 -0
  13. package/esm/utils/index.js +2 -1
  14. package/esm/utils/index.js.map +1 -1
  15. package/lib/constants/Settings.js +4 -0
  16. package/lib/constants/Settings.js.flow +8 -0
  17. package/lib/constants/Settings.js.map +1 -1
  18. package/lib/models/concepts/BusinessScenarioModel.js +27 -6
  19. package/lib/models/concepts/BusinessScenarioModel.js.flow +47 -11
  20. package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
  21. package/lib/models/href/Href.js.flow +2 -2
  22. package/lib/models/href/Href.js.map +1 -1
  23. package/lib/react-server/renderSSRComplete.js +3 -1
  24. package/lib/react-server/renderSSRComplete.js.flow +2 -0
  25. package/lib/react-server/renderSSRComplete.js.map +1 -1
  26. package/lib/redux/actions/Authorization.js +2 -1
  27. package/lib/redux/actions/Authorization.js.flow +1 -0
  28. package/lib/redux/actions/Authorization.js.map +1 -1
  29. package/lib/utils/helpers/checkResourceExists.js +34 -0
  30. package/lib/utils/helpers/checkResourceExists.js.flow +21 -0
  31. package/lib/utils/helpers/checkResourceExists.js.map +1 -0
  32. package/lib/utils/index.js +14 -0
  33. package/lib/utils/index.js.flow +1 -0
  34. package/lib/utils/index.js.map +1 -1
  35. package/package.json +12 -12
  36. package/src/constants/Settings.js +8 -0
  37. package/src/models/concepts/BusinessScenarioModel.js +47 -11
  38. package/src/models/href/Href.js +2 -2
  39. package/src/react-server/renderSSRComplete.js +2 -0
  40. package/src/redux/actions/Authorization.js +1 -0
  41. package/src/utils/helpers/checkResourceExists.js +21 -0
  42. package/src/utils/index.js +1 -0
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import ConceptDetailModel from "./ConceptDetailModel";
3
3
  import ConceptTypeDetailModel from "./ConceptTypeDetailModel";
4
+ import { getSetting } from "../../constants/Settings";
4
5
 
5
6
  import type { ModularUIResponse } from "../../modularui";
6
7
  import type { ModularUIModel } from "../types";
@@ -21,13 +22,43 @@ class BusinessScenarioModel extends ConceptDetailModel {
21
22
  /**
22
23
  */
23
24
  static isApplicableModel(data: ModularUIResponse): boolean {
24
- const conceptTypeHref = data?.data?._links?.concepttype?.href;
25
- return (
26
- conceptTypeHref ===
27
- "/concepttypes/Library/KMTs/Business scenarios.bixml/BusinessScenario"
25
+ return BusinessScenarioModel.isOfConceptType(
26
+ data?.data?._links?.concepttype?.href,
27
+ "SCENARIO"
28
28
  );
29
29
  }
30
30
 
31
+ /**
32
+ */
33
+ static isOfConceptType(
34
+ conceptTypeHref: ?string,
35
+ settingName: "STEP" | "PERSONA" | "SCENARIO"
36
+ ): boolean {
37
+ if (!conceptTypeHref) {
38
+ return false;
39
+ }
40
+
41
+ const pathToKmt = "/Library/KMTs/Business scenarios.bixml";
42
+
43
+ const conceptTypeSettings = {
44
+ STEP: getSetting(
45
+ "BUSINESS_SCENARIO_STEP_CONCEPT_TYPE",
46
+ `${pathToKmt}/ScenarioStep`
47
+ ),
48
+ PERSONA: getSetting(
49
+ "BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE",
50
+ `${pathToKmt}/Persona`
51
+ ),
52
+ SCENARIO: getSetting(
53
+ "BUSINESS_SCENARIO_CONCEPT_TYPE",
54
+ `${pathToKmt}/BusinessScenario`
55
+ ),
56
+ };
57
+
58
+ const conceptTypeSetting = conceptTypeSettings[settingName];
59
+ return conceptTypeHref.endsWith(conceptTypeSetting);
60
+ }
61
+
31
62
  /**
32
63
  */
33
64
  getInitialChildModelLinks(): Array<LinkModel> {
@@ -42,8 +73,10 @@ class BusinessScenarioModel extends ConceptDetailModel {
42
73
  .filter(
43
74
  (relation) =>
44
75
  relation.direction === "outgoing" &&
45
- relation.concept.concepttypeHref?.path ===
46
- "/concepttypes/Library/KMTs/Business scenarios.bixml/ScenarioStep"
76
+ BusinessScenarioModel.isOfConceptType(
77
+ relation.concept.concepttypeHref?.path,
78
+ "STEP"
79
+ )
47
80
  )
48
81
  .map((relation) => relation.concept.asLinkModel());
49
82
 
@@ -63,14 +96,15 @@ class BusinessScenarioModel extends ConceptDetailModel {
63
96
  );
64
97
 
65
98
  const scenarioSteps = [];
66
- const SCENARIO_STEP_HREF =
67
- "/concepttypes/Library/KMTs/Business scenarios.bixml/ScenarioStep";
68
99
  for (let i = 0; i < models.length; i++) {
69
100
  const model = models[i];
70
101
 
71
102
  if (
72
103
  model instanceof ConceptDetailModel &&
73
- model.conceptType?.selfhref.path === SCENARIO_STEP_HREF
104
+ BusinessScenarioModel.isOfConceptType(
105
+ model.conceptType?.selfhref.path,
106
+ "STEP"
107
+ )
74
108
  ) {
75
109
  scenarioSteps.push(model);
76
110
  }
@@ -100,8 +134,10 @@ class BusinessScenarioModel extends ConceptDetailModel {
100
134
  const relationsToActor = scenarioStep.relationsCollection.find(
101
135
  (relation) =>
102
136
  relation.direction === "outgoing" &&
103
- relation.concept.concepttypeHref?.path ===
104
- "/concepttypes/Library/KMTs/Business scenarios.bixml/Persona"
137
+ BusinessScenarioModel.isOfConceptType(
138
+ relation.concept.concepttypeHref?.path,
139
+ "PERSONA"
140
+ )
105
141
  );
106
142
 
107
143
  const newRelationToActor =
@@ -4,7 +4,7 @@ import { BASE, CONTENT_PATH, HTTP_METHODS } from "../../constants/Constants";
4
4
  import Parameter from "../parameter/Parameter";
5
5
  import { IllegalArgumentException } from "../../exceptions";
6
6
 
7
- import type { LocationShape, Location } from "react-router";
7
+ import type { LocationShape } from "react-router";
8
8
 
9
9
  type HrefObject = {
10
10
  _path: string,
@@ -439,7 +439,7 @@ class Href {
439
439
 
440
440
  /**
441
441
  */
442
- toLocation(): Location {
442
+ toLocation(): LocationShape {
443
443
  return {
444
444
  pathname: this.path,
445
445
  search: this.querystring.length > 0 ? `?${this.querystring}` : "",
@@ -48,6 +48,8 @@ const renderSSRComplete = ({
48
48
 
49
49
  const sheet = new ServerStyleSheet();
50
50
 
51
+ // $FlowFixMe[incompatible-type]
52
+ // $FlowFixMe[prop-missing]
51
53
  const location: Location = requestHref.toLocation();
52
54
 
53
55
  return createSSRComplete(store, () =>
@@ -58,6 +58,7 @@ export const handleUnauthorized =
58
58
  );
59
59
  }
60
60
 
61
+ // add current location as from location before redirect
61
62
  const location = getState().router.location;
62
63
  if (location?.pathname !== LOGIN_PATH) {
63
64
  const locationFrom = location?.state?.from;
@@ -0,0 +1,21 @@
1
+ // @flow
2
+ import { BASE } from "../../constants/Constants";
3
+
4
+ /**
5
+ * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
6
+ * When the resource returns a 404, the resource does not exists and the method returns false
7
+ *
8
+ * @param url
9
+ * @returns {boolean}
10
+ */
11
+ export const resourceExists = (url: string): boolean => {
12
+ const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
13
+
14
+ const xhr = new XMLHttpRequest();
15
+ xhr.open("HEAD", fullUrl, false);
16
+ xhr.setRequestHeader("Accept", "application/json");
17
+ xhr.setRequestHeader("Content-Type", "application/json");
18
+ xhr.send();
19
+
20
+ return xhr.status !== 404;
21
+ };
@@ -19,6 +19,7 @@ export { default as createUUID } from "./helpers/createUUID";
19
19
  export * from "./helpers/sanitizeHtml";
20
20
  export * from "./helpers/objects";
21
21
  export * from "./helpers/text";
22
+ export * from "./helpers/checkResourceExists";
22
23
 
23
24
  // number
24
25
  export { default as DecimalFormat } from "./number/DecimalFormat";