@reltio/components 1.4.1733 → 1.4.1734
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/cjs/components/Image/ImageActionsOverlay/ImageActionsOverlay.js +5 -3
- package/cjs/components/ImageAttributesGallery/ImageAttributesGallery.js +6 -3
- package/cjs/components/ImageDetailsView/MetaInfoHeader/MetaInfoHeader.js +3 -1
- package/cjs/components/RelationEditor/RelationEditor.js +1 -1
- package/cjs/components/activityLog/activities/RelationObject/styles.d.ts +1 -1
- package/cjs/components/attributes/OvIcon/OvIcon.d.ts +1 -1
- package/cjs/components/attributes/editMode/AttributesList/AttributesList.js +6 -3
- package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +10 -8
- package/cjs/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.js +4 -4
- package/cjs/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +10 -8
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +9 -5
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.js +2 -1
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.d.ts +13 -0
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.js +14 -0
- package/cjs/components/workflow/components/WorkflowComments/styles.d.ts +1 -1
- package/cjs/contexts/ConfigPermissionsContext/index.d.ts +19 -0
- package/cjs/contexts/ConfigPermissionsContext/index.js +62 -0
- package/cjs/contexts/index.d.ts +1 -0
- package/cjs/contexts/index.js +6 -1
- package/esm/components/Image/ImageActionsOverlay/ImageActionsOverlay.js +5 -3
- package/esm/components/ImageAttributesGallery/ImageAttributesGallery.js +9 -6
- package/esm/components/ImageDetailsView/MetaInfoHeader/MetaInfoHeader.js +4 -2
- package/esm/components/RelationEditor/RelationEditor.js +2 -2
- package/esm/components/activityLog/activities/RelationObject/styles.d.ts +1 -1
- package/esm/components/attributes/OvIcon/OvIcon.d.ts +1 -1
- package/esm/components/attributes/editMode/AttributesList/AttributesList.js +7 -4
- package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +11 -9
- package/esm/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.js +6 -6
- package/esm/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +11 -9
- package/esm/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +10 -6
- package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.js +2 -1
- package/esm/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.d.ts +13 -0
- package/esm/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.js +10 -0
- package/esm/components/workflow/components/WorkflowComments/styles.d.ts +1 -1
- package/esm/contexts/ConfigPermissionsContext/index.d.ts +19 -0
- package/esm/contexts/ConfigPermissionsContext/index.js +34 -0
- package/esm/contexts/index.d.ts +1 -0
- package/esm/contexts/index.js +1 -0
- package/package.json +2 -2
|
@@ -37,12 +37,14 @@ var DropDownMenuButton_1 = __importDefault(require("../../DropDownMenuButton/Dro
|
|
|
37
37
|
var CheckedIcon_1 = require("../CheckedIcon/CheckedIcon");
|
|
38
38
|
var Download_1 = __importDefault(require("../../../icons/Download"));
|
|
39
39
|
var core_1 = require("../../../core");
|
|
40
|
+
var contexts_1 = require("../../../contexts");
|
|
40
41
|
var styles_1 = require("./styles");
|
|
41
42
|
var ImageActionsOverlay = function (props) {
|
|
42
43
|
var _a;
|
|
43
44
|
var id = props.id, _b = props.canBeSelected, canBeSelected = _b === void 0 ? false : _b, _c = props.selected, selected = _c === void 0 ? false : _c, _d = props.selectionMode, selectionMode = _d === void 0 ? false : _d, _e = props.onDeselect, onDeselect = _e === void 0 ? core_1.noop : _e, _f = props.onSelect, onSelect = _f === void 0 ? core_1.noop : _f, onShareLink = props.onShareLink, onSetAsDefault = props.onSetAsDefault, onDelete = props.onDelete, _g = props.onDownload, onDownload = _g === void 0 ? core_1.noop : _g, onClick = props.onClick;
|
|
44
45
|
var styles = (0, styles_1.useStyles)();
|
|
45
46
|
var _h = (0, react_1.useState)(false), hovered = _h[0], setHovered = _h[1];
|
|
47
|
+
var canDelete = (0, contexts_1.useAttributeValueConfigPermissions)(id).canDelete;
|
|
46
48
|
var menuItems = (0, react_1.useMemo)(function () {
|
|
47
49
|
return [
|
|
48
50
|
{
|
|
@@ -55,10 +57,10 @@ var ImageActionsOverlay = function (props) {
|
|
|
55
57
|
},
|
|
56
58
|
{
|
|
57
59
|
text: ui_i18n_1.default.text('Delete'),
|
|
58
|
-
onClick: onDelete
|
|
60
|
+
onClick: canDelete && onDelete
|
|
59
61
|
}
|
|
60
62
|
].filter((0, ramda_1.prop)('onClick'));
|
|
61
|
-
}, [onShareLink, onSetAsDefault, onDelete]);
|
|
63
|
+
}, [onShareLink, onSetAsDefault, onDelete, canDelete]);
|
|
62
64
|
var handleMouseEnter = function () { return setHovered(true); };
|
|
63
65
|
var handleMouseLeave = function () { return setHovered(false); };
|
|
64
66
|
var toggleSelected = function (selected) { return function () { return (0, ramda_1.ifElse)((0, ramda_1.equals)(true), onDeselect, onSelect)(selected); }; };
|
|
@@ -72,7 +74,7 @@ var ImageActionsOverlay = function (props) {
|
|
|
72
74
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.overlay, (_a = {},
|
|
73
75
|
_a[styles.selected] = selected,
|
|
74
76
|
_a[styles.selectionMode] = selectionMode,
|
|
75
|
-
_a)), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: selectionMode ? toggleSelected(selected) : handleClick },
|
|
77
|
+
_a)), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: selectionMode ? toggleSelected(selected) : handleClick, "data-reltio-id": "image-actions-overlay" },
|
|
76
78
|
showCheckBox && (react_1.default.createElement(CheckedIcon_1.CheckedIcon, { className: styles.checkedIcon, checked: selected, onClick: toggleSelected(selected) })),
|
|
77
79
|
showActions && (react_1.default.createElement("div", { className: styles.actions },
|
|
78
80
|
react_1.default.createElement(SmallIconButton_1.SmallIconButton, { onClick: onDownload, className: styles.actionButton, icon: Download_1.default }),
|
|
@@ -96,19 +96,22 @@ var ImageAttributesGallery = function (_a) {
|
|
|
96
96
|
onDeleteAttribute({ uri: id, attributeType: attributeType });
|
|
97
97
|
};
|
|
98
98
|
var handleDeleteSelectedItems = function () {
|
|
99
|
-
var deleteUris =
|
|
99
|
+
var deleteUris = getUrisForDelete();
|
|
100
100
|
deleteUris.forEach(function (uri) {
|
|
101
101
|
handleDelete(uri);
|
|
102
102
|
});
|
|
103
103
|
if (selectedItems.length)
|
|
104
104
|
setSelectedItems([]);
|
|
105
105
|
};
|
|
106
|
+
var _d = (0, react_1.useContext)(contexts_1.ConfigPermissionsContext), canCreate = _d.canCreate, canDelete = _d.canDelete;
|
|
106
107
|
var isGalleryMode = mode === ImageGalleryDialog_1.Mode.GALLERY_MODE;
|
|
107
108
|
var isDetailsMode = mode === ImageGalleryDialog_1.Mode.DETAILS_MODE;
|
|
108
109
|
var hasSelectedItems = selectedItems.length > 0;
|
|
109
110
|
var isHasSelectedItemsOrDetailsMode = isDetailsMode || (isGalleryMode && hasSelectedItems);
|
|
110
|
-
var
|
|
111
|
-
var
|
|
111
|
+
var getUrisForDelete = function () { return (isGalleryMode ? selectedItems : [currentAttributeValueUri]); };
|
|
112
|
+
var areAllItemsDeletable = getUrisForDelete().every(function (uri) { return (0, mdm_sdk_1.isTempUri)(uri) || canDelete; });
|
|
113
|
+
var isShowDeleteButton = !isViewMode && isHasSelectedItemsOrDetailsMode && areAllItemsDeletable;
|
|
114
|
+
var isShowUploadButton = !isViewMode && canCreate && (isDetailsMode || (isGalleryMode && !hasSelectedItems));
|
|
112
115
|
var headerLeft = isGalleryMode && hasSelectedItems && (react_1.default.createElement(HeaderLeft_1.HeaderLeft, { items: imageItems, selectedItems: selectedItems, onClearAll: handleClearAll, onSelectAll: handleSelectAll }));
|
|
113
116
|
var headerRight = (react_1.default.createElement(HeaderRight_1.HeaderRight, { onDelete: isShowDeleteButton ? handleDeleteSelectedItems : undefined, onDownload: isHasSelectedItemsOrDetailsMode ? handleDownloadSelectedItems : undefined, onShare: isDetailsMode ? handleSharedCurrentItem : undefined, onUpload: isShowUploadButton ? onUpload : undefined }));
|
|
114
117
|
var handleClickByImage = function (id) {
|
|
@@ -36,12 +36,14 @@ var Divider_1 = __importDefault(require("@mui/material/Divider"));
|
|
|
36
36
|
var MoreAttributesButton_1 = __importDefault(require("../../attributes/editMode/MoreAttributesButton"));
|
|
37
37
|
var helpers_1 = require("../helpers");
|
|
38
38
|
var styles_1 = require("./styles");
|
|
39
|
+
var contexts_1 = require("../../../contexts");
|
|
39
40
|
var MetaInfoHeader = function (_a) {
|
|
40
41
|
var _b;
|
|
41
42
|
var attributeType = _a.attributeType, onAddAttributes = _a.onAddAttributes, uri = _a.uri;
|
|
42
43
|
var styles = (0, styles_1.useStyles)();
|
|
43
44
|
var moreAttrTypes = (0, helpers_1.getMoreAttrTypes)(attributeType);
|
|
44
|
-
var
|
|
45
|
+
var canCreate = (0, react_1.useContext)(contexts_1.ConfigPermissionsContext).canCreate;
|
|
46
|
+
var canAdd = canCreate && Boolean(onAddAttributes);
|
|
45
47
|
var handleApply = function (attrTypes) {
|
|
46
48
|
if (onAddAttributes) {
|
|
47
49
|
onAddAttributes(attrTypes.map(function (attributeType) { return ({ attributeType: attributeType, parentUri: uri }); }));
|
|
@@ -197,7 +197,7 @@ var RelationEditor = function (_a) {
|
|
|
197
197
|
react_1.default.createElement("div", { className: styles.editor },
|
|
198
198
|
react_1.default.createElement(Typography_1.default, { className: styles.title }, isNew ? ui_i18n_1.default.text('Add new item') : ui_i18n_1.default.text('Edit item')),
|
|
199
199
|
defaultRelationType === null && (react_1.default.createElement(ConnectionRelationTypeSelector_1.default, { className: styles.item, relation: connection.relation, inRelationTypes: inRelationTypes, outRelationTypes: outRelationTypes, onChange: onRelationTypeChange })),
|
|
200
|
-
Boolean(relationType) && (react_1.default.createElement(
|
|
200
|
+
Boolean(relationType) && (react_1.default.createElement(contexts_1.ConfigPermissionsContextProvider, null,
|
|
201
201
|
react_1.default.createElement("div", { ref: ref, className: errorClassName },
|
|
202
202
|
react_1.default.createElement(ErrorWrapper_1.default, { errorMessage: errorMessage },
|
|
203
203
|
react_1.default.createElement(EntitySelector_1.default, { className: (0, classnames_1.default)(styles.item, (_b = {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"link" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"link" | "delimiter" | "relationship">;
|
|
@@ -26,7 +26,7 @@ export declare const ChipWithTooltip: React.ForwardRefExoticComponent<import("pr
|
|
|
26
26
|
variant?: import("@mui/types").OverridableStringUnion<"filled" | "outlined", import("@mui/material/Chip").ChipPropsVariantOverrides>;
|
|
27
27
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
28
28
|
ref?: React.Ref<HTMLDivElement>;
|
|
29
|
-
}, "label" | "icon" | "children" | "size" | "color" | "disabled" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "tabIndex" | "variant" | "
|
|
29
|
+
}, "label" | "icon" | "children" | "size" | "color" | "disabled" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "tabIndex" | "variant" | "deleteIcon" | "avatar" | "clickable" | "onDelete" | "skipFocusWhenDisabled">>;
|
|
30
30
|
type ComplexWithLabel = NestedAttributeValue | ReferenceAttributeValue;
|
|
31
31
|
type Props = {
|
|
32
32
|
className?: string;
|
|
@@ -65,11 +65,14 @@ var AttributesList = function (_a) {
|
|
|
65
65
|
(0, react_1.useEffect)(function () {
|
|
66
66
|
setHasDeletionsMap({});
|
|
67
67
|
}, [parentUri]);
|
|
68
|
-
var
|
|
69
|
-
var
|
|
68
|
+
var canCreate = (0, react_1.useContext)(contexts_1.ConfigPermissionsContext).canCreate;
|
|
69
|
+
var canCreateParentAttrType = (0, react_1.useMemo)(function () { return canCreate && parentAttributeType && (0, mdm_sdk_1.checkCanCreateAttribute)({ attributeType: parentAttributeType, mode: mode }); }, [parentAttributeType, mode, canCreate]);
|
|
70
|
+
var creatableAttrTypes = (0, react_1.useMemo)(function () { return (canCreate ? (0, mdm_sdk_1.getCreatableAttributeTypes)(mode, attrTypes) : []); }, [attrTypes, mode, canCreate]);
|
|
70
71
|
var moreAttrTypes = (0, helpers_1.getMoreAttrTypes)(creatableAttrTypes, entity, showEmptyEditors, hasDeletionsMap);
|
|
71
72
|
var pinnedAttributes = (0, react_1.useContext)(PinnedAttributesContext_1.PinnedAttributesContext);
|
|
72
|
-
var pagersData = (0, react_1.useMemo)(function () {
|
|
73
|
+
var pagersData = (0, react_1.useMemo)(function () {
|
|
74
|
+
return (0, mdm_sdk_1.getAttributesListForEditMode)(attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes, canCreate);
|
|
75
|
+
}, [attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes, canCreate]);
|
|
73
76
|
var _e = (0, react_1.useMemo)(function () { return (0, attributesView_1.splitPagersData)(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
74
77
|
var onAddMoreAttributes = (0, react_1.useCallback)(function (attributeTypes) {
|
|
75
78
|
onAddAttributes(attributeTypes.map(function (attributeType) { return ({
|
|
@@ -73,15 +73,17 @@ var ComplexAttribute = function (_a) {
|
|
|
73
73
|
(0, react_1.useEffect)(function () {
|
|
74
74
|
setExpanded(defaultExpand);
|
|
75
75
|
}, [defaultExpand]);
|
|
76
|
+
var configCanDelete = (0, contexts_1.useAttributeValueConfigPermissions)(attributeValue.uri).canDelete;
|
|
76
77
|
var canDelete = (0, react_1.useMemo)(function () {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
return configCanDelete &&
|
|
79
|
+
(0, mdm_sdk_1.checkCanDeleteAttribute)({
|
|
80
|
+
attributeType: attributeType,
|
|
81
|
+
attributeValue: attributeValue,
|
|
82
|
+
mode: mode,
|
|
83
|
+
metadata: metadata,
|
|
84
|
+
isReltioCrosswalk: (0, mdm_sdk_1.isReltioCrosswalk)(crosswalks, attributeValue)
|
|
85
|
+
});
|
|
86
|
+
}, [attributeType, attributeValue, mode, metadata, crosswalks, configCanDelete]);
|
|
85
87
|
var showDeleteButton = !deleted && !hideDeleteButton && !!onDeleteAttribute && canDelete;
|
|
86
88
|
var onDeleteThis = function () { return onDeleteAttribute({ uri: uri, attributeType: attributeType, attributeValue: attributeValue }); };
|
|
87
89
|
var hasDescendantsWithErrors = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.hasAttributeDescendantsWithErrors)(attributeValue, errors); }, [errors, attributeValue]);
|
|
@@ -45,6 +45,7 @@ var ImageAttributesLine = function (_a) {
|
|
|
45
45
|
var setDefaultProfilePic = (0, contexts_1.useMdmAction)('setDefaultProfilePicForModifiedEntity');
|
|
46
46
|
var entity = (0, contexts_1.useMdmEntity)() || defaultEntity;
|
|
47
47
|
var defaultProfilePic = (0, contexts_1.useMdmModifiedEntityDefaultProfilePic)(entity.uri);
|
|
48
|
+
var canCreate = (0, react_1.useContext)(contexts_1.ConfigPermissionsContext).canCreate;
|
|
48
49
|
var toggleVisibilityUploadDialog = (0, react_1.useCallback)(function () {
|
|
49
50
|
setIsVisibleUploadDialog(function (visible) { return !visible; });
|
|
50
51
|
}, []);
|
|
@@ -100,10 +101,9 @@ var ImageAttributesLine = function (_a) {
|
|
|
100
101
|
};
|
|
101
102
|
return renderImage;
|
|
102
103
|
};
|
|
103
|
-
return (react_1.default.createElement("div", { className: styles.root },
|
|
104
|
-
react_1.default.createElement(ImageAttributesLine_1.default, { attributeValues: attributeValues, attributeType: attributeType, renderImage: renderImage, overlay: true, countFixedItems: 1, onUpload: toggleVisibilityUploadDialog, onDeleteAttribute: handleDeleteAttribute, imageSize: imageSize, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: paging, parentUri: parentUri, showNonOv: showNonOv },
|
|
105
|
-
react_1.default.createElement(
|
|
106
|
-
react_1.default.createElement(SmallIconButton_1.SmallIconButton, { className: styles.uploadButton, iconClassName: styles.uploadIcon, icon: CloudUpload_1.default, "data-reltio-id": "reltio-upload-image-button" }))),
|
|
104
|
+
return (react_1.default.createElement("div", { className: styles.root, "data-reltio-id": "image-line-edit-mode" },
|
|
105
|
+
react_1.default.createElement(ImageAttributesLine_1.default, { attributeValues: attributeValues, attributeType: attributeType, renderImage: renderImage, overlay: true, countFixedItems: canCreate ? 1 : 0, onUpload: toggleVisibilityUploadDialog, onDeleteAttribute: handleDeleteAttribute, imageSize: imageSize, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: paging, parentUri: parentUri, showNonOv: showNonOv }, canCreate && (react_1.default.createElement("div", { className: styles.uploadContainer, onClick: toggleVisibilityUploadDialog },
|
|
106
|
+
react_1.default.createElement(SmallIconButton_1.SmallIconButton, { className: styles.uploadButton, iconClassName: styles.uploadIcon, icon: CloudUpload_1.default, "data-reltio-id": "reltio-upload-image-button" })))),
|
|
107
107
|
react_1.default.createElement(UploadImageDialog_1.UploadImageDialog, { open: isVisibleUploadDialog, onUpload: handleAddAttributes, onClose: toggleVisibilityUploadDialog })));
|
|
108
108
|
};
|
|
109
109
|
exports.default = ImageAttributesLine;
|
|
@@ -132,15 +132,17 @@ var ReferenceAttribute = function (props) {
|
|
|
132
132
|
onChangeEntity(newEntity);
|
|
133
133
|
entityCreated(newEntity);
|
|
134
134
|
}, [newEntityAttrTypesSelectionStrategy, mode, referencedEntityType, metadata, onChangeEntity, entityCreated]);
|
|
135
|
+
var _c = (0, contexts_1.useAttributeValueConfigPermissions)(attributeValue.uri), configCanCreate = _c.canCreate, configCanUpdate = _c.canUpdate;
|
|
135
136
|
var canChangeReferencedEntity = (0, react_1.useMemo)(function () {
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
return configCanUpdate &&
|
|
138
|
+
(0, mdm_sdk_1.checkCanEditAttribute)({
|
|
139
|
+
attributeType: attributeType,
|
|
140
|
+
attributeValue: attributeValue,
|
|
141
|
+
mode: mode,
|
|
142
|
+
isReltioCrosswalk: (0, mdm_sdk_1.isReltioCrosswalk)(crosswalks, attributeValue)
|
|
143
|
+
});
|
|
144
|
+
}, [attributeType, attributeValue, mode, crosswalks, configCanUpdate]);
|
|
145
|
+
var canCreateReferencedEntity = (0, react_1.useMemo)(function () { return configCanCreate && (0, mdm_sdk_1.checkMetadataForCreate)(mode, referencedEntityType); }, [mode, referencedEntityType, configCanCreate]);
|
|
144
146
|
var errorMessage = (0, mdm_sdk_1.getErrorMessage)(referencedEntityMissedError);
|
|
145
147
|
return (react_1.default.createElement(ComplexAttribute_1.default, __assign({}, ownProps, { label: (0, mdm_sdk_1.getLabel)(label), attributeTypesList: editableAttrTypes, crosswalks: allCrosswalks, metadata: metadata }),
|
|
146
148
|
react_1.default.createElement("div", { ref: ref, className: errorClassName },
|
|
@@ -67,6 +67,7 @@ var HOCs_1 = require("../../../../HOCs");
|
|
|
67
67
|
var contexts_1 = require("../../../../contexts");
|
|
68
68
|
var hooks_1 = require("../../../../hooks");
|
|
69
69
|
var useAutopopulationContextValue_1 = require("./useAutopopulationContextValue");
|
|
70
|
+
var useAttributeValuePermissions_1 = require("./useAttributeValuePermissions");
|
|
70
71
|
var styles_1 = require("./styles");
|
|
71
72
|
var AsyncMountPlaceholder = function () {
|
|
72
73
|
var styles = (0, styles_1.useStyles)();
|
|
@@ -79,13 +80,16 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
79
80
|
var deleted = state === 'deleted';
|
|
80
81
|
var edited = state === 'edited';
|
|
81
82
|
var isEditableMode = (0, mdm_sdk_1.isEditableMode)(mode);
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
var _e = (0, useAttributeValuePermissions_1.useAttributeValuePermissions)({
|
|
84
|
+
attributeValue: attributeValue,
|
|
85
|
+
attributeType: attributeType,
|
|
86
|
+
mode: mode,
|
|
87
|
+
isReltioCrosswalk: isReltioCrosswalk
|
|
88
|
+
}), canCreate = _e.canCreate, canEdit = _e.canEdit, canDelete = _e.canDelete;
|
|
85
89
|
var showToEdit = canEdit && isEditableMode;
|
|
86
90
|
var errorMessage = (0, mdm_sdk_1.getErrorMessage)(ownError);
|
|
87
91
|
var dependentLookupEditorContext = (0, contexts_1.useMdmDependentLookupEditorContext)(attributeValue, attributeType);
|
|
88
|
-
var
|
|
92
|
+
var _f = (0, hooks_1.useScrollToAttributeError)({ highlightedError: highlightedError, isSimple: true }), ref = _f.ref, errorClassName = _f.errorClassName;
|
|
89
93
|
(0, react_1.useEffect)(function () {
|
|
90
94
|
// when editor is empty but has default lookup code, onChangeAttribute will be called by useLookupsResolver
|
|
91
95
|
if (isEmptyEditor && (0, mdm_sdk_1.isDependentLookupAttrType)(attributeType) && !(0, ramda_1.has)('lookupCode', attributeValue)) {
|
|
@@ -130,7 +134,7 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
130
134
|
"(",
|
|
131
135
|
ui_i18n_1.default.text('edited'),
|
|
132
136
|
")")),
|
|
133
|
-
showAddButton && (react_1.default.createElement(SmallIconButton_1.default, { icon: Add_1.default, onClick: onAddOneMore, size: "L", className: (0, classnames_1.default)(styles.addButton, styles.button) })),
|
|
137
|
+
showAddButton && (react_1.default.createElement(SmallIconButton_1.default, { icon: Add_1.default, onClick: onAddOneMore, size: "L", className: (0, classnames_1.default)(styles.addButton, styles.button), "data-reltio-id": "reltio-add-one-more-simple-attribute-button" })),
|
|
134
138
|
additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
|
|
135
139
|
showDeleteButton && (react_1.default.createElement(SmallIconButton_1.default, { className: styles.button, icon: Delete_1.default, onClick: onDelete, size: "L", "data-reltio-id": "reltio-delete-simple-attribute-button" })))));
|
|
136
140
|
};
|
|
@@ -23,7 +23,8 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
23
23
|
'editor-read-only-value': {
|
|
24
24
|
marginLeft: '12px',
|
|
25
25
|
display: 'flex',
|
|
26
|
-
alignItems: 'center'
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
color: theme.palette.text.primary
|
|
27
28
|
},
|
|
28
29
|
'editor-actions': {
|
|
29
30
|
display: 'flex',
|
package/cjs/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AttributeType, Mode, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
2
|
+
type Props = {
|
|
3
|
+
attributeType: AttributeType;
|
|
4
|
+
attributeValue: SimpleAttributeValue;
|
|
5
|
+
isReltioCrosswalk: boolean;
|
|
6
|
+
mode: Mode;
|
|
7
|
+
};
|
|
8
|
+
export declare const useAttributeValuePermissions: ({ attributeType, attributeValue, isReltioCrosswalk, mode }: Props) => {
|
|
9
|
+
canCreate: boolean;
|
|
10
|
+
canEdit: any;
|
|
11
|
+
canDelete: any;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/cjs/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAttributeValuePermissions = void 0;
|
|
4
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
5
|
+
var contexts_1 = require("../../../../contexts");
|
|
6
|
+
var useAttributeValuePermissions = function (_a) {
|
|
7
|
+
var attributeType = _a.attributeType, attributeValue = _a.attributeValue, isReltioCrosswalk = _a.isReltioCrosswalk, mode = _a.mode;
|
|
8
|
+
var _b = (0, contexts_1.useAttributeValueConfigPermissions)(attributeValue.uri), configCanCreate = _b.canCreate, configCanUpdate = _b.canUpdate, configCanDelete = _b.canDelete;
|
|
9
|
+
var canCreate = configCanCreate && (0, mdm_sdk_1.checkCanCreateAttribute)({ attributeType: attributeType, mode: mode });
|
|
10
|
+
var canEdit = configCanUpdate && (0, mdm_sdk_1.checkCanEditAttribute)({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
11
|
+
var canDelete = configCanDelete && (0, mdm_sdk_1.checkCanDeleteAttribute)({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
12
|
+
return { canCreate: canCreate, canEdit: canEdit, canDelete: canDelete };
|
|
13
|
+
};
|
|
14
|
+
exports.useAttributeValuePermissions = useAttributeValuePermissions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useCommentStyles: (props?: any) => import("@mui/styles").ClassNameMap<"date" | "icon" | "comment" | "text" | "info" | "avatar" | "firstLine" | "author">;
|
|
2
|
-
export declare const useCollapsedCommentsStyles: (props?: any) => import("@mui/styles").ClassNameMap<"
|
|
2
|
+
export declare const useCollapsedCommentsStyles: (props?: any) => import("@mui/styles").ClassNameMap<"circleButton" | "delimiter">;
|
|
3
3
|
export declare const useWorkflowStyles: (props?: any) => import("@mui/styles").ClassNameMap<"title" | "container" | "commentsContainer" | "filledInputRoot" | "modeSwitcherWrapper" | "sendButton">;
|
|
4
4
|
export declare const useExpandedComments: (props?: any) => import("@mui/styles").ClassNameMap<"messageContainer">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewExtension } from '@reltio/mdm-sdk';
|
|
3
|
+
type ConfigPermissionsContextValue = {
|
|
4
|
+
canCreate: boolean;
|
|
5
|
+
canUpdate: boolean;
|
|
6
|
+
canDelete: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const ConfigPermissionsContext: React.Context<ConfigPermissionsContextValue>;
|
|
9
|
+
type Props = {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
view?: ViewExtension;
|
|
12
|
+
};
|
|
13
|
+
declare const ConfigPermissionsContextProvider: ({ children, view }: Props) => JSX.Element;
|
|
14
|
+
declare const useAttributeValueConfigPermissions: (attributeValueUri: string) => {
|
|
15
|
+
canCreate: boolean;
|
|
16
|
+
canUpdate: any;
|
|
17
|
+
canDelete: any;
|
|
18
|
+
};
|
|
19
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.useAttributeValueConfigPermissions = exports.ConfigPermissionsContextProvider = exports.ConfigPermissionsContext = void 0;
|
|
27
|
+
var react_1 = __importStar(require("react"));
|
|
28
|
+
var hooks_1 = require("../../hooks");
|
|
29
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
30
|
+
var defaultValue = {
|
|
31
|
+
canCreate: true,
|
|
32
|
+
canUpdate: true,
|
|
33
|
+
canDelete: true
|
|
34
|
+
};
|
|
35
|
+
var ConfigPermissionsContext = react_1.default.createContext(defaultValue);
|
|
36
|
+
exports.ConfigPermissionsContext = ConfigPermissionsContext;
|
|
37
|
+
ConfigPermissionsContext.displayName = 'ConfigPermissionsContext';
|
|
38
|
+
var ConfigPermissionsContextProvider = function (_a) {
|
|
39
|
+
var children = _a.children, view = _a.view;
|
|
40
|
+
var _b = (0, hooks_1.useConfigPermissions)(), canCreate = _b.canCreate, canDelete = _b.canDelete, canUpdate = _b.canUpdate;
|
|
41
|
+
var value = (0, react_1.useMemo)(function () {
|
|
42
|
+
return view
|
|
43
|
+
? {
|
|
44
|
+
canCreate: canCreate(view),
|
|
45
|
+
canUpdate: canUpdate(view),
|
|
46
|
+
canDelete: canDelete(view)
|
|
47
|
+
}
|
|
48
|
+
: defaultValue;
|
|
49
|
+
}, [view, canCreate, canUpdate, canDelete]);
|
|
50
|
+
return react_1.default.createElement(ConfigPermissionsContext.Provider, { value: value }, children);
|
|
51
|
+
};
|
|
52
|
+
exports.ConfigPermissionsContextProvider = ConfigPermissionsContextProvider;
|
|
53
|
+
var useAttributeValueConfigPermissions = function (attributeValueUri) {
|
|
54
|
+
var _a = (0, react_1.useContext)(ConfigPermissionsContext), canCreate = _a.canCreate, canUpdate = _a.canUpdate, canDelete = _a.canDelete;
|
|
55
|
+
var isNew = (0, mdm_sdk_1.isTempUri)(attributeValueUri);
|
|
56
|
+
return (0, react_1.useMemo)(function () { return ({
|
|
57
|
+
canCreate: canCreate,
|
|
58
|
+
canUpdate: isNew || canUpdate,
|
|
59
|
+
canDelete: isNew || canDelete
|
|
60
|
+
}); }, [isNew, canCreate, canUpdate, canDelete]);
|
|
61
|
+
};
|
|
62
|
+
exports.useAttributeValueConfigPermissions = useAttributeValueConfigPermissions;
|
package/cjs/contexts/index.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export { FeaturesContext } from './FeaturesContext';
|
|
|
31
31
|
export { DependentLookupAutopopulationContext } from './DependentLookupAutopopulationContext';
|
|
32
32
|
export { PageRequestsAbortingContext } from './PageRequestsAbortingContext';
|
|
33
33
|
export { ActionsHookProvider, useActionsHook } from './ActionsHookContext';
|
|
34
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions } from './ConfigPermissionsContext';
|
|
34
35
|
export * from './MdmModuleContext';
|
package/cjs/contexts/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useActionsHook = exports.ActionsHookProvider = exports.PageRequestsAbortingContext = exports.DependentLookupAutopopulationContext = exports.FeaturesContext = exports.LabelsContext = exports.UrlGeneratorsContext = exports.isHighlightedAttributeType = exports.isHighlightedErrorType = exports.ScrollType = exports.ScrollToElementProvider = exports.ScrollToElementContext = exports.SearchValueContext = exports.InterceptHandlersContext = exports.HighlightedValuesContext = exports.SnackbarContext = exports.SearchFiltersContext = exports.useReloadFacet = exports.ReloadFacetProvider = exports.useReloadAllFacets = exports.SandboxAPIContext = exports.EntityContext = exports.RelatedObjectUrisContext = exports.WorkflowTasksContext = exports.useEntityLoadingIndication = exports.EntityLoadingIndicationProvider = exports.EntityMarkerContext = exports.useAttributeExpanded = exports.ExpandedAttributesProvider = exports.useHighlightedCrosswalks = exports.useCrosswalkHighlight = exports.useCrosswalkFocus = exports.useCrosswalkColor = exports.CrosswalksDisplayProvider = exports.EntitiesMapContext = exports.IdContext = exports.ProfilePerspectiveViewContext = exports.usePerspectivesSettings = exports.PerspectivesSettingsContext = exports.PivotingAttributeContext = exports.UsersContext = exports.CollaborationContextProvider = exports.CollaborationContext = exports.BlockImageGalleryDialogContext = exports.ViewIdContext = exports.PopupBoundariesContext = exports.HistoryDiffContext = exports.AsyncMountContext = void 0;
|
|
17
|
+
exports.ConfigPermissionsContextProvider = exports.ConfigPermissionsContext = exports.useActionsHook = exports.ActionsHookProvider = exports.PageRequestsAbortingContext = exports.DependentLookupAutopopulationContext = exports.FeaturesContext = exports.LabelsContext = exports.UrlGeneratorsContext = exports.isHighlightedAttributeType = exports.isHighlightedErrorType = exports.ScrollType = exports.ScrollToElementProvider = exports.ScrollToElementContext = exports.SearchValueContext = exports.InterceptHandlersContext = exports.HighlightedValuesContext = exports.SnackbarContext = exports.SearchFiltersContext = exports.useReloadFacet = exports.ReloadFacetProvider = exports.useReloadAllFacets = exports.SandboxAPIContext = exports.EntityContext = exports.RelatedObjectUrisContext = exports.WorkflowTasksContext = exports.useEntityLoadingIndication = exports.EntityLoadingIndicationProvider = exports.EntityMarkerContext = exports.useAttributeExpanded = exports.ExpandedAttributesProvider = exports.useHighlightedCrosswalks = exports.useCrosswalkHighlight = exports.useCrosswalkFocus = exports.useCrosswalkColor = exports.CrosswalksDisplayProvider = exports.EntitiesMapContext = exports.IdContext = exports.ProfilePerspectiveViewContext = exports.usePerspectivesSettings = exports.PerspectivesSettingsContext = exports.PivotingAttributeContext = exports.UsersContext = exports.CollaborationContextProvider = exports.CollaborationContext = exports.BlockImageGalleryDialogContext = exports.ViewIdContext = exports.PopupBoundariesContext = exports.HistoryDiffContext = exports.AsyncMountContext = void 0;
|
|
18
|
+
exports.useAttributeValueConfigPermissions = void 0;
|
|
18
19
|
var AsyncMountContext_1 = require("./AsyncMountContext");
|
|
19
20
|
Object.defineProperty(exports, "AsyncMountContext", { enumerable: true, get: function () { return AsyncMountContext_1.AsyncMountContext; } });
|
|
20
21
|
var HistoryAppearanceContext_1 = require("./HistoryAppearanceContext");
|
|
@@ -96,4 +97,8 @@ Object.defineProperty(exports, "PageRequestsAbortingContext", { enumerable: true
|
|
|
96
97
|
var ActionsHookContext_1 = require("./ActionsHookContext");
|
|
97
98
|
Object.defineProperty(exports, "ActionsHookProvider", { enumerable: true, get: function () { return ActionsHookContext_1.ActionsHookProvider; } });
|
|
98
99
|
Object.defineProperty(exports, "useActionsHook", { enumerable: true, get: function () { return ActionsHookContext_1.useActionsHook; } });
|
|
100
|
+
var ConfigPermissionsContext_1 = require("./ConfigPermissionsContext");
|
|
101
|
+
Object.defineProperty(exports, "ConfigPermissionsContext", { enumerable: true, get: function () { return ConfigPermissionsContext_1.ConfigPermissionsContext; } });
|
|
102
|
+
Object.defineProperty(exports, "ConfigPermissionsContextProvider", { enumerable: true, get: function () { return ConfigPermissionsContext_1.ConfigPermissionsContextProvider; } });
|
|
103
|
+
Object.defineProperty(exports, "useAttributeValueConfigPermissions", { enumerable: true, get: function () { return ConfigPermissionsContext_1.useAttributeValueConfigPermissions; } });
|
|
99
104
|
__exportStar(require("./MdmModuleContext"), exports);
|
|
@@ -9,12 +9,14 @@ import DropDownMenuButton from '../../DropDownMenuButton/DropDownMenuButton';
|
|
|
9
9
|
import { CheckedIcon } from '../CheckedIcon/CheckedIcon';
|
|
10
10
|
import DownloadIcon from '../../../icons/Download';
|
|
11
11
|
import { noop } from '../../../core';
|
|
12
|
+
import { useAttributeValueConfigPermissions } from '../../../contexts';
|
|
12
13
|
import { useStyles } from './styles';
|
|
13
14
|
var ImageActionsOverlay = function (props) {
|
|
14
15
|
var _a;
|
|
15
16
|
var id = props.id, _b = props.canBeSelected, canBeSelected = _b === void 0 ? false : _b, _c = props.selected, selected = _c === void 0 ? false : _c, _d = props.selectionMode, selectionMode = _d === void 0 ? false : _d, _e = props.onDeselect, onDeselect = _e === void 0 ? noop : _e, _f = props.onSelect, onSelect = _f === void 0 ? noop : _f, onShareLink = props.onShareLink, onSetAsDefault = props.onSetAsDefault, onDelete = props.onDelete, _g = props.onDownload, onDownload = _g === void 0 ? noop : _g, onClick = props.onClick;
|
|
16
17
|
var styles = useStyles();
|
|
17
18
|
var _h = useState(false), hovered = _h[0], setHovered = _h[1];
|
|
19
|
+
var canDelete = useAttributeValueConfigPermissions(id).canDelete;
|
|
18
20
|
var menuItems = useMemo(function () {
|
|
19
21
|
return [
|
|
20
22
|
{
|
|
@@ -27,10 +29,10 @@ var ImageActionsOverlay = function (props) {
|
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
text: i18n.text('Delete'),
|
|
30
|
-
onClick: onDelete
|
|
32
|
+
onClick: canDelete && onDelete
|
|
31
33
|
}
|
|
32
34
|
].filter(prop('onClick'));
|
|
33
|
-
}, [onShareLink, onSetAsDefault, onDelete]);
|
|
35
|
+
}, [onShareLink, onSetAsDefault, onDelete, canDelete]);
|
|
34
36
|
var handleMouseEnter = function () { return setHovered(true); };
|
|
35
37
|
var handleMouseLeave = function () { return setHovered(false); };
|
|
36
38
|
var toggleSelected = function (selected) { return function () { return ifElse(equals(true), onDeselect, onSelect)(selected); }; };
|
|
@@ -44,7 +46,7 @@ var ImageActionsOverlay = function (props) {
|
|
|
44
46
|
return (React.createElement("div", { className: classnames(styles.overlay, (_a = {},
|
|
45
47
|
_a[styles.selected] = selected,
|
|
46
48
|
_a[styles.selectionMode] = selectionMode,
|
|
47
|
-
_a)), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: selectionMode ? toggleSelected(selected) : handleClick },
|
|
49
|
+
_a)), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: selectionMode ? toggleSelected(selected) : handleClick, "data-reltio-id": "image-actions-overlay" },
|
|
48
50
|
showCheckBox && (React.createElement(CheckedIcon, { className: styles.checkedIcon, checked: selected, onClick: toggleSelected(selected) })),
|
|
49
51
|
showActions && (React.createElement("div", { className: styles.actions },
|
|
50
52
|
React.createElement(SmallIconButton, { onClick: onDownload, className: styles.actionButton, icon: DownloadIcon }),
|
|
@@ -8,15 +8,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
10
|
/* eslint-disable indent */
|
|
11
|
-
import React, { useEffect, useState } from 'react';
|
|
11
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
12
12
|
import { filter, pipe, pluck, propEq } from 'ramda';
|
|
13
|
-
import { getImageAttributeOvThumbnailUrl, getImageAttributeOvUrl } from '@reltio/mdm-sdk';
|
|
13
|
+
import { getImageAttributeOvThumbnailUrl, getImageAttributeOvUrl, isTempUri } from '@reltio/mdm-sdk';
|
|
14
14
|
import { ImageDetailsView } from '../ImageDetailsView/ImageDetailsView';
|
|
15
15
|
import { ImageGalleryDialog, Mode } from '../ImageGalleryDialog/ImageGalleryDialog';
|
|
16
16
|
import { GalleryView } from './GalleryView/GalleryView';
|
|
17
17
|
import { HeaderLeft } from './HeaderLeft/HeaderLeft';
|
|
18
18
|
import { HeaderRight } from './HeaderRight/HeaderRight';
|
|
19
|
-
import { useMdmIsViewMode } from '../../contexts';
|
|
19
|
+
import { ConfigPermissionsContext, useMdmIsViewMode } from '../../contexts';
|
|
20
20
|
var ImageAttributesGallery = function (_a) {
|
|
21
21
|
var attributeValues = _a.attributeValues, open = _a.open, onClose = _a.onClose, currentAttributeValueUri = _a.currentAttributeValueUri, setCurrentAttributeValueUri = _a.setCurrentAttributeValueUri, attributeType = _a.attributeType, onDownload = _a.onDownload, onShareLink = _a.onShareLink, onSetAsDefault = _a.onSetAsDefault, onUpload = _a.onUpload, onDeleteAttribute = _a.onDeleteAttribute;
|
|
22
22
|
var _b = useState([]), selectedItems = _b[0], setSelectedItems = _b[1];
|
|
@@ -71,19 +71,22 @@ var ImageAttributesGallery = function (_a) {
|
|
|
71
71
|
onDeleteAttribute({ uri: id, attributeType: attributeType });
|
|
72
72
|
};
|
|
73
73
|
var handleDeleteSelectedItems = function () {
|
|
74
|
-
var deleteUris =
|
|
74
|
+
var deleteUris = getUrisForDelete();
|
|
75
75
|
deleteUris.forEach(function (uri) {
|
|
76
76
|
handleDelete(uri);
|
|
77
77
|
});
|
|
78
78
|
if (selectedItems.length)
|
|
79
79
|
setSelectedItems([]);
|
|
80
80
|
};
|
|
81
|
+
var _d = useContext(ConfigPermissionsContext), canCreate = _d.canCreate, canDelete = _d.canDelete;
|
|
81
82
|
var isGalleryMode = mode === Mode.GALLERY_MODE;
|
|
82
83
|
var isDetailsMode = mode === Mode.DETAILS_MODE;
|
|
83
84
|
var hasSelectedItems = selectedItems.length > 0;
|
|
84
85
|
var isHasSelectedItemsOrDetailsMode = isDetailsMode || (isGalleryMode && hasSelectedItems);
|
|
85
|
-
var
|
|
86
|
-
var
|
|
86
|
+
var getUrisForDelete = function () { return (isGalleryMode ? selectedItems : [currentAttributeValueUri]); };
|
|
87
|
+
var areAllItemsDeletable = getUrisForDelete().every(function (uri) { return isTempUri(uri) || canDelete; });
|
|
88
|
+
var isShowDeleteButton = !isViewMode && isHasSelectedItemsOrDetailsMode && areAllItemsDeletable;
|
|
89
|
+
var isShowUploadButton = !isViewMode && canCreate && (isDetailsMode || (isGalleryMode && !hasSelectedItems));
|
|
87
90
|
var headerLeft = isGalleryMode && hasSelectedItems && (React.createElement(HeaderLeft, { items: imageItems, selectedItems: selectedItems, onClearAll: handleClearAll, onSelectAll: handleSelectAll }));
|
|
88
91
|
var headerRight = (React.createElement(HeaderRight, { onDelete: isShowDeleteButton ? handleDeleteSelectedItems : undefined, onDownload: isHasSelectedItemsOrDetailsMode ? handleDownloadSelectedItems : undefined, onShare: isDetailsMode ? handleSharedCurrentItem : undefined, onUpload: isShowUploadButton ? onUpload : undefined }));
|
|
89
92
|
var handleClickByImage = function (id) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
1
|
+
import React, { Fragment, useContext } from 'react';
|
|
2
2
|
import i18n from 'ui-i18n';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
@@ -7,12 +7,14 @@ import Divider from '@mui/material/Divider';
|
|
|
7
7
|
import MoreAttributesButton from '../../attributes/editMode/MoreAttributesButton';
|
|
8
8
|
import { getMoreAttrTypes } from '../helpers';
|
|
9
9
|
import { useStyles } from './styles';
|
|
10
|
+
import { ConfigPermissionsContext } from '../../../contexts';
|
|
10
11
|
export var MetaInfoHeader = function (_a) {
|
|
11
12
|
var _b;
|
|
12
13
|
var attributeType = _a.attributeType, onAddAttributes = _a.onAddAttributes, uri = _a.uri;
|
|
13
14
|
var styles = useStyles();
|
|
14
15
|
var moreAttrTypes = getMoreAttrTypes(attributeType);
|
|
15
|
-
var
|
|
16
|
+
var canCreate = useContext(ConfigPermissionsContext).canCreate;
|
|
17
|
+
var canAdd = canCreate && Boolean(onAddAttributes);
|
|
16
18
|
var handleApply = function (attrTypes) {
|
|
17
19
|
if (onAddAttributes) {
|
|
18
20
|
onAddAttributes(attrTypes.map(function (attributeType) { return ({ attributeType: attributeType, parentUri: uri }); }));
|
|
@@ -21,7 +21,7 @@ import ErrorWrapper from '../ErrorWrapper/ErrorWrapper';
|
|
|
21
21
|
import EntitySelector from '../attributes/editMode/EntitySelector/EntitySelector';
|
|
22
22
|
import AttributesList from '../attributes/editMode/AttributesList';
|
|
23
23
|
import { withContext } from '../../HOCs';
|
|
24
|
-
import { isHighlightedErrorType, ScrollToElementContext, useMdmAction, useMdmAuthoringItemsByEntityType, useMdmEntity, useMdmGlobalSearchRequestOptions, useMdmInitialConnection, useMdmInitialConnectionTempEntity, useMdmModifiedEntities, useMdmModifiedEntity, useMdmProfileErrors } from '../../contexts';
|
|
24
|
+
import { ConfigPermissionsContextProvider, isHighlightedErrorType, ScrollToElementContext, useMdmAction, useMdmAuthoringItemsByEntityType, useMdmEntity, useMdmGlobalSearchRequestOptions, useMdmInitialConnection, useMdmInitialConnectionTempEntity, useMdmModifiedEntities, useMdmModifiedEntity, useMdmProfileErrors } from '../../contexts';
|
|
25
25
|
import { useScrollToAttributeError } from '../../hooks';
|
|
26
26
|
import { useStyles } from './styles';
|
|
27
27
|
var areRelatedEntitiesChanged = function (initial, actual) {
|
|
@@ -169,7 +169,7 @@ var RelationEditor = function (_a) {
|
|
|
169
169
|
React.createElement("div", { className: styles.editor },
|
|
170
170
|
React.createElement(Typography, { className: styles.title }, isNew ? i18n.text('Add new item') : i18n.text('Edit item')),
|
|
171
171
|
defaultRelationType === null && (React.createElement(ConnectionRelationTypeSelector, { className: styles.item, relation: connection.relation, inRelationTypes: inRelationTypes, outRelationTypes: outRelationTypes, onChange: onRelationTypeChange })),
|
|
172
|
-
Boolean(relationType) && (React.createElement(
|
|
172
|
+
Boolean(relationType) && (React.createElement(ConfigPermissionsContextProvider, null,
|
|
173
173
|
React.createElement("div", { ref: ref, className: errorClassName },
|
|
174
174
|
React.createElement(ErrorWrapper, { errorMessage: errorMessage },
|
|
175
175
|
React.createElement(EntitySelector, { className: classnames(styles.item, (_b = {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"link" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"link" | "delimiter" | "relationship">;
|
|
@@ -26,7 +26,7 @@ export declare const ChipWithTooltip: React.ForwardRefExoticComponent<import("pr
|
|
|
26
26
|
variant?: import("@mui/types").OverridableStringUnion<"filled" | "outlined", import("@mui/material/Chip").ChipPropsVariantOverrides>;
|
|
27
27
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
28
28
|
ref?: React.Ref<HTMLDivElement>;
|
|
29
|
-
}, "label" | "icon" | "children" | "size" | "color" | "disabled" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "tabIndex" | "variant" | "
|
|
29
|
+
}, "label" | "icon" | "children" | "size" | "color" | "disabled" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "tabIndex" | "variant" | "deleteIcon" | "avatar" | "clickable" | "onDelete" | "skipFocusWhenDisabled">>;
|
|
30
30
|
type ComplexWithLabel = NestedAttributeValue | ReferenceAttributeValue;
|
|
31
31
|
type Props = {
|
|
32
32
|
className?: string;
|
|
@@ -23,7 +23,7 @@ import { getMoreAttrTypes } from './helpers';
|
|
|
23
23
|
import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
|
|
24
24
|
import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
|
|
25
25
|
import { withContext } from '../../../../HOCs';
|
|
26
|
-
import { ScrollType, ScrollToElementContext } from '../../../../contexts';
|
|
26
|
+
import { ScrollType, ScrollToElementContext, ConfigPermissionsContext } from '../../../../contexts';
|
|
27
27
|
var AttributesList = function (_a) {
|
|
28
28
|
var parentAttributeType = _a.parentAttributeType, attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv, highlightAttribute = _a.highlightAttribute;
|
|
29
29
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
@@ -37,11 +37,14 @@ var AttributesList = function (_a) {
|
|
|
37
37
|
useEffect(function () {
|
|
38
38
|
setHasDeletionsMap({});
|
|
39
39
|
}, [parentUri]);
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var canCreate = useContext(ConfigPermissionsContext).canCreate;
|
|
41
|
+
var canCreateParentAttrType = useMemo(function () { return canCreate && parentAttributeType && checkCanCreateAttribute({ attributeType: parentAttributeType, mode: mode }); }, [parentAttributeType, mode, canCreate]);
|
|
42
|
+
var creatableAttrTypes = useMemo(function () { return (canCreate ? getCreatableAttributeTypes(mode, attrTypes) : []); }, [attrTypes, mode, canCreate]);
|
|
42
43
|
var moreAttrTypes = getMoreAttrTypes(creatableAttrTypes, entity, showEmptyEditors, hasDeletionsMap);
|
|
43
44
|
var pinnedAttributes = useContext(PinnedAttributesContext);
|
|
44
|
-
var pagersData = useMemo(function () {
|
|
45
|
+
var pagersData = useMemo(function () {
|
|
46
|
+
return getAttributesListForEditMode(attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes, canCreate);
|
|
47
|
+
}, [attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes, canCreate]);
|
|
45
48
|
var _e = useMemo(function () { return splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
46
49
|
var onAddMoreAttributes = useCallback(function (attributeTypes) {
|
|
47
50
|
onAddAttributes(attributeTypes.map(function (attributeType) { return ({
|
|
@@ -23,7 +23,7 @@ import ArrowExpandButton from '../../../ArrowExpandButton/ArrowExpandButton';
|
|
|
23
23
|
import ErrorWrapper from '../../../ErrorWrapper/ErrorWrapper';
|
|
24
24
|
import AttributesList from '../AttributesList/AttributesList';
|
|
25
25
|
import { withContext } from '../../../../HOCs';
|
|
26
|
-
import { isHighlightedErrorType, ScrollToElementContext } from '../../../../contexts';
|
|
26
|
+
import { isHighlightedErrorType, ScrollToElementContext, useAttributeValueConfigPermissions } from '../../../../contexts';
|
|
27
27
|
import { useScrollToAttributeError } from '../../../../hooks';
|
|
28
28
|
import { useStyles } from './styles';
|
|
29
29
|
var ComplexAttribute = function (_a) {
|
|
@@ -45,15 +45,17 @@ var ComplexAttribute = function (_a) {
|
|
|
45
45
|
useEffect(function () {
|
|
46
46
|
setExpanded(defaultExpand);
|
|
47
47
|
}, [defaultExpand]);
|
|
48
|
+
var configCanDelete = useAttributeValueConfigPermissions(attributeValue.uri).canDelete;
|
|
48
49
|
var canDelete = useMemo(function () {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
return configCanDelete &&
|
|
51
|
+
checkCanDeleteAttribute({
|
|
52
|
+
attributeType: attributeType,
|
|
53
|
+
attributeValue: attributeValue,
|
|
54
|
+
mode: mode,
|
|
55
|
+
metadata: metadata,
|
|
56
|
+
isReltioCrosswalk: isReltioCrosswalk(crosswalks, attributeValue)
|
|
57
|
+
});
|
|
58
|
+
}, [attributeType, attributeValue, mode, metadata, crosswalks, configCanDelete]);
|
|
57
59
|
var showDeleteButton = !deleted && !hideDeleteButton && !!onDeleteAttribute && canDelete;
|
|
58
60
|
var onDeleteThis = function () { return onDeleteAttribute({ uri: uri, attributeType: attributeType, attributeValue: attributeValue }); };
|
|
59
61
|
var hasDescendantsWithErrors = useMemo(function () { return hasAttributeDescendantsWithErrors(attributeValue, errors); }, [errors, attributeValue]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useState } from 'react';
|
|
2
2
|
import CloudUploadIcon from '@mui/icons-material/CloudUpload';
|
|
3
3
|
import { generateUri, getImageAttributeOvThumbnailUrl, getImageAttributeOvUrl } from '@reltio/mdm-sdk';
|
|
4
4
|
import Image from '../../../Image/Image';
|
|
@@ -7,7 +7,7 @@ import { SmallIconButton } from '../../../SmallIconButton';
|
|
|
7
7
|
import { UploadImageDialog } from '../../../UploadImageDialog/UploadImageDialog';
|
|
8
8
|
import ImageAttributesLineCommon from '../../ImageAttributesLine';
|
|
9
9
|
import { DEFAULT_IMAGE_SIZE } from '../../ImageAttributesLine/constants';
|
|
10
|
-
import { useMdmAction, useMdmEntity, useMdmModifiedEntityDefaultProfilePic } from '../../../../contexts';
|
|
10
|
+
import { ConfigPermissionsContext, useMdmAction, useMdmEntity, useMdmModifiedEntityDefaultProfilePic } from '../../../../contexts';
|
|
11
11
|
import { useStyles } from './styles';
|
|
12
12
|
var defaultEntity = {};
|
|
13
13
|
var ImageAttributesLine = function (_a) {
|
|
@@ -17,6 +17,7 @@ var ImageAttributesLine = function (_a) {
|
|
|
17
17
|
var setDefaultProfilePic = useMdmAction('setDefaultProfilePicForModifiedEntity');
|
|
18
18
|
var entity = useMdmEntity() || defaultEntity;
|
|
19
19
|
var defaultProfilePic = useMdmModifiedEntityDefaultProfilePic(entity.uri);
|
|
20
|
+
var canCreate = useContext(ConfigPermissionsContext).canCreate;
|
|
20
21
|
var toggleVisibilityUploadDialog = useCallback(function () {
|
|
21
22
|
setIsVisibleUploadDialog(function (visible) { return !visible; });
|
|
22
23
|
}, []);
|
|
@@ -72,10 +73,9 @@ var ImageAttributesLine = function (_a) {
|
|
|
72
73
|
};
|
|
73
74
|
return renderImage;
|
|
74
75
|
};
|
|
75
|
-
return (React.createElement("div", { className: styles.root },
|
|
76
|
-
React.createElement(ImageAttributesLineCommon, { attributeValues: attributeValues, attributeType: attributeType, renderImage: renderImage, overlay: true, countFixedItems: 1, onUpload: toggleVisibilityUploadDialog, onDeleteAttribute: handleDeleteAttribute, imageSize: imageSize, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: paging, parentUri: parentUri, showNonOv: showNonOv },
|
|
77
|
-
React.createElement(
|
|
78
|
-
React.createElement(SmallIconButton, { className: styles.uploadButton, iconClassName: styles.uploadIcon, icon: CloudUploadIcon, "data-reltio-id": "reltio-upload-image-button" }))),
|
|
76
|
+
return (React.createElement("div", { className: styles.root, "data-reltio-id": "image-line-edit-mode" },
|
|
77
|
+
React.createElement(ImageAttributesLineCommon, { attributeValues: attributeValues, attributeType: attributeType, renderImage: renderImage, overlay: true, countFixedItems: canCreate ? 1 : 0, onUpload: toggleVisibilityUploadDialog, onDeleteAttribute: handleDeleteAttribute, imageSize: imageSize, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: paging, parentUri: parentUri, showNonOv: showNonOv }, canCreate && (React.createElement("div", { className: styles.uploadContainer, onClick: toggleVisibilityUploadDialog },
|
|
78
|
+
React.createElement(SmallIconButton, { className: styles.uploadButton, iconClassName: styles.uploadIcon, icon: CloudUploadIcon, "data-reltio-id": "reltio-upload-image-button" })))),
|
|
79
79
|
React.createElement(UploadImageDialog, { open: isVisibleUploadDialog, onUpload: handleAddAttributes, onClose: toggleVisibilityUploadDialog })));
|
|
80
80
|
};
|
|
81
81
|
export default ImageAttributesLine;
|
|
@@ -29,7 +29,7 @@ import ComplexAttribute from '../ComplexAttribute/ComplexAttribute';
|
|
|
29
29
|
import EntitySelector from '../EntitySelector/EntitySelector';
|
|
30
30
|
import { ErrorWrapper } from '../../../index';
|
|
31
31
|
import { withContext } from '../../../../HOCs';
|
|
32
|
-
import { isHighlightedErrorType, ScrollToElementContext, useMdmAction, useMdmGlobalSearchRequestOptions, useMdmMetadata, useMdmModifiedEntity } from '../../../../contexts';
|
|
32
|
+
import { isHighlightedErrorType, ScrollToElementContext, useAttributeValueConfigPermissions, useMdmAction, useMdmGlobalSearchRequestOptions, useMdmMetadata, useMdmModifiedEntity } from '../../../../contexts';
|
|
33
33
|
import { useScrollToAttributeError } from '../../../../hooks';
|
|
34
34
|
import { useStyles } from './styles';
|
|
35
35
|
var ReferenceAttribute = function (props) {
|
|
@@ -104,15 +104,17 @@ var ReferenceAttribute = function (props) {
|
|
|
104
104
|
onChangeEntity(newEntity);
|
|
105
105
|
entityCreated(newEntity);
|
|
106
106
|
}, [newEntityAttrTypesSelectionStrategy, mode, referencedEntityType, metadata, onChangeEntity, entityCreated]);
|
|
107
|
+
var _c = useAttributeValueConfigPermissions(attributeValue.uri), configCanCreate = _c.canCreate, configCanUpdate = _c.canUpdate;
|
|
107
108
|
var canChangeReferencedEntity = useMemo(function () {
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
return configCanUpdate &&
|
|
110
|
+
checkCanEditAttribute({
|
|
111
|
+
attributeType: attributeType,
|
|
112
|
+
attributeValue: attributeValue,
|
|
113
|
+
mode: mode,
|
|
114
|
+
isReltioCrosswalk: isReltioCrosswalk(crosswalks, attributeValue)
|
|
115
|
+
});
|
|
116
|
+
}, [attributeType, attributeValue, mode, crosswalks, configCanUpdate]);
|
|
117
|
+
var canCreateReferencedEntity = useMemo(function () { return configCanCreate && checkMetadataForCreate(mode, referencedEntityType); }, [mode, referencedEntityType, configCanCreate]);
|
|
116
118
|
var errorMessage = getErrorMessage(referencedEntityMissedError);
|
|
117
119
|
return (React.createElement(ComplexAttribute, __assign({}, ownProps, { label: getLabel(label), attributeTypesList: editableAttrTypes, crosswalks: allCrosswalks, metadata: metadata }),
|
|
118
120
|
React.createElement("div", { ref: ref, className: errorClassName },
|
|
@@ -28,7 +28,7 @@ import AddIcon from '@mui/icons-material/Add';
|
|
|
28
28
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
29
29
|
import Typography from '@mui/material/Typography';
|
|
30
30
|
import i18n from 'ui-i18n';
|
|
31
|
-
import { AttributeErrorType, AttributeTypeType, attributeUriToSearchUri,
|
|
31
|
+
import { AttributeErrorType, AttributeTypeType, attributeUriToSearchUri, ErrorType, getAttributeValue, getAttrDataTypeDefinition, getErrorId, getErrorMessage, getErrorType, isDependentLookupAttrType, isEditableMode as checkIsEditableMode, ModeType, SimpleAttributeValueType } from '@reltio/mdm-sdk';
|
|
32
32
|
import DataTypeValue from '../../../DataTypeValue/DataTypeValue';
|
|
33
33
|
import DataTypeValueEditor from '../../../editors/DataTypeValueEditor/DataTypeValueEditor';
|
|
34
34
|
import ErrorWrapper from '../../../ErrorWrapper/ErrorWrapper';
|
|
@@ -39,6 +39,7 @@ import { withContext } from '../../../../HOCs';
|
|
|
39
39
|
import { isHighlightedErrorType, ScrollToElementContext, DependentLookupAutopopulationContext, ProfilePerspectiveViewContext, useMdmDependentLookupEditorContext } from '../../../../contexts';
|
|
40
40
|
import { useScrollToAttributeError } from '../../../../hooks';
|
|
41
41
|
import { useAutopopulationContextValue } from './useAutopopulationContextValue';
|
|
42
|
+
import { useAttributeValuePermissions } from './useAttributeValuePermissions';
|
|
42
43
|
import { useStyles } from './styles';
|
|
43
44
|
var AsyncMountPlaceholder = function () {
|
|
44
45
|
var styles = useStyles();
|
|
@@ -51,13 +52,16 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
51
52
|
var deleted = state === 'deleted';
|
|
52
53
|
var edited = state === 'edited';
|
|
53
54
|
var isEditableMode = checkIsEditableMode(mode);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
var _e = useAttributeValuePermissions({
|
|
56
|
+
attributeValue: attributeValue,
|
|
57
|
+
attributeType: attributeType,
|
|
58
|
+
mode: mode,
|
|
59
|
+
isReltioCrosswalk: isReltioCrosswalk
|
|
60
|
+
}), canCreate = _e.canCreate, canEdit = _e.canEdit, canDelete = _e.canDelete;
|
|
57
61
|
var showToEdit = canEdit && isEditableMode;
|
|
58
62
|
var errorMessage = getErrorMessage(ownError);
|
|
59
63
|
var dependentLookupEditorContext = useMdmDependentLookupEditorContext(attributeValue, attributeType);
|
|
60
|
-
var
|
|
64
|
+
var _f = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _f.ref, errorClassName = _f.errorClassName;
|
|
61
65
|
useEffect(function () {
|
|
62
66
|
// when editor is empty but has default lookup code, onChangeAttribute will be called by useLookupsResolver
|
|
63
67
|
if (isEmptyEditor && isDependentLookupAttrType(attributeType) && !has('lookupCode', attributeValue)) {
|
|
@@ -102,7 +106,7 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
102
106
|
"(",
|
|
103
107
|
i18n.text('edited'),
|
|
104
108
|
")")),
|
|
105
|
-
showAddButton && (React.createElement(SmallIconButton, { icon: AddIcon, onClick: onAddOneMore, size: "L", className: classnames(styles.addButton, styles.button) })),
|
|
109
|
+
showAddButton && (React.createElement(SmallIconButton, { icon: AddIcon, onClick: onAddOneMore, size: "L", className: classnames(styles.addButton, styles.button), "data-reltio-id": "reltio-add-one-more-simple-attribute-button" })),
|
|
106
110
|
additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
|
|
107
111
|
showDeleteButton && (React.createElement(SmallIconButton, { className: styles.button, icon: DeleteIcon, onClick: onDelete, size: "L", "data-reltio-id": "reltio-delete-simple-attribute-button" })))));
|
|
108
112
|
};
|
|
@@ -20,7 +20,8 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
20
20
|
'editor-read-only-value': {
|
|
21
21
|
marginLeft: '12px',
|
|
22
22
|
display: 'flex',
|
|
23
|
-
alignItems: 'center'
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
color: theme.palette.text.primary
|
|
24
25
|
},
|
|
25
26
|
'editor-actions': {
|
|
26
27
|
display: 'flex',
|
package/esm/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AttributeType, Mode, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
2
|
+
type Props = {
|
|
3
|
+
attributeType: AttributeType;
|
|
4
|
+
attributeValue: SimpleAttributeValue;
|
|
5
|
+
isReltioCrosswalk: boolean;
|
|
6
|
+
mode: Mode;
|
|
7
|
+
};
|
|
8
|
+
export declare const useAttributeValuePermissions: ({ attributeType, attributeValue, isReltioCrosswalk, mode }: Props) => {
|
|
9
|
+
canCreate: boolean;
|
|
10
|
+
canEdit: any;
|
|
11
|
+
canDelete: any;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/esm/components/attributes/editMode/SimpleAttributeEditor/useAttributeValuePermissions.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { checkCanCreateAttribute, checkCanDeleteAttribute, checkCanEditAttribute } from '@reltio/mdm-sdk';
|
|
2
|
+
import { useAttributeValueConfigPermissions } from '../../../../contexts';
|
|
3
|
+
export var useAttributeValuePermissions = function (_a) {
|
|
4
|
+
var attributeType = _a.attributeType, attributeValue = _a.attributeValue, isReltioCrosswalk = _a.isReltioCrosswalk, mode = _a.mode;
|
|
5
|
+
var _b = useAttributeValueConfigPermissions(attributeValue.uri), configCanCreate = _b.canCreate, configCanUpdate = _b.canUpdate, configCanDelete = _b.canDelete;
|
|
6
|
+
var canCreate = configCanCreate && checkCanCreateAttribute({ attributeType: attributeType, mode: mode });
|
|
7
|
+
var canEdit = configCanUpdate && checkCanEditAttribute({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
8
|
+
var canDelete = configCanDelete && checkCanDeleteAttribute({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
9
|
+
return { canCreate: canCreate, canEdit: canEdit, canDelete: canDelete };
|
|
10
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useCommentStyles: (props?: any) => import("@mui/styles").ClassNameMap<"date" | "icon" | "comment" | "text" | "info" | "avatar" | "firstLine" | "author">;
|
|
2
|
-
export declare const useCollapsedCommentsStyles: (props?: any) => import("@mui/styles").ClassNameMap<"
|
|
2
|
+
export declare const useCollapsedCommentsStyles: (props?: any) => import("@mui/styles").ClassNameMap<"circleButton" | "delimiter">;
|
|
3
3
|
export declare const useWorkflowStyles: (props?: any) => import("@mui/styles").ClassNameMap<"title" | "container" | "commentsContainer" | "filledInputRoot" | "modeSwitcherWrapper" | "sendButton">;
|
|
4
4
|
export declare const useExpandedComments: (props?: any) => import("@mui/styles").ClassNameMap<"messageContainer">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewExtension } from '@reltio/mdm-sdk';
|
|
3
|
+
type ConfigPermissionsContextValue = {
|
|
4
|
+
canCreate: boolean;
|
|
5
|
+
canUpdate: boolean;
|
|
6
|
+
canDelete: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const ConfigPermissionsContext: React.Context<ConfigPermissionsContextValue>;
|
|
9
|
+
type Props = {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
view?: ViewExtension;
|
|
12
|
+
};
|
|
13
|
+
declare const ConfigPermissionsContextProvider: ({ children, view }: Props) => JSX.Element;
|
|
14
|
+
declare const useAttributeValueConfigPermissions: (attributeValueUri: string) => {
|
|
15
|
+
canCreate: boolean;
|
|
16
|
+
canUpdate: any;
|
|
17
|
+
canDelete: any;
|
|
18
|
+
};
|
|
19
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { useConfigPermissions } from '../../hooks';
|
|
3
|
+
import { isTempUri } from '@reltio/mdm-sdk';
|
|
4
|
+
var defaultValue = {
|
|
5
|
+
canCreate: true,
|
|
6
|
+
canUpdate: true,
|
|
7
|
+
canDelete: true
|
|
8
|
+
};
|
|
9
|
+
var ConfigPermissionsContext = React.createContext(defaultValue);
|
|
10
|
+
ConfigPermissionsContext.displayName = 'ConfigPermissionsContext';
|
|
11
|
+
var ConfigPermissionsContextProvider = function (_a) {
|
|
12
|
+
var children = _a.children, view = _a.view;
|
|
13
|
+
var _b = useConfigPermissions(), canCreate = _b.canCreate, canDelete = _b.canDelete, canUpdate = _b.canUpdate;
|
|
14
|
+
var value = useMemo(function () {
|
|
15
|
+
return view
|
|
16
|
+
? {
|
|
17
|
+
canCreate: canCreate(view),
|
|
18
|
+
canUpdate: canUpdate(view),
|
|
19
|
+
canDelete: canDelete(view)
|
|
20
|
+
}
|
|
21
|
+
: defaultValue;
|
|
22
|
+
}, [view, canCreate, canUpdate, canDelete]);
|
|
23
|
+
return React.createElement(ConfigPermissionsContext.Provider, { value: value }, children);
|
|
24
|
+
};
|
|
25
|
+
var useAttributeValueConfigPermissions = function (attributeValueUri) {
|
|
26
|
+
var _a = useContext(ConfigPermissionsContext), canCreate = _a.canCreate, canUpdate = _a.canUpdate, canDelete = _a.canDelete;
|
|
27
|
+
var isNew = isTempUri(attributeValueUri);
|
|
28
|
+
return useMemo(function () { return ({
|
|
29
|
+
canCreate: canCreate,
|
|
30
|
+
canUpdate: isNew || canUpdate,
|
|
31
|
+
canDelete: isNew || canDelete
|
|
32
|
+
}); }, [isNew, canCreate, canUpdate, canDelete]);
|
|
33
|
+
};
|
|
34
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions };
|
package/esm/contexts/index.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export { FeaturesContext } from './FeaturesContext';
|
|
|
31
31
|
export { DependentLookupAutopopulationContext } from './DependentLookupAutopopulationContext';
|
|
32
32
|
export { PageRequestsAbortingContext } from './PageRequestsAbortingContext';
|
|
33
33
|
export { ActionsHookProvider, useActionsHook } from './ActionsHookContext';
|
|
34
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions } from './ConfigPermissionsContext';
|
|
34
35
|
export * from './MdmModuleContext';
|
package/esm/contexts/index.js
CHANGED
|
@@ -31,4 +31,5 @@ export { FeaturesContext } from './FeaturesContext';
|
|
|
31
31
|
export { DependentLookupAutopopulationContext } from './DependentLookupAutopopulationContext';
|
|
32
32
|
export { PageRequestsAbortingContext } from './PageRequestsAbortingContext';
|
|
33
33
|
export { ActionsHookProvider, useActionsHook } from './ActionsHookContext';
|
|
34
|
+
export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttributeValueConfigPermissions } from './ConfigPermissionsContext';
|
|
34
35
|
export * from './MdmModuleContext';
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1734",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.1718",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"d3-cloud": "^1.2.5",
|
|
13
13
|
"d3-geo": "^2.0.1",
|