@beinformed/ui 1.27.3 → 1.27.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.27.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.4...v1.27.5) (2023-02-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **actions:** allow for action collections where part of contributions is not available ([ee1f482](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/ee1f482edf21f3c783b4f5f5b927f6838d36f626))
10
+
11
+ ### [1.27.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.3...v1.27.4) (2023-02-07)
12
+
13
+ ### Bug Fixes
14
+
15
+ - **server:** add property to skip preloading the web application on the server ([b9c8e17](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/b9c8e178bbef7cf94f9d3d80da9f64f78e228a24))
16
+
5
17
  ### [1.27.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.2...v1.27.3) (2023-02-06)
6
18
 
7
19
  ### Bug Fixes
@@ -1,10 +1,9 @@
1
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
1
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
3
2
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
3
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
4
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
5
  import BaseCollection from "../base/BaseCollection";
6
6
  import ActionModel from "./ActionModel";
7
- import { IllegalArgumentException } from "../../exceptions";
8
7
 
9
8
  /**
10
9
  * Collection of actions
@@ -14,22 +13,17 @@ export default class ActionCollection extends BaseCollection {
14
13
  super();
15
14
 
16
15
  // no actions gives an empty collection
17
- if (!actions) {
16
+ if (!Array.isArray(actions)) {
18
17
  this.collection = [];
19
-
20
- // When actions are available but no contributions, then an error occured
21
- } else if (!actionsContributions || !Array.isArray(actionsContributions)) {
22
- throw new IllegalArgumentException("Data for ActionCollection found, but no contributions available");
23
- } else {
24
- this.collection = _mapInstanceProperty(actions).call(actions, action => {
25
- if (actionsContributions) {
26
- const contributions = _findInstanceProperty(actionsContributions).call(actionsContributions, actionContribution => actionContribution.name === action.name);
27
- if (contributions) {
28
- return new ActionModel(action, contributions);
29
- }
18
+ } else if (Array.isArray(actionsContributions)) {
19
+ const actionModels = [];
20
+ for (const actionData of actions) {
21
+ const actionContribution = _findInstanceProperty(actionsContributions).call(actionsContributions, actionContribution => actionContribution.name === actionData.name);
22
+ if (actionContribution) {
23
+ actionModels.push(new ActionModel(actionData, actionContribution));
30
24
  }
31
- throw new Error(`Contributions not found for action ${action.name}`);
32
- });
25
+ }
26
+ this.collection = actionModels;
33
27
  }
34
28
  }
35
29
 
@@ -1 +1 @@
1
- {"version":3,"file":"ActionCollection.js","names":["BaseCollection","ActionModel","IllegalArgumentException","ActionCollection","constructor","actions","actionsContributions","collection","Array","isArray","action","contributions","actionContribution","name","Error","getActionByKey","key","newCollection","first","getActionsByType","type","getActionsByLayoutHint","hints","layouthint","has","hasActionsByLayoutHint","length","routePath","enabledRoutes","isDisabled","path","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(actions?: Object, actionsContributions?: Object) {\n super();\n\n // no actions gives an empty collection\n if (!actions) {\n this.collection = [];\n\n // When actions are available but no contributions, then an error occured\n } else if (!actionsContributions || !Array.isArray(actionsContributions)) {\n throw new IllegalArgumentException(\n \"Data for ActionCollection found, but no contributions available\"\n );\n } else {\n this.collection = actions.map((action) => {\n if (actionsContributions) {\n const contributions = actionsContributions.find(\n (actionContribution) => actionContribution.name === action.name\n );\n\n if (contributions) {\n return new ActionModel(action, contributions);\n }\n }\n\n throw new Error(`Contributions not found for action ${action.name}`);\n });\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints)\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(\"|\");\n\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,wBAAwB,QAAQ,kBAAkB;;AAE3D;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASH,cAAc,CAAc;EACxEI,WAAW,CAACC,OAAgB,EAAEC,oBAA6B,EAAE;IAC3D,KAAK,EAAE;;IAEP;IACA,IAAI,C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EA;AACF;AACA;EACEI,sBAAsB,GAA4C;IAAA;IAAA,kCAAxCC,KAAK;MAALA,KAAK;IAAA;IAC7B,MAAML,aAAa,GAAG,IAAId,gBAAgB,EAAE;IAE5Cc,aAAa,CAACV,UAAU,GAAG,wCAAI,kBAASG,MAAM,IAC5CA,MAAM,CAACa,UAAU,CAACC,GAAG,CAAC,GAAGF,KAAK,CAAC,CAChC;IAED,OAAOL,aAAa;EACtB;;EAEA;AACF;AACA;EACEQ,sBAAsB,GAAmC;IACvD,OAAO,IAAI,CAACJ,sBAAsB,CAAC,YAAQ,CAAC,CAACK,MAAM,GAAG,CAAC;EACzD;;EAEA;AACF;AACA;EACE,IAAIC,SAAS,GAAW;IAAA;IACtB,MAAMC,aAAa,GAAG,wCAAI,CAACrB,UAAU,kBAClCG,MAAM,IAAK,CAACA,MAAM,CAACmB,UAAU,CAC/B;IAED,IAAID,aAAa,CAACF,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,wBAAwB;IACjC;IAEA,MAAMI,IAAI,GAAG,qBAAAF,aAAa,OAAbA,aAAa,EAAMlB,MAAM,IAAKA,MAAM,CAACqB,QAAQ,CAACD,IAAI,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC;IAE1E,OAAO,IAAI,CAACN,MAAM,GAAG,CAAC,GAAI,IAAGI,IAAK,GAAE,GAAGA,IAAI;EAC7C;AACF"}
1
+ {"version":3,"file":"ActionCollection.js","names":["BaseCollection","ActionModel","ActionCollection","constructor","actions","actionsContributions","Array","isArray","collection","actionModels","actionData","actionContribution","name","push","getActionByKey","key","newCollection","action","first","getActionsByType","type","getActionsByLayoutHint","hints","layouthint","has","hasActionsByLayoutHint","length","routePath","enabledRoutes","isDisabled","path","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(actions?: Object, actionsContributions?: Object) {\n super();\n\n // no actions gives an empty collection\n if (!Array.isArray(actions)) {\n this.collection = [];\n } else if (Array.isArray(actionsContributions)) {\n const actionModels = [];\n for (const actionData of actions) {\n const actionContribution = actionsContributions.find(\n (actionContribution) => actionContribution.name === actionData.name\n );\n\n if (actionContribution) {\n actionModels.push(new ActionModel(actionData, actionContribution));\n }\n }\n\n this.collection = actionModels;\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints)\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(\"|\");\n\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,WAAW,MAAM,eAAe;;AAEvC;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,cAAc,CAAc;EACxEG,WAAW,CAACC,OAAgB,EAAEC,oBAA6B,EAAE;IAC3D,KAAK,EAAE;;IAEP;IACA,IAAI,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,gBAAgB,EAAE;IAE5Cc,aAAa,CAACR,UAAU,GAAG,wCAAI,kBAASS,MAAM,IAC5CA,MAAM,CAACM,UAAU,CAACC,GAAG,CAAC,GAAGF,KAAK,CAAC,CAChC;IAED,OAAON,aAAa;EACtB;;EAEA;AACF;AACA;EACES,sBAAsB,GAAmC;IACvD,OAAO,IAAI,CAACJ,sBAAsB,CAAC,YAAQ,CAAC,CAACK,MAAM,GAAG,CAAC;EACzD;;EAEA;AACF;AACA;EACE,IAAIC,SAAS,GAAW;IAAA;IACtB,MAAMC,aAAa,GAAG,wCAAI,CAACpB,UAAU,kBAClCS,MAAM,IAAK,CAACA,MAAM,CAACY,UAAU,CAC/B;IAED,IAAID,aAAa,CAACF,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,wBAAwB;IACjC;IAEA,MAAMI,IAAI,GAAG,qBAAAF,aAAa,OAAbA,aAAa,EAAMX,MAAM,IAAKA,MAAM,CAACc,QAAQ,CAACD,IAAI,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC;IAE1E,OAAO,IAAI,CAACN,MAAM,GAAG,CAAC,GAAI,IAAGI,IAAK,GAAE,GAAGA,IAAI;EAC7C;AACF"}
@@ -16,7 +16,8 @@ const serverNoSSR = _ref => {
16
16
  theme,
17
17
  render,
18
18
  template,
19
- beforeRenderHooks
19
+ beforeRenderHooks,
20
+ preloadApplication = true
20
21
  } = _ref;
21
22
  const UUID = createUUID();
22
23
  __webpack_nonce__ = UUID; // NOSONAR
@@ -31,7 +32,9 @@ const serverNoSSR = _ref => {
31
32
  createTheme(storedTheme, theme);
32
33
  }
33
34
  setI18n(store, locales, request);
34
- setApplication(store);
35
+ if (preloadApplication) {
36
+ setApplication(store);
37
+ }
35
38
  handleErrors(store);
36
39
  handleBeforeRenderHooks(beforeRenderHooks, {
37
40
  store,
@@ -1 +1 @@
1
- {"version":3,"file":"serverNoSSR.js","names":["createUUID","getFullRequestHref","createReduxStore","setI18n","setApplication","setServerPreferences","setConfigurationTheme","handleErrors","handleBeforeRenderHooks","renderSSRMinimal","createTheme","serverNoSSR","request","locales","customReducers","serverPreferences","theme","render","template","beforeRenderHooks","UUID","__webpack_nonce__","requestHref","store","storedTheme","getState","preferences"],"sources":["../../src/react-server/serverNoSSR.js"],"sourcesContent":["// @flow\nimport \"./contextPath\";\n\nimport createUUID from \"../utils/helpers/createUUID\";\nimport { getFullRequestHref } from \"./requestInformation\";\n\nimport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n handleErrors,\n} from \"./serverUtil\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport renderSSRMinimal from \"./renderSSRMinimal\";\n\nimport createTheme from \"../react-theme/createTheme\";\n\nimport type { TemplateProps } from \"./htmlpage\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { PreferenceValue } from \"./serverUtil\";\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { Theme } from \"../react-theme/types\";\n\ntype serverProps = {\n request: HttpServletRequestJava,\n locales?: Array<LocaleConfiguration>,\n customReducers?: Object,\n theme?: Theme | Array<Theme>,\n serverPreferences?: Array<string | PreferenceValue>,\n render: Function,\n template?: (TemplateProps) => string,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n};\n\n/**\n */\nconst serverNoSSR = ({\n request,\n locales,\n customReducers,\n serverPreferences = [],\n theme,\n render,\n template,\n beforeRenderHooks,\n}: serverProps): string => {\n const UUID = createUUID();\n __webpack_nonce__ = UUID; // NOSONAR\n\n const requestHref = getFullRequestHref(request);\n\n const store = createReduxStore(requestHref, customReducers);\n\n setServerPreferences(store, serverPreferences);\n setConfigurationTheme(store);\n\n if (theme) {\n const storedTheme = store.getState()?.preferences?.theme;\n //$FlowFixMe[incompatible-call]\n createTheme(storedTheme, theme);\n }\n\n setI18n(store, locales, request);\n\n setApplication(store);\n\n handleErrors(store);\n\n handleBeforeRenderHooks(beforeRenderHooks, { store, request });\n\n return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P,KAAK;IAAEI,IAAI;IAAEH,MAAM;IAAEC;EAAS,CAAC,CAAC;AACnE,CAAC;AAED,eAAeP,WAAW"}
1
+ {"version":3,"file":"serverNoSSR.js","names":["createUUID","getFullRequestHref","createReduxStore","setI18n","setApplication","setServerPreferences","setConfigurationTheme","handleErrors","handleBeforeRenderHooks","renderSSRMinimal","createTheme","serverNoSSR","request","locales","customReducers","serverPreferences","theme","render","template","beforeRenderHooks","preloadApplication","UUID","__webpack_nonce__","requestHref","store","storedTheme","getState","preferences"],"sources":["../../src/react-server/serverNoSSR.js"],"sourcesContent":["// @flow\nimport \"./contextPath\";\n\nimport createUUID from \"../utils/helpers/createUUID\";\nimport { getFullRequestHref } from \"./requestInformation\";\n\nimport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n handleErrors,\n} from \"./serverUtil\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport renderSSRMinimal from \"./renderSSRMinimal\";\n\nimport createTheme from \"../react-theme/createTheme\";\n\nimport type { TemplateProps } from \"./htmlpage\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { PreferenceValue } from \"./serverUtil\";\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { Theme } from \"../react-theme/types\";\n\ntype serverProps = {\n request: HttpServletRequestJava,\n locales?: Array<LocaleConfiguration>,\n customReducers?: Object,\n theme?: Theme | Array<Theme>,\n serverPreferences?: Array<string | PreferenceValue>,\n render: Function,\n template?: (TemplateProps) => string,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n preloadApplication?: boolean,\n};\n\n/**\n */\nconst serverNoSSR = ({\n request,\n locales,\n customReducers,\n serverPreferences = [],\n theme,\n render,\n template,\n beforeRenderHooks,\n preloadApplication = true,\n}: serverProps): string => {\n const UUID = createUUID();\n __webpack_nonce__ = UUID; // NOSONAR\n\n const requestHref = getFullRequestHref(request);\n\n const store = createReduxStore(requestHref, customReducers);\n\n setServerPreferences(store, serverPreferences);\n setConfigurationTheme(store);\n\n if (theme) {\n const storedTheme = store.getState()?.preferences?.theme;\n //$FlowFixMe[incompatible-call]\n createTheme(storedTheme, theme);\n }\n\n setI18n(store, locales, request);\n\n if (preloadApplication) {\n setApplication(store);\n }\n\n handleErrors(store);\n\n handleBeforeRenderHooks(beforeRenderHooks, { store, request });\n\n return renderSSRMinimal({ store, theme, UUID, render, template });\n};\n\nexport default serverNoSSR;\n"],"mappings":"AACA,OAAO,eAAe;AAEtB,OAAOA,UAAU,MAAM,6BAA6B;AACpD,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,SACEC,gBAAgB,EAChBC,OAAO,EACPC,cAAc,EACdC,oBAAoB,EACpBC,qBAAqB,EACrBC,YAAY,QACP,cAAc;AAErB,SAASC,uBAAuB,QAAQ,kCAAkC;AAE1E,OAAOC,gBAAgB,MAAM,oBAAoB;AAEjD,OAAOC,WAAW,MAAM,4BAA4B;AAoBpD;AACA;AACA,MAAMC,WAAW,GAAG,QAUO;EAAA,IAVN;IACnBC,OAAO;IACPC,OAAO;IACPC,cAAc;IACdC,iBAAiB,GAAG,EAAE;IACtBC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,iBAAiB;IACjBC,kBAAkB,GAAG;EACV,CAAC;EACZ,MAAMC,IAAI,GAAGrB,UAAU,EAAE;EACzBsB,iBAAiB,GAAGD,IAAI,CAAC,CAAC;;EAE1B,MAAME,WAAW,GAAGtB,kBAAkB,CAACW,OAAO,CAAC;EAE/C,MAAMY,KAAK,GAAGtB,gBAAgB,CAACqB,WAAW,EAAET,cAAc,CAAC;EAE3DT,oBAAoB,CAACmB,KAAK,EAAET,iBAAiB,CAAC;EAC9CT,qBAAqB,CAACkB,KAAK,CAAC;EAE5B,IAAIR,KAAK,EAAE;IACT,MAAMS,WAAW,GAAGD,KAAK,CAACE,QAAQ,EAAE,EAAEC,WAAW,EAAEX,KAAK;IACxD;IACAN,WAAW,CAACe,WAAW,EAAET,KAAK,CAAC;EACjC;EAEAb,OAAO,CAACqB,KAAK,EAAEX,OAAO,EAAED,OAAO,CAAC;EAEhC,IAAIQ,kBAAkB,EAAE;IACtBhB,cAAc,CAACoB,KAAK,CAAC;EACvB;EAEAjB,YAAY,CAACiB,KAAK,CAAC;EAEnBhB,uBAAuB,CAACW,iBAAiB,EAAE;IAAEK,KAAK;IAAEZ;EAAQ,CAAC,CAAC;EAE9D,OAAOH,gBAAgB,CAAC;IAAEe,KAAK;IAAER,KAAK;IAAEK,IAAI;IAAEJ,MAAM;IAAEC;EAAS,CAAC,CAAC;AACnE,CAAC;AAED,eAAeP,WAAW"}
@@ -5,13 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
9
8
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
10
9
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
11
10
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
11
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
12
12
  var _BaseCollection = _interopRequireDefault(require("../base/BaseCollection"));
13
13
  var _ActionModel = _interopRequireDefault(require("./ActionModel"));
14
- var _exceptions = require("../../exceptions");
15
14
  /**
16
15
  * Collection of actions
17
16
  */
@@ -20,22 +19,17 @@ class ActionCollection extends _BaseCollection.default {
20
19
  super();
21
20
 
22
21
  // no actions gives an empty collection
23
- if (!actions) {
22
+ if (!Array.isArray(actions)) {
24
23
  this.collection = [];
25
-
26
- // When actions are available but no contributions, then an error occured
27
- } else if (!actionsContributions || !Array.isArray(actionsContributions)) {
28
- throw new _exceptions.IllegalArgumentException("Data for ActionCollection found, but no contributions available");
29
- } else {
30
- this.collection = (0, _map.default)(actions).call(actions, action => {
31
- if (actionsContributions) {
32
- const contributions = (0, _find.default)(actionsContributions).call(actionsContributions, actionContribution => actionContribution.name === action.name);
33
- if (contributions) {
34
- return new _ActionModel.default(action, contributions);
35
- }
24
+ } else if (Array.isArray(actionsContributions)) {
25
+ const actionModels = [];
26
+ for (const actionData of actions) {
27
+ const actionContribution = (0, _find.default)(actionsContributions).call(actionsContributions, actionContribution => actionContribution.name === actionData.name);
28
+ if (actionContribution) {
29
+ actionModels.push(new _ActionModel.default(actionData, actionContribution));
36
30
  }
37
- throw new Error(`Contributions not found for action ${action.name}`);
38
- });
31
+ }
32
+ this.collection = actionModels;
39
33
  }
40
34
  }
41
35
 
@@ -1,7 +1,6 @@
1
1
  // @flow
2
2
  import BaseCollection from "../base/BaseCollection";
3
3
  import ActionModel from "./ActionModel";
4
- import { IllegalArgumentException } from "../../exceptions";
5
4
 
6
5
  /**
7
6
  * Collection of actions
@@ -11,28 +10,21 @@ export default class ActionCollection extends BaseCollection<ActionModel> {
11
10
  super();
12
11
 
13
12
  // no actions gives an empty collection
14
- if (!actions) {
13
+ if (!Array.isArray(actions)) {
15
14
  this.collection = [];
16
-
17
- // When actions are available but no contributions, then an error occured
18
- } else if (!actionsContributions || !Array.isArray(actionsContributions)) {
19
- throw new IllegalArgumentException(
20
- "Data for ActionCollection found, but no contributions available"
21
- );
22
- } else {
23
- this.collection = actions.map((action) => {
24
- if (actionsContributions) {
25
- const contributions = actionsContributions.find(
26
- (actionContribution) => actionContribution.name === action.name
27
- );
28
-
29
- if (contributions) {
30
- return new ActionModel(action, contributions);
31
- }
15
+ } else if (Array.isArray(actionsContributions)) {
16
+ const actionModels = [];
17
+ for (const actionData of actions) {
18
+ const actionContribution = actionsContributions.find(
19
+ (actionContribution) => actionContribution.name === actionData.name
20
+ );
21
+
22
+ if (actionContribution) {
23
+ actionModels.push(new ActionModel(actionData, actionContribution));
32
24
  }
25
+ }
33
26
 
34
- throw new Error(`Contributions not found for action ${action.name}`);
35
- });
27
+ this.collection = actionModels;
36
28
  }
37
29
  }
38
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"ActionCollection.js","names":["ActionCollection","BaseCollection","constructor","actions","actionsContributions","collection","Array","isArray","IllegalArgumentException","action","contributions","actionContribution","name","ActionModel","Error","getActionByKey","key","newCollection","first","getActionsByType","type","getActionsByLayoutHint","hints","layouthint","has","hasActionsByLayoutHint","length","routePath","enabledRoutes","isDisabled","path","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(actions?: Object, actionsContributions?: Object) {\n super();\n\n // no actions gives an empty collection\n if (!actions) {\n this.collection = [];\n\n // When actions are available but no contributions, then an error occured\n } else if (!actionsContributions || !Array.isArray(actionsContributions)) {\n throw new IllegalArgumentException(\n \"Data for ActionCollection found, but no contributions available\"\n );\n } else {\n this.collection = actions.map((action) => {\n if (actionsContributions) {\n const contributions = actionsContributions.find(\n (actionContribution) => actionContribution.name === action.name\n );\n\n if (contributions) {\n return new ActionModel(action, contributions);\n }\n }\n\n throw new Error(`Contributions not found for action ${action.name}`);\n });\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints)\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(\"|\");\n\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;AACA;AACA;AAEA;AACA;AACA;AACe,MAAMA,gBAAgB,SAASC,uBAAc,CAAc;EACxEC,WAAW,CAACC,OAAgB,EAAEC,oBAA6B,EAAE;IAC3D,KAAK,EAAE;;IAEP;IACA,IAAI,CAACD,OAAO,EAAE;MACZ,IAAI,CAACE,UAAU,GAAG,EAAE;;MAEpB;IACF,CAAC,MAAM,IAAI,CAACD,oBAAoB,IAAI,CAACE,KAAK,CAACC,OAAO,CAACH,oBAAoB,CAAC,EAAE;MACxE,MAAM,IAAII,oCAAwB,CAChC,iEAAiE,CAClE;IACH,CAAC,MAAM;MACL,IAAI,CAACH,UAAU,GAAG,kBAAAF,OAAO,OAAPA,OAAO,EAAMM,MAAM,IAAK;QACxC,IAAIL,oBAAoB,EAAE;UACxB,MAAMM,aAAa,GAAG,mBAAAN,oBAAoB,OAApBA,oBAAoB,EACvCO,kBAAkB,IAAKA,kBAAkB,CAACC,IAAI,KAAKH,MAAM,CAACG,IAAI,CAChE;UAED,IAAIF,aAAa,EAAE;YACjB,OAAO,IAAIG,oBAAW,CAACJ,MAAM,EAAEC,aAAa,CAAC;UAC/C;QACF;QAEA,MAAM,IAAII,KAAK,CAAE,sCAAqCL,MAAM,CAACG,IAAK,EAAC,CAAC;MACtE,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;EACEG,cAAc,CAACC,GAAW,EAAsB;IAAA;IAC9C,MAAMC,aAAa,GAAG,IAAIjB,gBAAgB,EAAE;IAE5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AAG,CAAC;IAE1E,OAAO,IAAI,CAACN,MAAM,GAAG,CAAC,GAAI,IAAGI,IAAK,GAAE,GAAGA,IAAI;EAC7C;AACF;AAAC"}
1
+ {"version":3,"file":"ActionCollection.js","names":["ActionCollection","BaseCollection","constructor","actions","actionsContributions","Array","isArray","collection","actionModels","actionData","actionContribution","name","push","ActionModel","getActionByKey","key","newCollection","action","first","getActionsByType","type","getActionsByLayoutHint","hints","layouthint","has","hasActionsByLayoutHint","length","routePath","enabledRoutes","isDisabled","path","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(actions?: Object, actionsContributions?: Object) {\n super();\n\n // no actions gives an empty collection\n if (!Array.isArray(actions)) {\n this.collection = [];\n } else if (Array.isArray(actionsContributions)) {\n const actionModels = [];\n for (const actionData of actions) {\n const actionContribution = actionsContributions.find(\n (actionContribution) => actionContribution.name === actionData.name\n );\n\n if (actionContribution) {\n actionModels.push(new ActionModel(actionData, actionContribution));\n }\n }\n\n this.collection = actionModels;\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints)\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(\"|\");\n\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;AACA;AAEA;AACA;AACA;AACe,MAAMA,gBAAgB,SAASC,uBAAc,CAAc;EACxEC,WAAW,CAACC,OAAgB,EAAEC,oBAA6B,EAAE;IAC3D,KAAK,EAAE;;IAEP;IACA,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;MAC3B,IAAI,CAACI,UAAU,GAAG,EAAE;IACtB,CAAC,MAAM,IAAIF,KAAK,CAACC,OAAO,CAACF,oBAAoB,CAAC,EAAE;MAC9C,MAAMI,YAAY,GAAG,EAAE;MACvB,KAAK,MAAMC,UAAU,IAAIN,OAAO,EAAE;QAChC,MAAMO,kBAAkB,GAAG,mBAAAN,oBAAoB,OAApBA,oBAAoB,EAC5CM,kBAAkB,IAAKA,kBAAkB,CAACC,IAAI,KAAKF,UAAU,CAACE,IAAI,CACpE;QAED,IAAID,kBAAkB,EAAE;UACtBF,YAAY,CAACI,IAAI,CAAC,IAAIC,oBAAW,CAACJ,UAAU,EAAEC,kBAAkB,CAAC,CAAC;QACpE;MACF;MAEA,IAAI,CAACH,UAAU,GAAGC,YAAY;IAChC;EACF;;EAEA;AACF;AACA;EACEM,cAAc,CAACC,GAAW,EAAsB;IAAA;IAC9C,MAAMC,aAAa,GAAG,IAAIhB,gBAAgB,EAAE;IAE5CgB,aAAa,CAACT,UAAU,GAAG,oCAAI,iBAASU,MAAM,IAAKA,MAAM,CAACF,GAAG,KAAKA,GAAG,CAAC;IAEtE,OAAOC,aAAa,CAACE,KAAK;EAC5B;;EAEA;AACF;AACA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ollection";
2
2
  import ActionModel from "../ActionModel";
3
- import { IllegalArgumentException } from "../../../exceptions";
4
3
 
5
4
  describe("actionCollection", () => {
6
5
  const collectionData = [
@@ -62,9 +61,8 @@ describe("actionCollection", () => {
62
61
  });
63
62
 
64
63
  it("should throw an error when action data is available but no contributions", () => {
65
- expect(() => {
66
- new ActionCollection(collectionData);
67
- }).toThrow(IllegalArgumentException);
64
+ const coll = new ActionCollection(collectionData);
65
+ expect(coll).toHaveLength(0);
68
66
  });
69
67
 
70
68
  it("should be able to create an ActionCollection with standard modular ui json", () => {
@@ -83,4 +81,18 @@ describe("actionCollection", () => {
83
81
  ActionModel
84
82
  );
85
83
  });
84
+
85
+ it("should be able to create an ActionCollection with part of contributions available", () => {
86
+ const actionCollection = new ActionCollection(collectionData, [
87
+ {
88
+ name: "sample2",
89
+ label: "Example of an action by layouthint",
90
+ type: "generic",
91
+ layouthint: ["testaction"],
92
+ },
93
+ ]);
94
+
95
+ expect(actionCollection).toHaveLength(1);
96
+ expect(actionCollection.getActionsByType("form")).toHaveLength(0);
97
+ });
86
98
  });
@@ -23,7 +23,8 @@ const serverNoSSR = _ref => {
23
23
  theme,
24
24
  render,
25
25
  template,
26
- beforeRenderHooks
26
+ beforeRenderHooks,
27
+ preloadApplication = true
27
28
  } = _ref;
28
29
  const UUID = (0, _createUUID.default)();
29
30
  __webpack_nonce__ = UUID; // NOSONAR
@@ -38,7 +39,9 @@ const serverNoSSR = _ref => {
38
39
  (0, _createTheme.default)(storedTheme, theme);
39
40
  }
40
41
  (0, _serverUtil.setI18n)(store, locales, request);
41
- (0, _serverUtil.setApplication)(store);
42
+ if (preloadApplication) {
43
+ (0, _serverUtil.setApplication)(store);
44
+ }
42
45
  (0, _serverUtil.handleErrors)(store);
43
46
  (0, _beforeRenderHooks.handleBeforeRenderHooks)(beforeRenderHooks, {
44
47
  store,
@@ -34,6 +34,7 @@ type serverProps = {
34
34
  render: Function,
35
35
  template?: (TemplateProps) => string,
36
36
  beforeRenderHooks?: Array<BeforeRenderHook>,
37
+ preloadApplication?: boolean,
37
38
  };
38
39
 
39
40
  /**
@@ -47,6 +48,7 @@ const serverNoSSR = ({
47
48
  render,
48
49
  template,
49
50
  beforeRenderHooks,
51
+ preloadApplication = true,
50
52
  }: serverProps): string => {
51
53
  const UUID = createUUID();
52
54
  __webpack_nonce__ = UUID; // NOSONAR
@@ -66,7 +68,9 @@ const serverNoSSR = ({
66
68
 
67
69
  setI18n(store, locales, request);
68
70
 
69
- setApplication(store);
71
+ if (preloadApplication) {
72
+ setApplication(store);
73
+ }
70
74
 
71
75
  handleErrors(store);
72
76
 
@@ -1 +1 @@
1
- {"version":3,"file":"serverNoSSR.js","names":["serverNoSSR","request","locales","customReducers","serverPreferences","theme","render","template","beforeRenderHooks","UUID","createUUID","__webpack_nonce__","requestHref","getFullRequestHref","store","createReduxStore","setServerPreferences","setConfigurationTheme","storedTheme","getState","preferences","createTheme","setI18n","setApplication","handleErrors","handleBeforeRenderHooks","renderSSRMinimal"],"sources":["../../src/react-server/serverNoSSR.js"],"sourcesContent":["// @flow\nimport \"./contextPath\";\n\nimport createUUID from \"../utils/helpers/createUUID\";\nimport { getFullRequestHref } from \"./requestInformation\";\n\nimport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n handleErrors,\n} from \"./serverUtil\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport renderSSRMinimal from \"./renderSSRMinimal\";\n\nimport createTheme from \"../react-theme/createTheme\";\n\nimport type { TemplateProps } from \"./htmlpage\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { PreferenceValue } from \"./serverUtil\";\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { Theme } from \"../react-theme/types\";\n\ntype serverProps = {\n request: HttpServletRequestJava,\n locales?: Array<LocaleConfiguration>,\n customReducers?: Object,\n theme?: Theme | Array<Theme>,\n serverPreferences?: Array<string | PreferenceValue>,\n render: Function,\n template?: (TemplateProps) => string,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n};\n\n/**\n */\nconst serverNoSSR = ({\n request,\n locales,\n customReducers,\n serverPreferences = [],\n theme,\n render,\n template,\n beforeRenderHooks,\n}: serverProps): string => {\n const UUID = createUUID();\n __webpack_nonce__ = UUID; // NOSONAR\n\n const requestHref = getFullRequestHref(request);\n\n const store = createReduxStore(requestHref, customReducers);\n\n setServerPreferences(store, serverPreferences);\n setConfigurationTheme(store);\n\n if (theme) {\n const storedTheme = store.getState()?.preferences?.theme;\n //$FlowFixMe[incompatible-call]\n createTheme(storedTheme, theme);\n }\n\n setI18n(store, locales, request);\n\n setApplication(store);\n\n handleErrors(store);\n\n handleBeforeRenderHooks(beforeRenderHooks, { store, request });\n\n return renderSSRMinimal({ store, theme, UUID, render, template });\n};\n\nexport default serverNoSSR;\n"],"mappings":";;;;;;;AACA;AAEA;AACA;AAEA;AASA;AAEA;AAEA;AAmBA;AACA;AACA,MAAMA,WAAW,GAAG,QASO;EAAA,IATN;IACnBC,OAAO;IACPC,OAAO;IACPC,cAAc;IACdC,iBAAiB,GAAG,EAAE;IACtBC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC;EACW,CAAC;EACZ,MAAMC,IAAI,GAAG,IAAAC,mBAAU,GAAE;EACzBC,iBAAiB,GAAGF,IAAI,CAAC,CAAC;;EAE1B,MAAMG,WAAW,GAAG,IAAAC,sCAAkB,EAACZ,OAAO,CAAC;EAE/C,MAAMa,KAAK,GAAG,IAAAC,4BAAgB,EAACH,WAAW,EAAET,cAAc,CAAC;EAE3D,IAAAa,gCAAoB,EAACF,KAAK,EAAEV,iBAAiB,CAAC;EAC9C,IAAAa,iCAAqB,EAACH,KAAK,CAAC;EAE5B,IAAIT,KAAK,EAAE;IACT,MAAMa,WAAW,GAAGJ,KAAK,CAACK,QAAQ,EAAE,EAAEC,WAAW,EAAEf,KAAK;IACxD;IACA,IAAAgB,oBAAW,EAACH,WAAW,EAAEb,KAAK,CAAC;EACjC;EAEA,IAAAiB,mBAAO,EAACR,KAAK,EAAEZ,OAAO,EAAED,OAAO,CAAC;EAEhC,IAAAsB,0BAAc,EAACT,KAAK,CAAC;EAErB,IAAAU,wBAAY,EAACV,KAAK,CAAC;EAEnB,IAAAW,0CAAuB,EAACjB,iBAAiB,EAAE;IAAEM,KAAK;IAAEb;EAAQ,CAAC,CAAC;EAE9D,OAAO,IAAAyB,yBAAgB,EAAC;IAAEZ,KAAK;IAAET,KAAK;IAAEI,IAAI;IAAEH,MAAM;IAAEC;EAAS,CAAC,CAAC;AACnE,CAAC;AAAC,eAEaP,WAAW;AAAA"}
1
+ {"version":3,"file":"serverNoSSR.js","names":["serverNoSSR","request","locales","customReducers","serverPreferences","theme","render","template","beforeRenderHooks","preloadApplication","UUID","createUUID","__webpack_nonce__","requestHref","getFullRequestHref","store","createReduxStore","setServerPreferences","setConfigurationTheme","storedTheme","getState","preferences","createTheme","setI18n","setApplication","handleErrors","handleBeforeRenderHooks","renderSSRMinimal"],"sources":["../../src/react-server/serverNoSSR.js"],"sourcesContent":["// @flow\nimport \"./contextPath\";\n\nimport createUUID from \"../utils/helpers/createUUID\";\nimport { getFullRequestHref } from \"./requestInformation\";\n\nimport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n handleErrors,\n} from \"./serverUtil\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport renderSSRMinimal from \"./renderSSRMinimal\";\n\nimport createTheme from \"../react-theme/createTheme\";\n\nimport type { TemplateProps } from \"./htmlpage\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { PreferenceValue } from \"./serverUtil\";\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { Theme } from \"../react-theme/types\";\n\ntype serverProps = {\n request: HttpServletRequestJava,\n locales?: Array<LocaleConfiguration>,\n customReducers?: Object,\n theme?: Theme | Array<Theme>,\n serverPreferences?: Array<string | PreferenceValue>,\n render: Function,\n template?: (TemplateProps) => string,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n preloadApplication?: boolean,\n};\n\n/**\n */\nconst serverNoSSR = ({\n request,\n locales,\n customReducers,\n serverPreferences = [],\n theme,\n render,\n template,\n beforeRenderHooks,\n preloadApplication = true,\n}: serverProps): string => {\n const UUID = createUUID();\n __webpack_nonce__ = UUID; // NOSONAR\n\n const requestHref = getFullRequestHref(request);\n\n const store = createReduxStore(requestHref, customReducers);\n\n setServerPreferences(store, serverPreferences);\n setConfigurationTheme(store);\n\n if (theme) {\n const storedTheme = store.getState()?.preferences?.theme;\n //$FlowFixMe[incompatible-call]\n createTheme(storedTheme, theme);\n }\n\n setI18n(store, locales, request);\n\n if (preloadApplication) {\n setApplication(store);\n }\n\n handleErrors(store);\n\n handleBeforeRenderHooks(beforeRenderHooks, { store, request });\n\n return renderSSRMinimal({ store, theme, UUID, render, template });\n};\n\nexport default serverNoSSR;\n"],"mappings":";;;;;;;AACA;AAEA;AACA;AAEA;AASA;AAEA;AAEA;AAoBA;AACA;AACA,MAAMA,WAAW,GAAG,QAUO;EAAA,IAVN;IACnBC,OAAO;IACPC,OAAO;IACPC,cAAc;IACdC,iBAAiB,GAAG,EAAE;IACtBC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,iBAAiB;IACjBC,kBAAkB,GAAG;EACV,CAAC;EACZ,MAAMC,IAAI,GAAG,IAAAC,mBAAU,GAAE;EACzBC,iBAAiB,GAAGF,IAAI,CAAC,CAAC;;EAE1B,MAAMG,WAAW,GAAG,IAAAC,sCAAkB,EAACb,OAAO,CAAC;EAE/C,MAAMc,KAAK,GAAG,IAAAC,4BAAgB,EAACH,WAAW,EAAEV,cAAc,CAAC;EAE3D,IAAAc,gCAAoB,EAACF,KAAK,EAAEX,iBAAiB,CAAC;EAC9C,IAAAc,iCAAqB,EAACH,KAAK,CAAC;EAE5B,IAAIV,KAAK,EAAE;IACT,MAAMc,WAAW,GAAGJ,KAAK,CAACK,QAAQ,EAAE,EAAEC,WAAW,EAAEhB,KAAK;IACxD;IACA,IAAAiB,oBAAW,EAACH,WAAW,EAAEd,KAAK,CAAC;EACjC;EAEA,IAAAkB,mBAAO,EAACR,KAAK,EAAEb,OAAO,EAAED,OAAO,CAAC;EAEhC,IAAIQ,kBAAkB,EAAE;IACtB,IAAAe,0BAAc,EAACT,KAAK,CAAC;EACvB;EAEA,IAAAU,wBAAY,EAACV,KAAK,CAAC;EAEnB,IAAAW,0CAAuB,EAAClB,iBAAiB,EAAE;IAAEO,KAAK;IAAEd;EAAQ,CAAC,CAAC;EAE9D,OAAO,IAAA0B,yBAAgB,EAAC;IAAEZ,KAAK;IAAEV,KAAK;IAAEK,IAAI;IAAEJ,MAAM;IAAEC;EAAS,CAAC,CAAC;AACnE,CAAC;AAAC,eAEaP,WAAW;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.27.3",
3
+ "version": "1.27.5",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -1,7 +1,6 @@
1
1
  // @flow
2
2
  import BaseCollection from "../base/BaseCollection";
3
3
  import ActionModel from "./ActionModel";
4
- import { IllegalArgumentException } from "../../exceptions";
5
4
 
6
5
  /**
7
6
  * Collection of actions
@@ -11,28 +10,21 @@ export default class ActionCollection extends BaseCollection<ActionModel> {
11
10
  super();
12
11
 
13
12
  // no actions gives an empty collection
14
- if (!actions) {
13
+ if (!Array.isArray(actions)) {
15
14
  this.collection = [];
16
-
17
- // When actions are available but no contributions, then an error occured
18
- } else if (!actionsContributions || !Array.isArray(actionsContributions)) {
19
- throw new IllegalArgumentException(
20
- "Data for ActionCollection found, but no contributions available"
21
- );
22
- } else {
23
- this.collection = actions.map((action) => {
24
- if (actionsContributions) {
25
- const contributions = actionsContributions.find(
26
- (actionContribution) => actionContribution.name === action.name
27
- );
28
-
29
- if (contributions) {
30
- return new ActionModel(action, contributions);
31
- }
15
+ } else if (Array.isArray(actionsContributions)) {
16
+ const actionModels = [];
17
+ for (const actionData of actions) {
18
+ const actionContribution = actionsContributions.find(
19
+ (actionContribution) => actionContribution.name === actionData.name
20
+ );
21
+
22
+ if (actionContribution) {
23
+ actionModels.push(new ActionModel(actionData, actionContribution));
32
24
  }
25
+ }
33
26
 
34
- throw new Error(`Contributions not found for action ${action.name}`);
35
- });
27
+ this.collection = actionModels;
36
28
  }
37
29
  }
38
30
 
@@ -1,6 +1,5 @@
1
1
  import ActionCollection from "../ActionCollection";
2
2
  import ActionModel from "../ActionModel";
3
- import { IllegalArgumentException } from "../../../exceptions";
4
3
 
5
4
  describe("actionCollection", () => {
6
5
  const collectionData = [
@@ -62,9 +61,8 @@ describe("actionCollection", () => {
62
61
  });
63
62
 
64
63
  it("should throw an error when action data is available but no contributions", () => {
65
- expect(() => {
66
- new ActionCollection(collectionData);
67
- }).toThrow(IllegalArgumentException);
64
+ const coll = new ActionCollection(collectionData);
65
+ expect(coll).toHaveLength(0);
68
66
  });
69
67
 
70
68
  it("should be able to create an ActionCollection with standard modular ui json", () => {
@@ -83,4 +81,18 @@ describe("actionCollection", () => {
83
81
  ActionModel
84
82
  );
85
83
  });
84
+
85
+ it("should be able to create an ActionCollection with part of contributions available", () => {
86
+ const actionCollection = new ActionCollection(collectionData, [
87
+ {
88
+ name: "sample2",
89
+ label: "Example of an action by layouthint",
90
+ type: "generic",
91
+ layouthint: ["testaction"],
92
+ },
93
+ ]);
94
+
95
+ expect(actionCollection).toHaveLength(1);
96
+ expect(actionCollection.getActionsByType("form")).toHaveLength(0);
97
+ });
86
98
  });
@@ -34,6 +34,7 @@ type serverProps = {
34
34
  render: Function,
35
35
  template?: (TemplateProps) => string,
36
36
  beforeRenderHooks?: Array<BeforeRenderHook>,
37
+ preloadApplication?: boolean,
37
38
  };
38
39
 
39
40
  /**
@@ -47,6 +48,7 @@ const serverNoSSR = ({
47
48
  render,
48
49
  template,
49
50
  beforeRenderHooks,
51
+ preloadApplication = true,
50
52
  }: serverProps): string => {
51
53
  const UUID = createUUID();
52
54
  __webpack_nonce__ = UUID; // NOSONAR
@@ -66,7 +68,9 @@ const serverNoSSR = ({
66
68
 
67
69
  setI18n(store, locales, request);
68
70
 
69
- setApplication(store);
71
+ if (preloadApplication) {
72
+ setApplication(store);
73
+ }
70
74
 
71
75
  handleErrors(store);
72
76