@reltio/components 1.4.1839 → 1.4.1841

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.
@@ -28,7 +28,8 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
28
28
  marginLeft: '40px'
29
29
  },
30
30
  commentTarget: {
31
- marginTop: '-15px'
31
+ marginTop: '-15px',
32
+ overflowWrap: 'break-word'
32
33
  },
33
34
  message: {
34
35
  marginTop: '12px'
@@ -55,8 +55,9 @@ var ramda_1 = require("ramda");
55
55
  var react_mentions_1 = require("react-mentions");
56
56
  var UsersContext_1 = require("../../../contexts/UsersContext");
57
57
  var styles_1 = require("./styles");
58
- var constants_1 = require("./constants");
58
+ var MENTIONS_TEXTAREA_CLASSNAME = 'mentionsTextArea';
59
59
  var TextFieldWithMentions = function (_a) {
60
+ var _b;
60
61
  var onChange = _a.onChange, className = _a.className, value = _a.value, placeholder = _a.placeholder, props = __rest(_a, ["onChange", "className", "value", "placeholder"]);
61
62
  var styles = (0, styles_1.useStyles)({ placeholder: value ? '' : placeholder });
62
63
  var users = (0, react_1.useContext)(UsersContext_1.UsersContext);
@@ -67,7 +68,14 @@ var TextFieldWithMentions = function (_a) {
67
68
  })));
68
69
  };
69
70
  return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.root, className) },
70
- react_1.default.createElement(react_mentions_1.MentionsInput, __assign({}, props, { value: value, placeholder: placeholder, onChange: handleChange, className: (0, classnames_1.default)(constants_1.MENTIONS_TEXTAREA_CLASSNAME), suggestionsPortalHost: document.body }),
71
+ react_1.default.createElement(react_mentions_1.MentionsInput, __assign({}, props, { value: value, placeholder: placeholder, onChange: handleChange, className: MENTIONS_TEXTAREA_CLASSNAME, suggestionsPortalHost: document.body, classNames: (_b = {},
72
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__input")] = styles.mentionsInput,
73
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__highlighter")] = styles.mentionsHighlighter,
74
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__control")] = styles.mentionsControl,
75
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = styles.mentionsSuggestions,
76
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = styles.mentionsSuggestionsList,
77
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = styles.mentionsSuggestionsItem,
78
+ _b) }),
71
79
  react_1.default.createElement(react_mentions_1.Mention, { trigger: "+", data: users.map(function (_a) {
72
80
  var username = _a.username;
73
81
  return ({ id: username, display: username });
@@ -1,5 +1,5 @@
1
1
  type StylesProps = {
2
2
  placeholder?: string;
3
3
  };
4
- export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mention">;
4
+ export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mention">;
5
5
  export {};
@@ -3,63 +3,58 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStyles = void 0;
4
4
  var styles_1 = require("@mui/styles");
5
5
  var constants_1 = require("../../../constants");
6
- var constants_2 = require("./constants");
7
6
  var suggestionsZIndex = constants_1.POPUP_Z_INDEX + 1;
8
- exports.useStyles = (0, styles_1.makeStyles)(function (theme) {
9
- var _a;
10
- return ({
11
- root: (_a = {
12
- backgroundColor: '#fff',
13
- fontFamily: 'Roboto'
14
- },
15
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__control")] = {
16
- fontSize: '13px'
17
- },
18
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__highlighter")] = {
19
- padding: '10px 22px',
20
- border: '1px solid transparent !important',
21
- '&::before': {
22
- content: function (_a) {
23
- var placeholder = _a.placeholder;
24
- return placeholder && "\"".concat(placeholder, "\"");
25
- }
26
- }
27
- },
28
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__input")] = {
29
- borderRadius: '2px',
30
- border: '1px solid rgba(0,0,0,0.12)',
31
- padding: '10px 22px',
32
- outline: 0,
33
- overflow: 'auto !important'
34
- },
35
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = {
36
- padding: '8px 0',
37
- zIndex: suggestionsZIndex + '!important',
38
- borderRadius: '4px',
39
- backgroundColor: '#fafafa !important',
40
- boxShadow: '0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)',
41
- transform: 'translateY(-100%)'
42
- },
43
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = {
44
- maxHeight: '200px',
45
- overflowY: 'scroll'
46
- },
47
- _a["& .".concat(constants_2.MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = {
48
- padding: '6px 12px',
49
- color: theme.palette.text.primary,
50
- fontSize: '13px',
51
- transition: theme.transitions.create(['background-color']),
52
- '&:hover, &--focused': {
53
- backgroundColor: 'rgba(0,0,0,0.04)'
54
- }
55
- },
56
- _a),
57
- mention: {
58
- position: 'relative',
59
- zIndex: 1,
60
- color: theme.palette.primary.main,
61
- textShadow: '1px 1px 1px white, 1px -1px 1px white, -1px 1px 1px white, -1px -1px 1px white',
62
- pointerEvents: 'none'
7
+ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
8
+ root: {
9
+ backgroundColor: '#fff',
10
+ fontFamily: 'Roboto'
11
+ },
12
+ mentionsControl: {
13
+ fontSize: '13px'
14
+ },
15
+ mentionsHighlighter: {
16
+ padding: '10px 22px',
17
+ border: '1px solid transparent !important',
18
+ '&::before': {
19
+ content: function (_a) {
20
+ var placeholder = _a.placeholder;
21
+ return placeholder && "\"".concat(placeholder, "\"");
22
+ }
63
23
  }
64
- });
65
- });
24
+ },
25
+ mentionsInput: {
26
+ borderRadius: '2px',
27
+ border: '1px solid rgba(0,0,0,0.12)',
28
+ padding: '10px 22px',
29
+ outline: 0,
30
+ overflow: 'auto !important'
31
+ },
32
+ mentionsSuggestions: {
33
+ padding: '8px 0',
34
+ zIndex: suggestionsZIndex + '!important',
35
+ borderRadius: '4px',
36
+ backgroundColor: '#fafafa !important',
37
+ boxShadow: '0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)',
38
+ transform: 'translateY(-100%)'
39
+ },
40
+ mentionsSuggestionsList: {
41
+ maxHeight: '200px',
42
+ overflowY: 'scroll'
43
+ },
44
+ mentionsSuggestionsItem: {
45
+ padding: '6px 12px',
46
+ color: theme.palette.text.primary,
47
+ fontSize: '13px',
48
+ transition: theme.transitions.create(['background-color']),
49
+ '&:hover, &--focused': {
50
+ backgroundColor: 'rgba(0,0,0,0.04)'
51
+ }
52
+ },
53
+ mention: {
54
+ position: 'relative',
55
+ zIndex: 1,
56
+ color: theme.palette.primary.main,
57
+ textShadow: '1px 1px 1px white, 1px -1px 1px white, -1px 1px 1px white, -1px -1px 1px white',
58
+ pointerEvents: 'none'
59
+ }
60
+ }); });
@@ -69,7 +69,7 @@ var useAttributeActions = function (_a) {
69
69
  uri: attributeValue.uri,
70
70
  crosswalk: sourceTable ? { type: type, value: value, sourceTable: sourceTable } : { type: type, value: value }
71
71
  });
72
- }), function (diff) { return ({ uri: (0, mdm_sdk_1.getBaseUri)(attributeValue.uri), diff: diff }); }, mdm_sdk_1.entityCumulativeDelete, handleErrorResponse)(crosswalks);
72
+ }), function (diff) { return ({ uri: (0, mdm_sdk_1.getBaseUri)(attributeValue.uri), diff: diff }); }, (0, mdm_sdk_1.isRelationUri)(attributeValue.uri) ? mdm_sdk_1.entityCumulativeUpdate : mdm_sdk_1.entityCumulativeDelete, handleErrorResponse)(crosswalks);
73
73
  handleAction(action);
74
74
  }, [handleAction, handleErrorResponse]);
75
75
  var pinAttributeAction = (0, react_1.useCallback)(function (_a) {
@@ -74,7 +74,7 @@ var useAttributeActions_1 = require("./useAttributeActions");
74
74
  var test_utils_1 = require("react-dom/test-utils");
75
75
  var react_hooks_1 = require("@testing-library/react-hooks");
76
76
  var mdmSdk = __importStar(require("@reltio/mdm-sdk"));
77
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
77
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), entityCumulativeUpdate: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
78
78
  describe('useAttributeActions', function () {
79
79
  var initialProps = {
80
80
  onSuccess: jest.fn(),
@@ -91,6 +91,12 @@ describe('useAttributeActions', function () {
91
91
  resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
92
92
  });
93
93
  });
94
+ var entityCumulativeUpdateMock = jest.spyOn(mdmSdk, 'entityCumulativeUpdate').mockImplementation(function () {
95
+ return new Promise(function (_resolve, _reject) {
96
+ resolveSuccess = function () { return _resolve({ uri: 'relations/03xNaHt', type: 'configuration/relationTypes/HCPtoHCA' }); };
97
+ resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
98
+ });
99
+ });
94
100
  var removeRelationMock = jest.spyOn(mdmSdk, 'removeRelation').mockImplementation(function () {
95
101
  return new Promise(function (_resolve, _reject) {
96
102
  resolveSuccess = function () { return _resolve({ status: 'success' }); };
@@ -414,6 +420,81 @@ describe('useAttributeActions', function () {
414
420
  }
415
421
  });
416
422
  }); });
423
+ it('should return correct delete action for relation attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
424
+ var deleteAttribute, deleteEvent, requestParams;
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0:
428
+ deleteAttribute = getActions().deleteAttribute;
429
+ deleteEvent = {
430
+ attributeType: {
431
+ name: 'Int',
432
+ type: 'Int',
433
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/Int'
434
+ },
435
+ attributeValue: {
436
+ type: 'configuration/relationTypes/HCPtoHCA/attributes/Int',
437
+ ov: true,
438
+ value: '123',
439
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
440
+ },
441
+ crosswalks: [
442
+ {
443
+ uri: 'relations/03xNaHt/crosswalks/n7HybxF',
444
+ type: 'configuration/sources/Reltio',
445
+ value: '03xNaHt',
446
+ createDate: '2024-02-02T14:11:10.208Z',
447
+ updateDate: '2024-02-02T14:11:10.208Z',
448
+ attributes: [
449
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8',
450
+ 'relations/03xNaHt/attributes/Int/10DnwKGs'
451
+ ],
452
+ singleAttributeUpdateDates: {
453
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8': '2024-05-07T08:24:58.683Z',
454
+ 'relations/03xNaHt/attributes/Int/10DnwKGs': '2024-05-07T08:24:58.683Z'
455
+ }
456
+ }
457
+ ]
458
+ };
459
+ deleteAttribute(deleteEvent);
460
+ requestParams = {
461
+ diff: [
462
+ {
463
+ crosswalk: { type: 'configuration/sources/Reltio', value: '03xNaHt' },
464
+ type: 'DELETE_ATTRIBUTE',
465
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
466
+ }
467
+ ],
468
+ uri: 'relations/03xNaHt'
469
+ };
470
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
471
+ expect(initialProps.onLoad).toHaveBeenCalled();
472
+ expect(initialProps.onSuccess).not.toHaveBeenCalled();
473
+ return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
474
+ return __generator(this, function (_a) {
475
+ resolveSuccess();
476
+ return [2 /*return*/];
477
+ });
478
+ }); })];
479
+ case 1:
480
+ _a.sent();
481
+ expect(initialProps.onSuccess).toHaveBeenCalled();
482
+ deleteAttribute(deleteEvent);
483
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
484
+ expect(initialProps.onError).not.toHaveBeenCalled();
485
+ return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
486
+ return __generator(this, function (_a) {
487
+ resolveError();
488
+ return [2 /*return*/];
489
+ });
490
+ }); })];
491
+ case 2:
492
+ _a.sent();
493
+ expect(initialProps.onError).toHaveBeenCalledWith({ errorMessage: 'Some error' });
494
+ return [2 /*return*/];
495
+ }
496
+ });
497
+ }); });
417
498
  it('should return correct pin action for attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
418
499
  var pinAttribute, attributeValue;
419
500
  return __generator(this, function (_a) {
@@ -25,7 +25,8 @@ export var useStyles = makeStyles(function (theme) { return ({
25
25
  marginLeft: '40px'
26
26
  },
27
27
  commentTarget: {
28
- marginTop: '-15px'
28
+ marginTop: '-15px',
29
+ overflowWrap: 'break-word'
29
30
  },
30
31
  message: {
31
32
  marginTop: '12px'
@@ -26,8 +26,9 @@ import { uniq } from 'ramda';
26
26
  import { MentionsInput, Mention } from 'react-mentions';
27
27
  import { UsersContext } from '../../../contexts/UsersContext';
28
28
  import { useStyles } from './styles';
29
- import { MENTIONS_TEXTAREA_CLASSNAME } from './constants';
29
+ var MENTIONS_TEXTAREA_CLASSNAME = 'mentionsTextArea';
30
30
  export var TextFieldWithMentions = function (_a) {
31
+ var _b;
31
32
  var onChange = _a.onChange, className = _a.className, value = _a.value, placeholder = _a.placeholder, props = __rest(_a, ["onChange", "className", "value", "placeholder"]);
32
33
  var styles = useStyles({ placeholder: value ? '' : placeholder });
33
34
  var users = useContext(UsersContext);
@@ -38,7 +39,14 @@ export var TextFieldWithMentions = function (_a) {
38
39
  })));
39
40
  };
40
41
  return (React.createElement("div", { className: classnames(styles.root, className) },
41
- React.createElement(MentionsInput, __assign({}, props, { value: value, placeholder: placeholder, onChange: handleChange, className: classnames(MENTIONS_TEXTAREA_CLASSNAME), suggestionsPortalHost: document.body }),
42
+ React.createElement(MentionsInput, __assign({}, props, { value: value, placeholder: placeholder, onChange: handleChange, className: MENTIONS_TEXTAREA_CLASSNAME, suggestionsPortalHost: document.body, classNames: (_b = {},
43
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__input")] = styles.mentionsInput,
44
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__highlighter")] = styles.mentionsHighlighter,
45
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__control")] = styles.mentionsControl,
46
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = styles.mentionsSuggestions,
47
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = styles.mentionsSuggestionsList,
48
+ _b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = styles.mentionsSuggestionsItem,
49
+ _b) }),
42
50
  React.createElement(Mention, { trigger: "+", data: users.map(function (_a) {
43
51
  var username = _a.username;
44
52
  return ({ id: username, display: username });
@@ -1,5 +1,5 @@
1
1
  type StylesProps = {
2
2
  placeholder?: string;
3
3
  };
4
- export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mention">;
4
+ export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mention">;
5
5
  export {};
@@ -1,62 +1,57 @@
1
1
  import { makeStyles } from '@mui/styles';
2
2
  import { POPUP_Z_INDEX } from '../../../constants';
3
- import { MENTIONS_TEXTAREA_CLASSNAME } from './constants';
4
3
  var suggestionsZIndex = POPUP_Z_INDEX + 1;
5
- export var useStyles = makeStyles(function (theme) {
6
- var _a;
7
- return ({
8
- root: (_a = {
9
- backgroundColor: '#fff',
10
- fontFamily: 'Roboto'
11
- },
12
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__control")] = {
13
- fontSize: '13px'
14
- },
15
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__highlighter")] = {
16
- padding: '10px 22px',
17
- border: '1px solid transparent !important',
18
- '&::before': {
19
- content: function (_a) {
20
- var placeholder = _a.placeholder;
21
- return placeholder && "\"".concat(placeholder, "\"");
22
- }
23
- }
24
- },
25
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__input")] = {
26
- borderRadius: '2px',
27
- border: '1px solid rgba(0,0,0,0.12)',
28
- padding: '10px 22px',
29
- outline: 0,
30
- overflow: 'auto !important'
31
- },
32
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = {
33
- padding: '8px 0',
34
- zIndex: suggestionsZIndex + '!important',
35
- borderRadius: '4px',
36
- backgroundColor: '#fafafa !important',
37
- boxShadow: '0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)',
38
- transform: 'translateY(-100%)'
39
- },
40
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = {
41
- maxHeight: '200px',
42
- overflowY: 'scroll'
43
- },
44
- _a["& .".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = {
45
- padding: '6px 12px',
46
- color: theme.palette.text.primary,
47
- fontSize: '13px',
48
- transition: theme.transitions.create(['background-color']),
49
- '&:hover, &--focused': {
50
- backgroundColor: 'rgba(0,0,0,0.04)'
51
- }
52
- },
53
- _a),
54
- mention: {
55
- position: 'relative',
56
- zIndex: 1,
57
- color: theme.palette.primary.main,
58
- textShadow: '1px 1px 1px white, 1px -1px 1px white, -1px 1px 1px white, -1px -1px 1px white',
59
- pointerEvents: 'none'
4
+ export var useStyles = makeStyles(function (theme) { return ({
5
+ root: {
6
+ backgroundColor: '#fff',
7
+ fontFamily: 'Roboto'
8
+ },
9
+ mentionsControl: {
10
+ fontSize: '13px'
11
+ },
12
+ mentionsHighlighter: {
13
+ padding: '10px 22px',
14
+ border: '1px solid transparent !important',
15
+ '&::before': {
16
+ content: function (_a) {
17
+ var placeholder = _a.placeholder;
18
+ return placeholder && "\"".concat(placeholder, "\"");
19
+ }
60
20
  }
61
- });
62
- });
21
+ },
22
+ mentionsInput: {
23
+ borderRadius: '2px',
24
+ border: '1px solid rgba(0,0,0,0.12)',
25
+ padding: '10px 22px',
26
+ outline: 0,
27
+ overflow: 'auto !important'
28
+ },
29
+ mentionsSuggestions: {
30
+ padding: '8px 0',
31
+ zIndex: suggestionsZIndex + '!important',
32
+ borderRadius: '4px',
33
+ backgroundColor: '#fafafa !important',
34
+ boxShadow: '0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)',
35
+ transform: 'translateY(-100%)'
36
+ },
37
+ mentionsSuggestionsList: {
38
+ maxHeight: '200px',
39
+ overflowY: 'scroll'
40
+ },
41
+ mentionsSuggestionsItem: {
42
+ padding: '6px 12px',
43
+ color: theme.palette.text.primary,
44
+ fontSize: '13px',
45
+ transition: theme.transitions.create(['background-color']),
46
+ '&:hover, &--focused': {
47
+ backgroundColor: 'rgba(0,0,0,0.04)'
48
+ }
49
+ },
50
+ mention: {
51
+ position: 'relative',
52
+ zIndex: 1,
53
+ color: theme.palette.primary.main,
54
+ textShadow: '1px 1px 1px white, 1px -1px 1px white, -1px 1px 1px white, -1px -1px 1px white',
55
+ pointerEvents: 'none'
56
+ }
57
+ }); });
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { useCallback } from 'react';
38
38
  import { andThen, pipe, prop, defaultTo, map } from 'ramda';
39
- import { createAttribute, entityCumulativeDelete, getBaseUri, getReferencedRelationFromAttrValue, ignoreAttribute, isComplexAttribute, isImage, isLookupAttrType, isLookupValue, isReference, pinAttribute, removeRelation, updateAttribute } from '@reltio/mdm-sdk';
39
+ import { createAttribute, entityCumulativeDelete, getBaseUri, isRelationUri, getReferencedRelationFromAttrValue, ignoreAttribute, isComplexAttribute, isImage, isLookupAttrType, isLookupValue, isReference, pinAttribute, removeRelation, updateAttribute, entityCumulativeUpdate } from '@reltio/mdm-sdk';
40
40
  import { noop } from '../../../core';
41
41
  export var useAttributeActions = function (_a) {
42
42
  var _b = _a.onSuccess, onSuccess = _b === void 0 ? noop : _b, _c = _a.onError, onError = _c === void 0 ? noop : _c, _d = _a.onLoad, onLoad = _d === void 0 ? noop : _d;
@@ -66,7 +66,7 @@ export var useAttributeActions = function (_a) {
66
66
  uri: attributeValue.uri,
67
67
  crosswalk: sourceTable ? { type: type, value: value, sourceTable: sourceTable } : { type: type, value: value }
68
68
  });
69
- }), function (diff) { return ({ uri: getBaseUri(attributeValue.uri), diff: diff }); }, entityCumulativeDelete, handleErrorResponse)(crosswalks);
69
+ }), function (diff) { return ({ uri: getBaseUri(attributeValue.uri), diff: diff }); }, isRelationUri(attributeValue.uri) ? entityCumulativeUpdate : entityCumulativeDelete, handleErrorResponse)(crosswalks);
70
70
  handleAction(action);
71
71
  }, [handleAction, handleErrorResponse]);
72
72
  var pinAttributeAction = useCallback(function (_a) {
@@ -49,7 +49,7 @@ import { useAttributeActions } from './useAttributeActions';
49
49
  import { act } from 'react-dom/test-utils';
50
50
  import { renderHook } from '@testing-library/react-hooks';
51
51
  import * as mdmSdk from '@reltio/mdm-sdk';
52
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
52
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { entityCumulativeDelete: jest.fn(), entityCumulativeUpdate: jest.fn(), ignoreAttribute: jest.fn(), pinAttribute: jest.fn(), removeRelation: jest.fn(), updateAttribute: jest.fn(), createAttribute: jest.fn() })); });
53
53
  describe('useAttributeActions', function () {
54
54
  var initialProps = {
55
55
  onSuccess: jest.fn(),
@@ -66,6 +66,12 @@ describe('useAttributeActions', function () {
66
66
  resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
67
67
  });
68
68
  });
69
+ var entityCumulativeUpdateMock = jest.spyOn(mdmSdk, 'entityCumulativeUpdate').mockImplementation(function () {
70
+ return new Promise(function (_resolve, _reject) {
71
+ resolveSuccess = function () { return _resolve({ uri: 'relations/03xNaHt', type: 'configuration/relationTypes/HCPtoHCA' }); };
72
+ resolveError = function () { return _reject({ errorMessage: 'Some error' }); };
73
+ });
74
+ });
69
75
  var removeRelationMock = jest.spyOn(mdmSdk, 'removeRelation').mockImplementation(function () {
70
76
  return new Promise(function (_resolve, _reject) {
71
77
  resolveSuccess = function () { return _resolve({ status: 'success' }); };
@@ -389,6 +395,81 @@ describe('useAttributeActions', function () {
389
395
  }
390
396
  });
391
397
  }); });
398
+ it('should return correct delete action for relation attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
399
+ var deleteAttribute, deleteEvent, requestParams;
400
+ return __generator(this, function (_a) {
401
+ switch (_a.label) {
402
+ case 0:
403
+ deleteAttribute = getActions().deleteAttribute;
404
+ deleteEvent = {
405
+ attributeType: {
406
+ name: 'Int',
407
+ type: 'Int',
408
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/Int'
409
+ },
410
+ attributeValue: {
411
+ type: 'configuration/relationTypes/HCPtoHCA/attributes/Int',
412
+ ov: true,
413
+ value: '123',
414
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
415
+ },
416
+ crosswalks: [
417
+ {
418
+ uri: 'relations/03xNaHt/crosswalks/n7HybxF',
419
+ type: 'configuration/sources/Reltio',
420
+ value: '03xNaHt',
421
+ createDate: '2024-02-02T14:11:10.208Z',
422
+ updateDate: '2024-02-02T14:11:10.208Z',
423
+ attributes: [
424
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8',
425
+ 'relations/03xNaHt/attributes/Int/10DnwKGs'
426
+ ],
427
+ singleAttributeUpdateDates: {
428
+ 'relations/03xNaHt/attributes/HierarchyCode/10DnwOX8': '2024-05-07T08:24:58.683Z',
429
+ 'relations/03xNaHt/attributes/Int/10DnwKGs': '2024-05-07T08:24:58.683Z'
430
+ }
431
+ }
432
+ ]
433
+ };
434
+ deleteAttribute(deleteEvent);
435
+ requestParams = {
436
+ diff: [
437
+ {
438
+ crosswalk: { type: 'configuration/sources/Reltio', value: '03xNaHt' },
439
+ type: 'DELETE_ATTRIBUTE',
440
+ uri: 'relations/03xNaHt/attributes/Int/10DnwKGs'
441
+ }
442
+ ],
443
+ uri: 'relations/03xNaHt'
444
+ };
445
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
446
+ expect(initialProps.onLoad).toHaveBeenCalled();
447
+ expect(initialProps.onSuccess).not.toHaveBeenCalled();
448
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
449
+ return __generator(this, function (_a) {
450
+ resolveSuccess();
451
+ return [2 /*return*/];
452
+ });
453
+ }); })];
454
+ case 1:
455
+ _a.sent();
456
+ expect(initialProps.onSuccess).toHaveBeenCalled();
457
+ deleteAttribute(deleteEvent);
458
+ expect(entityCumulativeUpdateMock).toHaveBeenCalledWith(requestParams);
459
+ expect(initialProps.onError).not.toHaveBeenCalled();
460
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
461
+ return __generator(this, function (_a) {
462
+ resolveError();
463
+ return [2 /*return*/];
464
+ });
465
+ }); })];
466
+ case 2:
467
+ _a.sent();
468
+ expect(initialProps.onError).toHaveBeenCalledWith({ errorMessage: 'Some error' });
469
+ return [2 /*return*/];
470
+ }
471
+ });
472
+ }); });
392
473
  it('should return correct pin action for attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
393
474
  var pinAttribute, attributeValue;
394
475
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1839",
3
+ "version": "1.4.1841",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -1 +0,0 @@
1
- export declare const MENTIONS_TEXTAREA_CLASSNAME = "mentionsTextArea";
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MENTIONS_TEXTAREA_CLASSNAME = void 0;
4
- exports.MENTIONS_TEXTAREA_CLASSNAME = 'mentionsTextArea';
@@ -1 +0,0 @@
1
- export declare const MENTIONS_TEXTAREA_CLASSNAME = "mentionsTextArea";
@@ -1 +0,0 @@
1
- export var MENTIONS_TEXTAREA_CLASSNAME = 'mentionsTextArea';