@reltio/components 1.4.1164 → 1.4.1168
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/CollaborationItem/CollaborationItem.js +3 -10
- package/cjs/components/CollaborationItem/Comment/Comment.d.ts +3 -2
- package/cjs/components/CollaborationItem/Comment/Comment.js +24 -14
- package/cjs/components/CollaborationItem/Comment/styles.d.ts +1 -1
- package/cjs/components/CollaborationItem/RepliedComment/RepliedComment.d.ts +7 -4
- package/cjs/components/CollaborationItem/RepliedComment/RepliedComment.js +57 -5
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +6 -4
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.js +30 -12
- package/cjs/components/CollaborationItem/SendMessageArea/styles.d.ts +5 -1
- package/cjs/components/CollaborationItem/SendMessageArea/styles.js +15 -9
- package/cjs/components/CollaborationItem/TextFieldWithMentions/styles.js +1 -3
- package/cjs/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -1
- package/cjs/components/attributes/editMode/AttributesList/AttributesList.js +9 -4
- package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +3 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +22 -23
- package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +8 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.js +18 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.js +20 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.d.ts +22 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +60 -0
- package/cjs/contexts/CollaborationContext/index.d.ts +8 -0
- package/cjs/contexts/CollaborationContext/index.js +3 -1
- package/cjs/hooks/useCollaboration.d.ts +2 -0
- package/cjs/hooks/useCollaboration.js +57 -5
- package/esm/components/CollaborationItem/CollaborationItem.js +4 -11
- package/esm/components/CollaborationItem/Comment/Comment.d.ts +3 -2
- package/esm/components/CollaborationItem/Comment/Comment.js +25 -15
- package/esm/components/CollaborationItem/Comment/styles.d.ts +1 -1
- package/esm/components/CollaborationItem/RepliedComment/RepliedComment.d.ts +7 -4
- package/esm/components/CollaborationItem/RepliedComment/RepliedComment.js +38 -5
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +6 -4
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.js +30 -12
- package/esm/components/CollaborationItem/SendMessageArea/styles.d.ts +5 -1
- package/esm/components/CollaborationItem/SendMessageArea/styles.js +15 -9
- package/esm/components/CollaborationItem/TextFieldWithMentions/styles.js +1 -3
- package/esm/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -1
- package/esm/components/attributes/editMode/AttributesList/AttributesList.js +10 -5
- package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +3 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +23 -24
- package/esm/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +8 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/helpers.js +15 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.js +20 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.d.ts +22 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +53 -0
- package/esm/contexts/CollaborationContext/index.d.ts +8 -0
- package/esm/contexts/CollaborationContext/index.js +3 -1
- package/esm/hooks/useCollaboration.d.ts +2 -0
- package/esm/hooks/useCollaboration.js +58 -6
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
2
|
+
import { GroupedItem } from './useMoreAttributesItems';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
attrTypes: AttributeType[];
|
|
5
|
+
filter?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const preparedGroupedItems: ({ attrTypes, filter }: Props) => GroupedItem[];
|
|
8
|
+
export { preparedGroupedItems };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preparedGroupedItems = void 0;
|
|
4
|
+
var ramda_1 = require("ramda");
|
|
5
|
+
var filterItems = ramda_1.curry(function (filterText, items) {
|
|
6
|
+
return ramda_1.filter(function (item) { return item.label.toLowerCase().includes(filterText.toLowerCase()); })(items);
|
|
7
|
+
});
|
|
8
|
+
var preparedGroupedItems = function (_a) {
|
|
9
|
+
var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b;
|
|
10
|
+
return ramda_1.pipe(filterItems(filter), ramda_1.map(function (attrType) { return ({
|
|
11
|
+
item: {
|
|
12
|
+
id: attrType.uri,
|
|
13
|
+
label: attrType.label,
|
|
14
|
+
attrType: attrType
|
|
15
|
+
}
|
|
16
|
+
}); }))(attrTypes);
|
|
17
|
+
};
|
|
18
|
+
exports.preparedGroupedItems = preparedGroupedItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"icon" | "dense" | "buttonLabel" | "moreButton" | "moreAttributes" | "popupContainer" | "moreAttributesPopup">;
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"icon" | "dense" | "buttonLabel" | "moreButton" | "subHeader" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "noResultsCaptionContainer">;
|
|
@@ -27,5 +27,25 @@ exports.useStyles = styles_1.makeStyles({
|
|
|
27
27
|
icon: {
|
|
28
28
|
fontSize: '18px',
|
|
29
29
|
marginRight: '8px'
|
|
30
|
+
},
|
|
31
|
+
subHeader: {
|
|
32
|
+
backgroundColor: 'rgb(245, 245, 245)',
|
|
33
|
+
padding: '0 16px',
|
|
34
|
+
margin: 0,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
color: 'rgba(0,0,0,0.84)',
|
|
38
|
+
fontSize: '14px',
|
|
39
|
+
fontWeight: 500
|
|
40
|
+
},
|
|
41
|
+
noResultsCaptionContainer: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
top: 0,
|
|
44
|
+
bottom: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
right: 0,
|
|
47
|
+
display: 'flex',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
alignItems: 'center'
|
|
30
50
|
}
|
|
31
51
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
data: AttributeType[];
|
|
4
|
+
parent?: AttributeType;
|
|
5
|
+
filter?: string;
|
|
6
|
+
};
|
|
7
|
+
declare type Item = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
attrType?: AttributeType;
|
|
11
|
+
};
|
|
12
|
+
export declare type GroupedItem = {
|
|
13
|
+
item: Item;
|
|
14
|
+
items?: GroupedItem[];
|
|
15
|
+
};
|
|
16
|
+
export declare const useMoreAttributesItems: ({ data, parent, filter }: Props) => {
|
|
17
|
+
items: any;
|
|
18
|
+
hasGroups: boolean;
|
|
19
|
+
parentGroupLength: number;
|
|
20
|
+
attributesGroupLength: number;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useMoreAttributesItems = void 0;
|
|
7
|
+
var react_1 = require("react");
|
|
8
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
9
|
+
var helpers_1 = require("../../../VirtualGroupedList/helpers");
|
|
10
|
+
var helpers_2 = require("./helpers");
|
|
11
|
+
var GROUP_NAMES;
|
|
12
|
+
(function (GROUP_NAMES) {
|
|
13
|
+
GROUP_NAMES["parent"] = "parent";
|
|
14
|
+
GROUP_NAMES["attributes"] = "attributes";
|
|
15
|
+
})(GROUP_NAMES || (GROUP_NAMES = {}));
|
|
16
|
+
var useMoreAttributesItems = function (_a) {
|
|
17
|
+
var data = _a.data, parent = _a.parent, filter = _a.filter;
|
|
18
|
+
var hasGroups = Boolean(parent);
|
|
19
|
+
var preparedParentGroupItem = react_1.useMemo(function () { return (hasGroups ? helpers_2.preparedGroupedItems({ attrTypes: [parent], filter: filter }) : []); }, [hasGroups, parent, filter]);
|
|
20
|
+
var parentGroup = react_1.useMemo(function () {
|
|
21
|
+
return hasGroups && (preparedParentGroupItem === null || preparedParentGroupItem === void 0 ? void 0 : preparedParentGroupItem.length)
|
|
22
|
+
? [
|
|
23
|
+
{
|
|
24
|
+
item: {
|
|
25
|
+
id: GROUP_NAMES.parent,
|
|
26
|
+
label: ui_i18n_1.default.text('Parent')
|
|
27
|
+
},
|
|
28
|
+
items: preparedParentGroupItem
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
: [];
|
|
32
|
+
}, [hasGroups, preparedParentGroupItem]);
|
|
33
|
+
var preparedAttributesGroupItems = react_1.useMemo(function () {
|
|
34
|
+
return helpers_2.preparedGroupedItems({
|
|
35
|
+
attrTypes: data,
|
|
36
|
+
filter: filter
|
|
37
|
+
});
|
|
38
|
+
}, [data, filter]);
|
|
39
|
+
var attributesGroup = react_1.useMemo(function () {
|
|
40
|
+
return hasGroups && (preparedAttributesGroupItems === null || preparedAttributesGroupItems === void 0 ? void 0 : preparedAttributesGroupItems.length)
|
|
41
|
+
? [
|
|
42
|
+
{
|
|
43
|
+
item: {
|
|
44
|
+
id: GROUP_NAMES.attributes,
|
|
45
|
+
label: ui_i18n_1.default.text('Attributes')
|
|
46
|
+
},
|
|
47
|
+
items: preparedAttributesGroupItems
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
: preparedAttributesGroupItems;
|
|
51
|
+
}, [hasGroups, preparedAttributesGroupItems]);
|
|
52
|
+
var items = react_1.useMemo(function () { return helpers_1.flattenGroupedItemsData((parentGroup || []).concat(attributesGroup)); }, [
|
|
53
|
+
parentGroup,
|
|
54
|
+
attributesGroup
|
|
55
|
+
]);
|
|
56
|
+
var parentGroupLength = parentGroup.length;
|
|
57
|
+
var attributesGroupLength = attributesGroup.length;
|
|
58
|
+
return { items: items, hasGroups: hasGroups, parentGroupLength: parentGroupLength, attributesGroupLength: attributesGroupLength };
|
|
59
|
+
};
|
|
60
|
+
exports.useMoreAttributesItems = useMoreAttributesItems;
|
|
@@ -14,9 +14,17 @@ export declare const CollaborationContext: React.Context<{
|
|
|
14
14
|
editComment: (params: Pick<Comment, 'content' | 'namedUsers' | 'objectType' | 'relatedObjectUris' | 'commentId' | 'replies'> & {
|
|
15
15
|
uri: string;
|
|
16
16
|
}) => Promise<void>;
|
|
17
|
+
editReply: (params: Pick<Reply, 'content' | 'namedUsers' | 'replyId'> & {
|
|
18
|
+
commentId: string;
|
|
19
|
+
}) => Promise<void>;
|
|
17
20
|
deleteComment: (params: Pick<Comment, 'commentId'> & {
|
|
18
21
|
uri: string;
|
|
19
22
|
}) => void;
|
|
23
|
+
deleteReply: (params: {
|
|
24
|
+
uri: string;
|
|
25
|
+
commentId: string;
|
|
26
|
+
reply: Pick<Reply, 'action' | 'replyId'>;
|
|
27
|
+
}) => void;
|
|
20
28
|
createReply: (params: Pick<Reply, 'content' | 'namedUsers' | 'action'> & {
|
|
21
29
|
uri: string;
|
|
22
30
|
commentId: string;
|
|
@@ -22,6 +22,8 @@ exports.CollaborationContext = react_1.default.createContext({
|
|
|
22
22
|
deleteComment: noop,
|
|
23
23
|
sending: false,
|
|
24
24
|
loading: false,
|
|
25
|
-
pageToken: null
|
|
25
|
+
pageToken: null,
|
|
26
|
+
deleteReply: noop,
|
|
27
|
+
editReply: function () { return new Promise(noop); }
|
|
26
28
|
});
|
|
27
29
|
exports.CollaborationContext.displayName = 'CollaborationContext';
|
|
@@ -22,5 +22,7 @@ export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Pro
|
|
|
22
22
|
reOpenThread: ({ commentId, uri }: any) => void;
|
|
23
23
|
resolveThread: ({ commentId, uri }: any) => void;
|
|
24
24
|
sending: boolean;
|
|
25
|
+
deleteReply: ({ uri, commentId, reply }: any) => void;
|
|
26
|
+
editReply: ({ content, namedUsers, commentId, replyId }: any) => Promise<void>;
|
|
25
27
|
};
|
|
26
28
|
export {};
|
|
@@ -25,6 +25,16 @@ var react_redux_1 = require("react-redux");
|
|
|
25
25
|
var ramda_1 = require("ramda");
|
|
26
26
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
27
27
|
var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
|
|
28
|
+
var filterReplies = function (replyId, replies) { return replies.filter(function (reply) { return reply.replyId !== replyId; }); };
|
|
29
|
+
var getUpdatedReplies = function (comment, reply) {
|
|
30
|
+
var changedReplyIndex = comment.replies.findIndex(function (_a) {
|
|
31
|
+
var replyId = _a.replyId;
|
|
32
|
+
return replyId === reply.replyId;
|
|
33
|
+
});
|
|
34
|
+
var newReplies = __spreadArray([], comment.replies);
|
|
35
|
+
newReplies[changedReplyIndex] = reply;
|
|
36
|
+
return newReplies;
|
|
37
|
+
};
|
|
28
38
|
var defaultObjectIds = [];
|
|
29
39
|
var catchErrorInRequest = function (e) { return console.error('Collaboration error', e); };
|
|
30
40
|
var useCollaboration = function (_a) {
|
|
@@ -150,8 +160,9 @@ var useCollaboration = function (_a) {
|
|
|
150
160
|
.catch(catchErrorInRequest)
|
|
151
161
|
.finally(function () { return setSending(false); });
|
|
152
162
|
}, [collaborationPath, tenant]);
|
|
153
|
-
var updateReplyInState = react_1.useCallback(function (reply, uri, commentId) {
|
|
163
|
+
var updateReplyInState = react_1.useCallback(function (reply, uri, commentId, isDeleteReply) {
|
|
154
164
|
var newStatus = reply.action === 'resolve' ? 'resolved' : 'open';
|
|
165
|
+
var replyId = reply.replyId;
|
|
155
166
|
if (newStatus === 'resolved') {
|
|
156
167
|
setCurrentComment(function (prevCurrentComment) {
|
|
157
168
|
if (prevCurrentComment) {
|
|
@@ -162,7 +173,9 @@ var useCollaboration = function (_a) {
|
|
|
162
173
|
else {
|
|
163
174
|
setCurrentComment(function (prevCurrentComment) {
|
|
164
175
|
if (prevCurrentComment) {
|
|
165
|
-
return __assign(__assign({}, prevCurrentComment), { replies:
|
|
176
|
+
return __assign(__assign({}, prevCurrentComment), { replies: isDeleteReply
|
|
177
|
+
? filterReplies(replyId, prevCurrentComment.replies)
|
|
178
|
+
: __spreadArray(__spreadArray([], prevCurrentComment.replies), [reply]) });
|
|
166
179
|
}
|
|
167
180
|
});
|
|
168
181
|
}
|
|
@@ -170,7 +183,7 @@ var useCollaboration = function (_a) {
|
|
|
170
183
|
var _a;
|
|
171
184
|
return (__assign(__assign({}, prevCommentsMap), (_a = {}, _a[uri] = (prevCommentsMap[uri] || []).map(function (comment) {
|
|
172
185
|
if (comment.commentId === commentId) {
|
|
173
|
-
return __assign(__assign({}, comment), { status: newStatus, replies: comment.replies + 1 });
|
|
186
|
+
return __assign(__assign({}, comment), { status: newStatus, replies: isDeleteReply ? comment.replies - 1 : comment.replies + 1 });
|
|
174
187
|
}
|
|
175
188
|
return comment;
|
|
176
189
|
}), _a)));
|
|
@@ -178,12 +191,49 @@ var useCollaboration = function (_a) {
|
|
|
178
191
|
setComments(function (prevComments) {
|
|
179
192
|
return prevComments.map(function (comment) {
|
|
180
193
|
if (comment.commentId === commentId) {
|
|
181
|
-
return __assign(__assign({}, comment), { status: newStatus, replies:
|
|
194
|
+
return __assign(__assign({}, comment), { status: newStatus, replies: isDeleteReply
|
|
195
|
+
? filterReplies(reply.replyId, comment.replies)
|
|
196
|
+
: __spreadArray(__spreadArray([], comment.replies), [reply]) });
|
|
197
|
+
}
|
|
198
|
+
return comment;
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}, []);
|
|
202
|
+
var deleteReply = react_1.useCallback(function (_a) {
|
|
203
|
+
var uri = _a.uri, commentId = _a.commentId, reply = _a.reply;
|
|
204
|
+
setSending(true);
|
|
205
|
+
mdm_sdk_1.deleteReply({ collaborationPath: collaborationPath, tenant: tenant, commentId: commentId, replyId: reply.replyId })
|
|
206
|
+
.then(function () { return updateReplyInState(reply, uri, commentId, true); })
|
|
207
|
+
.catch(catchErrorInRequest)
|
|
208
|
+
.finally(function () { return setSending(false); });
|
|
209
|
+
}, [collaborationPath, updateReplyInState, tenant]);
|
|
210
|
+
var editReplyInState = react_1.useCallback(function (reply, commentId) {
|
|
211
|
+
setCurrentComment(function (prevCurrentComment) {
|
|
212
|
+
if (prevCurrentComment) {
|
|
213
|
+
return __assign(__assign({}, prevCurrentComment), { replies: getUpdatedReplies(prevCurrentComment, reply) });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
setComments(function (prevComments) {
|
|
217
|
+
return prevComments.map(function (comment) {
|
|
218
|
+
if (comment.commentId === commentId) {
|
|
219
|
+
return __assign(__assign({}, comment), { replies: getUpdatedReplies(comment, reply) });
|
|
182
220
|
}
|
|
183
221
|
return comment;
|
|
184
222
|
});
|
|
185
223
|
});
|
|
186
224
|
}, []);
|
|
225
|
+
var editReply = react_1.useCallback(function (_a) {
|
|
226
|
+
var content = _a.content, namedUsers = _a.namedUsers, commentId = _a.commentId, replyId = _a.replyId;
|
|
227
|
+
setSending(true);
|
|
228
|
+
var data = {
|
|
229
|
+
content: content,
|
|
230
|
+
namedUsers: namedUsers
|
|
231
|
+
};
|
|
232
|
+
return mdm_sdk_1.updateReply({ collaborationPath: collaborationPath, tenant: tenant, commentId: commentId, replyId: replyId, data: data })
|
|
233
|
+
.then(function (reply) { return editReplyInState(reply, commentId); })
|
|
234
|
+
.catch(catchErrorInRequest)
|
|
235
|
+
.finally(function () { return setSending(false); });
|
|
236
|
+
}, [collaborationPath, tenant, editReplyInState]);
|
|
187
237
|
var createReply = react_1.useCallback(function (_a) {
|
|
188
238
|
var content = _a.content, namedUsers = _a.namedUsers, commentId = _a.commentId, action = _a.action, uri = _a.uri;
|
|
189
239
|
setSending(true);
|
|
@@ -228,7 +278,9 @@ var useCollaboration = function (_a) {
|
|
|
228
278
|
pageToken: pageToken,
|
|
229
279
|
reOpenThread: reOpenThread,
|
|
230
280
|
resolveThread: resolveThread,
|
|
231
|
-
sending: sending
|
|
281
|
+
sending: sending,
|
|
282
|
+
deleteReply: deleteReply,
|
|
283
|
+
editReply: editReply
|
|
232
284
|
};
|
|
233
285
|
};
|
|
234
286
|
exports.useCollaboration = useCollaboration;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef,
|
|
1
|
+
import React, { useRef, memo } from 'react';
|
|
2
2
|
import Box from '@material-ui/core/Box';
|
|
3
3
|
import { Comment } from './Comment/Comment';
|
|
4
4
|
import { RepliedComment } from './RepliedComment/RepliedComment';
|
|
@@ -8,22 +8,15 @@ export var CollaborationItem = memo(function (_a) {
|
|
|
8
8
|
var uri = _a.uri, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType, classes = _a.classes, popperRef = _a.popperRef, messagesRef = _a.messagesRef, comment = _a.comment;
|
|
9
9
|
var inputRef = useRef();
|
|
10
10
|
var styles = useStyles({ classes: classes });
|
|
11
|
-
var _b = useState(false), isEditingComment = _b[0], setIsEditingComment = _b[1];
|
|
12
11
|
var handleReply = function () {
|
|
13
|
-
if (isEditingComment) {
|
|
14
|
-
setIsEditingComment(false);
|
|
15
|
-
}
|
|
16
12
|
inputRef.current.focus();
|
|
17
13
|
};
|
|
18
|
-
var
|
|
19
|
-
setIsEditingComment(true);
|
|
20
|
-
};
|
|
21
|
-
var sendMessageArea = (React.createElement(SendMessageArea, { className: styles.sendMessageArea, inputRef: inputRef, popperRef: popperRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, comment: comment, onCancel: function () { return setIsEditingComment(false); }, isEditingComment: isEditingComment }));
|
|
14
|
+
var sendMessageArea = (React.createElement(SendMessageArea, { className: styles.sendMessageArea, inputRef: inputRef, popperRef: popperRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, comment: comment }));
|
|
22
15
|
return (React.createElement(Box, { className: styles.root },
|
|
23
16
|
comment && (React.createElement(React.Fragment, null,
|
|
24
17
|
React.createElement("div", { className: styles.messages, ref: messagesRef },
|
|
25
|
-
React.createElement(Comment, { comment: comment, uri: uri, onReply: handleReply,
|
|
26
|
-
React.createElement(Box, { className: styles.replies }, comment.replies.map(function (reply) { return (React.createElement(RepliedComment, { key: reply.replyId, className: styles.repliedComment, reply: reply })); }))),
|
|
18
|
+
React.createElement(Comment, { comment: comment, uri: uri, onReply: handleReply, className: styles.comment, relatedObjectUris: relatedObjectUris, objectType: objectType }),
|
|
19
|
+
React.createElement(Box, { className: styles.replies }, comment.replies.map(function (reply) { return (React.createElement(RepliedComment, { key: reply.replyId, className: styles.repliedComment, reply: reply, uri: uri, comment: comment })); }))),
|
|
27
20
|
sendMessageArea)),
|
|
28
21
|
!comment && sendMessageArea));
|
|
29
22
|
});
|
|
@@ -5,7 +5,8 @@ declare type Props = {
|
|
|
5
5
|
onReply: () => void;
|
|
6
6
|
className?: string;
|
|
7
7
|
comment: CommentType;
|
|
8
|
-
|
|
8
|
+
relatedObjectUris: CommentType['relatedObjectUris'];
|
|
9
|
+
objectType: CommentType['objectType'];
|
|
9
10
|
};
|
|
10
|
-
export declare const Comment: ({ onReply, className, uri, comment,
|
|
11
|
+
export declare const Comment: ({ onReply, className, uri, comment, relatedObjectUris, objectType }: Props) => JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import React, { useMemo, useContext } from 'react';
|
|
1
|
+
import React, { useMemo, useContext, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useSelector } from 'react-redux';
|
|
2
3
|
import i18n from 'ui-i18n';
|
|
3
4
|
import Link from '@material-ui/core/Link';
|
|
4
5
|
import Box from '@material-ui/core/Box';
|
|
5
6
|
import Typography from '@material-ui/core/Typography';
|
|
6
7
|
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
8
|
+
import mdm from '@reltio/mdm-module';
|
|
7
9
|
import DropDownMenuButton from '../../DropDownMenuButton/DropDownMenuButton';
|
|
8
10
|
import { SmallIconButtonWithTooltip } from '../../SmallIconButton';
|
|
9
11
|
import { CommentTarget } from '../CommentTarget/CommentTarget';
|
|
@@ -11,44 +13,52 @@ import { CommentContent } from '../CommentContent/CommentContent';
|
|
|
11
13
|
import { Avatar } from '../Avatar/Avatar';
|
|
12
14
|
import { CollaborationContext } from '../../../contexts';
|
|
13
15
|
import { formatDate } from '../utils';
|
|
16
|
+
import { SendMessageArea } from '../SendMessageArea/SendMessageArea';
|
|
14
17
|
import { useStyles } from './styles';
|
|
15
|
-
import { useSelector } from 'react-redux';
|
|
16
|
-
import mdm from '@reltio/mdm-module';
|
|
17
18
|
export var Comment = function (_a) {
|
|
18
|
-
var onReply = _a.onReply, className = _a.className, uri = _a.uri, comment = _a.comment,
|
|
19
|
+
var onReply = _a.onReply, className = _a.className, uri = _a.uri, comment = _a.comment, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType;
|
|
19
20
|
var styles = useStyles();
|
|
21
|
+
var inputRef = useRef();
|
|
22
|
+
var _b = useState(false), isEditingComment = _b[0], setIsEditingComment = _b[1];
|
|
20
23
|
var username = useSelector(mdm.selectors.getUserName);
|
|
21
|
-
var
|
|
22
|
-
var
|
|
24
|
+
var commentId = comment.commentId, createdBy = comment.createdBy, createdTime = comment.createdTime;
|
|
25
|
+
var canChangeComment = createdBy === username;
|
|
26
|
+
var _c = useContext(CollaborationContext), resolveThread = _c.resolveThread, reOpenThread = _c.reOpenThread, sending = _c.sending, deleteComment = _c.deleteComment;
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
if (isEditingComment) {
|
|
29
|
+
inputRef.current.focus();
|
|
30
|
+
}
|
|
31
|
+
}, [isEditingComment]);
|
|
23
32
|
var menuItems = useMemo(function () { return [
|
|
24
33
|
{
|
|
25
34
|
text: i18n.text('Edit'),
|
|
26
|
-
onClick:
|
|
35
|
+
onClick: function () { return setIsEditingComment(true); }
|
|
27
36
|
},
|
|
28
37
|
{
|
|
29
38
|
text: i18n.text('Delete'),
|
|
30
|
-
onClick: function () { return deleteComment({ uri: uri, commentId:
|
|
39
|
+
onClick: function () { return deleteComment({ uri: uri, commentId: commentId }); }
|
|
31
40
|
}
|
|
32
|
-
]; }, [
|
|
41
|
+
]; }, [deleteComment, uri, commentId]);
|
|
33
42
|
var handleResolve = function () {
|
|
34
|
-
resolveThread({ commentId:
|
|
43
|
+
resolveThread({ commentId: commentId, uri: uri });
|
|
35
44
|
};
|
|
36
45
|
var handleReOpen = function () {
|
|
37
|
-
reOpenThread({ commentId:
|
|
46
|
+
reOpenThread({ commentId: commentId, uri: uri });
|
|
38
47
|
};
|
|
48
|
+
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, onCancel: function () { return setIsEditingComment(false); }, isEditingComment: isEditingComment, comment: comment }));
|
|
39
49
|
return (React.createElement(Box, { className: className },
|
|
40
50
|
React.createElement(Box, { className: styles.header },
|
|
41
|
-
React.createElement(Avatar, { classes: { root: styles.avatar } },
|
|
51
|
+
React.createElement(Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
42
52
|
React.createElement(Box, { width: "100%" },
|
|
43
|
-
React.createElement(Typography, { className: styles.username },
|
|
44
|
-
React.createElement(Typography, { className: styles.createdAt }, formatDate(
|
|
53
|
+
React.createElement(Typography, { className: styles.username }, createdBy)),
|
|
54
|
+
React.createElement(Typography, { className: styles.createdAt }, formatDate(createdTime)),
|
|
45
55
|
canChangeComment && (React.createElement(DropDownMenuButton, { buttonComponent: SmallIconButtonWithTooltip, buttonProps: {
|
|
46
56
|
icon: MoreVertIcon,
|
|
47
57
|
tooltipTitle: i18n.text('Open menu')
|
|
48
58
|
}, popoverProps: { PopoverClasses: { root: styles.dropdownMenu } }, menuItems: menuItems, menuId: "collaboration-comment-menu" }))),
|
|
49
59
|
React.createElement(Box, { className: styles.body },
|
|
50
60
|
React.createElement(CommentTarget, { comment: comment, className: styles.commentTarget }),
|
|
51
|
-
React.createElement(CommentContent, { comment: comment, className: styles.message }),
|
|
61
|
+
isEditingComment ? sendMessageArea : React.createElement(CommentContent, { comment: comment, className: styles.message }),
|
|
52
62
|
React.createElement(Box, { className: styles.buttons },
|
|
53
63
|
React.createElement(Link, { className: styles.button, onClick: onReply, component: "button" }, i18n.text('Reply')),
|
|
54
64
|
comment.status === 'open' && (React.createElement(Link, { disabled: sending, className: styles.button, onClick: handleResolve, component: "button" }, i18n.text('Resolve'))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"body" | "message" | "button" | "header" | "avatar" | "username" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"body" | "message" | "button" | "header" | "avatar" | "username" | "buttons" | "createdAt" | "commentTarget" | "dropdownMenu">;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { Reply } from '@reltio/mdm-sdk';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Reply, Comment as CommentType } from '@reltio/mdm-sdk';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
className?: string;
|
|
5
|
-
reply: Pick<Reply, 'createdTime' | 'content' | 'createdBy' | 'action' | 'namedUsers'>;
|
|
5
|
+
reply: Pick<Reply, 'createdTime' | 'content' | 'createdBy' | 'action' | 'namedUsers' | 'replyId'>;
|
|
6
|
+
comment?: CommentType;
|
|
7
|
+
uri: string;
|
|
8
|
+
popperRef?: React.RefObject<any>;
|
|
6
9
|
};
|
|
7
|
-
export declare const RepliedComment: ({ className, reply }: Props) => JSX.Element;
|
|
10
|
+
export declare const RepliedComment: ({ className, reply, uri, comment, popperRef }: Props) => JSX.Element;
|
|
8
11
|
export {};
|
|
@@ -1,23 +1,56 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef, useContext, useMemo, useState, useEffect } from 'react';
|
|
2
|
+
import { useSelector } from 'react-redux';
|
|
2
3
|
import i18n from 'ui-i18n';
|
|
3
4
|
import classnames from 'classnames';
|
|
5
|
+
import mdm from '@reltio/mdm-module';
|
|
4
6
|
import Box from '@material-ui/core/Box';
|
|
7
|
+
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
5
8
|
import Typography from '@material-ui/core/Typography';
|
|
6
9
|
import { Avatar } from '../Avatar/Avatar';
|
|
7
10
|
import { CommentContent } from '../CommentContent/CommentContent';
|
|
8
11
|
import { formatDate } from '../utils';
|
|
9
12
|
import { useStyles } from './styles';
|
|
13
|
+
import { CollaborationContext } from '../../../contexts';
|
|
14
|
+
import DropDownMenuButton from '../../DropDownMenuButton/DropDownMenuButton';
|
|
15
|
+
import { SmallIconButtonWithTooltip } from '../../SmallIconButton';
|
|
16
|
+
import { SendMessageArea } from '../SendMessageArea/SendMessageArea';
|
|
10
17
|
export var RepliedComment = function (_a) {
|
|
11
|
-
var className = _a.className, reply = _a.reply;
|
|
18
|
+
var className = _a.className, reply = _a.reply, uri = _a.uri, comment = _a.comment, popperRef = _a.popperRef;
|
|
19
|
+
var inputRef = useRef();
|
|
20
|
+
var _b = useState(false), isEditingReply = _b[0], setIsEditingReply = _b[1];
|
|
12
21
|
var createdBy = reply.createdBy, action = reply.action, createdTime = reply.createdTime;
|
|
22
|
+
var username = useSelector(mdm.selectors.getUserName);
|
|
23
|
+
var canChangeReply = createdBy === username;
|
|
24
|
+
var deleteReply = useContext(CollaborationContext).deleteReply;
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
if (isEditingReply) {
|
|
27
|
+
inputRef.current.focus();
|
|
28
|
+
}
|
|
29
|
+
}, [isEditingReply]);
|
|
13
30
|
var styles = useStyles();
|
|
31
|
+
var menuItems = useMemo(function () { return [
|
|
32
|
+
{
|
|
33
|
+
text: i18n.text('Edit'),
|
|
34
|
+
onClick: function () { return setIsEditingReply(true); }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
text: i18n.text('Delete'),
|
|
38
|
+
onClick: function () { return deleteReply({ uri: uri, commentId: comment.commentId, reply: reply }); }
|
|
39
|
+
}
|
|
40
|
+
]; }, [deleteReply, uri, comment.commentId, reply]);
|
|
41
|
+
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, popperRef: popperRef, uri: uri, onCancel: function () { return setIsEditingReply(false); }, isEditingReply: isEditingReply, reply: reply, comment: comment }));
|
|
14
42
|
return (React.createElement(Box, { className: classnames(styles.root, className) },
|
|
15
43
|
React.createElement(Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
16
|
-
React.createElement(Box,
|
|
44
|
+
React.createElement(Box, { flexGrow: 1 },
|
|
17
45
|
React.createElement(Box, { className: styles.header },
|
|
18
46
|
React.createElement(Typography, { className: styles.username }, createdBy),
|
|
19
47
|
action === 'resolve' && (React.createElement(Typography, { className: styles.marked }, i18n.text('Marked as resolved'))),
|
|
20
48
|
action === 'reopen' && React.createElement(Typography, { className: styles.marked }, i18n.text('Re-opened'))),
|
|
21
|
-
action !== 'resolve' &&
|
|
22
|
-
|
|
49
|
+
action !== 'resolve' &&
|
|
50
|
+
(isEditingReply ? sendMessageArea : React.createElement(CommentContent, { className: styles.message, comment: reply })),
|
|
51
|
+
React.createElement(Typography, { className: styles.createdAt }, formatDate(createdTime))),
|
|
52
|
+
canChangeReply && (React.createElement(DropDownMenuButton, { buttonComponent: SmallIconButtonWithTooltip, buttonProps: {
|
|
53
|
+
icon: MoreVertIcon,
|
|
54
|
+
tooltipTitle: i18n.text('Open menu')
|
|
55
|
+
}, menuItems: menuItems, menuId: "collaboration-comment-menu" }))));
|
|
23
56
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Comment } from '@reltio/mdm-sdk';
|
|
2
|
+
import { Comment, Reply } from '@reltio/mdm-sdk';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
5
5
|
className?: string;
|
|
6
6
|
uri: string;
|
|
7
|
-
objectType
|
|
8
|
-
relatedObjectUris
|
|
7
|
+
objectType?: Comment['objectType'];
|
|
8
|
+
relatedObjectUris?: Comment['relatedObjectUris'];
|
|
9
9
|
popperRef?: React.RefObject<any>;
|
|
10
10
|
comment?: Comment;
|
|
11
|
+
reply?: Pick<Reply, 'content' | 'replyId'>;
|
|
11
12
|
isEditingComment?: boolean;
|
|
13
|
+
isEditingReply?: boolean;
|
|
12
14
|
onCancel?: () => void;
|
|
13
15
|
};
|
|
14
|
-
export declare const SendMessageArea: ({ inputRef, className, uri, relatedObjectUris, objectType, popperRef, comment, isEditingComment, onCancel }: Props) => JSX.Element;
|
|
16
|
+
export declare const SendMessageArea: ({ inputRef, className, uri, relatedObjectUris, objectType, popperRef, comment, reply, isEditingComment, isEditingReply, onCancel }: Props) => JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -2,6 +2,7 @@ import React, { useState, useContext, useEffect } from 'react';
|
|
|
2
2
|
import i18n from 'ui-i18n';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { useSelector } from 'react-redux';
|
|
5
|
+
import { always, cond, T } from 'ramda';
|
|
5
6
|
import mdm from '@reltio/mdm-module';
|
|
6
7
|
import Box from '@material-ui/core/Box';
|
|
7
8
|
import Button from '@material-ui/core/Button';
|
|
@@ -9,7 +10,6 @@ import { TextFieldWithMentions } from '../TextFieldWithMentions/TextFieldWithMen
|
|
|
9
10
|
import { Avatar } from '../Avatar/Avatar';
|
|
10
11
|
import { CollaborationContext } from '../../../contexts';
|
|
11
12
|
import { useStyles } from './styles';
|
|
12
|
-
import { always, cond, T } from 'ramda';
|
|
13
13
|
import { useSafePromise } from '../../../hooks';
|
|
14
14
|
var getPlaceholder = function (status) {
|
|
15
15
|
switch (status) {
|
|
@@ -21,8 +21,8 @@ var getPlaceholder = function (status) {
|
|
|
21
21
|
return '';
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
var getButtonText = function (status, isEditingComment) {
|
|
25
|
-
if (isEditingComment) {
|
|
24
|
+
var getButtonText = function (status, isEditingComment, isEditingReply) {
|
|
25
|
+
if (isEditingComment || isEditingReply) {
|
|
26
26
|
return i18n.text('Edit');
|
|
27
27
|
}
|
|
28
28
|
if (status === 'open' || status === 'resolved') {
|
|
@@ -31,10 +31,11 @@ var getButtonText = function (status, isEditingComment) {
|
|
|
31
31
|
return i18n.text('Comment');
|
|
32
32
|
};
|
|
33
33
|
export var SendMessageArea = function (_a) {
|
|
34
|
-
var inputRef = _a.inputRef, className = _a.className, uri = _a.uri, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType, popperRef = _a.popperRef, comment = _a.comment, isEditingComment = _a.isEditingComment, onCancel = _a.onCancel;
|
|
35
|
-
var
|
|
34
|
+
var inputRef = _a.inputRef, className = _a.className, uri = _a.uri, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType, popperRef = _a.popperRef, comment = _a.comment, reply = _a.reply, isEditingComment = _a.isEditingComment, isEditingReply = _a.isEditingReply, onCancel = _a.onCancel;
|
|
35
|
+
var isEditing = isEditingComment || isEditingReply;
|
|
36
|
+
var styles = useStyles({ isEditing: isEditing });
|
|
36
37
|
var username = useSelector(mdm.selectors.getUserName);
|
|
37
|
-
var _b = useContext(CollaborationContext), createReply = _b.createReply, createComment = _b.createComment, sending = _b.sending, editComment = _b.editComment;
|
|
38
|
+
var _b = useContext(CollaborationContext), createReply = _b.createReply, createComment = _b.createComment, sending = _b.sending, editComment = _b.editComment, editReply = _b.editReply;
|
|
38
39
|
var _c = useState(''), value = _c[0], setValue = _c[1];
|
|
39
40
|
var _d = useState(''), plainTextValue = _d[0], setPlainTextValue = _d[1];
|
|
40
41
|
var _e = useState([]), mentions = _e[0], setMentions = _e[1];
|
|
@@ -87,6 +88,17 @@ export var SendMessageArea = function (_a) {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
],
|
|
91
|
+
[
|
|
92
|
+
always(isEditingReply),
|
|
93
|
+
function () {
|
|
94
|
+
return editReply({
|
|
95
|
+
content: plainTextValue,
|
|
96
|
+
namedUsers: mentions,
|
|
97
|
+
commentId: comment.commentId,
|
|
98
|
+
replyId: reply.replyId
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
],
|
|
90
102
|
[
|
|
91
103
|
T,
|
|
92
104
|
function () {
|
|
@@ -108,19 +120,25 @@ export var SendMessageArea = function (_a) {
|
|
|
108
120
|
}
|
|
109
121
|
}, [popperRef, shouldShowButtons]);
|
|
110
122
|
useEffect(function () {
|
|
111
|
-
if (isEditingComment) {
|
|
112
|
-
|
|
123
|
+
if (isEditingComment || isEditingReply) {
|
|
124
|
+
if (isEditingComment) {
|
|
125
|
+
setValue(comment.content);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
setValue(reply.content);
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
else {
|
|
115
132
|
clearValue();
|
|
116
133
|
}
|
|
117
|
-
}, [isEditingComment]);
|
|
134
|
+
}, [isEditingComment, isEditingReply]);
|
|
135
|
+
var buttonSize = isEditing ? 'small' : 'medium';
|
|
118
136
|
return (React.createElement(Box, { className: classnames(styles.root, className) },
|
|
119
137
|
React.createElement("form", { onSubmit: handleSubmit, className: styles.form },
|
|
120
138
|
React.createElement(Box, { className: styles.main },
|
|
121
|
-
React.createElement(Avatar, { classes: { root: styles.avatar } }, username),
|
|
139
|
+
!isEditing && React.createElement(Avatar, { classes: { root: styles.avatar } }, username),
|
|
122
140
|
React.createElement(TextFieldWithMentions, { className: styles.textField, disabled: sending, onChange: handleChange, inputRef: inputRef, value: value, onFocus: handleFocus, onBlur: handleBlur, placeholder: getPlaceholder(status) })),
|
|
123
141
|
shouldShowButtons && (React.createElement(Box, { className: styles.buttons },
|
|
124
|
-
React.createElement(Button, { className: styles.button, variant: "contained", color: "primary", disabled: !hasValue || sending, type: "submit" }, getButtonText(status, isEditingComment)),
|
|
125
|
-
React.createElement(Button, { disabled: sending, onClick: handleCancel, className: styles.button, variant: "outlined", color: "primary" }, i18n.text('Cancel')))))));
|
|
142
|
+
React.createElement(Button, { className: styles.button, variant: "contained", color: "primary", disabled: !hasValue || sending, type: "submit", size: buttonSize }, getButtonText(status, isEditingComment, isEditingReply)),
|
|
143
|
+
React.createElement(Button, { disabled: sending, onClick: handleCancel, className: styles.button, variant: "outlined", color: "primary", size: buttonSize }, i18n.text('Cancel')))))));
|
|
126
144
|
};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
declare type StylesProps = {
|
|
2
|
+
isEditing?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "form" | "main" | "root" | "avatar" | "textField" | "buttons">;
|
|
5
|
+
export {};
|