@beinformed/ui 1.56.2 → 1.56.5

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 (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/esm/hooks/useModularUI.js +20 -18
  3. package/esm/hooks/useModularUI.js.map +1 -1
  4. package/esm/hooks/useModularUIBasic.js +18 -16
  5. package/esm/hooks/useModularUIBasic.js.map +1 -1
  6. package/esm/models/concepts/ConceptTypeDetailModel.js +2 -2
  7. package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  8. package/esm/redux/_modularui/ModularUIActions.js +10 -8
  9. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  10. package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
  11. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  12. package/esm/redux/_modularui/ModularUIReducer.js +2 -1
  13. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  14. package/esm/redux/_modularui/types.js.map +1 -1
  15. package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
  16. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
  17. package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
  18. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
  19. package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
  20. package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
  21. package/lib/hooks/useModularUI.js +19 -17
  22. package/lib/hooks/useModularUI.js.flow +26 -16
  23. package/lib/hooks/useModularUI.js.map +1 -1
  24. package/lib/hooks/useModularUIBasic.js +18 -16
  25. package/lib/hooks/useModularUIBasic.js.flow +23 -16
  26. package/lib/hooks/useModularUIBasic.js.map +1 -1
  27. package/lib/models/concepts/ConceptTypeDetailModel.js +2 -2
  28. package/lib/models/concepts/ConceptTypeDetailModel.js.flow +2 -2
  29. package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  30. package/lib/redux/_modularui/ModularUIActions.js +10 -8
  31. package/lib/redux/_modularui/ModularUIActions.js.flow +14 -9
  32. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  33. package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
  34. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
  35. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  36. package/lib/redux/_modularui/ModularUIReducer.js +2 -1
  37. package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
  38. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  39. package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
  40. package/lib/redux/_modularui/types.js.flow +1 -0
  41. package/lib/redux/_modularui/types.js.map +1 -1
  42. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
  43. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
  44. package/package.json +9 -9
  45. package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
  46. package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
  47. package/src/hooks/__tests__/useForm.spec.js +14 -12
  48. package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
  49. package/src/hooks/__tests__/useModels.spec.js +3 -12
  50. package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
  51. package/src/hooks/useModularUI.js +26 -16
  52. package/src/hooks/useModularUIBasic.js +23 -16
  53. package/src/models/concepts/ConceptTypeDetailModel.js +2 -2
  54. package/src/redux/_modularui/ModularUIActions.js +14 -9
  55. package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
  56. package/src/redux/_modularui/ModularUIReducer.js +1 -0
  57. package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
  58. package/src/redux/_modularui/types.js +1 -0
  59. package/src/redux/actions/__tests__/Application.spec.js +1 -8
  60. package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.56.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.56.4...v1.56.5) (2024-10-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **modularui:** don't start request if existing request for same model exists ([40dc861](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/40dc86188e37ca3d8c3b99ea547b30cb500d284e))
11
+
12
+ ## [1.56.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.56.3...v1.56.4) (2024-10-16)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **modularui:** memoize expectedmodels property ([8dac1a6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8dac1a6d6cfe4c78c9d67fd7cdab3a3d7cda7ab8))
18
+
19
+ ## [1.56.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.56.2...v1.56.3) (2024-10-16)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **concept-type:** rename name property to kmtId ([c8e8b77](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c8e8b779fb567747a600c626077201560a2b866e))
25
+ * **modularui:** force reload of existing model when form redirect ([91cfb43](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/91cfb436c1c076e8d424944a181e4599b58eccf4))
26
+
5
27
  ## [1.56.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.56.1...v1.56.2) (2024-10-10)
6
28
 
7
29
 
@@ -1,14 +1,16 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useEffect, useRef, useMemo } from "react";
2
2
  import { useDispatch, useSelector } from "react-redux";
3
+ import { useLocation } from "react-router";
3
4
  import { HTTP_METHODS } from "../constants";
4
5
  import { loadModularUI, removeModelByKey } from "../redux/_modularui/ModularUIActions";
5
6
  import useDeepCompareEffect from "./useDeepCompareEffect";
6
7
  import { useLocale } from "./useI18n";
8
+ import Href from "../models/href/Href";
7
9
  /**
8
10
  */
9
11
  const useKeyForHook = (modelKey, url) => {
10
12
  const locale = useLocale();
11
- return `${modelKey}(${url.split("?")[0]})(${locale})`;
13
+ return useMemo(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
12
14
  };
13
15
 
14
16
  /**
@@ -20,35 +22,35 @@ export const useModularUI = function (modelKey, url) {
20
22
  removeOnUnmount: false
21
23
  };
22
24
  const dispatch = useDispatch();
23
- const href = url?.toString() || "";
25
+ const href = useMemo(() => url?.toString() || "", [url]);
24
26
  const key = useKeyForHook(modelKey, href);
27
+ const location = useLocation();
28
+ const redirectLocation = location.state?.redirectLocation;
29
+ const forceReload = redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;
25
30
  const prevOptions = useRef(options);
26
31
  const prevHref = useRef(href);
32
+ const prevForceReload = useRef(forceReload);
27
33
 
28
34
  // dispatch loadModularUI
29
35
  useDeepCompareEffect(() => {
30
36
  // prevent reloads when previous option had the isReload, but the new options not
31
37
  const isOldReload = prevHref.current === href && prevOptions.current.isReload && !options.isReload;
32
- if (href !== "" && !isOldReload) {
38
+ const doForceReload = forceReload && !prevForceReload.current;
39
+ if (href !== "" && (doForceReload || !isOldReload)) {
33
40
  dispatch(loadModularUI(key, href, options));
34
41
  }
35
42
  prevOptions.current = options;
36
43
  prevHref.current = href;
37
- }, [key, href, options]);
38
- const {
39
- removeOnUnmount = false
40
- } = options;
44
+ prevForceReload.current = forceReload;
45
+ }, [key, href, options, forceReload]);
41
46
  useEffect(() => {
42
- return () => {
43
- if (removeOnUnmount) {
47
+ if (options.removeOnUnmount) {
48
+ return () => {
44
49
  dispatch(removeModelByKey(key));
45
- }
46
- };
47
- }, [dispatch, key, removeOnUnmount]);
48
-
49
- // retrieve current model from modularui reducer
50
- return useSelector(state => {
51
- return state.modularui[key];
52
- });
50
+ };
51
+ }
52
+ }, [dispatch, key, options.removeOnUnmount]);
53
+ const selector = useMemo(() => state => state.modularui[key], [key]);
54
+ return useSelector(selector);
53
55
  };
54
56
  //# sourceMappingURL=useModularUI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = url?.toString() || \"\";\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (href !== \"\" && !isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,SAASC,SAAS,QAAQ,WAAW;AAKrC;AACA;AACA,MAAMC,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAGJ,SAAS,CAAC,CAAC;EAC1B,OAAO,GAAGE,QAAQ,IAAIC,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKD,MAAM,GAAG;AACvD,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAME,YAAY,GAAG,SAAAA,CAC1BJ,QAAgB,EAChBC,GAAkB,EAKV;EAAA,IAJRI,OAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACjCG,MAAM,EAAEf,YAAY,CAACgB,GAAG;IACxBC,eAAe,EAAE;EACnB,CAAC;EAED,MAAMC,QAAQ,GAAGpB,WAAW,CAAC,CAAC;EAC9B,MAAMqB,IAAI,GAAGZ,GAAG,EAAEa,QAAQ,CAAC,CAAC,IAAI,EAAE;EAClC,MAAMC,GAAG,GAAGhB,aAAa,CAACC,QAAQ,EAAEa,IAAI,CAAC;EAEzC,MAAMG,WAAW,GAAGzB,MAAM,CAACc,OAAO,CAAC;EACnC,MAAMY,QAAQ,GAAG1B,MAAM,CAACsB,IAAI,CAAC;;EAE7B;EACAhB,oBAAoB,CAAC,MAAM;IACzB;IACA,MAAMqB,WAAW,GACfD,QAAQ,CAACE,OAAO,KAAKN,IAAI,IACzBG,WAAW,CAACG,OAAO,CAACC,QAAQ,IAC5B,CAACf,OAAO,CAACe,QAAQ;IAEnB,IAAIP,IAAI,KAAK,EAAE,IAAI,CAACK,WAAW,EAAE;MAC/BN,QAAQ,CAACjB,aAAa,CAACoB,GAAG,EAAEF,IAAI,EAAER,OAAO,CAAC,CAAC;IAC7C;IAEAW,WAAW,CAACG,OAAO,GAAGd,OAAO;IAC7BY,QAAQ,CAACE,OAAO,GAAGN,IAAI;EACzB,CAAC,EAAE,CAACE,GAAG,EAAEF,IAAI,EAAER,OAAO,CAAC,CAAC;EAExB,MAAM;IAAEM,eAAe,GAAG;EAAM,CAAC,GAAGN,OAAO;EAC3Cf,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX,IAAIqB,eAAe,EAAE;QACnBC,QAAQ,CAAChB,gBAAgB,CAACmB,GAAG,CAAC,CAAC;MACjC;IACF,CAAC;EACH,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEJ,eAAe,CAAC,CAAC;;EAEpC;EACA,OAAOlB,WAAW,CAAE4B,KAAK,IAAK;IAC5B,OAAOA,KAAK,CAACC,SAAS,CAACP,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useMemo","useDispatch","useSelector","useLocation","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","Href","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","location","redirectLocation","state","forceReload","equals","prevOptions","prevHref","prevForceReload","isOldReload","current","isReload","doForceReload","selector","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceReload =\n redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceReload = useRef(forceReload);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceReload = forceReload && !prevForceReload.current;\n\n if (href !== \"\" && (doForceReload || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceReload.current = forceReload;\n }, [key, href, options, forceReload]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n const selector = useMemo(() => (state) => state.modularui[key], [key]);\n return useSelector(selector);\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACt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sWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
2
+ import { useMemo } from "react";
2
3
  import { useModularUI } from "./useModularUI";
3
4
  import { useLocation } from "./useRouter";
4
5
  import { IllegalStateException } from "../exceptions";
@@ -12,6 +13,7 @@ export const useModularUIBasic = function (key, href) {
12
13
  forceTargetModel: false
13
14
  };
14
15
  const location = useLocation();
16
+ const memoizedHref = useMemo(() => href.toString(), [href]);
15
17
  const useModularUIOptions = {
16
18
  targetModel: undefined,
17
19
  forceTargetModel: undefined,
@@ -32,23 +34,23 @@ export const useModularUIBasic = function (key, href) {
32
34
  }
33
35
 
34
36
  // $FlowFixMe[incompatible-call]
35
- const modularUI = useModularUI(key, href, useModularUIOptions);
36
- if (modularUI?.model) {
37
- const {
38
- model
39
- } = modularUI;
40
- const expectedModels = options.expectedModels ?? [];
41
- if (expectedModels.length > 0) {
42
- const isCorrectModel = expectedModels.some(expectedModel => {
43
- return model.type === expectedModel;
44
- });
45
- if (!isCorrectModel) {
46
- console.error(modularUI, "is not of instance", expectedModels);
47
- throw new IllegalStateException("Resolved model has incorrect type");
37
+ const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);
38
+ const expectedModels = useMemo(() => options.expectedModels ?? [], [options.expectedModels]);
39
+ return useMemo(() => {
40
+ if (modularUI?.model) {
41
+ const {
42
+ model
43
+ } = modularUI;
44
+ if (expectedModels.length > 0) {
45
+ const isCorrectModel = expectedModels.some(expectedModel => model.type === expectedModel);
46
+ if (!isCorrectModel) {
47
+ console.error(modularUI, "is not of instance", expectedModels);
48
+ throw new IllegalStateException("Resolved model has incorrect type");
49
+ }
48
50
  }
51
+ return model;
49
52
  }
50
- return model;
51
- }
52
- return null;
53
+ return null;
54
+ }, [expectedModels, modularUI]);
53
55
  };
54
56
  //# sourceMappingURL=useModularUIBasic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n\n const expectedModels = options.expectedModels ?? [];\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,e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,EAAE;MAC7B,MAAMiB,cAAc,GAAGf,cAAc,CAACgB,IAAI,CAAEC,aAAa,IAAK;QAC5D,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEb,cAAc,CAAC;QAC9D,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOuB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["useMemo","useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","memoizedHref","toString","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useMemo } from \"react\";\n\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n const memoizedHref = useMemo(() => href.toString(), [href]);\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);\n\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n const { model } = modularUI;\n\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n"],"mappings":";AACA,SAASA,OAAO,QAAQ,OAAO;AAE/B,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAWrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ,GAAGb,WAAW,CAAC,CAAC;EAC9B,MAAMc,YAAY,GAAGhB,OAAO,CAAC,MAAMM,IAAI,CAACW,QAAQ,CAAC,CAAC,EAAE,CAACX,IAAI,CAAC,CAAC;EAE3D,MAAMY,mBAAmB,GAAG;IAC1BL,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BQ,QAAQ,EAAE,KAAK;IACfC,KAAK,EAAE;EACT,CAAC;EACD,IAAIZ,OAAO,CAACK,WAA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,8 +7,8 @@ class ConceptTypeDetailModel extends ResourceModel {
7
7
  * 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>
8
8
  * For example BEI_CaseManagement#Case
9
9
  */
10
- get name() {
11
- return this.getData("name", "");
10
+ get kmtId() {
11
+ return this.getData("kmtId", "");
12
12
  }
13
13
 
14
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ConceptTypeDetailModel.js","names":["ResourceModel","ConceptTypeDetailModel","name","getData","type","modelName","isApplicableModel","data","contributions","resourcetype","key","_id","label","modelCategory","isCoreTaxonomy","icon","textColor","backgroundColor","borderColor","labelTypes","propertyTypes","textFragmentTypes","sectionReferenceTypes","isOfConceptType","conceptTypeId","selfhref","equals"],"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 name(): string {\n return this.getData(\"name\", \"\");\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,OAAOA,aAAa,MAAM,uBAAuB;AAIjD;AACA;AACA;AACA,MAAMC,sBAAsB,SAASD,aAAa,CAAC;EACjD;AACF;AACA;AACA;EACE,IAAIE,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EACjC;;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;A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AAC,uBAAuB,EAAE,EAAE,CAAC;EAClD;;EAEA;AACF;EACEoB,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAACF,aAAa,CAAC;EAC5C;AACF;AAEA,eAAevB,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"ConceptTypeDetailModel.js","names":["ResourceModel","ConceptTypeDetailModel","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"],"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,OAAOA,aAAa,MAAM,uBAAuB;AAIjD;AACA;AACA;AACA,MAAMC,sBAAsB,SAASD,aAAa,CAAC;EACjD;AACF;AACA;AACA;EACE,IAAIE,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,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C;EAClD;;EAEA;AACF;EACEoB,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OAAO,IAAI,CAACC,QAAQ,CAACC,MAAM,CAACF,aAAa,CAAC;EAC5C;AACF;AAEA,eAAevB,sBAAsB","ignoreList":[]}
@@ -78,6 +78,7 @@ const loadModelSuccessAction = (key, model, updateHandler) => {
78
78
  export const loadModel = (key, href, options) => ({
79
79
  type: "MODULARUI/FETCH",
80
80
  payload: {
81
+ key,
81
82
  href: href instanceof Href ? href : new Href(href),
82
83
  method: options?.method ?? HTTP_METHODS.GET,
83
84
  data: options?.data,
@@ -107,16 +108,17 @@ export const loadModel = (key, href, options) => ({
107
108
 
108
109
  /**
109
110
  */
110
- export const loadModularUI = (key, href, options) => dispatch => {
111
- dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
111
+ export const loadModularUI = (key, href, options) => (dispatch, getState) => {
112
+ const modularuiStore = getState()?.modularui;
113
+ if (modularuiStore && modularuiStore[key]?.status === MODULARUI_STATUS.LOADING) {
114
+ // don't create duplicate requests during loading
115
+ return dispatch({
116
+ type: "NO_ACTION"
117
+ });
118
+ }
112
119
  dispatch(startProgress());
113
120
  const loadModelPromise = dispatch(loadModel(key, href, options));
114
- return _Promise.resolve(loadModelPromise).then(response => {
115
- if (response?.type === "FINISH_PROGRESS") {
116
- dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));
117
- }
118
- return dispatch(finishProgress());
119
- }).catch(error => dispatch(handleError(error)));
121
+ return _Promise.resolve(loadModelPromise).then(() => dispatch(finishProgress())).catch(error => dispatch(handleError(error)));
120
122
  };
121
123
 
122
124
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","_Promise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...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gBAAgB,CAACuC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,aAAa,GACxBA,CACEjC,GAAW,EACXgB,IAAmB,EACnBC,OAAiC,KAElCiB,QAAkB,IAAK;EACtBA,QAAQ,CAACvB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAAC0C,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAACrC,aAAa,CAAC,CAAC,CAAC;EAEzB,MAAMuC,gBAAgB,GAAGF,QAAQ,CAACnB,SAAS,CAACf,GAAG,EAAEgB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAOoB,QAAA,CAAQC,OAAO,CAACF,gBAAgB,CAAC,CACrCG,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAErC,IAAI,KAAK,iBAAiB,EAAE;MACxC+B,QAAQ,CAACvB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAACgD,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOP,QAAQ,CAACtC,cAAc,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACD8C,KAAK,CAAEd,KAAK,IAAKM,QAAQ,CAACpC,WAAW,CAAC8B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMe,WAAW,GAAGA,CACzB1C,KAAqB,EACrBgB,OAAiC,KAEjCgB,aAAa,CAAChC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC2C,QAAQ,EAAE;EAC9C,GAAG3B,OAAO;EACV4B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","getState","modularuiStore","modularui","LOADING","loadModelPromise","_Promise","resolve","then","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n key,\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n if (\n modularuiStore &&\n modularuiStore[key]?.status === MODULARUI_STATUS.LOADING\n ) {\n // don't create duplicate requests during loading\n return dispatch({\n type: \"NO_ACTION\",\n });\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\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;MAC9B;MAEA,OAAOW,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAACuC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,aAAa,GACxBA,CACEjC,GAAW,EACXgB,IAAmB,EACnBC,OAAiC,KAEnC,CAACiB,QAAkB,EAAEC,QAAQ,KAAK;EAChC,MAAMC,cAAc,GAAGD,QAAQ,CAAC,CAAC,EAAEE,SAAS;EAC5C,IACED,cAAc,IACdA,cAAc,CAACpC,GAAG,CAAC,EAAEY,MAAM,KAAKnB,gBAAgB,CAAC6C,OAAO,EACxD;IACA;IACA,OAAOJ,QAAQ,CAAC;MACd/B,IAAI,EAAE;IACR,CAAC,CAAC;EACJ;EAEA+B,QAAQ,CAACrC,aAAa,CAAC,CAAC,CAAC;EAEzB,MAAM0C,gBAAgB,GAAGL,QAAQ,CAACnB,SAAS,CAACf,GAAG,EAAEgB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAOuB,QAAA,CAAQC,OAAO,CAACF,gBAAgB,CAAC,CACrCG,IAAI,CAAC,MAAMR,QAAQ,CAACtC,cAAc,CAAC,CAAC,CAAC,CAAC,CACtC+C,KAAK,CAAEf,KAAK,IAAKM,QAAQ,CAACpC,WAAW,CAAC8B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMgB,WAAW,GAAGA,CACzB3C,KAAqB,EACrBgB,OAAiC,KAEjCgB,aAAa,CAAChC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC4C,QAAQ,EAAE;EAC9C,GAAG5B,OAAO;EACV6B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -1,8 +1,9 @@
1
1
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
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
  import { startProgress, finishProgress } from "../actions/ProgressIndicator";
5
5
  import { handleError } from "../actions/Error";
6
+ import { updateStatus } from "./ModularUIActions";
6
7
  /**
7
8
  * Symbol key that carries API call info interpreted by this Redux middleware.
8
9
  */
@@ -64,12 +65,14 @@ const errorHandler = (next, dispatch, errorAction, err) => {
64
65
  const handleFetch = (action, locale, dispatch, next) => {
65
66
  dispatch(startProgress());
66
67
  const {
68
+ key,
67
69
  successAction,
68
70
  errorAction,
69
71
  ...requestOptions
70
72
  } = action.payload;
71
73
  requestOptions.locale = locale;
72
74
  const modularuiRequest = createRequest(requestOptions);
75
+ dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
73
76
  return modularuiRequest.fetch().then(model => responseHandler(next, dispatch, successAction, model)).catch(error => errorHandler(next, dispatch, errorAction, error));
74
77
  };
75
78
 
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAAkB;AA0B9C;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAACM,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIR,YAAY,CAACS,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ,QAAQ;IAC5BC,KAAK,EAAET,SAAS,CAACS;EACnB,CAAC,CAAC;EAEF,IAAIT,SAAS,CAACU,WAAW,EAAE;IACzBT,OAAO,CAACS,WAAW,GAAGV,SAAS,CAACU,WAAW;IAC3CT,OAAO,CAACU,gBAAgB,GAAGX,SAAS,CAACW,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOV,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMW,eAAe,GAAGA,CACtBC,IAAc,EACdC,QAAkB,EAClBC,aAA4B,EAC5BC,KAAqB,KAClB;EACH,IAAID,aAAa,EAAE;IACjB,MAAME,aAAa,GAAGF,aAAa,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,MAAM0B,gBAAgB,GAAGjC,aAAa,CAAC+B,cAAc,CAAC;EAEtD,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPd,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMY,mBAIZ,GACEC,GAAqD,IACrDtB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACO,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOR,WAAW;IAChB;IACAC,MAAM,EACNM,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAChC,MAAM,EAC1B6B,GAAG,CAACrB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","MODULARUI_STATUS","startProgress","finishProgress","handleError","updateStatus","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","key","requestOptions","payload","modularuiRequest","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAE1E,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,YAAY,QAAQ,oBAAoB;AA0BjD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIT,gBAAgB,CAACQ,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIV,YAAY,CAACW,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ,QAAQ;IAC5BC,KAAK,EAAET,SAAS,CAACS;EACnB,CAAC,CAAC;EAEF,IAAIT,SAAS,CAACU,WAAW,EAAE;IACzBT,O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,CAAC,CAAC;AAC/B,CAAC;;AAED;AACA;AACA,MAAME,WAAW,GAAGA,CAClBC,MAAuB,EACvBvB,MAAc,EACdQ,QAAkB,EAClBD,IAAc,KACX;EACHC,QAAQ,CAACnB,aAAa,CAAC,CAAC,CAAC;EAEzB,MAAM;IAAEmC,GAAG;IAAEf,aAAa;IAAEU,WAAW;IAAE,GAAGM;EAAe,CAAC,GAAGF,MAAM,CAACG,OAAO;EAC7ED,cAAc,CAACzB,MAAM,GAAGA,MAAM;EAE9B,MAAM2B,gBAAgB,GAAGlC,aAAa,CAACgC,cAAc,CAAC;EAEtDjB,QAAQ,CAAChB,YAAY,CAACgC,GAAG,EAAEpC,gBAAgB,CAACwC,OAAO,CAAC,CAAC;EAErD,OAAOD,gBAAgB,CACpBE,KAAK,CAAC,CAAC,CACPhB,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMc,mBAIZ,GACEC,GAAqD,IACrDxB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACS,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOV,WAAW;IAChB;IACAC,MAAM,EACNQ,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAClC,MAAM,EAC1B+B,GAAG,CAACvB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -41,7 +41,8 @@ const setModel = (state, _ref2) => {
41
41
  [key]: {
42
42
  ...state[key],
43
43
  model,
44
- lastModification: Date.now()
44
+ lastModification: Date.now(),
45
+ status: MODULARUI_STATUS.FINISHED
45
46
  }
46
47
  };
47
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","initModularUI","models","newState","_Object$assign","forEach","_ref3","FINISHED","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel },\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>,\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC,GAAAF,IAAA;EAExE;EACA,IAAIE,MAAM,KAAKN,gBAAgB,CAACO,OAAO,IAAI,CAACJ,KAAK,CAACE,GAAG,CAAC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sD,GAAG,SAAAA,CAAA,EAGjE;EAAA,IAFH9B,KAAK,GAAA+B,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGF,YAAY;EAAA,IACpBK,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOlC,KAAK;EACd;EAEA,QAAQkC,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOxB,aAAa,CAACX,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOR,cAAc,CAAC5B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO5B,QAAQ,CAACR,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOZ,WAAW,CAACxB,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOT,SAAS,CAACO,MAAM,CAACE,OAAO,EAAEpC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","initModularUI","models","newState","_Object$assign","forEach","_ref3","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel },\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>,\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC,GAAAF,IAAA;EAExE;EACA,IAAIE,MAAM,KAAKN,gBAAgB,CAACO,OAAO,IAAI,CAACJ,KAAK,CAACE,GAAG,CAAC,EAAE;IACtD,OAAOF,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACE,GAAG,GAAG;MACL,GAAGF,KAAK,CAACE,GAAG,CAAC;MACbC,MAAM;MACNE,gBAAgB,EAAEC,IAAI,CAACC,GAAG,CAAC;IAC7B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfR,KAAqB,EAAAS,KAAA,KAElB;EAAA,IADH;IAAEP,GAAG;IAAEQ;EAA+C,CAAC,GAAAD,KAAA;EAEvD,IAAI,CAACT,KAAK,CAACE,GAAG,CAA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CAACZ,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOR,cAAc,CAAC5B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO5B,QAAQ,CAACR,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOZ,WAAW,CAACxB,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOT,SAAS,CAACO,MAAM,CAACE,OAAO,EAAEpC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n key: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
@@ -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", () => {
@@ -64,14 +71,11 @@ describe("modularui hooks", () => {
64
71
  expect(result.current).toBeNull();
65
72
 
66
73
  expect(store.getActions()).toStrictEqual([
67
- {
68
- type: "MODULARUI/STATUS",
69
- payload: { key: `${key}(${url})(en)`, status: "LOADING" },
70
- },
71
74
  { type: "START_PROGRESS" },
72
75
  {
73
76
  type: "MODULARUI/FETCH",
74
77
  payload: expect.objectContaining({
78
+ key: `${key}(${url})(en)`,
75
79
  href: new Href(url),
76
80
  locale: "en",
77
81
  targetModel: targetModel,
@@ -83,6 +87,9 @@ describe("modularui hooks", () => {
83
87
  // replace the real XHR object with the mock XHR object before each test
84
88
  // eslint-disable-next-line jest/no-hooks
85
89
  beforeEach(() => {
90
+ useLocation.mockReturnValue({
91
+ state: null,
92
+ });
86
93
  xhrMock.setup();
87
94
  });
88
95
 
@@ -61,14 +61,11 @@ describe("authentication hooks", () => {
61
61
 
62
62
  expect(store.getActions()).toStrictEqual([
63
63
  { type: "START_PROGRESS" },
64
- {
65
- type: "MODULARUI/STATUS",
66
- payload: { key: "application(/)(en)", status: "LOADING" },
67
- },
68
64
  { type: "START_PROGRESS" },
69
65
  expect.objectContaining({
70
66
  type: "MODULARUI/FETCH",
71
67
  payload: expect.objectContaining({
68
+ key: "application(/)(en)",
72
69
  href: new Href("/", "Application"),
73
70
  }),
74
71
  }),
@@ -108,14 +105,11 @@ describe("authentication hooks", () => {
108
105
  expect(store.getActions()).toStrictEqual([
109
106
  { type: "START_PROGRESS" },
110
107
  { type: "MODULARUI/RESET" },
111
- {
112
- type: "MODULARUI/STATUS",
113
- payload: { key: "application(/)(en)", status: "LOADING" },
114
- },
115
108
  { type: "START_PROGRESS" },
116
109
  expect.objectContaining({
117
110
  type: "MODULARUI/FETCH",
118
111
  payload: expect.objectContaining({
112
+ key: "application(/)(en)",
119
113
  href: new Href("/", "Application"),
120
114
  }),
121
115
  }),
@@ -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(() => xhrMock.setup());
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
@@ -58,14 +69,11 @@ describe("form hooks", () => {
58
69
  expect(result.current).toBeUndefined();
59
70
 
60
71
  expect(store.getActions()).toStrictEqual([
61
- {
62
- type: "MODULARUI/STATUS",
63
- payload: { key: "form(/form)(en)", status: "LOADING" },
64
- },
65
72
  { type: "START_PROGRESS" },
66
73
  {
67
74
  type: "MODULARUI/FETCH",
68
75
  payload: expect.objectContaining({
76
+ key: "form(/form)(en)",
69
77
  href: new Href("/form?commit=false"),
70
78
  locale: "en",
71
79
  targetModel: FormModel,
@@ -102,17 +110,11 @@ describe("form hooks", () => {
102
110
  href.resourcetype = "Form";
103
111
 
104
112
  expect(store.getActions()).toStrictEqual([
105
- {
106
- type: "MODULARUI/STATUS",
107
- payload: {
108
- key: "form(/persons/persons/createperson)(en)",
109
- status: "LOADING",
110
- },
111
- },
112
113
  { type: "START_PROGRESS" },
113
114
  {
114
115
  type: "MODULARUI/FETCH",
115
116
  payload: expect.objectContaining({
117
+ key: "form(/persons/persons/createperson)(en)",
116
118
  href: href,
117
119
  locale: "en",
118
120
  targetModel: FormModel,