orc-shared 5.8.0-dev.17 → 5.8.0-dev.18
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/dist/components/MaterialUI/DataDisplay/Badge.js +1 -1
- package/dist/components/Routing/SegmentPage.js +1 -1
- package/dist/utils/normalizeForSearch.js +4 -1
- package/dist/utils/propertyBagHelper.js +3 -3
- package/dist/utils/propertyHelper.js +6 -6
- package/dist/utils/testUtils.js +3 -0
- package/package.json +2 -2
- package/src/components/AppFrame/ConnectedToastList.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/Badge.js +1 -1
- package/src/components/Modal/Modal.test.js +3 -1
- package/src/components/Modal/Wrapper.test.js +3 -1
- package/src/components/Routing/SegmentPage.js +1 -1
- package/src/components/Scope/Scope.test.js +3 -1
- package/src/components/Sidepanel.test.js +3 -1
- package/src/utils/normalizeForSearch.js +2 -0
- package/src/utils/propertyBagHelper.js +6 -3
- package/src/utils/propertyHelper.js +6 -6
- package/src/utils/testUtils.js +25 -22
|
@@ -39,7 +39,7 @@ var Badge = function Badge(_ref) {
|
|
|
39
39
|
badge = _ref.badge,
|
|
40
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
41
|
var classes = useStyles();
|
|
42
|
-
var classProp =
|
|
42
|
+
var classProp = (_props$classProp = props.classProp) != null && _props$classProp.badge ? props.classProp : classes;
|
|
43
43
|
return /*#__PURE__*/_react.default.createElement(_Badge.default, {
|
|
44
44
|
overlap: "circular",
|
|
45
45
|
color: "primary",
|
|
@@ -186,7 +186,7 @@ var SegmentPage = function SegmentPage(_ref4) {
|
|
|
186
186
|
modulePrependPath = _ref4.modulePrependPath,
|
|
187
187
|
entityIdResolver = _ref4.entityIdResolver;
|
|
188
188
|
var classes = useStyles({
|
|
189
|
-
isComponentNull:
|
|
189
|
+
isComponentNull: !View
|
|
190
190
|
});
|
|
191
191
|
var pattern = new _urlPattern.default(path);
|
|
192
192
|
var baseHref = pattern.stringify(match.params);
|
|
@@ -22,7 +22,10 @@ if ("".normalize) {
|
|
|
22
22
|
normalizeForSearch = function normalizeForSearch(str) {
|
|
23
23
|
return str.toLowerCase()
|
|
24
24
|
// Strip accents by normalizing to letters + combining chars, then strip all combining chars.
|
|
25
|
-
.normalize("NFKD")
|
|
25
|
+
.normalize("NFKD")
|
|
26
|
+
// Note AD20240801: the new eslint config complains on the next line however I have no idea what it is supposed to do so to be safe I'll disable the warning
|
|
27
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
28
|
+
.replace(/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/g, "");
|
|
26
29
|
};
|
|
27
30
|
} else {
|
|
28
31
|
// IE11 does not support string#normalize(). V. sad for IE users.
|
|
@@ -127,7 +127,7 @@ var getPropertyBagFormattedPrimitiveValue = exports.getPropertyBagFormattedPrimi
|
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
if (dataTypesChecker.isBoolean(propertyBagValue[_constants.serializationTypeKey])) {
|
|
130
|
-
return
|
|
130
|
+
return propertyBagValue.value ? formatMessage(_sharedMessages.default.valueTypeWrapperTrue) : formatMessage(_sharedMessages.default.valueTypeWrapperFalse);
|
|
131
131
|
}
|
|
132
132
|
if (dataTypesChecker.isInteger(propertyBagValue[_constants.serializationTypeKey])) {
|
|
133
133
|
return formatNumber(propertyBagValue.value, 0);
|
|
@@ -153,7 +153,7 @@ var formatNumber = exports.formatNumber = function formatNumber(value, precision
|
|
|
153
153
|
};
|
|
154
154
|
var fixPropertyBagModifiedModel = exports.fixPropertyBagModifiedModel = function fixPropertyBagModifiedModel(model) {
|
|
155
155
|
var fixProfileOperations = function fixProfileOperations(model) {
|
|
156
|
-
if (
|
|
156
|
+
if (Object.prototype.hasOwnProperty.call(model, "profileOperations")) {
|
|
157
157
|
var _model$profileOperati = model.profileOperations,
|
|
158
158
|
profilesToAdd = _model$profileOperati.profilesToAdd,
|
|
159
159
|
profilesToUpdate = _model$profileOperati.profilesToUpdate;
|
|
@@ -198,7 +198,7 @@ var fixPropertyBagEmptyValues = exports.fixPropertyBagEmptyValues = function fix
|
|
|
198
198
|
var modifiedFields = Object.keys(propertyBag);
|
|
199
199
|
modifiedFields.forEach(function (propertyName) {
|
|
200
200
|
var property = propertyBag[propertyName];
|
|
201
|
-
var propertyValue = property && (0, _propertyValidator.isObject)(property) &&
|
|
201
|
+
var propertyValue = property && (0, _propertyValidator.isObject)(property) && Object.prototype.hasOwnProperty.call(property, "value") ? property.value : property;
|
|
202
202
|
if (propertyValue === "") {
|
|
203
203
|
propertyBag[propertyName] = null;
|
|
204
204
|
}
|
|
@@ -48,11 +48,11 @@ function getPropertyOrDefault(obj, property, defaultValue, ignoreCase, startWith
|
|
|
48
48
|
return getPropertyOrDefaultFromMap(obj, property, defaultValue, ignoreCase, startWith);
|
|
49
49
|
}
|
|
50
50
|
if (ignoreCase === false && startWith === false) {
|
|
51
|
-
return
|
|
51
|
+
return Object.prototype.hasOwnProperty.call(obj, property) ? obj[property] : defaultValue;
|
|
52
52
|
}
|
|
53
53
|
var compareFunction = startWith ? caseInsensitiveStartWithCompare : caseInsensitiveCompare;
|
|
54
54
|
for (var prop in obj) {
|
|
55
|
-
if (
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && compareFunction(prop, property)) {
|
|
56
56
|
return obj[prop];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -60,11 +60,11 @@ function getPropertyOrDefault(obj, property, defaultValue, ignoreCase, startWith
|
|
|
60
60
|
}
|
|
61
61
|
var isObjectContainsPropertyWithValue = exports.isObjectContainsPropertyWithValue = function isObjectContainsPropertyWithValue(obj, propertyName, value) {
|
|
62
62
|
if (obj === null || obj === undefined) return false;
|
|
63
|
-
if (
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName] === value) {
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
for (var prop in obj) {
|
|
67
|
-
if (
|
|
67
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
68
68
|
if (isObjectContainsPropertyWithValue(obj[prop], propertyName, value)) return true;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -72,11 +72,11 @@ var isObjectContainsPropertyWithValue = exports.isObjectContainsPropertyWithValu
|
|
|
72
72
|
};
|
|
73
73
|
var isObjectContainsPropertyWithAnyValue = exports.isObjectContainsPropertyWithAnyValue = function isObjectContainsPropertyWithAnyValue(obj, propertyName) {
|
|
74
74
|
if (!obj) return false;
|
|
75
|
-
if (
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName]) {
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
for (var prop in obj) {
|
|
79
|
-
if (
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
80
80
|
if (isObjectContainsPropertyWithAnyValue(obj[prop], propertyName)) return true;
|
|
81
81
|
}
|
|
82
82
|
}
|
package/dist/utils/testUtils.js
CHANGED
|
@@ -43,6 +43,7 @@ var spyOnConsole = exports.spyOnConsole = function spyOnConsole(spyNames) {
|
|
|
43
43
|
spyNames = ["log", "warn", "error"];
|
|
44
44
|
}
|
|
45
45
|
var spiedFuncs;
|
|
46
|
+
// eslint-disable-next-line no-undef
|
|
46
47
|
beforeEach(function () {
|
|
47
48
|
spiedFuncs = spyNames.map(function (funcName) {
|
|
48
49
|
var func = sinon.spy().named("console." + funcName);
|
|
@@ -51,6 +52,7 @@ var spyOnConsole = exports.spyOnConsole = function spyOnConsole(spyNames) {
|
|
|
51
52
|
return oldFunc;
|
|
52
53
|
});
|
|
53
54
|
});
|
|
55
|
+
// eslint-disable-next-line no-undef
|
|
54
56
|
afterEach(function () {
|
|
55
57
|
spiedFuncs.forEach(function (func, index) {
|
|
56
58
|
var name = spyNames[index];
|
|
@@ -117,6 +119,7 @@ var PropStruct = exports.PropStruct = _react.default.forwardRef(function (props,
|
|
|
117
119
|
);
|
|
118
120
|
});
|
|
119
121
|
var ignoreConsoleError = exports.ignoreConsoleError = function ignoreConsoleError(func) {
|
|
122
|
+
// eslint-disable-next-line no-undef
|
|
120
123
|
jest.spyOn(console, "error");
|
|
121
124
|
console.error.mockImplementation(function () {});
|
|
122
125
|
func();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "5.8.0-dev.
|
|
3
|
+
"version": "5.8.0-dev.18",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@testing-library/react": "^10.4.9"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"orc-scripts": "^4.0.0-dev.
|
|
58
|
+
"orc-scripts": "^4.0.0-dev.10",
|
|
59
59
|
"react-number-format": "^5.3.0"
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
@@ -169,7 +169,9 @@ describe("ConnectedToastList", () => {
|
|
|
169
169
|
try {
|
|
170
170
|
ReactDOM.unmountComponentAtNode(appRoot);
|
|
171
171
|
ReactDOM.unmountComponentAtNode(document.getElementById("toast"));
|
|
172
|
-
} catch
|
|
172
|
+
} catch {
|
|
173
|
+
// don't do anything
|
|
174
|
+
}
|
|
173
175
|
document.body.removeChild(appRoot);
|
|
174
176
|
});
|
|
175
177
|
});
|
|
@@ -13,7 +13,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
13
13
|
|
|
14
14
|
const Badge = ({ children, badge, ...props }) => {
|
|
15
15
|
const classes = useStyles();
|
|
16
|
-
const classProp =
|
|
16
|
+
const classProp = props.classProp?.badge ? props.classProp : classes;
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<BadgeMui overlap="circular" color="primary" max={999} badgeContent={badge} classes={classProp}>
|
|
@@ -168,7 +168,7 @@ const SegmentPage = ({
|
|
|
168
168
|
modulePrependPath,
|
|
169
169
|
entityIdResolver,
|
|
170
170
|
}) => {
|
|
171
|
-
const classes = useStyles({ isComponentNull:
|
|
171
|
+
const classes = useStyles({ isComponentNull: !View });
|
|
172
172
|
const pattern = new UrlPattern(path);
|
|
173
173
|
const baseHref = pattern.stringify(match.params);
|
|
174
174
|
const pages = [],
|
|
@@ -121,7 +121,9 @@ beforeEach(() => {
|
|
|
121
121
|
afterEach(() => {
|
|
122
122
|
try {
|
|
123
123
|
ReactDOM.unmountComponentAtNode(appRoot);
|
|
124
|
-
} catch
|
|
124
|
+
} catch {
|
|
125
|
+
// don't do anything
|
|
126
|
+
}
|
|
125
127
|
document.body.removeChild(appRoot);
|
|
126
128
|
document.body.removeChild(modalRoot);
|
|
127
129
|
});
|
|
@@ -6,6 +6,8 @@ if ("".normalize) {
|
|
|
6
6
|
.toLowerCase()
|
|
7
7
|
// Strip accents by normalizing to letters + combining chars, then strip all combining chars.
|
|
8
8
|
.normalize("NFKD")
|
|
9
|
+
// Note AD20240801: the new eslint config complains on the next line however I have no idea what it is supposed to do so to be safe I'll disable the warning
|
|
10
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
9
11
|
.replace(/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/g, "");
|
|
10
12
|
} else {
|
|
11
13
|
// IE11 does not support string#normalize(). V. sad for IE users.
|
|
@@ -149,7 +149,7 @@ export const getPropertyBagFormattedPrimitiveValue = (propertyBagValue, formatMe
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (dataTypesChecker.isBoolean(propertyBagValue[serializationTypeKey])) {
|
|
152
|
-
return
|
|
152
|
+
return propertyBagValue.value
|
|
153
153
|
? formatMessage(sharedMessages.valueTypeWrapperTrue)
|
|
154
154
|
: formatMessage(sharedMessages.valueTypeWrapperFalse);
|
|
155
155
|
}
|
|
@@ -182,7 +182,7 @@ export const formatNumber = (value, precision) => Number(value).toFixed(precisio
|
|
|
182
182
|
|
|
183
183
|
export const fixPropertyBagModifiedModel = (model, ...fields) => {
|
|
184
184
|
const fixProfileOperations = model => {
|
|
185
|
-
if (
|
|
185
|
+
if (Object.prototype.hasOwnProperty.call(model, "profileOperations")) {
|
|
186
186
|
let { profilesToAdd, profilesToUpdate } = model.profileOperations;
|
|
187
187
|
if (profilesToAdd) {
|
|
188
188
|
const items = Array.isArray(profilesToAdd) ? profilesToAdd : Object.values(profilesToAdd);
|
|
@@ -224,7 +224,10 @@ export const fixPropertyBagEmptyValues = propertyBag => {
|
|
|
224
224
|
const modifiedFields = Object.keys(propertyBag);
|
|
225
225
|
modifiedFields.forEach(propertyName => {
|
|
226
226
|
let property = propertyBag[propertyName];
|
|
227
|
-
let propertyValue =
|
|
227
|
+
let propertyValue =
|
|
228
|
+
property && isObject(property) && Object.prototype.hasOwnProperty.call(property, "value")
|
|
229
|
+
? property.value
|
|
230
|
+
: property;
|
|
228
231
|
if (propertyValue === "") {
|
|
229
232
|
propertyBag[propertyName] = null;
|
|
230
233
|
}
|
|
@@ -22,13 +22,13 @@ export function getPropertyOrDefault(obj, property, defaultValue, ignoreCase = f
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (ignoreCase === false && startWith === false) {
|
|
25
|
-
return
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(obj, property) ? obj[property] : defaultValue;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const compareFunction = startWith ? caseInsensitiveStartWithCompare : caseInsensitiveCompare;
|
|
29
29
|
|
|
30
30
|
for (let prop in obj) {
|
|
31
|
-
if (
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && compareFunction(prop, property)) {
|
|
32
32
|
return obj[prop];
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -39,12 +39,12 @@ export function getPropertyOrDefault(obj, property, defaultValue, ignoreCase = f
|
|
|
39
39
|
export const isObjectContainsPropertyWithValue = (obj, propertyName, value) => {
|
|
40
40
|
if (obj === null || obj === undefined) return false;
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName] === value) {
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
for (let prop in obj) {
|
|
47
|
-
if (
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
48
48
|
if (isObjectContainsPropertyWithValue(obj[prop], propertyName, value)) return true;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -55,12 +55,12 @@ export const isObjectContainsPropertyWithValue = (obj, propertyName, value) => {
|
|
|
55
55
|
export const isObjectContainsPropertyWithAnyValue = (obj, propertyName) => {
|
|
56
56
|
if (!obj) return false;
|
|
57
57
|
|
|
58
|
-
if (
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName]) {
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
for (let prop in obj) {
|
|
63
|
-
if (
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
64
64
|
if (isObjectContainsPropertyWithAnyValue(obj[prop], propertyName)) return true;
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/utils/testUtils.js
CHANGED
|
@@ -15,6 +15,7 @@ const sinon = require("sinon");
|
|
|
15
15
|
/* istanbul ignore next */
|
|
16
16
|
export const spyOnConsole = (spyNames = ["log", "warn", "error"]) => {
|
|
17
17
|
let spiedFuncs;
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
18
19
|
beforeEach(() => {
|
|
19
20
|
spiedFuncs = spyNames.map(funcName => {
|
|
20
21
|
const func = sinon.spy().named("console." + funcName);
|
|
@@ -23,6 +24,7 @@ export const spyOnConsole = (spyNames = ["log", "warn", "error"]) => {
|
|
|
23
24
|
return oldFunc;
|
|
24
25
|
});
|
|
25
26
|
});
|
|
27
|
+
// eslint-disable-next-line no-undef
|
|
26
28
|
afterEach(() => {
|
|
27
29
|
spiedFuncs.forEach((func, index) => {
|
|
28
30
|
const name = spyNames[index];
|
|
@@ -74,34 +76,35 @@ export const PropStruct = React.forwardRef((props, ref) => (
|
|
|
74
76
|
value === undefined || value === null
|
|
75
77
|
? null
|
|
76
78
|
: value === "__ignore"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
? [<Ignore key={"dt-" + key} />, <Ignore key={"dd-" + key} />]
|
|
80
|
+
: [
|
|
81
|
+
<dt key={"dt-" + key}>{`${key}:`}</dt>,
|
|
82
|
+
<dd key={"dd-" + key}>
|
|
83
|
+
{key === "children" ? (
|
|
84
|
+
value
|
|
85
|
+
) : typeof value === "object" ? (
|
|
86
|
+
value["$$typeof"] && value["$$typeof"] === Symbol.for("react.element") ? (
|
|
87
|
+
"React <" + (value.type.name || value.type) + ">"
|
|
88
|
+
) : (
|
|
89
|
+
<PropStruct {...value} />
|
|
90
|
+
)
|
|
91
|
+
) : typeof value === "function" ? (
|
|
92
|
+
"Function"
|
|
93
|
+
) : typeof value === "string" ? (
|
|
94
|
+
`string "${value}"`
|
|
95
|
+
) : typeof value === "symbol" ? (
|
|
96
|
+
`symbol ${value.toString()}`
|
|
86
97
|
) : (
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) : typeof value === "string" ? (
|
|
92
|
-
`string "${value}"`
|
|
93
|
-
) : typeof value === "symbol" ? (
|
|
94
|
-
`symbol ${value.toString()}`
|
|
95
|
-
) : (
|
|
96
|
-
typeof value + " " + value
|
|
97
|
-
)}
|
|
98
|
-
</dd>,
|
|
99
|
-
],
|
|
98
|
+
typeof value + " " + value
|
|
99
|
+
)}
|
|
100
|
+
</dd>,
|
|
101
|
+
],
|
|
100
102
|
)}
|
|
101
103
|
</dl>
|
|
102
104
|
));
|
|
103
105
|
|
|
104
106
|
export const ignoreConsoleError = func => {
|
|
107
|
+
// eslint-disable-next-line no-undef
|
|
105
108
|
jest.spyOn(console, "error");
|
|
106
109
|
console.error.mockImplementation(() => {});
|
|
107
110
|
|