@reltio/components 1.4.2211 → 1.4.2213

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 (51) hide show
  1. package/AttributesErrorsPanel/AttributesErrorsPanel.d.ts +2 -1
  2. package/AttributesErrorsPanel/AttributesErrorsPanel.js +5 -5
  3. package/AttributesErrorsPanel/components/Error/AttributeErrorItem.d.ts +8 -0
  4. package/AttributesErrorsPanel/components/Error/{Error.js → AttributeErrorItem.js} +4 -4
  5. package/AttributesErrorsPanel/components/Error/{Error.test.js → AttributeErrorItem.test.js} +3 -3
  6. package/AttributesErrorsPanel/components/Error/index.d.ts +1 -1
  7. package/AttributesErrorsPanel/components/Error/index.js +1 -1
  8. package/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.d.ts +2 -1
  9. package/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.js +3 -2
  10. package/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +30 -11
  11. package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.js +10 -2
  12. package/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +9 -2
  13. package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.d.ts +2 -1
  14. package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.js +4 -4
  15. package/cjs/AttributesErrorsPanel/components/Error/AttributeErrorItem.d.ts +8 -0
  16. package/cjs/AttributesErrorsPanel/components/Error/{Error.js → AttributeErrorItem.js} +5 -5
  17. package/cjs/AttributesErrorsPanel/components/Error/{Error.test.js → AttributeErrorItem.test.js} +3 -3
  18. package/cjs/AttributesErrorsPanel/components/Error/index.d.ts +1 -1
  19. package/cjs/AttributesErrorsPanel/components/Error/index.js +3 -3
  20. package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.d.ts +2 -1
  21. package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.js +3 -2
  22. package/cjs/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +30 -11
  23. package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.js +9 -1
  24. package/cjs/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +9 -2
  25. package/cjs/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.js +1 -1
  26. package/cjs/features/workflow/helpers/attributes.test.js +22 -18
  27. package/cjs/features/workflow/helpers/merge.test.js +26 -20
  28. package/cjs/features/workflow/helpers/metadata.test-data.d.ts +1 -1
  29. package/cjs/features/workflow/helpers/metadata.test-data.js +149 -3
  30. package/cjs/features/workflow/helpers/validation.js +0 -1
  31. package/cjs/features/workflow/helpers/validation.test-data.d.ts +14 -0
  32. package/cjs/features/workflow/helpers/validation.test-data.js +508 -0
  33. package/cjs/features/workflow/helpers/validation.test.d.ts +1 -0
  34. package/cjs/features/workflow/helpers/validation.test.js +257 -0
  35. package/cjs/features/workflow/hooks/useDCRValidation.js +1 -1
  36. package/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.js +1 -1
  37. package/features/workflow/helpers/attributes.test.js +5 -1
  38. package/features/workflow/helpers/merge.test.js +7 -1
  39. package/features/workflow/helpers/metadata.test-data.d.ts +1 -1
  40. package/features/workflow/helpers/metadata.test-data.js +147 -2
  41. package/features/workflow/helpers/validation.js +0 -1
  42. package/features/workflow/helpers/validation.test-data.d.ts +14 -0
  43. package/features/workflow/helpers/validation.test-data.js +498 -0
  44. package/features/workflow/helpers/validation.test.d.ts +1 -0
  45. package/features/workflow/helpers/validation.test.js +255 -0
  46. package/features/workflow/hooks/useDCRValidation.js +1 -1
  47. package/package.json +2 -2
  48. package/AttributesErrorsPanel/components/Error/Error.d.ts +0 -7
  49. package/cjs/AttributesErrorsPanel/components/Error/Error.d.ts +0 -7
  50. /package/AttributesErrorsPanel/components/Error/{Error.test.d.ts → AttributeErrorItem.test.d.ts} +0 -0
  51. /package/cjs/AttributesErrorsPanel/components/Error/{Error.test.d.ts → AttributeErrorItem.test.d.ts} +0 -0
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { AttributeError } from '@reltio/mdm-sdk';
3
3
  type Props = {
4
4
  attributesWithErrors?: AttributeError[];
5
+ alwaysShowLink?: boolean;
5
6
  };
6
- export declare const AttributesErrorsPanel: ({ attributesWithErrors }: Props) => React.JSX.Element;
7
+ export declare const AttributesErrorsPanel: ({ attributesWithErrors, alwaysShowLink }: Props) => React.JSX.Element;
7
8
  export {};
@@ -6,14 +6,14 @@ import WarningIcon from '@mui/icons-material/Error';
6
6
  import { splitErrorsBySeverity } from '@reltio/mdm-sdk';
7
7
  import { useCachedErrors } from './useCachedErrors';
8
8
  import { ErrorsPanel } from './components/ErrorsPanel';
9
- import { Error } from './components/Error';
9
+ import { AttributeErrorItem } from './components/Error';
10
10
  import { useStyles } from './styles';
11
11
  export var AttributesErrorsPanel = function (_a) {
12
- var _b = _a.attributesWithErrors, attributesWithErrors = _b === void 0 ? [] : _b;
12
+ var _b = _a.attributesWithErrors, attributesWithErrors = _b === void 0 ? [] : _b, _c = _a.alwaysShowLink, alwaysShowLink = _c === void 0 ? false : _c;
13
13
  var styles = useStyles();
14
14
  var cachedErrors = useCachedErrors(attributesWithErrors);
15
- var _c = useMemo(function () { return splitErrorsBySeverity(cachedErrors); }, [cachedErrors]), errors = _c[0], warnings = _c[1];
16
- var _d = useState(null), expandedPanelId = _d[0], setExpandedPanelId = _d[1];
15
+ var _d = useMemo(function () { return splitErrorsBySeverity(cachedErrors); }, [cachedErrors]), errors = _d[0], warnings = _d[1];
16
+ var _e = useState(null), expandedPanelId = _e[0], setExpandedPanelId = _e[1];
17
17
  var panels = useMemo(function () {
18
18
  return [
19
19
  {
@@ -49,5 +49,5 @@ export var AttributesErrorsPanel = function (_a) {
49
49
  var handleChange = useCallback(function (panelId) { return function (event, isExpanded) {
50
50
  setExpandedPanelId(isExpanded ? panelId : null);
51
51
  }; }, []);
52
- return panels.length > 0 ? (React.createElement(ErrorsPanel, { panels: panels, expandedPanelId: expandedPanelId, onToggle: handleChange, ErrorComponent: Error })) : null;
52
+ return panels.length > 0 ? (React.createElement(ErrorsPanel, { panels: panels, expandedPanelId: expandedPanelId, onToggle: handleChange, ErrorComponent: AttributeErrorItem, alwaysShowLink: alwaysShowLink })) : null;
53
53
  };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AttributeError } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ error: AttributeError;
5
+ alwaysShowLink?: boolean;
6
+ };
7
+ export declare const AttributeErrorItem: React.MemoExoticComponent<({ error, alwaysShowLink }: Props) => React.JSX.Element>;
8
+ export {};
@@ -9,8 +9,8 @@ import { useMdmIsEditableMode, useMdmMetadata } from '../../../contexts/MdmModul
9
9
  import { getDisplayedAttributeTypesPath, getDisplayedErrorMessage, getDisplayedErrorPath } from './helpers';
10
10
  import { ReadOnlyError } from '../../../icons';
11
11
  import { useStyles } from './styles';
12
- export var Error = memo(function (_a) {
13
- var error = _a.error;
12
+ export var AttributeErrorItem = memo(function (_a) {
13
+ var error = _a.error, _b = _a.alwaysShowLink, alwaysShowLink = _b === void 0 ? false : _b;
14
14
  var styles = useStyles();
15
15
  var metadata = useMdmMetadata();
16
16
  var isEditableMode = useMdmIsEditableMode();
@@ -18,7 +18,7 @@ export var Error = memo(function (_a) {
18
18
  var displayedErrorPath = getDisplayedErrorPath(error);
19
19
  var displayedAttributeTypesPath = getDisplayedAttributeTypesPath(error);
20
20
  var highlightError = useContext(ScrollToElementContext).highlightError;
21
- var showLink = (error.uri || (error.parentUri && error.attributeTypeUri)) && (isEditableMode || error.alwaysShow);
21
+ var showLink = (error.uri || (error.parentUri && error.attributeTypeUri)) && (isEditableMode || alwaysShowLink);
22
22
  return (React.createElement("div", { className: styles.errorListItem },
23
23
  React.createElement("div", { className: styles.listItemMarker }, error.type === ErrorType.rdmIssueInReference ? (React.createElement(Tooltip, { title: i18n.text('This error is visible only in view mode') },
24
24
  React.createElement("span", null,
@@ -30,4 +30,4 @@ export var Error = memo(function (_a) {
30
30
  showLink && (React.createElement(SmallIconButtonWithTooltip, { icon: HyperlinkIcon, size: "XXS", onClick: function () { return highlightError(error); }, tooltipTitle: i18n.text('Go to error'), className: styles.goToIcon }))),
31
31
  displayedErrorPath && React.createElement("span", { className: styles.parents }, displayedErrorPath))));
32
32
  });
33
- Error.displayName = 'Error';
33
+ AttributeErrorItem.displayName = 'AttributeErrorItem';
@@ -48,12 +48,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import React from 'react';
49
49
  import { render, screen } from '@testing-library/react';
50
50
  import { AttributeValuePathItemType, ErrorSeverity, ErrorSource, ErrorType, Mode } from '@reltio/mdm-sdk';
51
- import { Error } from '../Error';
51
+ import { AttributeErrorItem } from './AttributeErrorItem';
52
52
  import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
53
53
  import userEvent from '@testing-library/user-event';
54
54
  import { store as initStore } from '../../store.test-data';
55
55
  import { ScrollToElementContext } from '../../../contexts/ScrollToElementContext';
56
- describe('Error tests', function () {
56
+ describe('AttributeErrorItem tests', function () {
57
57
  var attributeType = initStore.metadata.entityTypes[0].attributes[0];
58
58
  var setUp = function (props, store) {
59
59
  if (store === void 0) { store = initStore; }
@@ -64,7 +64,7 @@ describe('Error tests', function () {
64
64
  React.createElement(ScrollToElementContext.Provider, { value: { highlightError: highlightError, element: null, type: null, scrollIntoRef: null } }, children)));
65
65
  };
66
66
  var user = userEvent.setup();
67
- return __assign({ user: user, highlightError: highlightError }, render(React.createElement(Error, __assign({}, props)), { wrapper: Providers }));
67
+ return __assign({ user: user, highlightError: highlightError }, render(React.createElement(AttributeErrorItem, __assign({}, props)), { wrapper: Providers }));
68
68
  };
69
69
  it('should render error message for validation service errors', function () {
70
70
  var error = {
@@ -1 +1 @@
1
- export { Error } from './Error';
1
+ export { AttributeErrorItem } from './AttributeErrorItem';
@@ -1 +1 @@
1
- export { Error } from './Error';
1
+ export { AttributeErrorItem } from './AttributeErrorItem';
@@ -12,6 +12,7 @@ type Props = {
12
12
  expandedPanelId: string;
13
13
  onToggle: (id: string) => (e: any, isExpanded: boolean) => void;
14
14
  ErrorComponent: ElementType;
15
+ alwaysShowLink?: boolean;
15
16
  };
16
- export declare const ErrorsPanel: React.MemoExoticComponent<({ panels, expandedPanelId, onToggle, ErrorComponent }: Props) => React.JSX.Element>;
17
+ export declare const ErrorsPanel: React.MemoExoticComponent<({ panels, expandedPanelId, onToggle, ErrorComponent, alwaysShowLink }: Props) => React.JSX.Element>;
17
18
  export {};
@@ -7,7 +7,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
7
7
  import Typography from '@mui/material/Typography';
8
8
  import { useStyles } from './styles';
9
9
  export var ErrorsPanel = memo(function (_a) {
10
- var panels = _a.panels, expandedPanelId = _a.expandedPanelId, onToggle = _a.onToggle, ErrorComponent = _a.ErrorComponent;
10
+ var panels = _a.panels, expandedPanelId = _a.expandedPanelId, onToggle = _a.onToggle, ErrorComponent = _a.ErrorComponent, _b = _a.alwaysShowLink, alwaysShowLink = _b === void 0 ? false : _b;
11
11
  var styles = useStyles();
12
12
  return panels.length > 0 ? (React.createElement("div", null, panels.map(function (_a) {
13
13
  var id = _a.id, icon = _a.icon, title = _a.title, items = _a.items, accordionClassName = _a.accordionClassName, accordionDetailsClassName = _a.accordionDetailsClassName;
@@ -19,7 +19,8 @@ export var ErrorsPanel = memo(function (_a) {
19
19
  }, expandIcon: React.createElement(ExpandMoreIcon, null) },
20
20
  icon,
21
21
  React.createElement(Typography, { className: styles.accordionSummaryHeading }, title)),
22
- React.createElement(AccordionDetails, { className: classnames(styles.accordionDetails, accordionDetailsClassName) }, items.map(function (error, i) { return (React.createElement(ErrorComponent, { key: i, error: error })); }))));
22
+ React.createElement(AccordionDetails, { className: classnames(styles.accordionDetails, accordionDetailsClassName) }, items.map(function (error, i) { return (React.createElement(ErrorComponent, { key: i, error: error, alwaysShowLink: alwaysShowLink }) //NOSONAR
23
+ ); }))));
23
24
  }))) : null;
24
25
  });
25
26
  ErrorsPanel.displayName = 'ErrorsPanel';
@@ -69,7 +69,8 @@ describe('ReadOnlyAttributesPager tests', function () {
69
69
  type: 'String',
70
70
  name: 'Simple',
71
71
  label: 'Simple label',
72
- description: 'Simple description'
72
+ description: 'Simple description',
73
+ masking: { regexPattern: '.*' }
73
74
  };
74
75
  var values = [
75
76
  { type: attributeType.uri, uri: 'entities/sIeHttl/attributes/Simple/u123', value: '123', ov: true },
@@ -86,8 +87,14 @@ describe('ReadOnlyAttributesPager tests', function () {
86
87
  afterEach(function () {
87
88
  jest.clearAllMocks();
88
89
  });
90
+ var defaultMdmValues = {
91
+ metadata: {
92
+ entityTypes: [{ uri: 'configuration/entityTypes/HCP', attributes: [attributeType] }]
93
+ },
94
+ showMasking: true
95
+ };
89
96
  var setUp = function (_a) {
90
- var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? {} : _d, _e = _b.featuresContextValue, featuresContextValue = _e === void 0 ? { showDescription: true } : _e;
97
+ var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.featuresContextValue, featuresContextValue = _e === void 0 ? { showDescription: true } : _e;
91
98
  var user = userEvent.setup();
92
99
  var Providers = function (_a) {
93
100
  var children = _a.children;
@@ -156,7 +163,11 @@ describe('ReadOnlyAttributesPager tests', function () {
156
163
  attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Simple',
157
164
  defaultMaxValues: 1,
158
165
  parentUri: 'entities/sIeHttl',
159
- values: ovValues
166
+ values: ovValues,
167
+ options: {
168
+ sendMasking: true,
169
+ ovOnly: true
170
+ }
160
171
  });
161
172
  labels = screen.getAllByTestId('reltio-attribute-complex-label');
162
173
  expect(labels).toHaveLength(2);
@@ -170,7 +181,11 @@ describe('ReadOnlyAttributesPager tests', function () {
170
181
  attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Simple',
171
182
  defaultMaxValues: 1,
172
183
  parentUri: 'entities/sIeHttl',
173
- values: ovValues
184
+ values: ovValues,
185
+ options: {
186
+ sendMasking: true,
187
+ ovOnly: true
188
+ }
174
189
  });
175
190
  labels = screen.getAllByTestId('reltio-attribute-complex-label');
176
191
  expect(labels).toHaveLength(3);
@@ -219,9 +234,10 @@ describe('ReadOnlyAttributesPager tests', function () {
219
234
  mdmValues: {
220
235
  metadata: {
221
236
  roles: [
222
- { uri: 'role1', label: 'Role1' },
223
- { uri: 'role2', label: 'Role2' }
224
- ]
237
+ { uri: 'role1', label: 'Role1', description: 'Role1 description' },
238
+ { uri: 'role2', label: 'Role2', description: 'Role2 description' }
239
+ ],
240
+ entityTypes: defaultMdmValues.metadata.entityTypes
225
241
  }
226
242
  }
227
243
  });
@@ -233,7 +249,10 @@ describe('ReadOnlyAttributesPager tests', function () {
233
249
  });
234
250
  it('should use SpecialRenderer for tags', function () {
235
251
  var props = __assign(__assign({}, defaultProps), { attributeType: EntityAttrTypes.tags, values: ['tag1', 'tag2'] });
236
- setUp({ props: props, mdmValues: { entity: {} } });
252
+ setUp({
253
+ props: props,
254
+ mdmValues: __assign(__assign({}, defaultMdmValues), { entity: { uri: 'entities/sIeHttl', type: 'configuration/entityTypes/HCP' } })
255
+ });
237
256
  expect(screen.queryByTestId('branch-decorator')).not.toBeInTheDocument();
238
257
  expect(screen.getByTestId('special-renderer')).toBeInTheDocument();
239
258
  expect(screen.getByText('Tags')).toBeInTheDocument();
@@ -279,7 +298,7 @@ describe('ReadOnlyAttributesPager tests', function () {
279
298
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
280
299
  ];
281
300
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false), max: 1 });
282
- setUp({ props: props, mdmValues: { maxValuesInResponse: 20 } });
301
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: 20 }) });
283
302
  expect(screen.getByTestId('show-more')).toBeInTheDocument();
284
303
  screen.getByText('Show 1 more of remaining 2 value');
285
304
  });
@@ -290,7 +309,7 @@ describe('ReadOnlyAttributesPager tests', function () {
290
309
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
291
310
  ];
292
311
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false) });
293
- setUp({ props: props, mdmValues: { maxValuesInResponse: 1 } });
312
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: 1 }) });
294
313
  expect(screen.getByTestId('show-more')).toBeInTheDocument();
295
314
  screen.getByText('Show 1 more of remaining 2 value');
296
315
  });
@@ -301,7 +320,7 @@ describe('ReadOnlyAttributesPager tests', function () {
301
320
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
302
321
  ];
303
322
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false) });
304
- setUp({ props: props, mdmValues: { maxValuesInResponse: undefined } });
323
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: undefined }) });
305
324
  expect(screen.queryByTestId('show-more')).not.toBeInTheDocument();
306
325
  });
307
326
  });
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo, useState } from 'react';
2
2
  import { min } from 'ramda';
3
3
  import classnames from 'classnames';
4
+ import { checkHasMasking } from '@reltio/mdm-sdk';
4
5
  import { ReadOnlyAttribute } from '../../../ReadOnlyAttributesFactory';
5
6
  import { AttributeTitle } from '../../../AttributeTitle';
6
7
  import { ShowMore } from '../../../ShowMore';
@@ -8,7 +9,7 @@ import { ShowLess } from '../../../ShowLess';
8
9
  import { OvIcon } from '../../../OvIcon';
9
10
  import { DescriptionIcon } from '../../../DescriptionIcon';
10
11
  import { ControlAttributeIcon } from '../../../ControlAttributeIcon';
11
- import { useMdmControlAttributes } from '../../../contexts/MdmModuleContext';
12
+ import { useMdmControlAttributes, useMdmMetadata, useMdmShowMasking } from '../../../contexts/MdmModuleContext';
12
13
  import { useMultiLineStyles } from '../../styles';
13
14
  export var MultiLineRenderer = function (_a) {
14
15
  var max = _a.max, values = _a.values, nonVisibleValues = _a.nonVisibleValues, totalVisibleValues = _a.totalVisibleValues, attributeType = _a.attributeType, parentUri = _a.parentUri, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues, showNonOv = _a.showNonOv, totalNonVisibleValues = _a.totalNonVisibleValues, classes = _a.classes;
@@ -20,6 +21,9 @@ export var MultiLineRenderer = function (_a) {
20
21
  var showMore = hasPaging && visibleValuesCount < totalVisibleValues;
21
22
  var showLess = hasPaging && visibleValuesCount >= totalVisibleValues;
22
23
  var label = attributeType.label, description = attributeType.description;
24
+ var metadata = useMdmMetadata();
25
+ var hasMasking = useMemo(function () { return checkHasMasking(metadata, attributeType); }, [metadata, attributeType]);
26
+ var showMasking = useMdmShowMasking();
23
27
  var onShowMore = function () {
24
28
  if (values.length < totalVisibleValues) {
25
29
  requestNextPageOfAttributeValues({
@@ -27,7 +31,11 @@ export var MultiLineRenderer = function (_a) {
27
31
  attributeTypeUri: attributeType.uri,
28
32
  attributeTypeName: attributeType.name,
29
33
  values: values,
30
- defaultMaxValues: max
34
+ defaultMaxValues: max,
35
+ options: {
36
+ sendMasking: showMasking && hasMasking,
37
+ ovOnly: !showNonOv
38
+ }
31
39
  });
32
40
  }
33
41
  setVisibleValuesCount(visibleValuesCount + max);
@@ -54,6 +54,7 @@ import { nestedAttributeType } from './nestedAttrType.test-data';
54
54
  import { nestedAttributeValue } from './nestedAttrValue.test-data';
55
55
  import { HighlightedValuesContext } from '../contexts/HighlightedValuesContext';
56
56
  import { CollaborationContext } from '../contexts/CollaborationContext';
57
+ import { MdmModuleProvider } from '../contexts/MdmModuleContext';
57
58
  var collaboration = { commentsMap: {} };
58
59
  var defaultHighlightedValues = {
59
60
  highlightedValuesUris: [],
@@ -65,13 +66,19 @@ var defaultProps = {
65
66
  attributeValue: nestedAttributeValue,
66
67
  attributeTypesList: nestedAttributeType.attributes
67
68
  };
69
+ var defaultMdmValues = {
70
+ metadata: {
71
+ entityTypes: [{ uri: 'configuration/entityTypes/HCP', attributes: [nestedAttributeType] }]
72
+ }
73
+ };
68
74
  var setUp = function (_a) {
69
75
  var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.highlightedValues, highlightedValues = _d === void 0 ? defaultHighlightedValues : _d;
70
76
  var user = userEvent.setup();
71
77
  var Providers = function (_a) {
72
78
  var children = _a.children;
73
- return (React.createElement(HighlightedValuesContext.Provider, { value: highlightedValues },
74
- React.createElement(CollaborationContext.Provider, { value: collaboration }, children)));
79
+ return (React.createElement(MdmModuleProvider, { values: defaultMdmValues },
80
+ React.createElement(HighlightedValuesContext.Provider, { value: highlightedValues },
81
+ React.createElement(CollaborationContext.Provider, { value: collaboration }, children))));
75
82
  };
76
83
  return __assign(__assign({}, render(React.createElement(ReadOnlyComplexAttribute, __assign({}, props)), { wrapper: Providers })), { user: user });
77
84
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { AttributeError } from '@reltio/mdm-sdk';
3
3
  type Props = {
4
4
  attributesWithErrors?: AttributeError[];
5
+ alwaysShowLink?: boolean;
5
6
  };
6
- export declare const AttributesErrorsPanel: ({ attributesWithErrors }: Props) => React.JSX.Element;
7
+ export declare const AttributesErrorsPanel: ({ attributesWithErrors, alwaysShowLink }: Props) => React.JSX.Element;
7
8
  export {};
@@ -38,11 +38,11 @@ var ErrorsPanel_1 = require("./components/ErrorsPanel");
38
38
  var Error_2 = require("./components/Error");
39
39
  var styles_1 = require("./styles");
40
40
  var AttributesErrorsPanel = function (_a) {
41
- var _b = _a.attributesWithErrors, attributesWithErrors = _b === void 0 ? [] : _b;
41
+ var _b = _a.attributesWithErrors, attributesWithErrors = _b === void 0 ? [] : _b, _c = _a.alwaysShowLink, alwaysShowLink = _c === void 0 ? false : _c;
42
42
  var styles = (0, styles_1.useStyles)();
43
43
  var cachedErrors = (0, useCachedErrors_1.useCachedErrors)(attributesWithErrors);
44
- var _c = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.splitErrorsBySeverity)(cachedErrors); }, [cachedErrors]), errors = _c[0], warnings = _c[1];
45
- var _d = (0, react_1.useState)(null), expandedPanelId = _d[0], setExpandedPanelId = _d[1];
44
+ var _d = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.splitErrorsBySeverity)(cachedErrors); }, [cachedErrors]), errors = _d[0], warnings = _d[1];
45
+ var _e = (0, react_1.useState)(null), expandedPanelId = _e[0], setExpandedPanelId = _e[1];
46
46
  var panels = (0, react_1.useMemo)(function () {
47
47
  return [
48
48
  {
@@ -78,6 +78,6 @@ var AttributesErrorsPanel = function (_a) {
78
78
  var handleChange = (0, react_1.useCallback)(function (panelId) { return function (event, isExpanded) {
79
79
  setExpandedPanelId(isExpanded ? panelId : null);
80
80
  }; }, []);
81
- return panels.length > 0 ? (react_1.default.createElement(ErrorsPanel_1.ErrorsPanel, { panels: panels, expandedPanelId: expandedPanelId, onToggle: handleChange, ErrorComponent: Error_2.Error })) : null;
81
+ return panels.length > 0 ? (react_1.default.createElement(ErrorsPanel_1.ErrorsPanel, { panels: panels, expandedPanelId: expandedPanelId, onToggle: handleChange, ErrorComponent: Error_2.AttributeErrorItem, alwaysShowLink: alwaysShowLink })) : null;
82
82
  };
83
83
  exports.AttributesErrorsPanel = AttributesErrorsPanel;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AttributeError } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ error: AttributeError;
5
+ alwaysShowLink?: boolean;
6
+ };
7
+ export declare const AttributeErrorItem: React.MemoExoticComponent<({ error, alwaysShowLink }: Props) => React.JSX.Element>;
8
+ export {};
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Error = void 0;
29
+ exports.AttributeErrorItem = void 0;
30
30
  var react_1 = __importStar(require("react"));
31
31
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
32
32
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
@@ -38,8 +38,8 @@ var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
38
38
  var helpers_1 = require("./helpers");
39
39
  var icons_1 = require("../../../icons");
40
40
  var styles_1 = require("./styles");
41
- exports.Error = (0, react_1.memo)(function (_a) {
42
- var error = _a.error;
41
+ exports.AttributeErrorItem = (0, react_1.memo)(function (_a) {
42
+ var error = _a.error, _b = _a.alwaysShowLink, alwaysShowLink = _b === void 0 ? false : _b;
43
43
  var styles = (0, styles_1.useStyles)();
44
44
  var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
45
45
  var isEditableMode = (0, MdmModuleContext_1.useMdmIsEditableMode)();
@@ -47,7 +47,7 @@ exports.Error = (0, react_1.memo)(function (_a) {
47
47
  var displayedErrorPath = (0, helpers_1.getDisplayedErrorPath)(error);
48
48
  var displayedAttributeTypesPath = (0, helpers_1.getDisplayedAttributeTypesPath)(error);
49
49
  var highlightError = (0, react_1.useContext)(ScrollToElementContext_1.ScrollToElementContext).highlightError;
50
- var showLink = (error.uri || (error.parentUri && error.attributeTypeUri)) && (isEditableMode || error.alwaysShow);
50
+ var showLink = (error.uri || (error.parentUri && error.attributeTypeUri)) && (isEditableMode || alwaysShowLink);
51
51
  return (react_1.default.createElement("div", { className: styles.errorListItem },
52
52
  react_1.default.createElement("div", { className: styles.listItemMarker }, error.type === mdm_sdk_1.ErrorType.rdmIssueInReference ? (react_1.default.createElement(Tooltip_1.default, { title: ui_i18n_1.default.text('This error is visible only in view mode') },
53
53
  react_1.default.createElement("span", null,
@@ -59,4 +59,4 @@ exports.Error = (0, react_1.memo)(function (_a) {
59
59
  showLink && (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { icon: Hyperlink_1.default, size: "XXS", onClick: function () { return highlightError(error); }, tooltipTitle: ui_i18n_1.default.text('Go to error'), className: styles.goToIcon }))),
60
60
  displayedErrorPath && react_1.default.createElement("span", { className: styles.parents }, displayedErrorPath))));
61
61
  });
62
- exports.Error.displayName = 'Error';
62
+ exports.AttributeErrorItem.displayName = 'AttributeErrorItem';
@@ -53,12 +53,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var react_1 = __importDefault(require("react"));
54
54
  var react_2 = require("@testing-library/react");
55
55
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
56
- var Error_1 = require("../Error");
56
+ var AttributeErrorItem_1 = require("./AttributeErrorItem");
57
57
  var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
58
58
  var user_event_1 = __importDefault(require("@testing-library/user-event"));
59
59
  var store_test_data_1 = require("../../store.test-data");
60
60
  var ScrollToElementContext_1 = require("../../../contexts/ScrollToElementContext");
61
- describe('Error tests', function () {
61
+ describe('AttributeErrorItem tests', function () {
62
62
  var attributeType = store_test_data_1.store.metadata.entityTypes[0].attributes[0];
63
63
  var setUp = function (props, store) {
64
64
  if (store === void 0) { store = store_test_data_1.store; }
@@ -69,7 +69,7 @@ describe('Error tests', function () {
69
69
  react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: { highlightError: highlightError, element: null, type: null, scrollIntoRef: null } }, children)));
70
70
  };
71
71
  var user = user_event_1.default.setup();
72
- return __assign({ user: user, highlightError: highlightError }, (0, react_2.render)(react_1.default.createElement(Error_1.Error, __assign({}, props)), { wrapper: Providers }));
72
+ return __assign({ user: user, highlightError: highlightError }, (0, react_2.render)(react_1.default.createElement(AttributeErrorItem_1.AttributeErrorItem, __assign({}, props)), { wrapper: Providers }));
73
73
  };
74
74
  it('should render error message for validation service errors', function () {
75
75
  var error = {
@@ -1 +1 @@
1
- export { Error } from './Error';
1
+ export { AttributeErrorItem } from './AttributeErrorItem';
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Error = void 0;
4
- var Error_1 = require("./Error");
5
- Object.defineProperty(exports, "Error", { enumerable: true, get: function () { return Error_1.Error; } });
3
+ exports.AttributeErrorItem = void 0;
4
+ var AttributeErrorItem_1 = require("./AttributeErrorItem");
5
+ Object.defineProperty(exports, "AttributeErrorItem", { enumerable: true, get: function () { return AttributeErrorItem_1.AttributeErrorItem; } });
@@ -12,6 +12,7 @@ type Props = {
12
12
  expandedPanelId: string;
13
13
  onToggle: (id: string) => (e: any, isExpanded: boolean) => void;
14
14
  ErrorComponent: ElementType;
15
+ alwaysShowLink?: boolean;
15
16
  };
16
- export declare const ErrorsPanel: React.MemoExoticComponent<({ panels, expandedPanelId, onToggle, ErrorComponent }: Props) => React.JSX.Element>;
17
+ export declare const ErrorsPanel: React.MemoExoticComponent<({ panels, expandedPanelId, onToggle, ErrorComponent, alwaysShowLink }: Props) => React.JSX.Element>;
17
18
  export {};
@@ -36,7 +36,7 @@ var ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
36
36
  var Typography_1 = __importDefault(require("@mui/material/Typography"));
37
37
  var styles_1 = require("./styles");
38
38
  exports.ErrorsPanel = (0, react_1.memo)(function (_a) {
39
- var panels = _a.panels, expandedPanelId = _a.expandedPanelId, onToggle = _a.onToggle, ErrorComponent = _a.ErrorComponent;
39
+ var panels = _a.panels, expandedPanelId = _a.expandedPanelId, onToggle = _a.onToggle, ErrorComponent = _a.ErrorComponent, _b = _a.alwaysShowLink, alwaysShowLink = _b === void 0 ? false : _b;
40
40
  var styles = (0, styles_1.useStyles)();
41
41
  return panels.length > 0 ? (react_1.default.createElement("div", null, panels.map(function (_a) {
42
42
  var id = _a.id, icon = _a.icon, title = _a.title, items = _a.items, accordionClassName = _a.accordionClassName, accordionDetailsClassName = _a.accordionDetailsClassName;
@@ -48,7 +48,8 @@ exports.ErrorsPanel = (0, react_1.memo)(function (_a) {
48
48
  }, expandIcon: react_1.default.createElement(ExpandMore_1.default, null) },
49
49
  icon,
50
50
  react_1.default.createElement(Typography_1.default, { className: styles.accordionSummaryHeading }, title)),
51
- react_1.default.createElement(AccordionDetails_1.default, { className: (0, classnames_1.default)(styles.accordionDetails, accordionDetailsClassName) }, items.map(function (error, i) { return (react_1.default.createElement(ErrorComponent, { key: i, error: error })); }))));
51
+ react_1.default.createElement(AccordionDetails_1.default, { className: (0, classnames_1.default)(styles.accordionDetails, accordionDetailsClassName) }, items.map(function (error, i) { return (react_1.default.createElement(ErrorComponent, { key: i, error: error, alwaysShowLink: alwaysShowLink }) //NOSONAR
52
+ ); }))));
52
53
  }))) : null;
53
54
  });
54
55
  exports.ErrorsPanel.displayName = 'ErrorsPanel';
@@ -74,7 +74,8 @@ describe('ReadOnlyAttributesPager tests', function () {
74
74
  type: 'String',
75
75
  name: 'Simple',
76
76
  label: 'Simple label',
77
- description: 'Simple description'
77
+ description: 'Simple description',
78
+ masking: { regexPattern: '.*' }
78
79
  };
79
80
  var values = [
80
81
  { type: attributeType.uri, uri: 'entities/sIeHttl/attributes/Simple/u123', value: '123', ov: true },
@@ -91,8 +92,14 @@ describe('ReadOnlyAttributesPager tests', function () {
91
92
  afterEach(function () {
92
93
  jest.clearAllMocks();
93
94
  });
95
+ var defaultMdmValues = {
96
+ metadata: {
97
+ entityTypes: [{ uri: 'configuration/entityTypes/HCP', attributes: [attributeType] }]
98
+ },
99
+ showMasking: true
100
+ };
94
101
  var setUp = function (_a) {
95
- var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? {} : _d, _e = _b.featuresContextValue, featuresContextValue = _e === void 0 ? { showDescription: true } : _e;
102
+ var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.featuresContextValue, featuresContextValue = _e === void 0 ? { showDescription: true } : _e;
96
103
  var user = user_event_1.default.setup();
97
104
  var Providers = function (_a) {
98
105
  var children = _a.children;
@@ -161,7 +168,11 @@ describe('ReadOnlyAttributesPager tests', function () {
161
168
  attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Simple',
162
169
  defaultMaxValues: 1,
163
170
  parentUri: 'entities/sIeHttl',
164
- values: ovValues
171
+ values: ovValues,
172
+ options: {
173
+ sendMasking: true,
174
+ ovOnly: true
175
+ }
165
176
  });
166
177
  labels = react_2.screen.getAllByTestId('reltio-attribute-complex-label');
167
178
  expect(labels).toHaveLength(2);
@@ -175,7 +186,11 @@ describe('ReadOnlyAttributesPager tests', function () {
175
186
  attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Simple',
176
187
  defaultMaxValues: 1,
177
188
  parentUri: 'entities/sIeHttl',
178
- values: ovValues
189
+ values: ovValues,
190
+ options: {
191
+ sendMasking: true,
192
+ ovOnly: true
193
+ }
179
194
  });
180
195
  labels = react_2.screen.getAllByTestId('reltio-attribute-complex-label');
181
196
  expect(labels).toHaveLength(3);
@@ -224,9 +239,10 @@ describe('ReadOnlyAttributesPager tests', function () {
224
239
  mdmValues: {
225
240
  metadata: {
226
241
  roles: [
227
- { uri: 'role1', label: 'Role1' },
228
- { uri: 'role2', label: 'Role2' }
229
- ]
242
+ { uri: 'role1', label: 'Role1', description: 'Role1 description' },
243
+ { uri: 'role2', label: 'Role2', description: 'Role2 description' }
244
+ ],
245
+ entityTypes: defaultMdmValues.metadata.entityTypes
230
246
  }
231
247
  }
232
248
  });
@@ -238,7 +254,10 @@ describe('ReadOnlyAttributesPager tests', function () {
238
254
  });
239
255
  it('should use SpecialRenderer for tags', function () {
240
256
  var props = __assign(__assign({}, defaultProps), { attributeType: mdm_sdk_1.EntityAttrTypes.tags, values: ['tag1', 'tag2'] });
241
- setUp({ props: props, mdmValues: { entity: {} } });
257
+ setUp({
258
+ props: props,
259
+ mdmValues: __assign(__assign({}, defaultMdmValues), { entity: { uri: 'entities/sIeHttl', type: 'configuration/entityTypes/HCP' } })
260
+ });
242
261
  expect(react_2.screen.queryByTestId('branch-decorator')).not.toBeInTheDocument();
243
262
  expect(react_2.screen.getByTestId('special-renderer')).toBeInTheDocument();
244
263
  expect(react_2.screen.getByText('Tags')).toBeInTheDocument();
@@ -284,7 +303,7 @@ describe('ReadOnlyAttributesPager tests', function () {
284
303
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
285
304
  ];
286
305
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false), max: 1 });
287
- setUp({ props: props, mdmValues: { maxValuesInResponse: 20 } });
306
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: 20 }) });
288
307
  expect(react_2.screen.getByTestId('show-more')).toBeInTheDocument();
289
308
  react_2.screen.getByText('Show 1 more of remaining 2 value');
290
309
  });
@@ -295,7 +314,7 @@ describe('ReadOnlyAttributesPager tests', function () {
295
314
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
296
315
  ];
297
316
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false) });
298
- setUp({ props: props, mdmValues: { maxValuesInResponse: 1 } });
317
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: 1 }) });
299
318
  expect(react_2.screen.getByTestId('show-more')).toBeInTheDocument();
300
319
  react_2.screen.getByText('Show 1 more of remaining 2 value');
301
320
  });
@@ -306,7 +325,7 @@ describe('ReadOnlyAttributesPager tests', function () {
306
325
  __assign(__assign({}, values[2]), { value: { Name: [{ value: '444', uri: '444' }] } })
307
326
  ];
308
327
  var props = __assign(__assign({}, defaultProps), { attributeType: __assign(__assign({}, defaultProps.attributeType), { type: 'Nested' }), values: __spreadArray(__spreadArray([], ovValues, true), [__assign(__assign({}, values[1]), { ov: false })], false) });
309
- setUp({ props: props, mdmValues: { maxValuesInResponse: undefined } });
328
+ setUp({ props: props, mdmValues: __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: undefined }) });
310
329
  expect(react_2.screen.queryByTestId('show-more')).not.toBeInTheDocument();
311
330
  });
312
331
  });
@@ -30,6 +30,7 @@ exports.MultiLineRenderer = void 0;
30
30
  var react_1 = __importStar(require("react"));
31
31
  var ramda_1 = require("ramda");
32
32
  var classnames_1 = __importDefault(require("classnames"));
33
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
33
34
  var ReadOnlyAttributesFactory_1 = require("../../../ReadOnlyAttributesFactory");
34
35
  var AttributeTitle_1 = require("../../../AttributeTitle");
35
36
  var ShowMore_1 = require("../../../ShowMore");
@@ -49,6 +50,9 @@ var MultiLineRenderer = function (_a) {
49
50
  var showMore = hasPaging && visibleValuesCount < totalVisibleValues;
50
51
  var showLess = hasPaging && visibleValuesCount >= totalVisibleValues;
51
52
  var label = attributeType.label, description = attributeType.description;
53
+ var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
54
+ var hasMasking = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.checkHasMasking)(metadata, attributeType); }, [metadata, attributeType]);
55
+ var showMasking = (0, MdmModuleContext_1.useMdmShowMasking)();
52
56
  var onShowMore = function () {
53
57
  if (values.length < totalVisibleValues) {
54
58
  requestNextPageOfAttributeValues({
@@ -56,7 +60,11 @@ var MultiLineRenderer = function (_a) {
56
60
  attributeTypeUri: attributeType.uri,
57
61
  attributeTypeName: attributeType.name,
58
62
  values: values,
59
- defaultMaxValues: max
63
+ defaultMaxValues: max,
64
+ options: {
65
+ sendMasking: showMasking && hasMasking,
66
+ ovOnly: !showNonOv
67
+ }
60
68
  });
61
69
  }
62
70
  setVisibleValuesCount(visibleValuesCount + max);