@reltio/components 1.4.819 → 1.4.823
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/components/attributes/inline/ComplexAttribute/ComplexAttribute.js +2 -2
- package/components/attributes/inline/SimpleAttribute/SimpleAttribute.js +12 -5
- package/components/attributes/inline/SimpleAttribute/styles.d.ts +3 -2
- package/components/attributes/inline/SimpleAttribute/styles.js +35 -10
- package/components/attributes/inline/common/IgnoreButton.d.ts +2 -1
- package/components/attributes/inline/common/IgnoreButton.js +2 -2
- package/components/attributes/inline/common/PinButton.d.ts +2 -1
- package/components/attributes/inline/common/PinButton.js +2 -2
- package/components/attributes/inline/common/__test__/IgnoreButton.spec.js +9 -5
- package/components/attributes/inline/common/__test__/PinButton.spec.js +9 -5
- package/components/crosswalks/ColoredBlock/ColoredBlock.d.ts +1 -0
- package/components/crosswalks/ColoredBlock/ColoredBlock.js +2 -2
- package/components/crosswalks/ColoredBlock/styles.d.ts +1 -0
- package/components/crosswalks/ColoredBlock/styles.js +13 -6
- package/components/crosswalks/CrosswalkRow/CrosswalkRow.js +4 -3
- package/components/crosswalks/hooks/useCrosswalkActions.js +16 -23
- package/package.json +3 -3
|
@@ -61,8 +61,8 @@ var ComplexAttribute = function (_a) {
|
|
|
61
61
|
crosswalks.map(function (crosswalk) { return (react_1.default.createElement(CrosswalkIcon_1.default, { key: mdm_sdk_1.getCrosswalkId(crosswalk), crosswalk: crosswalk, className: styles.crosswalkIcon })); })),
|
|
62
62
|
react_1.default.createElement(index_1.Spacer, null),
|
|
63
63
|
react_1.default.createElement("div", { className: styles.actions },
|
|
64
|
-
showPin && react_1.default.createElement(PinButton_1.default, { isPinned: attributeValue.pin, onClick: function () { return onPin({ attributeValue: attributeValue }); } }),
|
|
65
|
-
showIgnore && (react_1.default.createElement(IgnoreButton_1.default, { isIgnored: attributeValue.ignored, onClick: function () { return onIgnore({ attributeValue: attributeValue }); } })),
|
|
64
|
+
showPin && (react_1.default.createElement(PinButton_1.default, { disabled: !canEdit, isPinned: attributeValue.pin, onClick: function () { return onPin({ attributeValue: attributeValue }); } })),
|
|
65
|
+
showIgnore && (react_1.default.createElement(IgnoreButton_1.default, { disabled: !canEdit, isIgnored: attributeValue.ignored, onClick: function () { return onIgnore({ attributeValue: attributeValue }); } })),
|
|
66
66
|
showDelete && (react_1.default.createElement(DeleteButton_1.default, { onClick: function () {
|
|
67
67
|
return onDelete({
|
|
68
68
|
attributeType: attributeType,
|
|
@@ -44,14 +44,21 @@ var SimpleAttribute = function (_a) {
|
|
|
44
44
|
var _e = useAttributeState_1.useAttributeState(), isReadingMode = _e.isReadingMode, isEditingMode = _e.isEditingMode, isHovered = _e.isHovered, onMouseOver = _e.onMouseOver, onMouseOut = _e.onMouseOut, setReadingMode = _e.setReadingMode, setEditingMode = _e.setEditingMode;
|
|
45
45
|
var containerRef = react_1.useRef();
|
|
46
46
|
var id = mdm_sdk_1.getLastUriPart(attributeValue.uri);
|
|
47
|
-
var
|
|
48
|
-
var
|
|
47
|
+
var crosswalkDisabled = mdm_sdk_1.isCrosswalkDisabled(crosswalk);
|
|
48
|
+
var canModifyAttribute = !attributeType.system && !crosswalkDisabled;
|
|
49
|
+
var canEdit = canModifyAttribute && allowEdit && mdm_sdk_1.checkMetadataForUpdate(mdm_sdk_1.ModeTypes.EDITING, attributeType);
|
|
50
|
+
var canDelete = canModifyAttribute && allowDelete && mdm_sdk_1.checkMetadataForDelete(mdm_sdk_1.ModeTypes.EDITING, attributeType);
|
|
49
51
|
var isTemporary = mdm_sdk_1.isTempUri(attributeValue.uri);
|
|
50
52
|
var showPin = !isTemporary && ((!isReadingMode && canEdit) || attributeValue.pin);
|
|
51
53
|
var showIgnore = !isTemporary && ((!isReadingMode && canEdit) || attributeValue.ignored);
|
|
52
54
|
var color = contexts_1.useCrosswalkColor(crosswalk);
|
|
53
55
|
var _f = contexts_1.useCrosswalkHighlight(crosswalk), isHighlighted = _f.isHighlighted, isDimmed = _f.isDimmed, highlightCrosswalk = _f.highlightCrosswalk, removeHighlight = _f.removeHighlight;
|
|
54
|
-
var styles = styles_1.useStyles({
|
|
56
|
+
var styles = styles_1.useStyles({
|
|
57
|
+
variant: crosswalkDisabled ? 'outlined' : 'filled',
|
|
58
|
+
opaque: !isDimmed,
|
|
59
|
+
fullyColored: isHighlighted,
|
|
60
|
+
color: color
|
|
61
|
+
});
|
|
55
62
|
var actions = [
|
|
56
63
|
{
|
|
57
64
|
crosswalk: crosswalk,
|
|
@@ -88,8 +95,8 @@ var SimpleAttribute = function (_a) {
|
|
|
88
95
|
react_1.default.createElement("div", { className: styles.attributeValue },
|
|
89
96
|
react_1.default.createElement(DataTypeValue_1.default, { value: mdm_sdk_1.getAttributeValue(attributeValue), dataTypeDefinition: mdm_sdk_1.getAttrDataTypeDefinition(attributeType) })),
|
|
90
97
|
react_1.default.createElement("div", { className: styles.actions },
|
|
91
|
-
showPin && react_1.default.createElement(PinButton_1.default, { isPinned: attributeValue.pin, onClick: function () { return onPin({ attributeValue: attributeValue }); } }),
|
|
92
|
-
showIgnore && (react_1.default.createElement(IgnoreButton_1.default, { isIgnored: attributeValue.ignored, onClick: function () { return onIgnore({ attributeValue: attributeValue }); } })),
|
|
98
|
+
showPin && (react_1.default.createElement(PinButton_1.default, { isPinned: attributeValue.pin, onClick: function () { return onPin({ attributeValue: attributeValue }); }, disabled: !canEdit })),
|
|
99
|
+
showIgnore && (react_1.default.createElement(IgnoreButton_1.default, { isIgnored: attributeValue.ignored, onClick: function () { return onIgnore({ attributeValue: attributeValue }); }, disabled: !canEdit })),
|
|
93
100
|
isHovered && (react_1.default.createElement(DropDownMenuButton_1.default, { MenuItemRenderer: CrosswalkMenuItem_1.default, menuId: "simple-attribute-additional-actions-" + id, buttonComponent: SmallIconButton_1.SmallIconButtonWithTooltip, buttonProps: {
|
|
94
101
|
icon: MoreVert_1.default,
|
|
95
102
|
size: 'XS',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare type StylesProps = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
variant: 'filled' | 'outlined';
|
|
3
|
+
fullyColored: boolean;
|
|
4
|
+
opaque: boolean;
|
|
4
5
|
color: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"attributeValue" | "root" | "actions">;
|
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.useStyles = void 0;
|
|
4
15
|
var styles_1 = require("@material-ui/core/styles");
|
|
5
16
|
exports.useStyles = styles_1.makeStyles(function () { return ({
|
|
6
17
|
root: function (_a) {
|
|
7
|
-
var
|
|
8
|
-
return ({
|
|
9
|
-
height: '28px',
|
|
18
|
+
var fullyColored = _a.fullyColored, opaque = _a.opaque, color = _a.color, variant = _a.variant;
|
|
19
|
+
return (__assign(__assign(__assign({ height: '28px' }, (variant === 'filled' && {
|
|
10
20
|
borderRadius: '4px',
|
|
11
|
-
background:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
background: fullyColored ? color : "linear-gradient(to right, " + color + " 8px, rgba(0,0,0,0.05) 8px)"
|
|
22
|
+
})), (variant === 'outlined' && {
|
|
23
|
+
'&::after': {
|
|
24
|
+
content: '""',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
background: color,
|
|
27
|
+
borderRadius: '4px 0px 0px 4px',
|
|
28
|
+
width: '8px',
|
|
29
|
+
height: '100%',
|
|
30
|
+
pointerEvents: 'none'
|
|
31
|
+
},
|
|
32
|
+
'&::before': {
|
|
33
|
+
content: '""',
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
boxSizing: 'border-box',
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
border: fullyColored ? color + " solid 2px" : 'rgba(0,0,0,0.12) solid 1px',
|
|
38
|
+
width: '100%',
|
|
39
|
+
height: '100%',
|
|
40
|
+
pointerEvents: 'none'
|
|
41
|
+
}
|
|
42
|
+
})), { display: 'flex', alignItems: 'center', maxWidth: '230px', opacity: opaque ? 1 : 0.38, transition: 'opacity 0.3s', position: 'relative' }));
|
|
18
43
|
},
|
|
19
44
|
attributeValue: {
|
|
20
45
|
marginLeft: '16px',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
declare type Props = {
|
|
3
3
|
isIgnored: boolean;
|
|
4
4
|
onClick: () => void;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
};
|
|
6
|
-
declare const IgnoreButton: ({ isIgnored, onClick }: Props) => JSX.Element;
|
|
7
|
+
declare const IgnoreButton: ({ isIgnored, onClick, disabled }: Props) => JSX.Element;
|
|
7
8
|
export default IgnoreButton;
|
|
@@ -9,7 +9,7 @@ var Ignored_1 = __importDefault(require("../../../../icons/Ignored"));
|
|
|
9
9
|
var IgnoredOutlined_1 = __importDefault(require("../../../../icons/IgnoredOutlined"));
|
|
10
10
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
11
11
|
var IgnoreButton = function (_a) {
|
|
12
|
-
var isIgnored = _a.isIgnored, onClick = _a.onClick;
|
|
13
|
-
return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { icon: isIgnored ? Ignored_1.default : IgnoredOutlined_1.default, tooltipTitle: ui_i18n_1.default.text('Ignore'), onClick: onClick, size: "XS", disableRipple: true }));
|
|
12
|
+
var isIgnored = _a.isIgnored, onClick = _a.onClick, disabled = _a.disabled;
|
|
13
|
+
return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { disabled: disabled, showForDisabled: true, icon: isIgnored ? Ignored_1.default : IgnoredOutlined_1.default, tooltipTitle: disabled ? ui_i18n_1.default.text("You don't have permissions to ignore") : ui_i18n_1.default.text('Ignore'), onClick: onClick, size: "XS", disableRipple: true }));
|
|
14
14
|
};
|
|
15
15
|
exports.default = IgnoreButton;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
declare type Props = {
|
|
3
3
|
isPinned: boolean;
|
|
4
4
|
onClick: () => void;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
};
|
|
6
|
-
declare const PinButton: ({ isPinned, onClick }: Props) => JSX.Element;
|
|
7
|
+
declare const PinButton: ({ isPinned, onClick, disabled }: Props) => JSX.Element;
|
|
7
8
|
export default PinButton;
|
|
@@ -9,7 +9,7 @@ var Pin_1 = __importDefault(require("../../../../icons/Pin"));
|
|
|
9
9
|
var PinOutlined_1 = __importDefault(require("../../../../icons/PinOutlined"));
|
|
10
10
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
11
11
|
var PinButton = function (_a) {
|
|
12
|
-
var isPinned = _a.isPinned, onClick = _a.onClick;
|
|
13
|
-
return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { onClick: onClick, icon: isPinned ? Pin_1.default : PinOutlined_1.default, tooltipTitle: ui_i18n_1.default.text('Pin'), size: "XS", disableRipple: true }));
|
|
12
|
+
var isPinned = _a.isPinned, onClick = _a.onClick, disabled = _a.disabled;
|
|
13
|
+
return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { disabled: disabled, showForDisabled: true, onClick: onClick, icon: isPinned ? Pin_1.default : PinOutlined_1.default, tooltipTitle: disabled ? "You don't have permissions to pin" : ui_i18n_1.default.text('Pin'), size: "XS", disableRipple: true }));
|
|
14
14
|
};
|
|
15
15
|
exports.default = PinButton;
|
|
@@ -16,15 +16,19 @@ describe('Ignore button test', function () {
|
|
|
16
16
|
onClickFn = jest.fn();
|
|
17
17
|
component = enzyme_1.mount(react_1.default.createElement(IgnoreButton_1.default, { isIgnored: false, onClick: onClickFn }));
|
|
18
18
|
});
|
|
19
|
-
it('should
|
|
20
|
-
expect(getButton(component).
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
19
|
+
it('should pass button props correctly', function () {
|
|
20
|
+
expect(getButton(component).prop('onClick')).toBe(onClickFn);
|
|
21
|
+
component.setProps({ disabled: true });
|
|
22
|
+
expect(getButton(component).prop('disabled')).toBe(true);
|
|
24
23
|
});
|
|
25
24
|
it('should show correct icon', function () {
|
|
26
25
|
expect(getButton(component).prop('icon')).toBe(IgnoredOutlined_1.default);
|
|
27
26
|
component.setProps({ isIgnored: true });
|
|
28
27
|
expect(getButton(component).prop('icon')).toBe(Ignored_1.default);
|
|
29
28
|
});
|
|
29
|
+
it('should show correct tooltip', function () {
|
|
30
|
+
expect(getButton(component).prop('tooltipTitle')).toBe('Ignore');
|
|
31
|
+
component.setProps({ disabled: true });
|
|
32
|
+
expect(getButton(component).prop('tooltipTitle')).toBe("You don't have permissions to ignore");
|
|
33
|
+
});
|
|
30
34
|
});
|
|
@@ -16,15 +16,19 @@ describe('Pin button test', function () {
|
|
|
16
16
|
onClickFn = jest.fn();
|
|
17
17
|
component = enzyme_1.mount(react_1.default.createElement(PinButton_1.default, { isPinned: false, onClick: onClickFn }));
|
|
18
18
|
});
|
|
19
|
-
it('should
|
|
20
|
-
expect(getButton(component).
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
19
|
+
it('should pass button props correctly', function () {
|
|
20
|
+
expect(getButton(component).prop('onClick')).toBe(onClickFn);
|
|
21
|
+
component.setProps({ disabled: true });
|
|
22
|
+
expect(getButton(component).prop('disabled')).toBe(true);
|
|
24
23
|
});
|
|
25
24
|
it('should show correct icon', function () {
|
|
26
25
|
expect(getButton(component).prop('icon')).toBe(PinOutlined_1.default);
|
|
27
26
|
component.setProps({ isPinned: true });
|
|
28
27
|
expect(getButton(component).prop('icon')).toBe(Pin_1.default);
|
|
29
28
|
});
|
|
29
|
+
it('should show correct tooltip', function () {
|
|
30
|
+
expect(getButton(component).prop('tooltipTitle')).toBe('Pin');
|
|
31
|
+
component.setProps({ disabled: true });
|
|
32
|
+
expect(getButton(component).prop('tooltipTitle')).toBe("You don't have permissions to pin");
|
|
33
|
+
});
|
|
30
34
|
});
|
|
@@ -2,5 +2,6 @@ import React from 'react';
|
|
|
2
2
|
declare const ColoredBlock: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
color: string;
|
|
4
4
|
opacity?: number;
|
|
5
|
+
variant?: 'filled' | 'outlined';
|
|
5
6
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
6
7
|
export default ColoredBlock;
|
|
@@ -48,8 +48,8 @@ var react_1 = __importStar(require("react"));
|
|
|
48
48
|
var classnames_1 = __importDefault(require("classnames"));
|
|
49
49
|
var styles_1 = require("./styles");
|
|
50
50
|
var ColoredBlock = react_1.forwardRef(function (_a, ref) {
|
|
51
|
-
var color = _a.color, opacity = _a.opacity, children = _a.children, className = _a.className, props = __rest(_a, ["color", "opacity", "children", "className"]);
|
|
52
|
-
var styles = styles_1.useColoredItemStyles({ color: color, opacity: opacity });
|
|
51
|
+
var color = _a.color, opacity = _a.opacity, _b = _a.variant, variant = _b === void 0 ? 'filled' : _b, children = _a.children, className = _a.className, props = __rest(_a, ["color", "opacity", "variant", "children", "className"]);
|
|
52
|
+
var styles = styles_1.useColoredItemStyles({ color: color, opacity: opacity, variant: variant });
|
|
53
53
|
return (react_1.default.createElement("div", __assign({ ref: ref, className: classnames_1.default(styles.item, className) }, props), children));
|
|
54
54
|
});
|
|
55
55
|
exports.default = ColoredBlock;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.useColoredItemStyles = void 0;
|
|
4
15
|
var styles_1 = require("@material-ui/core/styles");
|
|
5
16
|
exports.useColoredItemStyles = styles_1.makeStyles({
|
|
6
17
|
item: function (_a) {
|
|
7
|
-
var color = _a.color, opacity = _a.opacity;
|
|
8
|
-
return ({
|
|
9
|
-
backgroundColor: color,
|
|
10
|
-
opacity: opacity,
|
|
11
|
-
transition: 'opacity 0.3s'
|
|
12
|
-
});
|
|
18
|
+
var color = _a.color, opacity = _a.opacity, variant = _a.variant;
|
|
19
|
+
return (__assign(__assign(__assign({}, (variant === 'filled' && { backgroundColor: color })), (variant === 'outlined' && { border: color + " solid 2px" })), { opacity: opacity, transition: 'opacity 0.3s', boxSizing: 'border-box' }));
|
|
13
20
|
}
|
|
14
21
|
});
|
|
@@ -57,14 +57,15 @@ var CrosswalkRow = function (_a) {
|
|
|
57
57
|
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata);
|
|
58
58
|
var sourceSystemLabel = mdm_sdk_1.getSourceSystemLabel(metadata, crosswalk.type);
|
|
59
59
|
var crosswalkId = mdm_sdk_1.getLastUriPart(crosswalk.uri);
|
|
60
|
+
var crosswalkDisabled = mdm_sdk_1.isCrosswalkDisabled(crosswalk);
|
|
60
61
|
var _j = react_dnd_1.useDrag({
|
|
61
62
|
item: {
|
|
62
63
|
type: 'Crosswalk',
|
|
63
64
|
crosswalk: crosswalk
|
|
64
65
|
},
|
|
65
|
-
canDrag: !
|
|
66
|
+
canDrag: !crosswalkDisabled
|
|
66
67
|
}), drag = _j[1], preview = _j[2];
|
|
67
|
-
var canDelete = !
|
|
68
|
+
var canDelete = !crosswalkDisabled && crosswalk.ownerType !== 'relation';
|
|
68
69
|
react_1.useEffect(function () {
|
|
69
70
|
preview(react_dnd_html5_backend_1.getEmptyImage(), { captureDraggingState: true });
|
|
70
71
|
}, []);
|
|
@@ -85,7 +86,7 @@ var CrosswalkRow = function (_a) {
|
|
|
85
86
|
return (react_1.default.createElement("div", { className: styles.root, ref: ref },
|
|
86
87
|
react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { size: "XXS", className: styles.focusedIcon, icon: focusable && Visibility_1.default, onClick: function () { return toggleCrosswalkFocus(); }, disabled: !focusable, tooltipTitle: focusable && ui_i18n_1.default.text('Focus') }),
|
|
87
88
|
react_1.default.createElement("div", { className: styles.crosswalkWrapper },
|
|
88
|
-
react_1.default.createElement(ColoredBlock_1.default, { ref: drag, className: styles.header, color: color, onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } },
|
|
89
|
+
react_1.default.createElement(ColoredBlock_1.default, { ref: drag, className: styles.header, color: color, variant: crosswalkDisabled ? 'outlined' : 'filled', onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } },
|
|
89
90
|
isDependent && react_1.default.createElement(NestedAttribute_1.default, { className: styles.dependentIcon }),
|
|
90
91
|
react_1.default.createElement(ArrowExpandButton_1.default, { onClick: function () { return setExpanded(function (value) { return !value; }); }, expanded: expanded }),
|
|
91
92
|
react_1.default.createElement(SourceIcon_1.default, { className: styles.sourceIcon, sourceType: crosswalk.type }),
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useCrosswalkActions = void 0;
|
|
7
4
|
var react_1 = require("react");
|
|
8
5
|
var ramda_1 = require("ramda");
|
|
9
|
-
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
10
6
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
11
7
|
var core_1 = require("../../../core");
|
|
12
8
|
var useCrosswalkActions = function (_a) {
|
|
13
9
|
var _b = _a.onLoad, onLoad = _b === void 0 ? core_1.noop : _b, _c = _a.onSuccess, onSuccess = _c === void 0 ? core_1.noop : _c, _d = _a.onError, onError = _d === void 0 ? core_1.noop : _d;
|
|
14
|
-
var
|
|
10
|
+
var handleRequest = react_1.useCallback(function (request) {
|
|
15
11
|
onLoad();
|
|
16
12
|
request
|
|
17
|
-
.then(function () {
|
|
13
|
+
.then(function (_a) {
|
|
14
|
+
var errors = _a.errors;
|
|
15
|
+
if (errors)
|
|
16
|
+
throw errors;
|
|
18
17
|
onSuccess();
|
|
19
18
|
})
|
|
20
19
|
.catch(onError);
|
|
21
20
|
}, [onLoad, onError, onSuccess]);
|
|
22
21
|
var addCrosswalkAction = react_1.useCallback(function (_a) {
|
|
23
22
|
var entity = _a.entity, contributorCrosswalk = _a.contributorCrosswalk, crosswalk = _a.crosswalk;
|
|
24
|
-
var
|
|
23
|
+
var addRequest = contributorCrosswalk
|
|
25
24
|
? mdm_sdk_1.addCrosswalkInContributor({
|
|
26
25
|
entityTypeUri: entity.type,
|
|
27
26
|
contributorCrosswalkType: contributorCrosswalk.type,
|
|
@@ -34,38 +33,32 @@ var useCrosswalkActions = function (_a) {
|
|
|
34
33
|
})
|
|
35
34
|
: mdm_sdk_1.addCrosswalk({ entityUri: entity.uri, crosswalk: crosswalk });
|
|
36
35
|
ramda_1.pipe(ramda_1.andThen(function (_a) {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, [handleAction]);
|
|
36
|
+
var response = _a[0];
|
|
37
|
+
return response;
|
|
38
|
+
}), handleRequest)(addRequest);
|
|
39
|
+
}, [handleRequest]);
|
|
42
40
|
var editCrosswalkAction = react_1.useCallback(function (_a) {
|
|
43
41
|
var entityUri = _a.entityUri, crosswalkId = _a.crosswalkId, attributeName = _a.attributeName, value = _a.value;
|
|
44
42
|
ramda_1.pipe(ramda_1.ifElse(function (_a) {
|
|
45
43
|
var value = _a.value;
|
|
46
44
|
return ramda_1.isNil(value);
|
|
47
|
-
}, mdm_sdk_1.deleteCrosswalkAttribute, mdm_sdk_1.editCrosswalkAttribute), ramda_1.andThen(function (
|
|
48
|
-
|
|
49
|
-
throw new Error(ui_i18n_1.default.text('Failed to edit crosswalk'));
|
|
45
|
+
}, mdm_sdk_1.deleteCrosswalkAttribute, mdm_sdk_1.editCrosswalkAttribute), ramda_1.andThen(function (_a) {
|
|
46
|
+
var response = _a[0];
|
|
50
47
|
return response;
|
|
51
|
-
}),
|
|
48
|
+
}), handleRequest)({
|
|
52
49
|
entityUri: entityUri,
|
|
53
50
|
crosswalkId: crosswalkId,
|
|
54
51
|
attributeName: attributeName,
|
|
55
52
|
value: value
|
|
56
53
|
});
|
|
57
|
-
}, [
|
|
54
|
+
}, [handleRequest]);
|
|
58
55
|
var deleteCrosswalkAction = react_1.useCallback(function (_a) {
|
|
59
56
|
var entityUri = _a.entityUri, crosswalkId = _a.crosswalkId;
|
|
60
|
-
ramda_1.pipe(mdm_sdk_1.deleteCrosswalk,
|
|
61
|
-
if (response.status === 'failed')
|
|
62
|
-
throw new Error(ui_i18n_1.default.text('Failed to delete crosswalk'));
|
|
63
|
-
return response;
|
|
64
|
-
}), handleAction)({
|
|
57
|
+
ramda_1.pipe(mdm_sdk_1.deleteCrosswalk, handleRequest)({
|
|
65
58
|
entityUri: entityUri,
|
|
66
59
|
crosswalkId: crosswalkId
|
|
67
60
|
});
|
|
68
|
-
}, [
|
|
61
|
+
}, [handleRequest]);
|
|
69
62
|
return {
|
|
70
63
|
addCrosswalk: addCrosswalkAction,
|
|
71
64
|
editCrosswalk: editCrosswalkAction,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.823",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@date-io/moment": "^1.3.5",
|
|
8
8
|
"@react-google-maps/api": "^2.7.0",
|
|
9
|
-
"@reltio/mdm-module": "^1.4.
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
9
|
+
"@reltio/mdm-module": "^1.4.823",
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.823",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"frontend-collective-react-dnd-scrollzone": "^1.0.2",
|
|
13
13
|
"nanoid": "^2.0.0",
|