@beinformed/ui 1.20.0 → 1.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -2
- package/esm/constants/Constants.js +0 -15
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +6 -0
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useAuthentication.js +40 -5
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/hooks/useContent.js +2 -6
- package/esm/hooks/useContent.js.map +1 -1
- package/esm/hooks/useI18n.js +10 -11
- package/esm/hooks/useI18n.js.map +1 -1
- package/esm/hooks/useModularUI.js +2 -3
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIRequest.js +2 -5
- package/esm/hooks/useModularUIRequest.js.map +1 -1
- package/esm/i18n/Message.js.map +1 -1
- package/esm/i18n/withMessage.js +2 -10
- package/esm/i18n/withMessage.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +6 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/redux/_modularui/connector.js +3 -4
- package/esm/redux/_modularui/connector.js.map +1 -1
- package/esm/redux/_modularui/selectors.js +22 -5
- package/esm/redux/_modularui/selectors.js.map +1 -1
- package/esm/redux/_modularui/withModularUI.js +2 -10
- package/esm/redux/_modularui/withModularUI.js.map +1 -1
- package/esm/redux/actions/Application.js +26 -7
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/actions/Authorization.js +2 -1
- package/esm/redux/actions/Authorization.js.map +1 -1
- package/esm/redux/actions/Error.js +3 -1
- package/esm/redux/actions/Error.js.map +1 -1
- package/esm/redux/selectors/i18n.js +16 -0
- package/esm/redux/selectors/i18n.js.map +1 -0
- package/esm/utils/datetime/DateTimeUtil.js +3 -1
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/constants/Constants.js +2 -20
- package/lib/constants/Constants.js.flow +0 -15
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +6 -0
- package/lib/constants/Settings.js.flow +9 -0
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +0 -8
- package/lib/hooks/useAuthentication.js +47 -5
- package/lib/hooks/useAuthentication.js.flow +40 -3
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/hooks/useContent.js +3 -7
- package/lib/hooks/useContent.js.flow +2 -2
- package/lib/hooks/useContent.js.map +1 -1
- package/lib/hooks/useI18n.js +12 -9
- package/lib/hooks/useI18n.js.flow +10 -11
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useModularUI.js +3 -3
- package/lib/hooks/useModularUI.js.flow +3 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIRequest.js +2 -4
- package/lib/hooks/useModularUIRequest.js.flow +8 -10
- package/lib/hooks/useModularUIRequest.js.map +1 -1
- package/lib/i18n/Message.js.flow +1 -1
- package/lib/i18n/Message.js.map +1 -1
- package/lib/i18n/withMessage.js +2 -8
- package/lib/i18n/withMessage.js.flow +3 -4
- package/lib/i18n/withMessage.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +7 -1
- package/lib/models/application/ApplicationModel.js.flow +7 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/redux/_modularui/connector.js +3 -3
- package/lib/redux/_modularui/connector.js.flow +3 -2
- package/lib/redux/_modularui/connector.js.map +1 -1
- package/lib/redux/_modularui/selectors.js +26 -6
- package/lib/redux/_modularui/selectors.js.flow +19 -1
- package/lib/redux/_modularui/selectors.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js +3 -9
- package/lib/redux/_modularui/withModularUI.js.flow +3 -5
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/actions/Application.js +31 -8
- package/lib/redux/actions/Application.js.flow +6 -8
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/Authorization.js +3 -2
- package/lib/redux/actions/Authorization.js.flow +2 -1
- package/lib/redux/actions/Authorization.js.map +1 -1
- package/lib/redux/actions/Error.js +4 -1
- package/lib/redux/actions/Error.js.flow +3 -1
- package/lib/redux/actions/Error.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -5
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +1 -1
- package/lib/redux/selectors/i18n.js +28 -0
- package/lib/redux/selectors/i18n.js.flow +15 -0
- package/lib/redux/selectors/i18n.js.map +1 -0
- package/lib/utils/datetime/DateTimeUtil.js +3 -1
- package/lib/utils/datetime/DateTimeUtil.js.flow +1 -1
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/package.json +5 -5
- package/src/constants/Constants.js +0 -15
- package/src/constants/Settings.js +9 -0
- package/src/hooks/__tests__/useAuthentication.spec.js +0 -8
- package/src/hooks/useAuthentication.js +40 -3
- package/src/hooks/useContent.js +2 -2
- package/src/hooks/useI18n.js +10 -11
- package/src/hooks/useModularUI.js +3 -2
- package/src/hooks/useModularUIRequest.js +8 -10
- package/src/i18n/Message.js +1 -1
- package/src/i18n/withMessage.js +3 -4
- package/src/models/application/ApplicationModel.js +7 -1
- package/src/redux/_modularui/connector.js +3 -2
- package/src/redux/_modularui/selectors.js +19 -1
- package/src/redux/_modularui/withModularUI.js +3 -5
- package/src/redux/actions/Application.js +6 -8
- package/src/redux/actions/Authorization.js +2 -1
- package/src/redux/actions/Error.js +3 -1
- package/src/redux/actions/__tests__/Application.spec.js +1 -5
- package/src/redux/actions/__tests__/Authorization.spec.js +1 -1
- package/src/redux/selectors/i18n.js +15 -0
- package/src/utils/datetime/DateTimeUtil.js +1 -1
|
@@ -3,20 +3,18 @@ import { createSelector } from "reselect";
|
|
|
3
3
|
import { useSelector } from "react-redux";
|
|
4
4
|
|
|
5
5
|
import ModularUIRequest from "../modularui/ModularUIRequest";
|
|
6
|
+
import { getLocale } from "../redux/selectors/i18n";
|
|
6
7
|
|
|
7
8
|
import type { RequestBaseOptions } from "../utils";
|
|
8
9
|
import type Href from "../models/href/Href";
|
|
9
10
|
|
|
10
|
-
const getModularUIRequest = createSelector(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
);
|
|
11
|
+
const getModularUIRequest = createSelector([getLocale], (localeCode) => {
|
|
12
|
+
return (href: Href, options?: $Shape<RequestBaseOptions>) => {
|
|
13
|
+
const request = new ModularUIRequest(href, options);
|
|
14
|
+
request.locale = localeCode;
|
|
15
|
+
return request;
|
|
16
|
+
};
|
|
17
|
+
});
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Creates a ModularUIRequest with the locale as available in the redux store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","
|
|
1
|
+
{"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n});\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAKA,IAAMA,mBAAmB,GAAG,IAAAC,wBAAA,EAAe,CAACC,eAAD,CAAf,EAA4B,UAACC,UAAD,EAAgB;EACtE,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACE,MAAR,GAAiBL,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CAN2B,CAA5B;AAQA;AACA;AACA;;AACO,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGT,IAAAC,uBAAA,EAAYV,mBAAZ,CAHS;AAAA,CAA5B"}
|
package/lib/i18n/Message.js.flow
CHANGED
package/lib/i18n/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id
|
|
1
|
+
{"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id: string,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n }\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA,IAAMA,OAAqD,gBACzD,IAAAC,WAAA,EACE,gBAQoB;EAAA,IAPlBC,SAOkB,QAPlBA,SAOkB;EAAA,IANlBC,EAMkB,QANlBA,EAMkB;EAAA,IALlBC,cAKkB,QALlBA,cAKkB;EAAA,IAJlBC,QAIkB,QAJlBA,QAIkB;EAAA,IAHlBC,IAGkB,QAHlBA,IAGkB;EAAA,iCAFlBC,gBAEkB;EAAA,IAFlBA,gBAEkB,sCAFC,KAED;EAAA,0BADlBC,SACkB;EAAA,IADlBA,SACkB,+BADN,KACM;EAClB,IAAMC,iBAAiB,GAAG,IAAAC,mBAAA,EACxBP,EADwB,EAExBC,cAAc,IAAIC,QAFM,EAGxBC,IAHwB,CAA1B;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMI,MAAM,qBACP,IAAAC,sBAAA,GADO,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEV,SAAjB;MAA4B,KAAK,EAAES,MAAnC;MAAA,UACGF;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBW,MAAM,EAAEJ;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCH,CADF;AA4CAT,OAAO,CAACc,WAAR,GAAsB,YAAtB;eAEed,O"}
|
package/lib/i18n/withMessage.js
CHANGED
|
@@ -15,15 +15,9 @@ var _reselect = require("reselect");
|
|
|
15
15
|
|
|
16
16
|
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
return state.i18n.locale || "en";
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var getLocales = function getLocales(state) {
|
|
23
|
-
return state.i18n.locales;
|
|
24
|
-
};
|
|
18
|
+
var _i18n = require("../redux/selectors/i18n");
|
|
25
19
|
|
|
26
|
-
var getMessage = (0, _reselect.createSelector)([getLocales,
|
|
20
|
+
var getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], function (locales, localeCode) {
|
|
27
21
|
return (0, _memoize.default)(function (id, defaultMessage, placeholders) {
|
|
28
22
|
return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
|
|
29
23
|
}, function () {
|
|
@@ -4,6 +4,8 @@ import { connect } from "react-redux";
|
|
|
4
4
|
import { createSelector } from "reselect";
|
|
5
5
|
import memoize from "lodash/memoize";
|
|
6
6
|
|
|
7
|
+
import { getLocales, getLocale } from "../redux/selectors/i18n";
|
|
8
|
+
|
|
7
9
|
import type { ReduxState } from "../redux/types";
|
|
8
10
|
import type { ComponentType } from "react";
|
|
9
11
|
|
|
@@ -20,11 +22,8 @@ type Props = {
|
|
|
20
22
|
...
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
const getLocaleCode = (state) => state.i18n.locale || "en";
|
|
24
|
-
const getLocales = (state) => state.i18n.locales;
|
|
25
|
-
|
|
26
25
|
const getMessage = createSelector(
|
|
27
|
-
[getLocales,
|
|
26
|
+
[getLocales, getLocale],
|
|
28
27
|
(locales, localeCode) =>
|
|
29
28
|
memoize(
|
|
30
29
|
(id: string, defaultMessage?: string, placeholders?: Object) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMessage.js","names":["
|
|
1
|
+
{"version":3,"file":"withMessage.js","names":["getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","mapStateToProps","state","message","withMessage","connect"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... }\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAkBA,IAAMA,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACC,gBAAD,EAAaC,eAAb,CADiB,EAEjB,UAACC,OAAD,EAAUC,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEL,OAAO,CACJD,SADH,CACaE,UADb,EAEGL,UAFH,CAEcO,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DC,OAAO,EAAEb,UAAU,CAACY,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAME,WAA+B,GAAG,IAAAC,mBAAA,EACtCJ,eADsC,CAAxC;eAIeG,W"}
|
|
@@ -13,6 +13,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
13
13
|
|
|
14
14
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
15
15
|
|
|
16
|
+
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort"));
|
|
17
|
+
|
|
16
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
17
19
|
|
|
18
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
@@ -119,7 +121,11 @@ var ApplicationModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
119
121
|
}, {
|
|
120
122
|
key: "authenticationTypes",
|
|
121
123
|
get: function get() {
|
|
122
|
-
|
|
124
|
+
var authenticationTypes = this.getContribution("security", []); //put primary first
|
|
125
|
+
|
|
126
|
+
return authenticationTypes === null || authenticationTypes === void 0 ? void 0 : (0, _sort.default)(authenticationTypes).call(authenticationTypes, function (a, b) {
|
|
127
|
+
return a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1;
|
|
128
|
+
});
|
|
123
129
|
}
|
|
124
130
|
/**
|
|
125
131
|
* Getting the tab links
|
|
@@ -68,7 +68,13 @@ export default class ApplicationModel extends ResourceModel {
|
|
|
68
68
|
* Getting the authentication types of the application
|
|
69
69
|
*/
|
|
70
70
|
get authenticationTypes(): Array<AuthenticationType> {
|
|
71
|
-
|
|
71
|
+
const authenticationTypes = this.getContribution("security", []);
|
|
72
|
+
|
|
73
|
+
//put primary first
|
|
74
|
+
return authenticationTypes?.sort(
|
|
75
|
+
(a: AuthenticationType, b: AuthenticationType) =>
|
|
76
|
+
a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1
|
|
77
|
+
);
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* Getting the tab links
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userLink","data","contributions","resourcetype","ResourceModel"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n
|
|
1
|
+
{"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","authenticationTypes","a","b","isPrimary","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userLink","data","contributions","resourcetype","ResourceModel"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", []);\n\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1\n );\n }\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,gB;;;;;;;;;;;;;;;;;;;;;;;;IAGnB;AACF;AACA;IACE,eAAmB;MACjB,OAAO,aAAP;IACD;IAED;AACF;;;;;IAQE;AACF;IACE,qCAA8C;MAC5C,IAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;MACA,IAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;QACrD,MAAM,IAAIC,kCAAJ,CACJ,kIADI,CAAN;MAGD;;MAED,OAAOL,WAAW,GAAG,CAACA,WAAD,CAAH,GAAmB,EAArC;IACD;IAED;AACF;;;;WACE,wBAAeM,MAAf,EAA8C;MAC5C,IAAMC,gBAAgB,GAAG,mBAAAD,MAAM,MAAN,CAAAA,MAAM,EAC7B,UAACE,KAAD;QAAA,OAAWA,KAAK,CAACC,IAAN,KAAe,cAA1B;MAAA,CAD6B,CAA/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,EAAqE;QACnE,OAAO,KAAKZ,YAAL,CAAkBY,QAAlB,CAA2BnB,IAAlC;MACD;;MAED,OAAO,IAAP;IACD;;;WAhGD,2BAAyBoB,IAAzB,EAA2D;MACzD,OACEA,IAAI,CAACC,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;IAID;;;EAjB2CC,uB"}
|
|
@@ -37,6 +37,8 @@ var _modularuiUtils = require("./modularuiUtils");
|
|
|
37
37
|
|
|
38
38
|
var _useModularUI = require("../../hooks/useModularUI");
|
|
39
39
|
|
|
40
|
+
var _useI18n = require("../../hooks/useI18n");
|
|
41
|
+
|
|
40
42
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
41
43
|
|
|
42
44
|
var _excluded = ["propName", "removeOnUnmount"];
|
|
@@ -100,9 +102,7 @@ var connector = function connector(name, resource) {
|
|
|
100
102
|
};
|
|
101
103
|
}, [dispatch, modelKey]); // Create new properties object to inject modularui properties to own props
|
|
102
104
|
|
|
103
|
-
var locale = (0,
|
|
104
|
-
return state.i18n.locale;
|
|
105
|
-
});
|
|
105
|
+
var locale = (0, _useI18n.useLocale)();
|
|
106
106
|
var newProps = (_newProps = {
|
|
107
107
|
modelKey: modelKey
|
|
108
108
|
}, (0, _defineProperty2.default)(_newProps, propName, modelEntry ? modelEntry.model : null), (0, _defineProperty2.default)(_newProps, "location", location), (0, _defineProperty2.default)(_newProps, "status", modelEntry ? modelEntry.status : null), (0, _defineProperty2.default)(_newProps, "lastModification", modelEntry ? modelEntry.lastModification : null), (0, _defineProperty2.default)(_newProps, "hasModel", Boolean(modelEntry)), (0, _defineProperty2.default)(_newProps, "locale", locale), (0, _defineProperty2.default)(_newProps, "fetchModularUI", handleFetch), (0, _defineProperty2.default)(_newProps, "reloadModel", handleManualReload), _newProps);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { useDispatch
|
|
3
|
+
import { useDispatch } from "react-redux";
|
|
4
4
|
import { useLocation } from "react-router";
|
|
5
5
|
|
|
6
6
|
import { loadModularUI, reloadModel, removeModelByKey } from "./actions";
|
|
@@ -10,6 +10,7 @@ import { getDisplayName } from "../../react/utils";
|
|
|
10
10
|
|
|
11
11
|
import { useUrl, useReload } from "./modularuiUtils";
|
|
12
12
|
import { useModularUI } from "../../hooks/useModularUI";
|
|
13
|
+
import { useLocale } from "../../hooks/useI18n";
|
|
13
14
|
|
|
14
15
|
import type { ComponentType, Node } from "react";
|
|
15
16
|
import type { Location } from "react-router";
|
|
@@ -88,7 +89,7 @@ const connector = (
|
|
|
88
89
|
}, [dispatch, modelKey]);
|
|
89
90
|
|
|
90
91
|
// Create new properties object to inject modularui properties to own props
|
|
91
|
-
const locale =
|
|
92
|
+
const locale = useLocale();
|
|
92
93
|
const newProps: InjectedProps = {
|
|
93
94
|
modelKey,
|
|
94
95
|
[propName]: modelEntry ? modelEntry.model : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","
|
|
1
|
+
{"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useLocale","newProps","status","lastModification","Boolean"],"sources":["../../../src/redux/_modularui/connector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel, removeModelByKey } from \"./actions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./modularuiUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\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\n/**\n */\nconst connector = (\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 dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, { ...otherOptions, isReload: true })\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useLocale();\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default connector;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAmBA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAChBC,IADgB,EAEhBC,QAFgB,EAI8C;EAAA,IAD9DC,OAC8D,uEADlC;IAAEC,QAAQ,EAAE,MAAZ;IAAoBC,eAAe,EAAE;EAArC,CACkC;EAC9D,wBAIIF,OAJJ,CACEC,QADF;EAAA,IACEA,QADF,kCACa,MADb;EAAA,4BAIID,OAJJ,CAEEE,eAFF;EAAA,IAEEA,eAFF,sCAEoB,KAFpB;EAAA,IAGKC,YAHL,0CAIIH,OAJJ;EAMA,OAAO,UAACI,SAAD,EAAmC;IACxC,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAgB;MAAA;;MACvC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;MACA,IAAMC,QAAQ,GAAG,IAAAC,wBAAA,GAAjB;MAEA,IAAMC,GAAG,GAAG,IAAAC,sBAAA,EAAOb,QAAP;QAAmBU,QAAQ,EAARA;MAAn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d,OAAO,YAAM;UACX,IAAI9B,eAAJ,EAAqB;YACnBK,QAAQ,CAAC,IAAA2B,yBAAA,EAAiBhB,QAAjB,CAAD,CAAR;UACD;QACF,CAJD;MAKD,CAND,EAMG,CAACX,QAAD,EAAWW,QAAX,CANH,EArCuC,CA6CvC;;MACA,IAAMiB,MAAM,GAAG,IAAAC,kBAAA,GAAf;MACA,IAAMC,QAAuB;QAC3BnB,QAAQ,EAARA;MAD2B,4CAE1BjB,QAF0B,EAEfe,UAAU,GAAGA,UAAU,CAACG,KAAd,GAAsB,IAFjB,wDAG3BV,QAH2B,sDAInBO,UAAU,GAAGA,UAAU,CAACsB,MAAd,GAAuB,IAJd,gEAKTtB,UAAU,GAAGA,UAAU,CAACuB,gBAAd,GAAiC,IALlC,wDAMjBC,OAAO,CAACxB,UAAD,CANU,sDAO3BmB,MAP2B,8DAQXX,WARW,2DASdH,kBATc,aAA7B;MAYA,oBAAO,qBAAC,SAAD,kCAAef,KAAf,GAA0B+B,QAA1B,EAAP;IACD,CA5DD;;IA8DAhC,gBAAgB,CAACQ,WAAjB,0BAA+C,IAAAC,qBAAA,EAC7CT,gBAD6C,EAE7CP,IAF6C,CAA/C;IAKA,OAAOO,gBAAP;EACD,CArED;AAsED,CAjFD;;eAmFeR,S"}
|
|
@@ -15,7 +15,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", {
|
|
16
16
|
value: true
|
|
17
17
|
});
|
|
18
|
-
exports.modelByHref = exports.keyByHref = exports.getTab = exports.getPreference = exports.getModelsByType = exports.getForm = exports.getFirstModelByInstance = exports.getCaseView = exports.getApplication = exports.getAllModelsByInstance = exports.getActiveModels = exports.getActiveModelByInstance = void 0;
|
|
18
|
+
exports.modelByHref = exports.keyByHref = exports.getTab = exports.getPreference = exports.getModelsByType = exports.getForm = exports.getFirstModelByInstance = exports.getCaseView = exports.getApplication = exports.getAllModelsByInstance = exports.getActiveModels = exports.getActiveModelByInstance = exports.allKeysByHref = void 0;
|
|
19
19
|
|
|
20
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
21
21
|
|
|
@@ -221,11 +221,31 @@ var keyByHref = function keyByHref(state, href) {
|
|
|
221
221
|
return null;
|
|
222
222
|
};
|
|
223
223
|
/**
|
|
224
|
+
* Returns all model keys found in the store, restrict on href
|
|
224
225
|
*/
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
exports.keyByHref = keyByHref;
|
|
228
229
|
|
|
230
|
+
var allKeysByHref = function allKeysByHref(state, href) {
|
|
231
|
+
if (state && state.modularui) {
|
|
232
|
+
var _context7;
|
|
233
|
+
|
|
234
|
+
var findHref = href instanceof _Href.default ? href : new _Href.default(href);
|
|
235
|
+
return (0, _filter.default)(_context7 = (0, _keys.default)(state.modularui)).call(_context7, function (key) {
|
|
236
|
+
var model = state.modularui[key].model;
|
|
237
|
+
return model && model.selfhref && model.selfhref.equals(findHref);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return [];
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
exports.allKeysByHref = allKeysByHref;
|
|
248
|
+
|
|
229
249
|
var getLocation = function getLocation(state) {
|
|
230
250
|
var _state$router;
|
|
231
251
|
|
|
@@ -274,9 +294,9 @@ var getActiveModels = (0, _reselect.createSelectorCreator)(_reselect.defaultMemo
|
|
|
274
294
|
if (location) {
|
|
275
295
|
var locationParts = location.split("/");
|
|
276
296
|
locationParts.reduce(function (accumulator, current) {
|
|
277
|
-
var
|
|
297
|
+
var _context8;
|
|
278
298
|
|
|
279
|
-
var path = (0, _concat.default)(
|
|
299
|
+
var path = (0, _concat.default)(_context8 = "".concat(accumulator, "/")).call(_context8, current); // Remove modelcatalog part to match breadcrumb parts
|
|
280
300
|
|
|
281
301
|
var comparePath = decodeURIComponent(path).replace("/modelcatalog/", "/");
|
|
282
302
|
var foundEntry = (0, _find.default)(models).call(models, function (model) {
|
|
@@ -325,11 +345,11 @@ exports.getPreference = getPreference;
|
|
|
325
345
|
|
|
326
346
|
var getModelsByType = function getModelsByType(state, type) {
|
|
327
347
|
if (state && state.modularui) {
|
|
328
|
-
var
|
|
348
|
+
var _context9, _context10;
|
|
329
349
|
|
|
330
|
-
return (0, _map.default)(
|
|
350
|
+
return (0, _map.default)(_context9 = (0, _filter.default)(_context10 = (0, _keys.default)(state.modularui)).call(_context10, function (key) {
|
|
331
351
|
return state.modularui[key] && state.modularui[key].model && state.modularui[key].model.type === type;
|
|
332
|
-
})).call(
|
|
352
|
+
})).call(_context9, function (key) {
|
|
333
353
|
return state.modularui[key].model;
|
|
334
354
|
});
|
|
335
355
|
}
|
|
@@ -150,7 +150,6 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
|
|
|
150
150
|
|
|
151
151
|
return Object.keys(state.modularui).find((key) => {
|
|
152
152
|
const { model } = state.modularui[key];
|
|
153
|
-
|
|
154
153
|
return model && model.selfhref && model.selfhref.equals(findHref);
|
|
155
154
|
});
|
|
156
155
|
}
|
|
@@ -158,6 +157,25 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
|
|
|
158
157
|
return null;
|
|
159
158
|
};
|
|
160
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Returns all model keys found in the store, restrict on href
|
|
162
|
+
*/
|
|
163
|
+
export const allKeysByHref = (
|
|
164
|
+
state: ReduxState,
|
|
165
|
+
href: Href | string
|
|
166
|
+
): Array<string> => {
|
|
167
|
+
if (state && state.modularui) {
|
|
168
|
+
const findHref = href instanceof Href ? href : new Href(href);
|
|
169
|
+
|
|
170
|
+
return Object.keys(state.modularui).filter((key) => {
|
|
171
|
+
const { model } = state.modularui[key];
|
|
172
|
+
return model && model.selfhref && model.selfhref.equals(findHref);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return [];
|
|
177
|
+
};
|
|
178
|
+
|
|
161
179
|
/**
|
|
162
180
|
*/
|
|
163
181
|
const getLocation = (state): string => state?.router?.location.pathname;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","names":["getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","findHref","Href","modelConfigKey","equals","keyByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType"],"sources":["../../../src/redux/_modularui/selectors.js"],"sourcesContent":["// @flow\nimport { createSelectorCreator, defaultMemoize } from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n */\nconst getLocation = (state): string => state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA;AACA;AACO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,CACpCC,KADoC,EAEpCC,QAFoC,EAGV;EAAA;;EAC1B,IAAMC,MAAM,GAAG,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,2BAAAA,KAAK,CAAEG,IAAP,4DAAaD,MAAb,KAAuB,IAAtC;EACA,IAAME,SAAS,GAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,SAAzB;;EAEA,IAAIA,SAAJ,EAAe;IAAA;;IACb,OAAO,iFAAYA,SAAZ,mBACG,UAACC,GAAD,EAAS;MACf,IAAQC,KAAR,GAAkBF,SAAS,CAACC,GAAD,CAA3B,CAAQC,KAAR;MACA,OAAOA,KAAK,YAAYL,QAAjB,IAA6BK,KAAK,CAACJ,MAAN,KAAiBA,MAArD;IACD,CAJI,kBAKA,UAACG,GAAD;MAAA,OAASD,SAAS,CAACC,GAAD,CAAT,CAAeC,KAAxB;IAAA,CALA,CAAP;EAMD;;EAED,OAAO,EAAP;AACD,CAjBM;AAmBP;AACA;;;;;AACO,IAAMC,uBAAuB,GAAG,SAA1BA,uBAA0B,CACrCP,KADqC,EAErCC,QAFqC,EAGxB;EAAA;;EACb,IAAMC,MAAM,GAAG,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,4BAAAA,KAAK,CAAEG,IAAP,8DAAaD,MAAb,KAAuB,IAAtC;EACA,IAAME,SAAS,GAAG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;AACA;AACA;;;;;AACO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7B/D,KAD6B,EAE7BqC,IAF6B,EAGH;EAC1B,IAAIrC,KAAK,IAAIA,KAAK,CAACI,SAAnB,EAA8B;IAAA;;IAC5B,OAAO,kFAAYJ,KAAK,CAACI,SAAlB,mBAEH,UAACC,GAAD;MAAA,OACEL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,KACAL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KADrB,IAEAN,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAArB,CAA2B+B,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAAChC,GAAD;MAAA,OAASL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAA9B;IAAA,CAPA,CAAP;EAQD;;EAED,OAAO,EAAP;AACD,CAhBM"}
|
|
1
|
+
{"version":3,"file":"selectors.js","names":["getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","findHref","Href","modelConfigKey","equals","keyByHref","allKeysByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType"],"sources":["../../../src/redux/_modularui/selectors.js"],"sourcesContent":["// @flow\nimport { createSelectorCreator, defaultMemoize } from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state): string => state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA;AACA;AACO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,CACpCC,KADoC,EAEpCC,QAFoC,EAGV;EAAA;;EAC1B,IAAMC,MAAM,GAAG,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,2BAAAA,KAAK,CAAEG,IAAP,4DAAaD,MAAb,KAAuB,IAAtC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,IAAP;AACD,CATM;AAWP;AACA;AACA;;;;;AACO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7BhE,KAD6B,EAE7BsC,IAF6B,EAGH;EAC1B,IAAItC,KAAK,IAAIA,KAAK,CAACI,SAAnB,EAA8B;IAAA;;IAC5B,OAAO,mFAAYJ,KAAK,CAACI,SAAlB,oBAEH,UAACC,GAAD;MAAA,OACEL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,KACAL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KADrB,IAEAN,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAArB,CAA2BgC,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAACjC,GAAD;MAAA,OAASL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAA9B;IAAA,CAPA,CAAP;EAQD;;EAED,OAAO,EAAP;AACD,CAhBM"}
|
|
@@ -17,17 +17,11 @@ var _ProgressIndicator = require("../actions/ProgressIndicator");
|
|
|
17
17
|
|
|
18
18
|
var _Error = require("../actions/Error");
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*/
|
|
24
|
-
var getLocaleCode = function getLocaleCode(state) {
|
|
25
|
-
var _state$i18n$locale;
|
|
20
|
+
var _i18n = require("../selectors/i18n");
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
};
|
|
22
|
+
var _actions = require("./actions");
|
|
29
23
|
|
|
30
|
-
var modularui = (0, _reselect.createSelector)([
|
|
24
|
+
var modularui = (0, _reselect.createSelector)([_i18n.getLocale], function (localeCode) {
|
|
31
25
|
return function (href) {
|
|
32
26
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
27
|
var modularuiRequest = new _ModularUIRequest.default(href, options);
|
|
@@ -9,6 +9,8 @@ import { startProgress, finishProgress } from "../actions/ProgressIndicator";
|
|
|
9
9
|
|
|
10
10
|
import { handleError } from "../actions/Error";
|
|
11
11
|
|
|
12
|
+
import { getLocale } from "../selectors/i18n";
|
|
13
|
+
|
|
12
14
|
import { reloadModel } from "./actions";
|
|
13
15
|
|
|
14
16
|
import type {
|
|
@@ -43,12 +45,8 @@ type Props = {
|
|
|
43
45
|
...DispatchProps,
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
/**
|
|
47
|
-
*/
|
|
48
|
-
const getLocaleCode = (state) => state.i18n.locale ?? "en";
|
|
49
|
-
|
|
50
48
|
const modularui = createSelector(
|
|
51
|
-
[
|
|
49
|
+
[getLocale],
|
|
52
50
|
(localeCode) =>
|
|
53
51
|
(href, options = {}) => {
|
|
54
52
|
const modularuiRequest = new ModularUIRequest(href, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withModularUI.js","names":["
|
|
1
|
+
{"version":3,"file":"withModularUI.js","names":["modularui","createSelector","getLocale","localeCode","href","options","modularuiRequest","ModularUIRequest","locale","mapStateToProps","state","i18n","mapDispatchToProps","startProgress","finishProgress","reloadModel","handleError","withModularui","connect"],"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 \"./actions\";\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 { RequestBaseOptions } from \"../../utils/fetch/types\";\nimport type FetchException from \"../../exceptions/FetchException\";\nimport type { ComponentType } from \"react\";\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?: RequestBaseOptions\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;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAkCA,IAAMA,SAAS,GAAG,IAAAC,wBAAA,EAChB,CAACC,eAAD,CADgB,EAEhB,UAACC,UAAD;EAAA,OACE,UAACC,IAAD,EAAwB;IAAA,IAAjBC,OAAiB,uEAAP,EAAO;IACtB,IAAMC,gBAAgB,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAzB;IACAC,gBAAgB,CAACE,MAAjB,GAA0BL,UAA1B;IACA,OAAOG,gBAAP;EACD,CALH;AAAA,CAFgB,CAAlB;AAUA;AACA;;AACA,IAAMG,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DV,SAAS,EAAEA,SAAS,CAACU,KAAD,CADsC;IAE1DF,MAAM,EAAEE,KAAK,CAACC,IAAN,CAAWH;EAFuC,CAApC;AAAA,CAAxB;;AAKA,IAAMI,kBAAiC,GAAG;EACxCC,aAAa,EAAbA,gCADwC;EAExCC,cAAc,EAAdA,iCAFwC;EAGxCC,WAAW,EAAXA,oBAHwC;EAIxCC,WAAW,EAAXA;AAJwC,CAA1C;AAOA;AACA;AACA;AACA;;AACA,IAAMC,aAAiC,GAAG,IAAAC,mBAAA,EAOxCT,eAPwC,EAOvBG,kBAPuB,CAA1C;eASeK,a"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
+
|
|
5
|
+
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
6
|
+
|
|
7
|
+
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
8
|
+
|
|
9
|
+
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
10
|
+
|
|
3
11
|
Object.defineProperty(exports, "__esModule", {
|
|
4
12
|
value: true
|
|
5
13
|
});
|
|
@@ -11,20 +19,35 @@ var _selectors = require("../_modularui/selectors");
|
|
|
11
19
|
|
|
12
20
|
var _models = require("../../models");
|
|
13
21
|
|
|
22
|
+
var _i18n = require("../selectors/i18n");
|
|
23
|
+
|
|
24
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
25
|
+
|
|
26
|
+
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
+
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
+
|
|
14
30
|
/**
|
|
15
31
|
*/
|
|
16
32
|
var reloadApplication = function reloadApplication() {
|
|
17
33
|
return function (dispatch, getState) {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
var allKeys = (0, _selectors.allKeysByHref)(getState(), "/");
|
|
35
|
+
|
|
36
|
+
var _iterator = _createForOfIteratorHelper(allKeys),
|
|
37
|
+
_step;
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
41
|
+
var key = _step.value;
|
|
42
|
+
dispatch((0, _actions.removeModelByKey)(key));
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_iterator.e(err);
|
|
46
|
+
} finally {
|
|
47
|
+
_iterator.f();
|
|
25
48
|
}
|
|
26
49
|
|
|
27
|
-
|
|
50
|
+
var modelKey = "application(/)(".concat((0, _i18n.getLocale)(getState()), ")");
|
|
28
51
|
return dispatch((0, _actions.loadModularUI)(modelKey, new _models.Href("/", "Application"), {
|
|
29
52
|
targetModel: _models.ApplicationModel
|
|
30
53
|
}));
|