orc-shared 1.2.0-dev.10 → 1.2.0-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/components/AppFrame/About.js +5 -1
  4. package/dist/components/AppFrame/AppFrame.js +14 -4
  5. package/dist/components/AppFrame/MenuItem.js +1 -4
  6. package/dist/components/MaterialUI/Inputs/InputBase.js +41 -4
  7. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +8 -2
  8. package/dist/components/Routing/FullPage.js +6 -3
  9. package/dist/selectors/metadata.js +13 -3
  10. package/dist/selectors/scope.js +2 -1
  11. package/dist/utils/setTranslation.js +27 -1
  12. package/dist/utils/setTranslationWithFallback.js +30 -1
  13. package/package.json +1 -1
  14. package/src/components/AppFrame/About.js +8 -1
  15. package/src/components/AppFrame/AppFrame.js +13 -2
  16. package/src/components/AppFrame/AppFrame.test.js +53 -0
  17. package/src/components/AppFrame/MenuItem.js +1 -12
  18. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +7 -1
  19. package/src/components/MaterialUI/Inputs/InputBase.js +19 -2
  20. package/src/components/MaterialUI/Inputs/InputBase.test.js +68 -0
  21. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +5 -1
  22. package/src/components/Routing/FullPage.js +12 -4
  23. package/src/components/Routing/FullPage.test.js +24 -0
  24. package/src/components/Scope/Scope.test.js +4 -0
  25. package/src/selectors/metadata.js +18 -7
  26. package/src/selectors/metadata.test.js +221 -283
  27. package/src/selectors/scope.js +1 -1
  28. package/src/translations/en-US.json +1 -1
  29. package/src/translations/fr-CA.json +1 -1
  30. package/src/utils/setTranslation.js +16 -1
  31. package/src/utils/setTranslation.test.js +24 -0
  32. package/src/utils/setTranslationWithFallback.js +18 -1
  33. package/src/utils/setTranslationWithFallback.test.js +108 -0
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2018 Orckestra Inc.
1
+ Copyright (C) 2022 Orckestra Technologies Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -10,7 +10,7 @@ This library provides the [infrastructure](docs/infrastructure.md) to construct
10
10
 
11
11
  ## License
12
12
 
13
- Copyright © 2018 Orckestra Inc.
13
+ Copyright © 2022 Orckestra Technologies Inc.
14
14
 
15
15
  Permission is hereby granted, free of charge, to any person obtaining a copy
16
16
  of this software and associated documentation files (the "Software"), to deal
@@ -198,7 +198,11 @@ var About = function About(_ref2) {
198
198
  }, /*#__PURE__*/_react.default.createElement(_Text.default, {
199
199
  message: _sharedMessages.default.ccName
200
200
  }))), /*#__PURE__*/_react.default.createElement(AboutParagraph, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
201
- message: _sharedMessages.default.copyright
201
+ message: _objectSpread(_objectSpread({}, _sharedMessages.default.copyright), {}, {
202
+ values: {
203
+ year: new Date().getFullYear()
204
+ }
205
+ })
202
206
  }), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_Text.default, {
203
207
  message: _sharedMessages.default.allRightsReserved
204
208
  })));
@@ -165,7 +165,17 @@ var AppFrame = function AppFrame(_ref) {
165
165
  }, [needLogin]);
166
166
  (0, _react.useEffect)(function () {
167
167
  document.title = (currentApplication == null ? void 0 : currentApplication.displayName) || applicationId;
168
- }, [currentApplication, applicationId]);
168
+ }, [currentApplication, applicationId]); // Extract only what's needed for the SideBar and its menuItems
169
+
170
+ var menuItemFromModules = (0, _react.useMemo)(function () {
171
+ return (modules != null ? modules : []).map(function (item) {
172
+ return {
173
+ id: item.id,
174
+ label: item.label,
175
+ icon: item.icon
176
+ };
177
+ });
178
+ }, [modules]);
169
179
 
170
180
  var _useViewState = (0, _useViewState3.default)(_Preferences.PREFS_NAME),
171
181
  _useViewState2 = _slicedToArray(_useViewState, 1),
@@ -191,7 +201,7 @@ var AppFrame = function AppFrame(_ref) {
191
201
  }), /*#__PURE__*/_react.default.createElement(_Sidebar.default, {
192
202
  open: open,
193
203
  toggle: toggle,
194
- modules: modules,
204
+ modules: menuItemFromModules,
195
205
  activeModules: activeModules
196
206
  }), /*#__PURE__*/_react.default.createElement(ViewPort, {
197
207
  open: open,
@@ -201,11 +211,11 @@ var AppFrame = function AppFrame(_ref) {
201
211
  }), /*#__PURE__*/_react.default.createElement(_loadingScreen.default, null), /*#__PURE__*/_react.default.createElement(_Preferences.default, null));
202
212
  };
203
213
 
204
- __signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseViewState{[prefViewState]}", function () {
214
+ __signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseMemo{menuItemFromModules}\nuseViewState{[prefViewState]}", function () {
205
215
  return [_reactIntl.useIntl, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _useApplicationHelpUrl.default, _useLoader.default, _useToggle3.default, _useLoader.default, _useViewState3.default];
206
216
  });
207
217
 
208
- __signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseViewState{[prefViewState]}", function () {
218
+ __signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseMemo{menuItemFromModules}\nuseViewState{[prefViewState]}", function () {
209
219
  return [_reactIntl.useIntl, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _useApplicationHelpUrl.default, _useLoader.default, _useToggle3.default, _useLoader.default, _useViewState3.default];
210
220
  });
211
221
 
@@ -20,7 +20,7 @@ var _Icon = _interopRequireDefault(require("../Icon"));
20
20
  var _templateObject;
21
21
 
22
22
  var _excluded = ["menuToggle", "staticContext", "dispatch", "active", "component"],
23
- _excluded2 = ["open", "label", "icon", "alert", "pageScopeSelector", "closingTabHandler", "hide", "isHidden", "href"];
23
+ _excluded2 = ["open", "label", "icon", "alert", "isHidden", "href"];
24
24
 
25
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
26
 
@@ -134,9 +134,6 @@ var MenuItem = function MenuItem(_ref5) {
134
134
  label = _ref5$label === void 0 ? "" : _ref5$label,
135
135
  icon = _ref5.icon,
136
136
  alert = _ref5.alert,
137
- pageScopeSelector = _ref5.pageScopeSelector,
138
- closingTabHandler = _ref5.closingTabHandler,
139
- hide = _ref5.hide,
140
137
  _ref5$isHidden = _ref5.isHidden,
141
138
  isHidden = _ref5$isHidden === void 0 ? false : _ref5$isHidden,
142
139
  href = _ref5.href,
@@ -29,6 +29,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
29
  enterModule && enterModule(module);
30
30
  })();
31
31
 
32
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
+
34
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
+
36
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(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); }
37
+
38
+ 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; }
39
+
40
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
41
+
42
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
+
32
44
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
33
45
  return a;
34
46
  };
@@ -159,11 +171,36 @@ var InputBase = function InputBase(_ref) {
159
171
 
160
172
  var onChangeHandler = function onChangeHandler(event) {
161
173
  event.persist();
162
- update(event.target.value, metadata);
174
+
175
+ if (!event.target.value || window.bypassDebounce === true) {
176
+ update(event.target.value, metadata);
177
+ }
178
+
179
+ setInputText(event.target.value);
163
180
  };
164
181
 
165
182
  var inputBaseInputStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.input);
166
183
  var errorTextStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.errorText);
184
+
185
+ var _React$useState = _react.default.useState(null),
186
+ _React$useState2 = _slicedToArray(_React$useState, 2),
187
+ inputText = _React$useState2[0],
188
+ setInputText = _React$useState2[1];
189
+
190
+ var textToDisplay = inputText != null ? inputText : value;
191
+
192
+ _react.default.useEffect(function () {
193
+ if (inputText !== value && inputText != null && window.bypassDebounce !== true) {
194
+ var timeOutId = setTimeout(function () {
195
+ return update(inputText, metadata);
196
+ }, 100);
197
+ return function () {
198
+ return clearTimeout(timeOutId);
199
+ };
200
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
201
+
202
+ }, [inputText, value]);
203
+
167
204
  return /*#__PURE__*/_react.default.createElement("div", {
168
205
  className: classes.container
169
206
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -182,7 +219,7 @@ var InputBase = function InputBase(_ref) {
182
219
  onClick: onClick,
183
220
  type: type,
184
221
  placeholder: placeholder,
185
- value: value,
222
+ value: textToDisplay,
186
223
  fullWidth: true,
187
224
  onChange: function onChange(event) {
188
225
  return onChangeHandler(event);
@@ -201,11 +238,11 @@ var InputBase = function InputBase(_ref) {
201
238
  }, error));
202
239
  };
203
240
 
204
- __signature__(InputBase, "useStyles{classes}", function () {
241
+ __signature__(InputBase, "useStyles{classes}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
205
242
  return [useStyles];
206
243
  });
207
244
 
208
- __signature__(InputBase, "useStyles{classes}", function () {
245
+ __signature__(InputBase, "useStyles{classes}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
209
246
  return [useStyles];
210
247
  });
211
248
 
@@ -49,7 +49,11 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
49
49
  backgroundColor: theme.palette.grey.light,
50
50
  border: "1px solid ".concat(theme.palette.grey.borders),
51
51
  boxShadow: "0 2px 4px rgba(0,0,0,0.5)",
52
- width: theme.spacing(50)
52
+ width: theme.spacing(50),
53
+ display: "flex"
54
+ },
55
+ scopeContainer: {
56
+ width: "100%"
53
57
  },
54
58
  scopeSelector: {
55
59
  display: "flex",
@@ -108,7 +112,9 @@ var ScopeSelector = function ScopeSelector(_ref) {
108
112
  onClickAway: function onClickAway(e) {
109
113
  return closeSelector(e);
110
114
  }
111
- }, /*#__PURE__*/_react.default.createElement("div", null, show ? scopeSelectorContent : null)));
115
+ }, /*#__PURE__*/_react.default.createElement("div", {
116
+ className: classes.scopeContainer
117
+ }, show ? scopeSelectorContent : null)));
112
118
 
113
119
  return scopeSelector;
114
120
  };
@@ -35,8 +35,11 @@ var FullPage = function FullPage(_ref) {
35
35
  location = _ref.location,
36
36
  match = _ref.match,
37
37
  modulePrependPath = _ref.modulePrependPath,
38
- isVisible = _ref.isVisible;
38
+ _ref$isVisible = _ref.isVisible,
39
+ isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible;
39
40
  var component = config.component,
41
+ _config$routerCompone = config.routerComponent,
42
+ routerComponent = _config$routerCompone === void 0 ? null : _config$routerCompone,
40
43
  componentProps = config.componentProps,
41
44
  _config$pages = config.pages,
42
45
  pages = _config$pages === void 0 ? {} : _config$pages,
@@ -59,12 +62,12 @@ var FullPage = function FullPage(_ref) {
59
62
 
60
63
  return /*#__PURE__*/_react.default.createElement(_Page.default, {
61
64
  path: path,
62
- component: component,
65
+ component: component != null ? component : routerComponent,
63
66
  pages: pages,
64
67
  subpages: subpages,
65
68
  location: location,
66
69
  match: match,
67
- isVisible: isVisible,
70
+ isVisible: isVisible === true || routerComponent != null,
68
71
  modulePrependPath: modulePrependPath
69
72
  });
70
73
  };
@@ -93,9 +93,9 @@ var namedLookupSelector = (0, _utils.memoize)(function (moduleName, lookupName)
93
93
  });
94
94
  exports.namedLookupSelector = namedLookupSelector;
95
95
  var namedLookupValuesSelector = (0, _utils.memoize)(function (moduleName, lookupName) {
96
- return (0, _reselect.createSelector)(namedLookupSelector(moduleName, lookupName), _locale.currentLocaleOrDefault, function (statuses, locale) {
97
- return (statuses.get("values") || _immutable.default.Map()).map(function (status) {
98
- return (0, _utils.setTranslation)(locale, status, "displayName");
96
+ return (0, _reselect.createSelector)(namedLookupSelector(moduleName, lookupName), _locale.currentLocaleOrDefault, function (lookup, locale) {
97
+ return (lookup.get("values") || _immutable.default.Map()).map(function (lookupValue) {
98
+ return (0, _setTranslationWithFallback.setTranslationWithFallbackField)(locale, lookupValue, "name", "displayName");
99
99
  });
100
100
  });
101
101
  });
@@ -230,6 +230,8 @@ var filterIsBuiltInAttributes = function filterIsBuiltInAttributes(isBuiltIn) {
230
230
  return function (attributes) {
231
231
  return attributes.filter(function (a) {
232
232
  return a.get("isBuiltIn") === isBuiltIn;
233
+ }).sortBy(function (x) {
234
+ return x.get("displayOrder");
233
235
  });
234
236
  };
235
237
  };
@@ -278,8 +280,12 @@ var groupedCustomAttributesDefinitionSelector = (0, _utils.memoize)(function (mo
278
280
  displayOrder: profileAttributeGroup == null ? void 0 : profileAttributeGroup.get("displayOrder")
279
281
  }).set("baseAttributes", group.filter(function (i) {
280
282
  return i.get("dataType") !== _constants.attributeDataType.entityReference;
283
+ }).sortBy(function (x) {
284
+ return x.get("displayOrder");
281
285
  })).set("profileAttributes", group.filter(function (i) {
282
286
  return i.get("dataType") === _constants.attributeDataType.entityReference;
287
+ }).sortBy(function (x) {
288
+ return x.get("displayOrder");
283
289
  }));
284
290
  }).sortBy(function (x) {
285
291
  return x.get("displayOrder");
@@ -291,9 +297,13 @@ var customAttributesDefinitionSelector = (0, _utils.memoize)(function (moduleNam
291
297
  return (0, _reselect.createSelector)(mappedDefinitionEntity(moduleName, profileEntityName), customAttributesSelector(moduleName, profileEntityName), function (definition, attributes) {
292
298
  var profileAttributes = attributes == null ? void 0 : attributes.filter(function (a) {
293
299
  return a.get("dataType") === _constants.attributeDataType.entityReference;
300
+ }).sortBy(function (x) {
301
+ return x.get("displayOrder");
294
302
  });
295
303
  var baseAttributes = attributes == null ? void 0 : attributes.filter(function (a) {
296
304
  return a.get("dataType") !== _constants.attributeDataType.entityReference;
305
+ }).sortBy(function (x) {
306
+ return x.get("displayOrder");
297
307
  });
298
308
  return definition.set("baseAttributes", baseAttributes).set("profileAttributes", profileAttributes);
299
309
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.scopeGetter = exports.scopeDefaultCultureSelector = exports.localizedScopesSelectorByIds = exports.localizedScopeSelector = exports.isCurrentScopeAuthorizedSelector = exports.getScopesSelector = exports.currentScopeSelector = void 0;
4
+ exports.scopeGetter = exports.scopeDefaultCultureSelector = exports.localizedScopesSelectorByIds = exports.localizedScopesSelector = exports.localizedScopeSelector = exports.isCurrentScopeAuthorizedSelector = exports.getScopesSelector = exports.currentScopeSelector = void 0;
5
5
 
6
6
  var _reselect = require("reselect");
7
7
 
@@ -52,6 +52,7 @@ var localizedScopesSelector = (0, _reselect.createSelector)(scopeData, _locale.c
52
52
  });
53
53
  });
54
54
  });
55
+ exports.localizedScopesSelector = localizedScopesSelector;
55
56
  var currentScopeSelector = (0, _reselect.createSelector)(_navigation.getCurrentScope, localizedScopesSelector, function (id, scopes) {
56
57
  return scopes.get(id) || _immutable.default.Map();
57
58
  });
@@ -15,6 +15,12 @@ var _flatten = require("./flatten");
15
15
  enterModule && enterModule(module);
16
16
  })();
17
17
 
18
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(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); }
21
+
22
+ 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; }
23
+
18
24
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
19
25
  return a;
20
26
  };
@@ -30,7 +36,27 @@ var setTranslation = function setTranslation(locale, obj) {
30
36
  }
31
37
 
32
38
  if (!obj || !obj.getIn((0, _flatten.flatten)([field]))) return obj;
33
- var value = obj.getIn((0, _flatten.flatten)([field, locale])) || obj.getIn((0, _flatten.flatten)([field])).filter(function (i) {
39
+ var localeValue = obj.getIn((0, _flatten.flatten)([field, locale]));
40
+
41
+ if (!localeValue && locale.includes("-")) {
42
+ var fieldValue = obj.getIn((0, _flatten.flatten)([field]));
43
+ var fieldKeys = fieldValue.keys();
44
+ var language = locale.substring(0, locale.indexOf("-"));
45
+
46
+ for (var _iterator = _createForOfIteratorHelperLoose(fieldKeys), _step; !(_step = _iterator()).done;) {
47
+ var key = _step.value;
48
+
49
+ if (key !== locale && key.startsWith(language)) {
50
+ localeValue = obj.getIn((0, _flatten.flatten)([field, key]));
51
+
52
+ if (localeValue) {
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ var value = localeValue || obj.getIn((0, _flatten.flatten)([field])).filter(function (i) {
34
60
  return i;
35
61
  }).first() || "";
36
62
  return obj.setIn((0, _flatten.flatten)([field]), value);
@@ -15,6 +15,12 @@ var _flatten = require("./flatten");
15
15
  enterModule && enterModule(module);
16
16
  })();
17
17
 
18
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(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); }
21
+
22
+ 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; }
23
+
18
24
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
19
25
  return a;
20
26
  };
@@ -30,7 +36,30 @@ var setTranslationWithFallbackValue = function setTranslationWithFallbackValue(l
30
36
  field[_key - 3] = arguments[_key];
31
37
  }
32
38
 
33
- var value = obj.getIn((0, _flatten.flatten)([field, locale])) || fallbackValue || "";
39
+ var localeValue = obj.getIn((0, _flatten.flatten)([field, locale]));
40
+
41
+ if (!localeValue && locale.includes("-")) {
42
+ var fieldValue = obj.getIn((0, _flatten.flatten)([field]));
43
+
44
+ if (fieldValue) {
45
+ var fieldKeys = fieldValue.keys();
46
+ var language = locale.substring(0, locale.indexOf("-"));
47
+
48
+ for (var _iterator = _createForOfIteratorHelperLoose(fieldKeys), _step; !(_step = _iterator()).done;) {
49
+ var key = _step.value;
50
+
51
+ if (key !== locale && key.startsWith(language)) {
52
+ localeValue = obj.getIn((0, _flatten.flatten)([field, key]));
53
+
54
+ if (localeValue) {
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ var value = localeValue || fallbackValue || "";
34
63
  return obj.setIn((0, _flatten.flatten)([field]), value);
35
64
  };
36
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "1.2.0-dev.10",
3
+ "version": "1.2.0-dev.14",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -164,7 +164,14 @@ export const About = ({ currentApplication }) => {
164
164
  </AboutLink>
165
165
  </AboutParagraph>
166
166
  <AboutParagraph>
167
- <Text message={sharedMessages.copyright} />
167
+ <Text
168
+ message={{
169
+ ...sharedMessages.copyright,
170
+ values: {
171
+ year: new Date().getFullYear(),
172
+ },
173
+ }}
174
+ />
168
175
  <br />
169
176
  <Text message={sharedMessages.allRightsReserved} />
170
177
  </AboutParagraph>
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useMemo } from "react";
2
2
  import { useIntl } from "react-intl";
3
3
  import pt from "prop-types";
4
4
  import styled, { css } from "styled-components";
@@ -89,6 +89,17 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
89
89
  document.title = currentApplication?.displayName || applicationId;
90
90
  }, [currentApplication, applicationId]);
91
91
 
92
+ // Extract only what's needed for the SideBar and its menuItems
93
+ const menuItemFromModules = useMemo(
94
+ () =>
95
+ (modules ?? []).map(item => ({
96
+ id: item.id,
97
+ label: item.label,
98
+ icon: item.icon,
99
+ })),
100
+ [modules],
101
+ );
102
+
92
103
  const [prefViewState] = useViewState(PREFS_NAME);
93
104
 
94
105
  return (
@@ -109,7 +120,7 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
109
120
  }}
110
121
  onClick={reset}
111
122
  />
112
- <Sidebar {...{ open, toggle, modules, activeModules }} />
123
+ <Sidebar {...{ open, toggle, modules: menuItemFromModules, activeModules }} />
113
124
  <ViewPort open={open} onClick={reset}>
114
125
  {noScope && !forceShowScope.includes(moduleName) ? (
115
126
  <React.Fragment>
@@ -294,6 +294,59 @@ describe("AppFrame", () => {
294
294
  expect(document.title, "to equal", "Marketing Legacy");
295
295
  });
296
296
 
297
+ it("renders a viewport with scope selector, top bar and sidebar with undefined modules", () => {
298
+ props.modules = undefined;
299
+ props.children = [<TestComp1 key="1" />, <TestComp2 key="2" />, <TestComp3 key="3" />];
300
+ expect(
301
+ <Provider store={store}>
302
+ <MemoryRouter initialEntries={["/Foo/bar"]}>
303
+ <ThemeProvider theme={{}}>
304
+ <I18n>
305
+ <AppFrame {...props} />
306
+ </I18n>
307
+ </ThemeProvider>
308
+ </MemoryRouter>
309
+ </Provider>,
310
+ "when mounted",
311
+ "to satisfy",
312
+ <Provider store={store}>
313
+ <ThemeProvider theme={{}}>
314
+ <MemoryRouter initialEntries={["/Foo/bar"]}>
315
+ <Base>
316
+ <Wrapper>
317
+ <AppBox>
318
+ <ApplicationSelector {...props} />
319
+ <AppLabel>
320
+ <AppLogo />
321
+ Marketing Legacy
322
+ </AppLabel>
323
+ </AppBox>
324
+ <MenuWrapper>
325
+ <Ignore />
326
+ </MenuWrapper>
327
+ <HelpLink>Help</HelpLink>
328
+ </Wrapper>
329
+ <SideBar>
330
+ <MenuToggle />
331
+ <Logo />
332
+ </SideBar>
333
+ <ViewPort>
334
+ <ScopeBar name="Test 1" />
335
+ <TestComp1 key="1" />
336
+ <TestComp2 key="2" />
337
+ <TestComp3 key="3" />
338
+ </ViewPort>
339
+ <About messages={props.aboutMessages} />
340
+ <LoadingScreen />
341
+ </Base>
342
+ </MemoryRouter>
343
+ </ThemeProvider>
344
+ </Provider>,
345
+ );
346
+
347
+ expect(document.title, "to equal", "Marketing Legacy");
348
+ });
349
+
297
350
  it("renders a viewport with scope selector, top bar and sidebar when no current application", () => {
298
351
  props.modules = [
299
352
  { id: "test1", component: TestComp1, route: "/test1" },
@@ -116,18 +116,7 @@ export const Label = styled.span`
116
116
  opacity: ${ifFlag("show", 1, 0)};
117
117
  `;
118
118
 
119
- const MenuItem = ({
120
- open = false,
121
- label = "",
122
- icon,
123
- alert,
124
- pageScopeSelector,
125
- closingTabHandler,
126
- hide, // This props is not used in the component, but we need to destructure it so props can be used in ItemWrapper
127
- isHidden = false,
128
- href,
129
- ...props
130
- }) => {
119
+ const MenuItem = ({ open = false, label = "", icon, alert, isHidden = false, href, ...props }) => {
131
120
  let ItemWrapper = Block;
132
121
  if (props.menuToggle) {
133
122
  ItemWrapper = BlockWithA;
@@ -18,6 +18,8 @@ describe("Translations ", () => {
18
18
  const theme = createMuiTheme();
19
19
 
20
20
  beforeEach(() => {
21
+ window.bypassDebounce = true;
22
+
21
23
  collapsibleListProps = new CollapsibleListProps();
22
24
  collapsibleListProps.set(CollapsibleListProps.propNames.hasMessage, true);
23
25
  collapsibleListProps.set(
@@ -32,6 +34,10 @@ describe("Translations ", () => {
32
34
  collapsibleListProps.set(CollapsibleListProps.propNames.containerWidth, "unset");
33
35
  });
34
36
 
37
+ afterEach(() => {
38
+ delete window.bypassDebounce;
39
+ });
40
+
35
41
  it("Renders Translations correctly", () => {
36
42
  const component = (
37
43
  <TestWrapper stylesProvider muiThemeProvider={{ theme }} intlProvider={{ messages }}>
@@ -135,7 +141,7 @@ describe("Translations ", () => {
135
141
  expect(component, "when mounted", "to satisfy", expected);
136
142
  });
137
143
 
138
- it("Translations component handles change", () => {
144
+ it("Translations component handles change", () => {
139
145
  const aValue = "aValue";
140
146
  const update = sinon.spy().named("update");
141
147
 
@@ -111,12 +111,29 @@ const InputBase = ({ inputProps }) => {
111
111
 
112
112
  const onChangeHandler = event => {
113
113
  event.persist();
114
- update(event.target.value, metadata);
114
+
115
+ if (!event.target.value || window.bypassDebounce === true) {
116
+ update(event.target.value, metadata);
117
+ }
118
+
119
+ setInputText(event.target.value);
115
120
  };
116
121
 
117
122
  const inputBaseInputStyle = inputProps?.getStyle(InputBaseProps.ruleNames.input);
118
123
  const errorTextStyle = inputProps?.getStyle(InputBaseProps.ruleNames.errorText);
119
124
 
125
+ const [inputText, setInputText] = React.useState(null);
126
+
127
+ const textToDisplay = inputText ?? value;
128
+
129
+ React.useEffect(() => {
130
+ if (inputText !== value && inputText != null && window.bypassDebounce !== true) {
131
+ const timeOutId = setTimeout(() => update(inputText, metadata), 100);
132
+ return () => clearTimeout(timeOutId);
133
+ }
134
+ // eslint-disable-next-line react-hooks/exhaustive-deps
135
+ }, [inputText, value]);
136
+
120
137
  return (
121
138
  <div className={classes.container}>
122
139
  <div className={classes.inputContainer}>
@@ -133,7 +150,7 @@ const InputBase = ({ inputProps }) => {
133
150
  onClick={onClick}
134
151
  type={type}
135
152
  placeholder={placeholder}
136
- value={value}
153
+ value={textToDisplay}
137
154
  fullWidth={true}
138
155
  onChange={event => onChangeHandler(event)}
139
156
  error={!!error}