orc-shared 1.2.0-dev.6 → 1.3.0-dev.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/actions/makeApiAction.js +2 -2
- package/dist/actions/makeOrcApiAction.js +2 -2
- package/dist/actions/metadata.js +2 -2
- package/dist/actions/navigation.js +2 -2
- package/dist/buildStore.js +2 -2
- package/dist/components/AppFrame/About.js +7 -3
- package/dist/components/AppFrame/AppFrame.js +14 -4
- package/dist/components/AppFrame/MenuItem.js +1 -4
- package/dist/components/AppFrame/Preferences.js +2 -2
- package/dist/components/Culture.js +106 -0
- package/dist/components/Form/FieldList.js +2 -2
- package/dist/components/Form/Inputs/Translation.js +2 -2
- package/dist/components/I18n.js +5 -2
- package/dist/components/List/enhanceColumnDefs.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +2 -2
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
- package/dist/components/MaterialUI/Inputs/DatePicker.js +10 -37
- package/dist/components/MaterialUI/Inputs/InputBase.js +42 -4
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +4 -1
- package/dist/components/MaterialUI/Inputs/Select.js +2 -2
- package/dist/components/MaterialUI/Inputs/Switch.js +2 -2
- package/dist/components/MaterialUI/Inputs/TimePicker.js +5 -2
- package/dist/components/MaterialUI/Inputs/createInput.js +2 -2
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +8 -2
- package/dist/components/MaterialUI/muiThemes.js +2 -2
- package/dist/components/Navigation/Bar.js +2 -2
- package/dist/components/Navigation/useNavigationState.js +2 -2
- package/dist/components/Provision.js +3 -1
- package/dist/components/Routing/FullPage.js +6 -3
- package/dist/components/Routing/withWaypointing.js +2 -2
- package/dist/components/Scope/index.js +2 -2
- package/dist/components/Treeview/Node.js +2 -2
- package/dist/components/Treeview/index.js +2 -2
- package/dist/content/icons/lock.svg +3 -0
- package/dist/content/icons/unlock.svg +3 -0
- package/dist/content/iconsSheet.svg +6 -3
- package/dist/getThemeOverrides.js +2 -2
- package/dist/hocs/withUpdateHandler.js +2 -2
- package/dist/hooks/useEditState.js +2 -2
- package/dist/hooks/useEntityLoader.js +2 -2
- package/dist/hooks/useFullEntityEditState.js +2 -2
- package/dist/hooks/useLabelMessage.js +2 -2
- package/dist/hooks/useMultipleFieldEditState.js +2 -2
- package/dist/hooks/useNotificationRequestState.js +2 -2
- package/dist/selectors/metadata.js +15 -5
- package/dist/selectors/modules.js +2 -2
- package/dist/selectors/scope.js +2 -1
- package/dist/utils/flatten.js +2 -2
- package/dist/utils/localizationHelper.js +11 -1
- package/dist/utils/setTranslation.js +27 -1
- package/dist/utils/setTranslationWithFallback.js +30 -1
- package/package.json +1 -1
- package/src/components/AppFrame/About.js +8 -1
- package/src/components/AppFrame/AppFrame.js +13 -2
- package/src/components/AppFrame/AppFrame.test.js +53 -0
- package/src/components/AppFrame/MenuItem.js +1 -12
- package/src/components/Culture.js +25 -0
- package/src/components/Culture.test.js +86 -0
- package/src/components/I18n.js +4 -2
- package/src/components/I18n.test.js +32 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +7 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +2 -2
- package/src/components/MaterialUI/Inputs/DatePicker.js +5 -27
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +6 -34
- package/src/components/MaterialUI/Inputs/InputBase.js +20 -2
- package/src/components/MaterialUI/Inputs/InputBase.test.js +68 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.js +2 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +6 -2
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +5 -1
- package/src/components/Provision.js +2 -0
- package/src/components/Routing/FullPage.js +12 -4
- package/src/components/Routing/FullPage.test.js +24 -0
- package/src/components/Scope/Scope.test.js +4 -0
- package/src/content/icons/lock.svg +3 -0
- package/src/content/icons/unlock.svg +3 -0
- package/src/content/iconsSheet.svg +6 -3
- package/src/selectors/metadata.js +18 -7
- package/src/selectors/metadata.test.js +221 -283
- package/src/selectors/scope.js +1 -1
- package/src/translations/en-US.json +1 -1
- package/src/translations/fr-CA.json +1 -1
- package/src/utils/localizationHelper.js +12 -0
- package/src/utils/localizationHelper.test.js +64 -0
- package/src/utils/setTranslation.js +16 -1
- package/src/utils/setTranslation.test.js +24 -0
- package/src/utils/setTranslationWithFallback.js +18 -1
- package/src/utils/setTranslationWithFallback.test.js +108 -0
|
@@ -35,9 +35,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
35
|
enterModule && enterModule(module);
|
|
36
36
|
})();
|
|
37
37
|
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
38
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
39
|
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
40
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
41
|
|
|
42
42
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
43
|
|
|
@@ -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 (
|
|
97
|
-
return (
|
|
98
|
-
return (0,
|
|
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
|
});
|
|
@@ -15,9 +15,9 @@ var _reselect = require("reselect");
|
|
|
15
15
|
enterModule && enterModule(module);
|
|
16
16
|
})();
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
21
|
|
|
22
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
23
|
|
package/dist/selectors/scope.js
CHANGED
|
@@ -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
|
});
|
package/dist/utils/flatten.js
CHANGED
|
@@ -13,9 +13,9 @@ exports.flattenObj = exports.flatten = void 0;
|
|
|
13
13
|
enterModule && enterModule(module);
|
|
14
14
|
})();
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
17
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
19
|
|
|
20
20
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
21
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
+
exports.findCorrespondingLocale = findCorrespondingLocale;
|
|
5
6
|
exports.getLocalization = getLocalization;
|
|
6
7
|
exports.getNotLocalizedString = getNotLocalizedString;
|
|
7
8
|
|
|
@@ -51,9 +52,16 @@ function getNotLocalizedString(value) {
|
|
|
51
52
|
return value && "[".concat(value, "]");
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
function findCorrespondingLocale(locales, language) {
|
|
56
|
+
var _ref, _ref2, _ref3, _ref4, _locales$language;
|
|
57
|
+
|
|
58
|
+
return (_ref = (_ref2 = (_ref3 = (_ref4 = (_locales$language = locales[language]) != null ? _locales$language : locales[language.replace(/-/g, "")]) != null ? _ref4 : locales[language.toLowerCase()]) != null ? _ref3 : locales[language.toLowerCase().replace(/-/g, "")]) != null ? _ref2 : locales[language.substring(0, 2).toLowerCase()]) != null ? _ref : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
var _default = {
|
|
55
62
|
getLocalization: getLocalization,
|
|
56
|
-
getNotLocalizedString: getNotLocalizedString
|
|
63
|
+
getNotLocalizedString: getNotLocalizedString,
|
|
64
|
+
findCorrespondingLocale: findCorrespondingLocale
|
|
57
65
|
};
|
|
58
66
|
var _default2 = _default;
|
|
59
67
|
var _default3 = _default2;
|
|
@@ -69,6 +77,7 @@ exports.default = _default3;
|
|
|
69
77
|
|
|
70
78
|
reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
71
79
|
reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
80
|
+
reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
72
81
|
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
73
82
|
})();
|
|
74
83
|
|
|
@@ -90,6 +99,7 @@ exports.default = _default3;
|
|
|
90
99
|
|
|
91
100
|
reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
92
101
|
reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
102
|
+
reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
93
103
|
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
|
|
94
104
|
})();
|
|
95
105
|
|
|
@@ -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
|
|
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
|
|
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
|
@@ -164,7 +164,14 @@ export const About = ({ currentApplication }) => {
|
|
|
164
164
|
</AboutLink>
|
|
165
165
|
</AboutParagraph>
|
|
166
166
|
<AboutParagraph>
|
|
167
|
-
<Text
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useSelector } from "react-redux";
|
|
4
|
+
import { currentLocaleOrDefault } from "../selectors/locale";
|
|
5
|
+
import { registerLocale, setDefaultLocale } from "react-datepicker";
|
|
6
|
+
import * as date_fns_locale from "date-fns/locale";
|
|
7
|
+
import { findCorrespondingLocale } from "../utils/localizationHelper";
|
|
8
|
+
|
|
9
|
+
const Culture = () => {
|
|
10
|
+
const locale = useSelector(currentLocaleOrDefault);
|
|
11
|
+
const language = navigator.language ?? locale;
|
|
12
|
+
|
|
13
|
+
useMemo(() => {
|
|
14
|
+
const fnsLocale = findCorrespondingLocale(date_fns_locale, language);
|
|
15
|
+
|
|
16
|
+
if (fnsLocale != null) {
|
|
17
|
+
registerLocale(language, fnsLocale);
|
|
18
|
+
setDefaultLocale(language);
|
|
19
|
+
}
|
|
20
|
+
}, [language]);
|
|
21
|
+
|
|
22
|
+
return <React.Fragment />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default Culture;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Immutable from "immutable";
|
|
3
|
+
import { Provider } from "react-redux";
|
|
4
|
+
import { getDefaultLocale } from "react-datepicker";
|
|
5
|
+
import Culture from "./Culture";
|
|
6
|
+
|
|
7
|
+
describe("Culture", () => {
|
|
8
|
+
let state, store, languageGetter;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
languageGetter = jest.spyOn(window.navigator, "language", "get");
|
|
12
|
+
|
|
13
|
+
state = Immutable.fromJS({
|
|
14
|
+
requests: {},
|
|
15
|
+
settings: {
|
|
16
|
+
defaultScope: "aDefaultScope",
|
|
17
|
+
},
|
|
18
|
+
locale: {
|
|
19
|
+
supportedLocales: [
|
|
20
|
+
{ language: "English", cultureIso: "en" },
|
|
21
|
+
{ language: "Français", cultureIso: "fr" },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
store = {
|
|
26
|
+
subscribe: () => {},
|
|
27
|
+
getState: () => state,
|
|
28
|
+
dispatch: () => {},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
languageGetter.mockReset();
|
|
34
|
+
jest.clearAllMocks();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("shows the wrapped component if authenticated and default scope is known", () => {
|
|
38
|
+
languageGetter.mockReturnValue(null);
|
|
39
|
+
|
|
40
|
+
const component = (
|
|
41
|
+
<Provider store={store}>
|
|
42
|
+
<Culture />
|
|
43
|
+
</Provider>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(component, "when mounted", "to satisfy", null);
|
|
47
|
+
|
|
48
|
+
expect(getDefaultLocale(), "to be", undefined); // Default behavior for react-datepicker
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("shows the wrapped component if authenticated and default scope is known 222", () => {
|
|
52
|
+
state = state.setIn(["locale", "supportedLocales"], [{ language: "English", cultureIso: "en" }]);
|
|
53
|
+
languageGetter.mockReturnValue("en-GB");
|
|
54
|
+
|
|
55
|
+
const component = (
|
|
56
|
+
<Provider store={store}>
|
|
57
|
+
<Culture />
|
|
58
|
+
</Provider>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(component, "when mounted", "to satisfy", null);
|
|
62
|
+
|
|
63
|
+
expect(getDefaultLocale(), "to equal", "en-GB");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("shows the wrapped component if authenticated and default scope is known 333", () => {
|
|
67
|
+
state = state.setIn(
|
|
68
|
+
["locale", "supportedLocales"],
|
|
69
|
+
[
|
|
70
|
+
{ language: "French", cultureIso: "fr" },
|
|
71
|
+
{ language: "EnglishMy", cultureIso: "enMy" },
|
|
72
|
+
],
|
|
73
|
+
);
|
|
74
|
+
languageGetter.mockReturnValue("fr-FR");
|
|
75
|
+
|
|
76
|
+
const component = (
|
|
77
|
+
<Provider store={store}>
|
|
78
|
+
<Culture />
|
|
79
|
+
</Provider>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
expect(component, "when mounted", "to satisfy", null);
|
|
83
|
+
|
|
84
|
+
expect(getDefaultLocale(), "to equal", "fr-FR");
|
|
85
|
+
});
|
|
86
|
+
});
|
package/src/components/I18n.js
CHANGED
|
@@ -6,10 +6,12 @@ import { currentLocaleOrDefault } from "../selectors/locale";
|
|
|
6
6
|
const I18n = props => {
|
|
7
7
|
const locale = useSelector(currentLocaleOrDefault);
|
|
8
8
|
const messages = require("translations/" + locale + ".json");
|
|
9
|
+
const language = navigator.language ?? locale;
|
|
10
|
+
|
|
9
11
|
return (
|
|
10
12
|
<IntlProvider
|
|
11
|
-
key={
|
|
12
|
-
locale={
|
|
13
|
+
key={language} // TODO: Remove this when react-intl suports new React context API
|
|
14
|
+
locale={language}
|
|
13
15
|
messages={messages}
|
|
14
16
|
{...props}
|
|
15
17
|
/>
|
|
@@ -9,10 +9,13 @@ import I18n from "./I18n";
|
|
|
9
9
|
jest.mock("translations/en-US.json", () => ({
|
|
10
10
|
WORD: "Word",
|
|
11
11
|
}));
|
|
12
|
+
jest.mock("translations/fr-CA.json", () => ({
|
|
13
|
+
WORD: "Mots",
|
|
14
|
+
}));
|
|
12
15
|
|
|
13
16
|
describe("I18n", () => {
|
|
14
17
|
spyOnConsole();
|
|
15
|
-
let store, state;
|
|
18
|
+
let store, state, languageGetter;
|
|
16
19
|
beforeEach(() => {
|
|
17
20
|
state = Immutable.fromJS({
|
|
18
21
|
locale: {
|
|
@@ -25,9 +28,16 @@ describe("I18n", () => {
|
|
|
25
28
|
dispatch: () => {},
|
|
26
29
|
getState: () => state,
|
|
27
30
|
};
|
|
31
|
+
|
|
32
|
+
languageGetter = jest.spyOn(window.navigator, "language", "get");
|
|
28
33
|
});
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
languageGetter.mockReset();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("renders a react-intl IntlProvider with locale data provided", () => {
|
|
40
|
+
languageGetter.mockReturnValue(null);
|
|
31
41
|
expect(
|
|
32
42
|
<Provider store={store}>
|
|
33
43
|
<MemoryRouter>
|
|
@@ -39,5 +49,24 @@ describe("I18n", () => {
|
|
|
39
49
|
"when mounted",
|
|
40
50
|
"to satisfy",
|
|
41
51
|
"Word",
|
|
42
|
-
).then(() => expect(console.error, "was not called"))
|
|
52
|
+
).then(() => expect(console.error, "was not called"));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("renders a react-intl IntlProvider with navigator language provided", () => {
|
|
56
|
+
languageGetter.mockReturnValue("fr-CA");
|
|
57
|
+
state = state.setIn(["locale", "locale"], "fr-CA");
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
<Provider store={store}>
|
|
61
|
+
<MemoryRouter>
|
|
62
|
+
<I18n>
|
|
63
|
+
<FormattedMessage id="WORD" defaultMessage="Failure" />
|
|
64
|
+
</I18n>
|
|
65
|
+
</MemoryRouter>
|
|
66
|
+
</Provider>,
|
|
67
|
+
"when mounted",
|
|
68
|
+
"to satisfy",
|
|
69
|
+
"Mots",
|
|
70
|
+
).then(() => expect(console.error, "was not called"));
|
|
71
|
+
});
|
|
43
72
|
});
|
|
@@ -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
|
|
144
|
+
it("Translations component handles change", () => {
|
|
139
145
|
const aValue = "aValue";
|
|
140
146
|
const update = sinon.spy().named("update");
|
|
141
147
|
|
|
@@ -179,7 +179,7 @@ describe("SelectionList", () => {
|
|
|
179
179
|
let item = mountedComponent.find(ListItem).at(0);
|
|
180
180
|
item.invoke("onClick")();
|
|
181
181
|
|
|
182
|
-
expect(onChange.args[2][0], "to equal", {
|
|
182
|
+
expect(onChange.args[2][0], "to equal", { selectedItems: [list[0]] });
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
it("Calls onChange with defaultSelection", () => {
|
|
@@ -196,7 +196,7 @@ describe("SelectionList", () => {
|
|
|
196
196
|
|
|
197
197
|
mount(component);
|
|
198
198
|
|
|
199
|
-
expect(onChange.args[1][0], "to equal", {
|
|
199
|
+
expect(onChange.args[1][0], "to equal", { selectedItems: [data[1]] });
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
it("handle scrolling event", () => {
|