@beinformed/ui 1.57.0-contextpath.0 → 1.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/esm/constants/Settings.js +10 -2
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/hooks/useModularUI.js +24 -18
  5. package/esm/hooks/useModularUI.js.map +1 -1
  6. package/esm/hooks/useModularUIBasic.js +52 -41
  7. package/esm/hooks/useModularUIBasic.js.map +1 -1
  8. package/esm/models/concepts/ConceptDetailModel.js +1 -8
  9. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  10. package/esm/models/concepts/ConceptIndexModel.js +1 -1
  11. package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
  12. package/esm/models/concepts/ConceptLinkModel.js +8 -9
  13. package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
  14. package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
  15. package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  16. package/esm/models/concepts/SourceReferenceCollection.js +3 -1
  17. package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
  18. package/esm/models/concepts/SourceReferenceModel.js +9 -3
  19. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  20. package/esm/models/content/ContentLinkModel.js +10 -4
  21. package/esm/models/content/ContentLinkModel.js.map +1 -1
  22. package/esm/models/content/SectionModel.js +10 -6
  23. package/esm/models/content/SectionModel.js.map +1 -1
  24. package/esm/models/error/ErrorResponse.js +20 -5
  25. package/esm/models/error/ErrorResponse.js.map +1 -1
  26. package/esm/models/href/Href.js +21 -4
  27. package/esm/models/href/Href.js.map +1 -1
  28. package/esm/models/list/ListItemCollection.js +1 -1
  29. package/esm/models/list/ListItemCollection.js.map +1 -1
  30. package/esm/modularui/CaptchaRequest.js +12 -3
  31. package/esm/modularui/CaptchaRequest.js.map +1 -1
  32. package/esm/modularui/ModularUIRequest.js +1 -1
  33. package/esm/modularui/ModularUIRequest.js.map +1 -1
  34. package/esm/modularui/UploadRequest.js +7 -3
  35. package/esm/modularui/UploadRequest.js.map +1 -1
  36. package/esm/redux/_modularui/ModularUIActions.js +11 -9
  37. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  38. package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
  39. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  40. package/esm/redux/_modularui/ModularUIReducer.js +2 -1
  41. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  42. package/esm/redux/_modularui/ModularUISelectors.js +7 -6
  43. package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
  44. package/esm/redux/_modularui/types.js.map +1 -1
  45. package/esm/redux/actions/Application.js +11 -6
  46. package/esm/redux/actions/Application.js.map +1 -1
  47. package/esm/redux/connectors/PanelRenderer.js +0 -2
  48. package/esm/redux/connectors/PanelRenderer.js.map +1 -1
  49. package/esm/utils/helpers/checkResource.js +0 -2
  50. package/esm/utils/helpers/checkResource.js.map +1 -1
  51. package/esm/utils/helpers/repositoryResource.js +6 -5
  52. package/esm/utils/helpers/repositoryResource.js.map +1 -1
  53. package/lib/constants/Settings.js +10 -2
  54. package/lib/constants/Settings.js.flow +8 -2
  55. package/lib/constants/Settings.js.map +1 -1
  56. package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
  57. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
  58. package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
  59. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
  60. package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
  61. package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
  62. package/lib/hooks/useModularUI.js +23 -17
  63. package/lib/hooks/useModularUI.js.flow +31 -16
  64. package/lib/hooks/useModularUI.js.map +1 -1
  65. package/lib/hooks/useModularUIBasic.js +52 -41
  66. package/lib/hooks/useModularUIBasic.js.flow +66 -50
  67. package/lib/hooks/useModularUIBasic.js.map +1 -1
  68. package/lib/models/concepts/ConceptDetailModel.js +1 -8
  69. package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
  70. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  71. package/lib/models/concepts/ConceptIndexModel.js +1 -1
  72. package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
  73. package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
  74. package/lib/models/concepts/ConceptLinkModel.js +8 -9
  75. package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
  76. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  77. package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
  78. package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
  79. package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  80. package/lib/models/concepts/SourceReferenceCollection.js +3 -1
  81. package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
  82. package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
  83. package/lib/models/concepts/SourceReferenceModel.js +9 -3
  84. package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
  85. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  86. package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
  87. package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
  88. package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
  89. package/lib/models/content/ContentLinkModel.js +9 -4
  90. package/lib/models/content/ContentLinkModel.js.flow +19 -4
  91. package/lib/models/content/ContentLinkModel.js.map +1 -1
  92. package/lib/models/content/SectionModel.js +10 -6
  93. package/lib/models/content/SectionModel.js.flow +31 -5
  94. package/lib/models/content/SectionModel.js.map +1 -1
  95. package/lib/models/error/ErrorResponse.js +20 -5
  96. package/lib/models/error/ErrorResponse.js.flow +34 -5
  97. package/lib/models/error/ErrorResponse.js.map +1 -1
  98. package/lib/models/href/Href.js +21 -4
  99. package/lib/models/href/Href.js.flow +21 -4
  100. package/lib/models/href/Href.js.map +1 -1
  101. package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
  102. package/lib/models/list/ListItemCollection.js +1 -1
  103. package/lib/models/list/ListItemCollection.js.flow +2 -0
  104. package/lib/models/list/ListItemCollection.js.map +1 -1
  105. package/lib/modularui/CaptchaRequest.js +11 -2
  106. package/lib/modularui/CaptchaRequest.js.flow +17 -3
  107. package/lib/modularui/CaptchaRequest.js.map +1 -1
  108. package/lib/modularui/ModularUIRequest.js +1 -1
  109. package/lib/modularui/ModularUIRequest.js.flow +3 -1
  110. package/lib/modularui/ModularUIRequest.js.map +1 -1
  111. package/lib/modularui/UploadRequest.js +6 -2
  112. package/lib/modularui/UploadRequest.js.flow +12 -2
  113. package/lib/modularui/UploadRequest.js.map +1 -1
  114. package/lib/redux/_modularui/ModularUIActions.js +11 -9
  115. package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
  116. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  117. package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
  118. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
  119. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  120. package/lib/redux/_modularui/ModularUIReducer.js +2 -1
  121. package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
  122. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  123. package/lib/redux/_modularui/ModularUISelectors.js +5 -6
  124. package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
  125. package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
  126. package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
  127. package/lib/redux/_modularui/types.js.flow +1 -0
  128. package/lib/redux/_modularui/types.js.map +1 -1
  129. package/lib/redux/actions/Application.js +10 -5
  130. package/lib/redux/actions/Application.js.flow +16 -5
  131. package/lib/redux/actions/Application.js.map +1 -1
  132. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
  133. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
  134. package/lib/redux/connectors/PanelRenderer.js +0 -2
  135. package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
  136. package/lib/redux/connectors/PanelRenderer.js.map +1 -1
  137. package/lib/utils/helpers/checkResource.js +0 -2
  138. package/lib/utils/helpers/checkResource.js.flow +0 -2
  139. package/lib/utils/helpers/checkResource.js.map +1 -1
  140. package/lib/utils/helpers/repositoryResource.js +6 -5
  141. package/lib/utils/helpers/repositoryResource.js.flow +8 -6
  142. package/lib/utils/helpers/repositoryResource.js.map +1 -1
  143. package/package.json +18 -18
  144. package/src/constants/Settings.js +8 -2
  145. package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
  146. package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
  147. package/src/hooks/__tests__/useForm.spec.js +14 -12
  148. package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
  149. package/src/hooks/__tests__/useModels.spec.js +3 -12
  150. package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
  151. package/src/hooks/useModularUI.js +31 -16
  152. package/src/hooks/useModularUIBasic.js +66 -50
  153. package/src/models/concepts/ConceptDetailModel.js +2 -7
  154. package/src/models/concepts/ConceptIndexModel.js +7 -1
  155. package/src/models/concepts/ConceptLinkModel.js +14 -9
  156. package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
  157. package/src/models/concepts/SourceReferenceCollection.js +8 -1
  158. package/src/models/concepts/SourceReferenceModel.js +19 -3
  159. package/src/models/concepts/__mock__/conceptindex.js +15 -0
  160. package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
  161. package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
  162. package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
  163. package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
  164. package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
  165. package/src/models/content/ContentLinkModel.js +19 -4
  166. package/src/models/content/SectionModel.js +31 -5
  167. package/src/models/error/ErrorResponse.js +34 -5
  168. package/src/models/href/Href.js +21 -4
  169. package/src/models/href/__tests__/Href.spec.js +9 -3
  170. package/src/models/list/ListItemCollection.js +2 -0
  171. package/src/modularui/CaptchaRequest.js +17 -3
  172. package/src/modularui/ModularUIRequest.js +3 -1
  173. package/src/modularui/UploadRequest.js +12 -2
  174. package/src/redux/_modularui/ModularUIActions.js +20 -10
  175. package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
  176. package/src/redux/_modularui/ModularUIReducer.js +1 -0
  177. package/src/redux/_modularui/ModularUISelectors.js +22 -10
  178. package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
  179. package/src/redux/_modularui/types.js +1 -0
  180. package/src/redux/actions/Application.js +16 -5
  181. package/src/redux/actions/__tests__/Application.spec.js +1 -8
  182. package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
  183. package/src/redux/connectors/PanelRenderer.js +0 -1
  184. package/src/utils/helpers/checkResource.js +0 -2
  185. package/src/utils/helpers/repositoryResource.js +8 -6
@@ -172,12 +172,18 @@ export const getBasePath = (): string =>
172
172
  /**
173
173
  * Path to upload service
174
174
  */
175
- export const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;
175
+ export const getUploadPath = (
176
+ contextPath: string = getBasePath(),
177
+ origin: string = "",
178
+ ): string => `${origin}${contextPath}${UPLOAD_PATH}`;
176
179
 
177
180
  /**
178
181
  * Path to captcha service
179
182
  */
180
- export const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;
183
+ export const getCaptchaPath = (
184
+ contextPath: string = getBasePath(),
185
+ origin: string = "",
186
+ ): string => `${origin}${contextPath}${CAPTCHA_PATH}`;
181
187
 
182
188
  /**
183
189
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Settings.js","names":["_objects","require","_repositoryResource","_Constants","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","settings","setSettings","config","isPlainObject","_assign","default","exports","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","loginType","LOGIN_TYPE","INTERNAL_LOGIN_TYPE","JAAS","loginPath","clientName","arguments","length","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","_startsWith","call","getRepositoryResourceUrl","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`,\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (clientName: string = \"FormClient\"): string =>\n getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAcA,MAAMG,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE,IAAI;EAE5B;EACAC,qCAAqC,EAAE,IAAI;EAE3C;EACAC,oCAAoC,EAAE,KAAK;EAE3C;EACAC,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;EAE/C;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,6BAA6B,EAAE,IAAI;EAEnC;EACAC,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EAE7B;EACAC,wBAAwB,E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WAAmB,IAAK;EACrD8C,UAAU,CAAC,cAAc,EAAE9C,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AAFAuC,OAAA,CAAAsC,cAAA,GAAAA,cAAA;AAGO,MAAMC,IAAY,GAAAvC,OAAA,CAAAuC,IAAA,GAAG5B,WAAW,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Settings.js","names":["_objects","require","_repositoryResource","_Constants","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","settings","setSettings","config","isPlainObject","_assign","default","exports","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","arguments","length","origin","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","loginType","LOGIN_TYPE","INTERNAL_LOGIN_TYPE","JAAS","loginPath","clientName","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","_startsWith","call","getRepositoryResourceUrl","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`,\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (\n contextPath: string = getBasePath(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (\n contextPath: string = getBasePath(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (clientName: string = \"FormClient\"): string =>\n getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAcA,MAAMG,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EA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BAAA;AAEO,MAAME,kBAAkB,GAAGA,CAAA,KAChC7B,UAAU,CAAC8B,iCAAsB,EAAE,YAAY,CAAC;AAClD;AACA;AADA/B,OAAA,CAAA8B,kBAAA,GAAAA,kBAAA;AAEO,MAAME,UAAU,GAAGA,CAAA,KACxB/B,UAAU,CAACgC,8BAAmB,EAAE,SAAS,CAAC;AAACjC,OAAA,CAAAgC,UAAA,GAAAA,UAAA;AAEtC,MAAMxD,UAAkB,GAAAwB,OAAA,CAAAxB,UAAA,GAAGiD,SAAS,CAAC,CAAC;AACtC,MAAM/C,WAAmB,GAAAsB,OAAA,CAAAtB,WAAA,GAAGsD,UAAU,CAAC,CAAC;;AAE/C;AACA;AACA;AACO,MAAME,+BAAuC,GAAGA,CAAA,KAAM;EAC3D,IAAIC,cAAc,GAAGlC,UAAU,CAC7B,iCAAiC,EACjC,kCACF,CAAC;EACD,IAAI,CAAC,IAAAmC,WAAA,CAAArC,OAAA,EAAAoC,cAAc,EAAAE,IAAA,CAAdF,cAAc,EAAY,GAAG,CAAC,EAAE;IACnCA,cAAc,GAAG,IAAIA,cAAc,EAAE;EACvC;EACA,OAAO,IAAAG,4CAAwB,EAACH,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AAFAnC,OAAA,CAAAkC,+BAAA,GAAAA,+BAAA;AAGO,MAAMK,cAAc,GAAI9E,WAAmB,IAAK;EACrD8C,UAAU,CAAC,cAAc,EAAE9C,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AAFAuC,OAAA,CAAAuC,cAAA,GAAAA,cAAA;AAGO,MAAMC,IAAY,GAAAxC,OAAA,CAAAwC,IAAA,GAAG7B,WAAW,CAAC,CAAC","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,
@@ -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", () => {
@@ -58,14 +64,11 @@ describe("modelcatalog hooks", () => {
58
64
  expect(result.current).toBeNull();
59
65
 
60
66
  expect(store.getActions()).toStrictEqual([
61
- {
62
- type: "MODULARUI/STATUS",
63
- payload: { key: `${key}(${url})(en)`, status: "LOADING" },
64
- },
65
67
  { type: "START_PROGRESS" },
66
68
  {
67
69
  type: "MODULARUI/FETCH",
68
70
  payload: expect.objectContaining({
71
+ key: `${key}(${url})(en)`,
69
72
  href: new Href(url),
70
73
  locale: "en",
71
74
  targetModel: targetModel,
@@ -77,6 +80,9 @@ describe("modelcatalog hooks", () => {
77
80
  // replace the real XHR object with the mock XHR object before each test
78
81
  // eslint-disable-next-line jest/no-hooks
79
82
  beforeEach(() => {
83
+ useLocation.mockReturnValue({
84
+ state: null,
85
+ });
80
86
  xhrMock.setup();
81
87
  });
82
88
 
@@ -37,14 +37,11 @@ describe("model hooks", () => {
37
37
 
38
38
  result.current.reload(application);
39
39
  expect(store.getActions()).toStrictEqual([
40
- {
41
- type: "MODULARUI/STATUS",
42
- payload: { key: "application(/)(en)", status: "LOADING" },
43
- },
44
40
  { type: "START_PROGRESS" },
45
41
  {
46
42
  type: "MODULARUI/FETCH",
47
43
  payload: expect.objectContaining({
44
+ key: "application(/)(en)",
48
45
  href: new Href("/", "Application"),
49
46
  locale: "en",
50
47
  }),
@@ -83,14 +80,11 @@ describe("model hooks", () => {
83
80
  model.selfhref.equals(new Href("/")),
84
81
  );
85
82
  expect(store.getActions()).toStrictEqual([
86
- {
87
- type: "MODULARUI/STATUS",
88
- payload: { key: "application(/)(en)", status: "LOADING" },
89
- },
90
83
  { type: "START_PROGRESS" },
91
84
  {
92
85
  type: "MODULARUI/FETCH",
93
86
  payload: expect.objectContaining({
87
+ key: "application(/)(en)",
94
88
  href: new Href("/", "Application"),
95
89
  locale: "en",
96
90
  }),
@@ -130,14 +124,11 @@ describe("model hooks", () => {
130
124
  model.selfhref.equals(new Href("/books/books")),
131
125
  );
132
126
  expect(store.getActions()).toStrictEqual([
133
- {
134
- type: "MODULARUI/STATUS",
135
- payload: { key: "list(/books/books)(en)", status: "LOADING" },
136
- },
137
127
  { type: "START_PROGRESS" },
138
128
  {
139
129
  type: "MODULARUI/FETCH",
140
130
  payload: expect.objectContaining({
131
+ key: "list(/books/books)(en)",
141
132
  href: caselist.selfhref,
142
133
  locale: "en",
143
134
  }),
@@ -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
 
@@ -57,10 +66,6 @@ describe("modularui hooks", () => {
57
66
  expect(result.current).toBeNull();
58
67
 
59
68
  expect(store.getActions()).toStrictEqual([
60
- {
61
- type: "MODULARUI/STATUS",
62
- payload: { key: `app(/)(en)`, status: "LOADING" },
63
- },
64
69
  { type: "START_PROGRESS" },
65
70
  {
66
71
  type: "MODULARUI/FETCH",
@@ -107,10 +112,6 @@ describe("modularui hooks", () => {
107
112
  expect(result.current).toBeNull();
108
113
 
109
114
  expect(store.getActions()).toStrictEqual([
110
- {
111
- type: "MODULARUI/STATUS",
112
- payload: { key: `app(/)(en)`, status: "LOADING" },
113
- },
114
115
  { type: "START_PROGRESS" },
115
116
  {
116
117
  type: "MODULARUI/FETCH",
@@ -7,15 +7,17 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useModularUI = void 0;
8
8
  var _react = require("react");
9
9
  var _reactRedux = require("react-redux");
10
+ var _reactRouter = require("react-router");
10
11
  var _constants = require("../constants");
11
12
  var _ModularUIActions = require("../redux/_modularui/ModularUIActions");
12
13
  var _useDeepCompareEffect = _interopRequireDefault(require("./useDeepCompareEffect"));
13
14
  var _useI18n = require("./useI18n");
15
+ var _Href = _interopRequireDefault(require("../models/href/Href"));
14
16
  /**
15
17
  */
16
18
  const useKeyForHook = (modelKey, url) => {
17
19
  const locale = (0, _useI18n.useLocale)();
18
- return `${modelKey}(${url.split("?")[0]})(${locale})`;
20
+ return (0, _react.useMemo)(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
19
21
  };
20
22
 
21
23
  /**
@@ -27,36 +29,40 @@ const useModularUI = function (modelKey, url) {
27
29
  removeOnUnmount: false
28
30
  };
29
31
  const dispatch = (0, _reactRedux.useDispatch)();
30
- const href = url?.toString() || "";
32
+ const href = (0, _react.useMemo)(() => url?.toString() || "", [url]);
31
33
  const key = useKeyForHook(modelKey, href);
34
+ if (url instanceof _Href.default) {
35
+ options.origin = options.origin ?? url.origin;
36
+ options.contextPath = options.contextPath ?? url.contextPath;
37
+ }
38
+ const location = (0, _reactRouter.useLocation)();
39
+ const redirectLocation = location.state?.redirectLocation;
40
+ const forceReload = redirectLocation instanceof _Href.default ? redirectLocation?.equals(href) : false;
32
41
  const prevOptions = (0, _react.useRef)(options);
33
42
  const prevHref = (0, _react.useRef)(href);
43
+ const prevForceReload = (0, _react.useRef)(forceReload);
34
44
 
35
45
  // dispatch loadModularUI
36
46
  (0, _useDeepCompareEffect.default)(() => {
37
47
  // prevent reloads when previous option had the isReload, but the new options not
38
48
  const isOldReload = prevHref.current === href && prevOptions.current.isReload && !options.isReload;
39
- if (href !== "" && !isOldReload) {
49
+ const doForceReload = forceReload && !prevForceReload.current;
50
+ if (href !== "" && (doForceReload || !isOldReload)) {
40
51
  dispatch((0, _ModularUIActions.loadModularUI)(key, href, options));
41
52
  }
42
53
  prevOptions.current = options;
43
54
  prevHref.current = href;
44
- }, [key, href, options]);
45
- const {
46
- removeOnUnmount = false
47
- } = options;
55
+ prevForceReload.current = forceReload;
56
+ }, [key, href, options, forceReload]);
48
57
  (0, _react.useEffect)(() => {
49
- return () => {
50
- if (removeOnUnmount) {
58
+ if (options.removeOnUnmount) {
59
+ return () => {
51
60
  dispatch((0, _ModularUIActions.removeModelByKey)(key));
52
- }
53
- };
54
- }, [dispatch, key, removeOnUnmount]);
55
-
56
- // retrieve current model from modularui reducer
57
- return (0, _reactRedux.useSelector)(state => {
58
- return state.modularui[key];
59
- });
61
+ };
62
+ }
63
+ }, [dispatch, key, options.removeOnUnmount]);
64
+ const selector = (0, _react.useMemo)(() => state => state.modularui[key], [key]);
65
+ return (0, _reactRedux.useSelector)(selector);
60
66
  };
61
67
  exports.useModularUI = useModularUI;
62
68
  //# sourceMappingURL=useModularUI.js.map
@@ -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 {
@@ -11,15 +12,18 @@ import {
11
12
  import useDeepCompareEffect from "./useDeepCompareEffect";
12
13
 
13
14
  import { useLocale } from "./useI18n";
15
+ import Href from "../models/href/Href";
14
16
 
15
- import type 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 `${modelKey}(${url.split("?")[0]})(${locale})`;
23
+ return useMemo(
24
+ () => `${modelKey}(${url.split("?")[0]})(${locale})`,
25
+ [modelKey, url, locale],
26
+ );
23
27
  };
24
28
 
25
29
  /**
@@ -34,11 +38,22 @@ 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
+ if (url instanceof Href) {
45
+ options.origin = options.origin ?? url.origin;
46
+ options.contextPath = options.contextPath ?? url.contextPath;
47
+ }
48
+
49
+ const location = useLocation();
50
+ const redirectLocation = location.state?.redirectLocation;
51
+ const forceReload =
52
+ redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;
53
+
40
54
  const prevOptions = useRef(options);
41
55
  const prevHref = useRef(href);
56
+ const prevForceReload = useRef(forceReload);
42
57
 
43
58
  // dispatch loadModularUI
44
59
  useDeepCompareEffect(() => {
@@ -48,25 +63,25 @@ export const useModularUI = (
48
63
  prevOptions.current.isReload &&
49
64
  !options.isReload;
50
65
 
51
- if (href !== "" && !isOldReload) {
66
+ const doForceReload = forceReload && !prevForceReload.current;
67
+
68
+ if (href !== "" && (doForceReload || !isOldReload)) {
52
69
  dispatch(loadModularUI(key, href, options));
53
70
  }
54
71
 
55
72
  prevOptions.current = options;
56
73
  prevHref.current = href;
57
- }, [key, href, options]);
74
+ prevForceReload.current = forceReload;
75
+ }, [key, href, options, forceReload]);
58
76
 
59
- const { removeOnUnmount = false } = options;
60
77
  useEffect(() => {
61
- return () => {
62
- if (removeOnUnmount) {
78
+ if (options.removeOnUnmount) {
79
+ return () => {
63
80
  dispatch(removeModelByKey(key));
64
- }
65
- };
66
- }, [dispatch, key, removeOnUnmount]);
81
+ };
82
+ }
83
+ }, [dispatch, key, options.removeOnUnmount]);
67
84
 
68
- // retrieve current model from modularui reducer
69
- return useSelector((state) => {
70
- return state.modularui[key];
71
- });
85
+ const selector = useMemo(() => (state) => state.modularui[key], [key]);
86
+ return useSelector(selector);
72
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","useKeyForHook","modelKey","url","locale","useLocale","split","useModularUI","options","arguments","length","undefined","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","useSelector","state","modularui","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAKA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AAKA;AACA;AACA,MAAMO,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,GAAGH,QAAQ,IAAIC,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKF,MAAM,GAAG;AACvD,CAAC;;AAED;AACA;AACA;AACO,MAAMG,YAAY,GAAG,SAAAA,CAC1BL,QAAgB,EAChBC,GAAkB,EAKV;EAAA,IAJRK,OAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAA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AACC,SAAS,CAACb,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC;AAACc,OAAA,CAAA3B,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","useKeyForHook","modelKey","url","locale","useLocale","useMemo","split","useModularUI","options","arguments","length","undefined","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","Href","origin","contextPath","location","useLocation","redirectLocation","state","forceReload","equals","prevOptions","useRef","prevHref","prevForceReload","useDeepCompareEffect","isOldReload","current","isReload","doForceReload","loadModularUI","useEffect","removeModelByKey","selector","modularui","useSelector","exports"],"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\";\nimport Href from \"../models/href/Href\";\n\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 if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAEA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAF,sBAAA,CAAAN,OAAA;AAIA;AACA;AACA,MAAMS,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,IAAAC,cAAO,EACZ,MAAM,GAAGJ,QAAQ,IAAIC,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKH,MAAM,GAAG,EACpD,CAACF,QAAQ,EAAEC,GAAG,EAAEC,MAAM,CACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACO,MAA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