@beinformed/ui 1.65.22 → 1.65.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/esm/hooks/__tests__/useAuthentication.spec.js.flow +100 -132
- package/esm/hooks/useAuthentication.js +14 -8
- package/esm/hooks/useAuthentication.js.flow +23 -23
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/hooks/useModularUI.js +1 -1
- package/esm/hooks/useModularUI.js.flow +1 -1
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/models/filters/RangeFilterModel.js +1 -1
- package/esm/models/filters/RangeFilterModel.js.flow +1 -1
- package/esm/models/filters/RangeFilterModel.js.map +1 -1
- package/esm/models/filters/__tests__/RangeFilterModel.spec.js.flow +5 -7
- package/esm/redux/_i18n/I18nActions.js.flow +1 -1
- package/esm/redux/_i18n/I18nActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js.flow +2 -2
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIConnector.js +2 -2
- package/esm/redux/_modularui/ModularUIConnector.js.flow +2 -2
- package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +12 -18
- package/esm/redux/_modularui/ModularUISelectors.js.flow +13 -14
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/withModularUI.js.flow +2 -2
- package/esm/redux/_modularui/withModularUI.js.map +1 -1
- package/esm/redux/actions/Application.js +32 -4
- package/esm/redux/actions/Application.js.flow +34 -5
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/actions/Authorization.js +20 -25
- package/esm/redux/actions/Authorization.js.flow +28 -29
- package/esm/redux/actions/Authorization.js.map +1 -1
- package/esm/redux/actions/Error.js +2 -0
- package/esm/redux/actions/Error.js.flow +5 -4
- package/esm/redux/actions/Error.js.map +1 -1
- package/esm/redux/actions/Form.js.flow +1 -1
- package/esm/redux/actions/Form.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js.flow +1 -1
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAutosave.js.flow +1 -1
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormAutosubmit.js.flow +1 -1
- package/esm/redux/actions/FormAutosubmit.js.map +1 -1
- package/esm/redux/actions/FormAutoupdate.js.flow +1 -1
- package/esm/redux/actions/FormAutoupdate.js.map +1 -1
- package/esm/redux/actions/FormValidations.js.flow +1 -1
- package/esm/redux/actions/FormValidations.js.map +1 -1
- package/esm/redux/actions/Notification.js.flow +3 -3
- package/esm/redux/actions/Notification.js.map +1 -1
- package/esm/redux/actions/SignIn.js +2 -4
- package/esm/redux/actions/SignIn.js.flow +4 -7
- package/esm/redux/actions/SignIn.js.map +1 -1
- package/esm/redux/actions/SignOut.js.flow +1 -1
- package/esm/redux/actions/SignOut.js.map +1 -1
- package/esm/redux/actions/__tests__/Application.spec.js.flow +67 -29
- package/esm/redux/actions/__tests__/Authorization.spec.js.flow +77 -83
- package/esm/redux/connectors/Form.js.flow +2 -2
- package/esm/redux/connectors/Form.js.map +1 -1
- package/esm/redux/connectors/FormAttributeSet.js.flow +2 -5
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/connectors/Progress.js.flow +1 -1
- package/esm/redux/connectors/Progress.js.map +1 -1
- package/esm/redux/connectors/SignIn.js.flow +1 -1
- package/esm/redux/connectors/SignIn.js.map +1 -1
- package/esm/redux/connectors/SignOut.js.flow +1 -1
- package/esm/redux/connectors/SignOut.js.map +1 -1
- package/esm/redux/store/configureStore.js +5 -1
- package/esm/redux/store/configureStore.js.flow +10 -1
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/redux/types.js.flow +24 -5
- package/esm/redux/types.js.map +1 -1
- package/lib/hooks/useAuthentication.js +14 -8
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/hooks/useModularUI.js +1 -1
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/models/filters/RangeFilterModel.js +1 -1
- package/lib/models/filters/RangeFilterModel.js.map +1 -1
- package/lib/redux/_i18n/I18nActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIConnector.js +2 -2
- package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +12 -18
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/actions/Application.js +33 -4
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/Authorization.js +20 -25
- package/lib/redux/actions/Authorization.js.map +1 -1
- package/lib/redux/actions/Error.js +2 -0
- package/lib/redux/actions/Error.js.map +1 -1
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormAutosubmit.js.map +1 -1
- package/lib/redux/actions/FormAutoupdate.js.map +1 -1
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/Notification.js.map +1 -1
- package/lib/redux/actions/SignIn.js +2 -4
- package/lib/redux/actions/SignIn.js.map +1 -1
- package/lib/redux/actions/SignOut.js.map +1 -1
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/connectors/Progress.js.map +1 -1
- package/lib/redux/connectors/SignIn.js.map +1 -1
- package/lib/redux/connectors/SignOut.js.map +1 -1
- package/lib/redux/store/configureStore.js +5 -1
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.map +1 -1
- package/package.json +11 -11
|
@@ -17,7 +17,7 @@ export const receiveLocale = (locale: string): UpdateLocaleAction => ({
|
|
|
17
17
|
* Change locale of application and redirect
|
|
18
18
|
*/
|
|
19
19
|
export const updateLocale =
|
|
20
|
-
(locale: string): ThunkAction =>
|
|
20
|
+
(locale: string): ThunkAction<> =>
|
|
21
21
|
(dispatch) => {
|
|
22
22
|
dispatch(startProgress());
|
|
23
23
|
dispatch(receiveLocale(locale));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nActions.js","names":["startProgress","finishProgress","receiveLocale","locale","type","payload","updateLocale","dispatch","setLocales","locales"],"sources":["../../../src/redux/_i18n/I18nActions.js"],"sourcesContent":["// @flow\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport type Locales from \"../../i18n/Locales\";\nimport type { SetLocalesAction, UpdateLocaleAction } from \"./types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n * Update current locale\n */\nexport const receiveLocale = (locale: string): UpdateLocaleAction => ({\n type: \"UPDATE_LOCALE\",\n payload: locale,\n});\n\n/**\n * Change locale of application and redirect\n */\nexport const updateLocale =\n (locale: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n dispatch(receiveLocale(locale));\n dispatch(finishProgress());\n };\n\n/**\n */\nexport const setLocales = (\n locales: Locales,\n locale: string,\n): SetLocalesAction => ({\n type: \"SET_LOCALES\",\n payload: {\n locales,\n locale,\n },\n});\n"],"mappings":"AACA,SAASA,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAM5E;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAIC,MAAc,KAA0B;EACpEC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAEF;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMG,YAAY,GACtBH,MAAc,IACdI,QAAQ,IAAK;EACZA,QAAQ,CAACP,aAAa,CAAC,CAAC,CAAC;EACzBO,QAAQ,CAACL,aAAa,CAACC,MAAM,CAAC,CAAC;EAC/BI,QAAQ,CAACN,cAAc,CAAC,CAAC,CAAC;AAC5B,CAAC;;AAEH;AACA;AACA,OAAO,MAAMO,UAAU,GAAGA,CACxBC,OAAgB,EAChBN,MAAc,MACQ;EACtBC,IAAI,EAAE,aAAa;EACnBC,OAAO,EAAE;IACPI,OAAO;IACPN;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"I18nActions.js","names":["startProgress","finishProgress","receiveLocale","locale","type","payload","updateLocale","dispatch","setLocales","locales"],"sources":["../../../src/redux/_i18n/I18nActions.js"],"sourcesContent":["// @flow\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport type Locales from \"../../i18n/Locales\";\nimport type { SetLocalesAction, UpdateLocaleAction } from \"./types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n * Update current locale\n */\nexport const receiveLocale = (locale: string): UpdateLocaleAction => ({\n type: \"UPDATE_LOCALE\",\n payload: locale,\n});\n\n/**\n * Change locale of application and redirect\n */\nexport const updateLocale =\n (locale: string): ThunkAction<> =>\n (dispatch) => {\n dispatch(startProgress());\n dispatch(receiveLocale(locale));\n dispatch(finishProgress());\n };\n\n/**\n */\nexport const setLocales = (\n locales: Locales,\n locale: string,\n): SetLocalesAction => ({\n type: \"SET_LOCALES\",\n payload: {\n locales,\n locale,\n },\n});\n"],"mappings":"AACA,SAASA,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAM5E;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAIC,MAAc,KAA0B;EACpEC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAEF;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMG,YAAY,GACtBH,MAAc,IACdI,QAAQ,IAAK;EACZA,QAAQ,CAACP,aAAa,CAAC,CAAC,CAAC;EACzBO,QAAQ,CAACL,aAAa,CAACC,MAAM,CAAC,CAAC;EAC/BI,QAAQ,CAACN,cAAc,CAAC,CAAC,CAAC;AAC5B,CAAC;;AAEH;AACA;AACA,OAAO,MAAMO,UAAU,GAAGA,CACxBC,OAAgB,EAChBN,MAAc,MACQ;EACtBC,IAAI,EAAE,aAAa;EACnBC,OAAO,EAAE;IACPI,OAAO;IACPN;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -180,7 +180,7 @@ export const loadModularUI =
|
|
|
180
180
|
options?: RequestModularUIOptions,
|
|
181
181
|
retryCount: number = 3,
|
|
182
182
|
retryDelay: number = 200,
|
|
183
|
-
): ThunkAction =>
|
|
183
|
+
): ThunkAction<> =>
|
|
184
184
|
(dispatch: Dispatch, getState) => {
|
|
185
185
|
const modularuiStore = getState()?.modularui;
|
|
186
186
|
const currentRequest = modularuiStore?.[key];
|
|
@@ -220,7 +220,7 @@ export const loadModularUI =
|
|
|
220
220
|
export const reloadModel = (
|
|
221
221
|
model: ModularUIModel,
|
|
222
222
|
options?: RequestModularUIOptions,
|
|
223
|
-
): ThunkAction =>
|
|
223
|
+
): ThunkAction<> =>
|
|
224
224
|
loadModularUI(model.connectKey, model.selfhref, {
|
|
225
225
|
...options,
|
|
226
226
|
isReload: true,
|
|
@@ -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","requestOptions","loadModelSuccessAction","updateHandler","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","method","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","retryCount","retryDelay","dispatch","getState","modularuiStore","modularui","currentRequest","isLoading","LOADING","isDifferentRequest","toString","_Promise","resolve","setTimeout","loadModelPromise","then","catch","reloadModel","selfhref"],"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 requestOptions: any,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status, requestOptions },\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 * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\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 origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\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 retryCount: number = 3,\n retryDelay: number = 200,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n const currentRequest = modularuiStore?.[key];\n\n const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;\n\n if (isLoading) {\n const isDifferentRequest =\n currentRequest.requestOptions?.href?.toString() !== href.toString();\n if (isDifferentRequest && retryCount > 0) {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(\n dispatch(\n loadModularUI(key, href, options, retryCount - 1, retryDelay),\n ),\n );\n }, retryDelay);\n });\n }\n\n // Same request is already loading — do nothing\n return Promise.resolve();\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 =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAM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AC,CACtCqE,KAAK,CAAEtB,KAAK,IAAKQ,QAAQ,CAACrD,WAAW,CAAC6C,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMuB,WAAW,GAAGA,CACzBjE,KAAqB,EACrBsB,OAAiC,KAEjCyB,aAAa,CAAC/C,KAAK,CAACC,UAAU,EAAED,KAAK,CAACkE,QAAQ,EAAE;EAC9C,GAAG5C,OAAO;EACVgB,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","requestOptions","loadModelSuccessAction","updateHandler","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","method","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","retryCount","retryDelay","dispatch","getState","modularuiStore","modularui","currentRequest","isLoading","LOADING","isDifferentRequest","toString","_Promise","resolve","setTimeout","loadModelPromise","then","catch","reloadModel","selfhref"],"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 requestOptions: any,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status, requestOptions },\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 * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\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 origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\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 retryCount: number = 3,\n retryDelay: number = 200,\n ): ThunkAction<> =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n const currentRequest = modularuiStore?.[key];\n\n const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;\n\n if (isLoading) {\n const isDifferentRequest =\n currentRequest.requestOptions?.href?.toString() !== href.toString();\n if (isDifferentRequest && retryCount > 0) {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(\n dispatch(\n loadModularUI(key, href, options, retryCount - 1, retryDelay),\n ),\n );\n }, retryDelay);\n });\n }\n\n // Same request is already loading — do nothing\n return Promise.resolve();\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<> =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMU,cAAc,GAAGA,CAAA,MAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,YAAY,GAAGA,CAC1BX,GAAW,EACXY,MAAsC,EACtCC,cAAmB,MACK;EACx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EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -32,11 +32,11 @@ const patchUpdateModelOption = oldOptions => {
|
|
|
32
32
|
*/
|
|
33
33
|
const modularUIConnector = (name, resource, options = {
|
|
34
34
|
propName: "data",
|
|
35
|
-
removeOnUnmount:
|
|
35
|
+
removeOnUnmount: false
|
|
36
36
|
}) => {
|
|
37
37
|
const {
|
|
38
38
|
propName = "data",
|
|
39
|
-
removeOnUnmount =
|
|
39
|
+
removeOnUnmount = false,
|
|
40
40
|
...otherOptions
|
|
41
41
|
} = options;
|
|
42
42
|
return Component => {
|
|
@@ -60,11 +60,11 @@ const patchUpdateModelOption = (oldOptions: Object) => {
|
|
|
60
60
|
const modularUIConnector = (
|
|
61
61
|
name: string,
|
|
62
62
|
resource: string | Function,
|
|
63
|
-
options: ModularUIOptions = { propName: "data", removeOnUnmount:
|
|
63
|
+
options: ModularUIOptions = { propName: "data", removeOnUnmount: false },
|
|
64
64
|
): ((Component: ComponentType<any>) => (props: any) => Node) => {
|
|
65
65
|
const {
|
|
66
66
|
propName = "data",
|
|
67
|
-
removeOnUnmount =
|
|
67
|
+
removeOnUnmount = false,
|
|
68
68
|
...otherOptions
|
|
69
69
|
} = options;
|
|
70
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIConnector.js","names":["useDispatch","useLocation","loadModularUI","reloadModel","Href","getDisplayName","useUrl","useModularUI","useModularUIBasic","useLocale","FormModel","jsx","_jsx","patchUpdateModelOption","oldOptions","updateModel","updateHandler","newModel","clonedModel","clone","update","modularUIConnector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","finalRemoveOnUnmount","dispatch","location","locale","url","model","modelEntry","modelKey","connectKey","handleFetch","href","fetchOptions","handleManualReload","m","o","newProps","status","lastModification","hasModel","Boolean","fetchModularUI","displayName"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel } from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useModularUIBasic } from \"../../hooks/useModularUIBasic\";\n\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\nconst patchUpdateModelOption = (oldOptions: Object) => {\n if (\n \"updateModel\" in oldOptions &&\n oldOptions.updateModel instanceof FormModel\n ) {\n return {\n ...oldOptions,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n // $FLowFixMe\n const clonedModel: FormModel = oldOptions.updateModel.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n };\n }\n\n return oldOptions;\n};\n\n/**\n * @deprecated - will be removed in the future, use the equivalent hook 'useModularUI' or 'useModularUIBasic' instead\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount:
|
|
1
|
+
{"version":3,"file":"ModularUIConnector.js","names":["useDispatch","useLocation","loadModularUI","reloadModel","Href","getDisplayName","useUrl","useModularUI","useModularUIBasic","useLocale","FormModel","jsx","_jsx","patchUpdateModelOption","oldOptions","updateModel","updateHandler","newModel","clonedModel","clone","update","modularUIConnector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","finalRemoveOnUnmount","dispatch","location","locale","url","model","modelEntry","modelKey","connectKey","handleFetch","href","fetchOptions","handleManualReload","m","o","newProps","status","lastModification","hasModel","Boolean","fetchModularUI","displayName"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel } from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useModularUIBasic } from \"../../hooks/useModularUIBasic\";\n\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\nconst patchUpdateModelOption = (oldOptions: Object) => {\n if (\n \"updateModel\" in oldOptions &&\n oldOptions.updateModel instanceof FormModel\n ) {\n return {\n ...oldOptions,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n // $FLowFixMe\n const clonedModel: FormModel = oldOptions.updateModel.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n };\n }\n\n return oldOptions;\n};\n\n/**\n * @deprecated - will be removed in the future, use the equivalent hook 'useModularUI' or 'useModularUIBasic' instead\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false },\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const finalRemoveOnUnmount = props.removeOnUnmount ?? removeOnUnmount;\n\n const dispatch = useDispatch();\n const location = useLocation();\n const locale = useLocale();\n const url = useUrl(resource, { location, ...props });\n\n // $FlowFixMe\n const model = useModularUIBasic<ModularUIModel>(name, url, options);\n\n const modelEntry = useModularUI(name, url, {\n ...otherOptions,\n removeOnUnmount: finalRemoveOnUnmount,\n });\n const modelKey = model?.connectKey ?? name;\n\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(\n loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)),\n );\n };\n\n const handleManualReload = (m: ModularUIModel, o: Object) => {\n dispatch(reloadModel(m, o));\n };\n\n const newProps: InjectedProps = {\n modelKey,\n [propName ?? \"data\"]: model,\n location,\n status: modelEntry?.status ?? null,\n lastModification: modelEntry?.lastModification ?? null,\n hasModel: Boolean(model),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(Component, name)})`;\n return WrappedComponent;\n };\n};\n\nexport default modularUIConnector;\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AACzC,SAASC,WAAW,QAAQ,cAAc;AAE1C,SAASC,aAAa,EAAEC,WAAW,QAAQ,oBAAoB;AAE/D,OAAOC,IAAI,MAAM,wBAAwB;AACzC,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,iBAAiB,QAAQ,+BAA+B;AAEjE,SAASC,SAAS,QAAQ,qBAAqB;AAE/C,OAAOC,SAAS,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAmBpD,MAAMC,sBAAsB,GAAIC,UAAkB,IAAK;EACrD,IACE,aAAa,IAAIA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O,QAAQ,GAAGF,KAAK,EAAEG,UAAU,IAAIjB,IAAI;MAE1C,MAAMkB,WAAW,GAAGA,CAACC,IAAmB,EAAEC,YAAoB,KAAK;QACjEV,QAAQ,CACN9B,aAAa,CAACoC,QAAQ,EAAEG,IAAI,EAAE5B,sBAAsB,CAAC6B,YAAY,CAAC,CACpE,CAAC;MACH,CAAC;MAED,MAAMC,kBAAkB,GAAGA,CAACC,CAAiB,EAAEC,CAAS,KAAK;QAC3Db,QAAQ,CAAC7B,WAAW,CAACyC,CAAC,EAAEC,CAAC,CAAC,CAAC;MAC7B,CAAC;MAED,MAAMC,QAAuB,GAAG;QAC9BR,QAAQ;QACR,CAACb,QAAQ,IAAI,MAAM,GAAGW,KAAK;QAC3BH,QAAQ;QACRc,MAAM,EAAEV,UAAU,EAAEU,MAAM,IAAI,IAAI;QAClCC,gBAAgB,EAAEX,UAAU,EAAEW,gBAAgB,IAAI,IAAI;QACtDC,QAAQ,EAAEC,OAAO,CAACd,KAAK,CAAC;QACxBF,MAAM;QACNiB,cAAc,EAAEX,WAAW;QAC3BrC,WAAW,EAAEwC;MACf,CAAC;MAED,oBAAO/B,IAAA,CAACgB,SAAS;QAAA,GAAKE,KAAK;QAAA,GAAMgB;MAAQ,CAAG,CAAC;IAC/C,CAAC;IAEDjB,gBAAgB,CAACuB,WAAW,GAAG,gBAAgB/C,cAAc,CAACuB,SAAS,EAAEN,IAAI,CAAC,GAAG;IACjF,OAAOO,gBAAgB;EACzB,CAAC;AACH,CAAC;AAED,eAAeR,kBAAkB","ignoreList":[]}
|
|
@@ -35,26 +35,20 @@ export const getAllModelsByInstance = (state, instance) => {
|
|
|
35
35
|
/**
|
|
36
36
|
*/
|
|
37
37
|
export const getFirstModelByInstance = (state, instance) => {
|
|
38
|
+
var _context3;
|
|
38
39
|
const locale = state?.i18n?.locale || "en";
|
|
39
40
|
const modularui = state?.modularui;
|
|
40
|
-
if (modularui)
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} = modularui[key];
|
|
52
|
-
if (model instanceof instance) {
|
|
53
|
-
return model;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
41
|
+
if (!modularui) return null;
|
|
42
|
+
const foundKey = _findInstanceProperty(_context3 = _Object$keys(modularui)).call(_context3, key => {
|
|
43
|
+
const entry = modularui[key];
|
|
44
|
+
if (!entry || !entry.model) return false;
|
|
45
|
+
const isInstance = entry.model instanceof instance;
|
|
46
|
+
const localeMatches = entry.model.locale === locale;
|
|
47
|
+
return isInstance && localeMatches;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// $FlowIssue
|
|
51
|
+
return foundKey ? modularui[foundKey].model : null;
|
|
58
52
|
};
|
|
59
53
|
|
|
60
54
|
/**
|
|
@@ -41,28 +41,27 @@ export const getAllModelsByInstance = <T>(
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
*/
|
|
44
|
-
export const getFirstModelByInstance = <T>(
|
|
44
|
+
export const getFirstModelByInstance = <T = ModularUIModel>(
|
|
45
45
|
state: ReduxState,
|
|
46
46
|
instance: Class<T>,
|
|
47
47
|
): T | null => {
|
|
48
48
|
const locale = state?.i18n?.locale || "en";
|
|
49
49
|
const modularui = state?.modularui;
|
|
50
50
|
|
|
51
|
-
if (modularui)
|
|
52
|
-
const key = Object.keys(modularui).find((key) => {
|
|
53
|
-
const { model } = modularui[key];
|
|
54
|
-
return model instanceof instance && model.locale === locale;
|
|
55
|
-
});
|
|
51
|
+
if (!modularui) return null;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return model;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
53
|
+
const foundKey = Object.keys(modularui).find((key) => {
|
|
54
|
+
const entry = modularui[key];
|
|
55
|
+
if (!entry || !entry.model) return false;
|
|
64
56
|
|
|
65
|
-
|
|
57
|
+
const isInstance = entry.model instanceof instance;
|
|
58
|
+
const localeMatches = entry.model.locale === locale;
|
|
59
|
+
|
|
60
|
+
return isInstance && localeMatches;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// $FlowIssue
|
|
64
|
+
return foundKey ? modularui[foundKey].model : null;
|
|
66
65
|
};
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUISelectors.js","names":["createSelector","createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","MODULARUI_STATUS","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","_findInstanceProperty","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context0","_context1","status","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;AACA,SACEA,cAAc,EACdC,qBAAqB,EACrBC,cAAc,QACT,UAAU;AACjB,SAASC,G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AACX,CACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModularUISelectors.js","names":["createSelector","createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","MODULARUI_STATUS","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","foundKey","_findInstanceProperty","entry","isInstance","localeMatches","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context0","_context1","status","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T = ModularUIModel>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (!modularui) return null;\n\n const foundKey = Object.keys(modularui).find((key) => {\n const entry = modularui[key];\n if (!entry || !entry.model) return false;\n\n const isInstance = entry.model instanceof instance;\n const localeMatches = entry.model.locale === locale;\n\n return isInstance && localeMatches;\n });\n\n // $FlowIssue\n return foundKey ? modularui[foundKey].model : null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;AACA,SACEA,cAAc,EACdC,qBAAqB,EACrBC,cAAc,QACT,UAAU;AACjB,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,YAAY,MAAM,mCAAmC;AAC5D,OAAOC,eAAe,MAAM,sCAAsC;AAClE,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,QAAQ,MAAM,2BAA2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
|
38
38
|
options?: RequestModularUIOptions,
|
|
39
|
-
) => ThunkAction
|
|
40
|
-
handleError: (error: Error | FetchException) => ThunkAction
|
|
39
|
+
) => ThunkAction<>,
|
|
40
|
+
handleError: (error: Error | FetchException) => ThunkAction<>,
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
type Props = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withModularUI.js","names":["connect","createSelector","ModularUIRequest","startProgress","finishProgress","handleError","getLocale","reloadModel","modularui","localeCode","href","options","modularuiRequest","locale","mapStateToProps","state","i18n","mapDispatchToProps","withModularui"],"sources":["../../../src/redux/_modularui/withModularUI.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport { getLocale } from \"../selectors/i18n\";\n\nimport { reloadModel } from \"./ModularUIActions\";\n\nimport type {\n ReduxState,\n StartProgressAction,\n FinishProgressAction,\n ThunkAction,\n} from \"../types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type FetchException from \"../../exceptions/FetchException\";\nimport type { ComponentType } from \"react\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\ntype StateProps = {\n modularui: (href: Href, options: any) => ModularUIRequest,\n locale: string,\n};\n\ntype DispatchProps = {\n startProgress: () => StartProgressAction,\n finishProgress: () => FinishProgressAction,\n reloadModel: (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n ) => ThunkAction
|
|
1
|
+
{"version":3,"file":"withModularUI.js","names":["connect","createSelector","ModularUIRequest","startProgress","finishProgress","handleError","getLocale","reloadModel","modularui","localeCode","href","options","modularuiRequest","locale","mapStateToProps","state","i18n","mapDispatchToProps","withModularui"],"sources":["../../../src/redux/_modularui/withModularUI.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport { getLocale } from \"../selectors/i18n\";\n\nimport { reloadModel } from \"./ModularUIActions\";\n\nimport type {\n ReduxState,\n StartProgressAction,\n FinishProgressAction,\n ThunkAction,\n} from \"../types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type FetchException from \"../../exceptions/FetchException\";\nimport type { ComponentType } from \"react\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\ntype StateProps = {\n modularui: (href: Href, options: any) => ModularUIRequest,\n locale: string,\n};\n\ntype DispatchProps = {\n startProgress: () => StartProgressAction,\n finishProgress: () => FinishProgressAction,\n reloadModel: (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n ) => ThunkAction<>,\n handleError: (error: Error | FetchException) => ThunkAction<>,\n};\n\ntype Props = {\n ...StateProps,\n ...DispatchProps,\n};\n\nconst modularui = createSelector(\n [getLocale],\n (localeCode) =>\n (href, options = {}) => {\n const modularuiRequest = new ModularUIRequest(href, options);\n modularuiRequest.locale = localeCode;\n return modularuiRequest;\n },\n);\n\n/**\n */\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n modularui: modularui(state),\n locale: state.i18n.locale,\n});\n\nconst mapDispatchToProps: DispatchProps = {\n startProgress,\n finishProgress,\n reloadModel,\n handleError,\n};\n\n/**\n * Injects the modular ui service and the progress start and finish actions\n * This can be used to request modular ui services inside react view components\n */\nconst withModularui: ComponentType<any> = connect<\n Props,\n {},\n StateProps,\n _,\n _,\n _,\n>(mapStateToProps, mapDispatchToProps);\n\nexport default withModularui;\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,aAAa;AAErC,SAASC,cAAc,QAAQ,UAAU;AAEzC,OAAOC,gBAAgB,MAAM,kCAAkC;AAE/D,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,SAAS,QAAQ,mBAAmB;AAE7C,SAASC,WAAW,QAAQ,oBAAoB;AAkChD,MAAMC,SAAS,GAAGP,cAAc,CAC9B,CAACK,SAAS,CAAC,EACVG,UAAU,IACT,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,KAAK;EACtB,MAAMC,gBAAgB,GAAG,IAAIV,gBAAgB,CAACQ,IAAI,EAAEC,OAAO,CAAC;EAC5DC,gBAAgB,CAACC,MAAM,GAAGJ,UAAU;EACpC,OAAOG,gBAAgB;AACzB,CACJ,CAAC;;AAED;AACA;AACA,MAAME,eAAe,GAAIC,KAAiB,KAAkB;EAC1DP,SAAS,EAAEA,SAAS,CAACO,KAAK,CAAC;EAC3BF,MAAM,EAAEE,KAAK,CAACC,IAAI,CAACH;AACrB,CAAC,CAAC;AAEF,MAAMI,kBAAiC,GAAG;EACxCd,aAAa;EACbC,cAAc;EACdG,WAAW;EACXF;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,aAAiC,GAAGlB,OAAO,CAO/Cc,eAAe,EAAEG,kBAAkB,CAAC;AAEtC,eAAeC,aAAa","ignoreList":[]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
1
2
|
import { loadModularUI, removeModelByKey } from "../_modularui/ModularUIActions";
|
|
2
3
|
import { allKeysByHref, getApplication } from "../_modularui/ModularUISelectors";
|
|
3
4
|
import { ApplicationModel, Href } from "../../models";
|
|
4
5
|
import { getLocale } from "../selectors/i18n";
|
|
5
6
|
/**
|
|
6
7
|
*/
|
|
7
|
-
export const reloadApplication = () => (dispatch, getState
|
|
8
|
+
export const reloadApplication = () => async (dispatch, getState, {
|
|
9
|
+
subscribe
|
|
10
|
+
}) => {
|
|
8
11
|
const state = getState();
|
|
9
12
|
let applicationHref = new Href("/", "Application");
|
|
10
13
|
const application = getApplication(state);
|
|
@@ -12,14 +15,39 @@ export const reloadApplication = () => (dispatch, getState) => {
|
|
|
12
15
|
applicationHref.contextPath = application.contextPath;
|
|
13
16
|
applicationHref.origin = application.origin;
|
|
14
17
|
}
|
|
18
|
+
const modelKey = `application(/)(${getLocale(state)})`;
|
|
15
19
|
const allKeys = allKeysByHref(state, applicationHref);
|
|
16
20
|
for (const key of allKeys) {
|
|
17
|
-
|
|
21
|
+
if (key !== modelKey) {
|
|
22
|
+
// only remove applications we're not reloading (e.g. different locale)
|
|
23
|
+
dispatch(removeModelByKey(key));
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
return dispatch(loadModularUI(modelKey, applicationHref, {
|
|
26
|
+
dispatch(loadModularUI(modelKey, applicationHref, {
|
|
21
27
|
targetModel: ApplicationModel
|
|
22
28
|
}));
|
|
29
|
+
return new _Promise((resolve, reject) => {
|
|
30
|
+
const unsubscribe = subscribe(() => {
|
|
31
|
+
const entry = getState().modularui?.[modelKey];
|
|
32
|
+
if (entry?.status === "FINISHED") {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
if (entry.model instanceof ApplicationModel) {
|
|
35
|
+
resolve(entry.model);
|
|
36
|
+
} else {
|
|
37
|
+
reject(new Error("Loaded model was not an ApplicationModel"));
|
|
38
|
+
}
|
|
39
|
+
} else if (entry?.status === "ERROR") {
|
|
40
|
+
unsubscribe();
|
|
41
|
+
reject(new Error("Application reload failed."));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Safety timeout so the login screen doesn't hang forever if the API fails silently
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
unsubscribe();
|
|
48
|
+
reject(new Error("Timeout waiting for application reload."));
|
|
49
|
+
}, 15000);
|
|
50
|
+
});
|
|
23
51
|
};
|
|
24
52
|
|
|
25
53
|
/**
|
|
@@ -10,12 +10,13 @@ import {
|
|
|
10
10
|
import { ApplicationModel, Href } from "../../models";
|
|
11
11
|
import { getLocale } from "../selectors/i18n";
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type { ThunkAction, NoAction } from "../types";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*/
|
|
17
17
|
export const reloadApplication =
|
|
18
|
-
(): ThunkAction =>
|
|
18
|
+
(): ThunkAction<Promise<ApplicationModel>> =>
|
|
19
|
+
async (dispatch, getState, { subscribe }) => {
|
|
19
20
|
const state = getState();
|
|
20
21
|
|
|
21
22
|
let applicationHref = new Href("/", "Application");
|
|
@@ -25,17 +26,45 @@ export const reloadApplication =
|
|
|
25
26
|
applicationHref.origin = application.origin;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
const modelKey = `application(/)(${getLocale(state)})`;
|
|
28
30
|
const allKeys = allKeysByHref(state, applicationHref);
|
|
31
|
+
|
|
29
32
|
for (const key of allKeys) {
|
|
30
|
-
|
|
33
|
+
if (key !== modelKey) {
|
|
34
|
+
// only remove applications we're not reloading (e.g. different locale)
|
|
35
|
+
dispatch(removeModelByKey(key));
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
return dispatch(
|
|
39
|
+
dispatch(
|
|
35
40
|
loadModularUI(modelKey, applicationHref, {
|
|
36
41
|
targetModel: ApplicationModel,
|
|
37
42
|
}),
|
|
38
43
|
);
|
|
44
|
+
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const unsubscribe = subscribe(() => {
|
|
47
|
+
const entry = getState().modularui?.[modelKey];
|
|
48
|
+
|
|
49
|
+
if (entry?.status === "FINISHED") {
|
|
50
|
+
unsubscribe();
|
|
51
|
+
if (entry.model instanceof ApplicationModel) {
|
|
52
|
+
resolve(entry.model);
|
|
53
|
+
} else {
|
|
54
|
+
reject(new Error("Loaded model was not an ApplicationModel"));
|
|
55
|
+
}
|
|
56
|
+
} else if (entry?.status === "ERROR") {
|
|
57
|
+
unsubscribe();
|
|
58
|
+
reject(new Error("Application reload failed."));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Safety timeout so the login screen doesn't hang forever if the API fails silently
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
unsubscribe();
|
|
65
|
+
reject(new Error("Timeout waiting for application reload."));
|
|
66
|
+
}, 15000);
|
|
67
|
+
});
|
|
39
68
|
};
|
|
40
69
|
|
|
41
70
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","allKeysByHref","getApplication","ApplicationModel","Href","getLocale","reloadApplication","dispatch","getState","state","applicationHref","application","contextPath","origin","allKeys","key","
|
|
1
|
+
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","allKeysByHref","getApplication","ApplicationModel","Href","getLocale","reloadApplication","dispatch","getState","subscribe","state","applicationHref","application","contextPath","origin","modelKey","allKeys","key","targetModel","_Promise","resolve","reject","unsubscribe","entry","modularui","status","model","Error","setTimeout","noAction","type"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../_modularui/ModularUIActions\";\nimport {\n allKeysByHref,\n getApplication,\n} from \"../_modularui/ModularUISelectors\";\nimport { ApplicationModel, Href } from \"../../models\";\nimport { getLocale } from \"../selectors/i18n\";\n\nimport type { ThunkAction, NoAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction<Promise<ApplicationModel>> =>\n async (dispatch, getState, { subscribe }) => {\n const state = getState();\n\n let applicationHref = new Href(\"/\", \"Application\");\n const application = getApplication(state);\n if (application) {\n applicationHref.contextPath = application.contextPath;\n applicationHref.origin = application.origin;\n }\n\n const modelKey = `application(/)(${getLocale(state)})`;\n const allKeys = allKeysByHref(state, applicationHref);\n\n for (const key of allKeys) {\n if (key !== modelKey) {\n // only remove applications we're not reloading (e.g. different locale)\n dispatch(removeModelByKey(key));\n }\n }\n\n dispatch(\n loadModularUI(modelKey, applicationHref, {\n targetModel: ApplicationModel,\n }),\n );\n\n return new Promise((resolve, reject) => {\n const unsubscribe = subscribe(() => {\n const entry = getState().modularui?.[modelKey];\n\n if (entry?.status === \"FINISHED\") {\n unsubscribe();\n if (entry.model instanceof ApplicationModel) {\n resolve(entry.model);\n } else {\n reject(new Error(\"Loaded model was not an ApplicationModel\"));\n }\n } else if (entry?.status === \"ERROR\") {\n unsubscribe();\n reject(new Error(\"Application reload failed.\"));\n }\n });\n\n // Safety timeout so the login screen doesn't hang forever if the API fails silently\n setTimeout(() => {\n unsubscribe();\n reject(new Error(\"Timeout waiting for application reload.\"));\n }, 15000);\n });\n };\n\n/**\n */\nexport const noAction = (): NoAction => ({\n type: \"NO_ACTION\",\n});\n"],"mappings":";AACA,SACEA,aAAa,EACbC,gBAAgB,QACX,gCAAgC;AACvC,SACEC,aAAa,EACbC,cAAc,QACT,kCAAkC;AACzC,SAASC,gBAAgB,EAAEC,IAAI,QAAQ,cAAc;AACrD,SAASC,SAAS,QAAQ,mBAAmB;AAI7C;AACA;AACA,OAAO,MAAMC,iBAAiB,GAC5BA,CAAA,KACA,OAAOC,QAAQ,EAAEC,QAAQ,EAAE;EAAEC;AAAU,CAAC,KAAK;EAC3C,MAAMC,KAAK,GAAGF,QAAQ,CAAC,CAAC;EAExB,IAAIG,eAAe,GAAG,IAAIP,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC;EAClD,MAAMQ,WAAW,GAAGV,cAAc,CAACQ,KAAK,CAAC;EACzC,IAAIE,WAAW,EAAE;IACfD,eAAe,CAACE,WAAW,GAAGD,WAAW,CAACC,WAAW;IACrDF,eAAe,CAACG,MAAM,GAAGF,WAAW,CAACE,MAAM;EAC7C;EAEA,MAAMC,QAAQ,GAAG,kBAAkBV,SAAS,CAACK,KAAK,CAAC,GAAG;EACtD,MAAMM,OAAO,GAAGf,aAAa,CAACS,KAAK,EAAEC,eAAe,CAAC;EAErD,KAAK,MAAMM,GAAG,IAAID,OAAO,EAAE;IACzB,IAAIC,GAAG,KAAKF,QAAQ,EAAE;MACpB;MACAR,QAAQ,CAACP,gBAAgB,CAACiB,GAAG,CAAC,CAAC;IACjC;EACF;EAEAV,QAAQ,CACNR,aAAa,CAACgB,QAAQ,EAAEJ,eAAe,EAAE;IACvCO,WAAW,EAAEf;EACf,CAAC,CACH,CAAC;EAED,OAAO,IAAAgB,QAAA,CAAY,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,MAAMC,WAAW,GAAGb,SAAS,CAAC,MAAM;MAClC,MAAMc,KAAK,GAAGf,QAAQ,CAAC,CAAC,CAACgB,SAAS,GAAGT,QAAQ,CAAC;MAE9C,IAAIQ,KAAK,EAAEE,MAAM,KAAK,UAAU,EAAE;QAChCH,WAAW,CAAC,CAAC;QACb,IAAIC,KAAK,CAACG,KAAK,YAAYvB,gBAAgB,EAAE;UAC3CiB,OAAO,CAACG,KAAK,CAACG,KAAK,CAAC;QACtB,CAAC,MAAM;UACLL,MAAM,CAAC,IAAIM,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC/D;MACF,CAAC,MAAM,IAAIJ,KAAK,EAAEE,MAAM,KAAK,OAAO,EAAE;QACpCH,WAAW,CAAC,CAAC;QACbD,MAAM,CAAC,IAAIM,KAAK,CAAC,4BAA4B,CAAC,CAAC;MACjD;IACF,CAAC,CAAC;;IAEF;IACAC,UAAU,CAAC,MAAM;MACfN,WAAW,CAAC,CAAC;MACbD,MAAM,CAAC,IAAIM,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC9D,CAAC,EAAE,KAAK,CAAC;EACX,CAAC,CAAC;AACJ,CAAC;;AAEH;AACA;AACA,OAAO,MAAME,QAAQ,GAAGA,CAAA,MAAiB;EACvCC,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,24 @@ import { getSetting } from "../../constants";
|
|
|
10
10
|
/**
|
|
11
11
|
*/
|
|
12
12
|
export const handleUnauthorized = errorResponse => (dispatch, getState) => {
|
|
13
|
+
const finish = () => {
|
|
14
|
+
dispatch(logoutSuccess());
|
|
15
|
+
Cache.removeItem("auth");
|
|
16
|
+
if (errorResponse.isInvalidUsername) {
|
|
17
|
+
dispatch(sendAuthenticationError(errorResponse.message));
|
|
18
|
+
}
|
|
19
|
+
const state = getState();
|
|
20
|
+
const location = state.router.location;
|
|
21
|
+
const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
|
|
22
|
+
if (location?.pathname !== LOGIN_PATH) {
|
|
23
|
+
const locationFrom = location?.state?.from;
|
|
24
|
+
return dispatch(replace(LOGIN_PATH, {
|
|
25
|
+
from: locationFrom ? locationFrom : state.router.location,
|
|
26
|
+
modal: false
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
return dispatch(noAction());
|
|
30
|
+
};
|
|
13
31
|
if (errorResponse.connectKey) {
|
|
14
32
|
dispatch(removeModelByKey(errorResponse.connectKey));
|
|
15
33
|
}
|
|
@@ -17,31 +35,8 @@ export const handleUnauthorized = errorResponse => (dispatch, getState) => {
|
|
|
17
35
|
window.location.reload();
|
|
18
36
|
return;
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
// reload application when flag auth is set or isLogged
|
|
22
38
|
const application = getApplication(getState());
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// set logged out
|
|
28
|
-
dispatch(logoutSuccess());
|
|
29
|
-
Cache.removeItem("auth");
|
|
30
|
-
if (errorResponse.isInvalidUsername) {
|
|
31
|
-
dispatch(sendAuthenticationError(errorResponse.message));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// add current location as from location before redirect
|
|
35
|
-
const location = getState().router.location;
|
|
36
|
-
const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
|
|
37
|
-
if (location?.pathname !== LOGIN_PATH) {
|
|
38
|
-
const locationFrom = location?.state?.from;
|
|
39
|
-
return dispatch(replace(LOGIN_PATH, {
|
|
40
|
-
from: locationFrom ? locationFrom : getState().router.location,
|
|
41
|
-
// cannot open login in a modal, because of previous locations that might be secure
|
|
42
|
-
modal: false
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
return dispatch(noAction());
|
|
39
|
+
const shouldReload = Cache.getItem("auth") || application?.isLoggedIn;
|
|
40
|
+
return shouldReload ? dispatch(reloadApplication()).then(finish) : finish();
|
|
46
41
|
};
|
|
47
42
|
//# sourceMappingURL=Authorization.js.map
|