@reltio/components 1.4.1326 → 1.4.1328
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/Comment/Comment.js +10 -8
- package/cjs/components/CollaborationItem/RepliedComment/RepliedComment.js +11 -9
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +1 -1
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.js +20 -29
- package/cjs/components/CollaborationItem/utils/index.d.ts +14 -1
- package/cjs/components/CollaborationItem/utils/index.js +35 -1
- package/cjs/components/charts/BarChart/getBarChartSettings.js +2 -0
- package/cjs/components/charts/LineChart/getLineChartSettings.js +2 -0
- package/cjs/contexts/CollaborationContext/index.d.ts +4 -1
- package/cjs/contexts/CollaborationContext/index.js +3 -0
- package/cjs/hooks/useCollaboration.d.ts +4 -1
- package/cjs/hooks/useCollaboration.js +15 -0
- package/esm/components/CollaborationItem/Comment/Comment.js +12 -10
- package/esm/components/CollaborationItem/RepliedComment/RepliedComment.js +13 -11
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +1 -1
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.js +20 -29
- package/esm/components/CollaborationItem/utils/index.d.ts +14 -1
- package/esm/components/CollaborationItem/utils/index.js +28 -0
- package/esm/components/charts/BarChart/getBarChartSettings.js +2 -0
- package/esm/components/charts/LineChart/getLineChartSettings.js +2 -0
- package/esm/contexts/CollaborationContext/index.d.ts +4 -1
- package/esm/contexts/CollaborationContext/index.js +3 -0
- package/esm/hooks/useCollaboration.d.ts +4 -1
- package/esm/hooks/useCollaboration.js +16 -1
- package/package.json +3 -3
|
@@ -48,33 +48,35 @@ var Comment = function (_a) {
|
|
|
48
48
|
var onReply = _a.onReply, className = _a.className, uri = _a.uri, comment = _a.comment, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType;
|
|
49
49
|
var styles = (0, styles_1.useStyles)();
|
|
50
50
|
var inputRef = (0, react_1.useRef)();
|
|
51
|
-
var _b = (0, react_1.useState)(false), isEditingComment = _b[0], setIsEditingComment = _b[1];
|
|
52
51
|
var username = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getUserName);
|
|
53
52
|
var commentId = comment.commentId, createdBy = comment.createdBy, createdTime = comment.createdTime;
|
|
54
53
|
var canChangeComment = createdBy === username;
|
|
55
|
-
var
|
|
54
|
+
var _b = (0, react_1.useContext)(contexts_1.CollaborationContext), resolveThread = _b.resolveThread, reOpenThread = _b.reOpenThread, sending = _b.sending, deleteComment = _b.deleteComment, updateCommentState = _b.updateCommentState, getCommentState = _b.getCommentState;
|
|
55
|
+
var commentUri = (0, utils_1.createEditedCommentUri)(comment);
|
|
56
|
+
var isEditing = getCommentState(uri, commentUri).isEditing;
|
|
57
|
+
var updateIsEditingComment = (0, react_1.useCallback)(function (value) { return updateCommentState(uri, commentUri, { isEditing: value }); }, [commentUri, updateCommentState, uri]);
|
|
56
58
|
(0, react_1.useEffect)(function () {
|
|
57
|
-
if (
|
|
59
|
+
if (isEditing) {
|
|
58
60
|
inputRef.current.focus();
|
|
59
61
|
}
|
|
60
|
-
}, [
|
|
62
|
+
}, [isEditing]);
|
|
61
63
|
var menuItems = (0, react_1.useMemo)(function () { return [
|
|
62
64
|
{
|
|
63
65
|
text: ui_i18n_1.default.text('Edit'),
|
|
64
|
-
onClick: function () { return
|
|
66
|
+
onClick: function () { return updateIsEditingComment(true); }
|
|
65
67
|
},
|
|
66
68
|
{
|
|
67
69
|
text: ui_i18n_1.default.text('Delete'),
|
|
68
70
|
onClick: function () { return deleteComment({ uri: uri, commentId: commentId }); }
|
|
69
71
|
}
|
|
70
|
-
]; }, [deleteComment, uri, commentId]);
|
|
72
|
+
]; }, [deleteComment, uri, commentId, updateIsEditingComment]);
|
|
71
73
|
var handleResolve = function () {
|
|
72
74
|
resolveThread({ commentId: commentId, uri: uri });
|
|
73
75
|
};
|
|
74
76
|
var handleReOpen = function () {
|
|
75
77
|
reOpenThread({ commentId: commentId, uri: uri });
|
|
76
78
|
};
|
|
77
|
-
var sendMessageArea = (react_1.default.createElement(SendMessageArea_1.SendMessageArea, { inputRef: inputRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, onCancel: function () { return
|
|
79
|
+
var sendMessageArea = (react_1.default.createElement(SendMessageArea_1.SendMessageArea, { inputRef: inputRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, onCancel: function () { return updateIsEditingComment(false); }, isEditingComment: isEditing, comment: comment }));
|
|
78
80
|
return (react_1.default.createElement(Box_1.default, { className: className },
|
|
79
81
|
react_1.default.createElement(Box_1.default, { className: styles.header },
|
|
80
82
|
react_1.default.createElement(Avatar_1.Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
@@ -87,7 +89,7 @@ var Comment = function (_a) {
|
|
|
87
89
|
}, popoverProps: { PopoverClasses: { root: styles.dropdownMenu } }, menuItems: menuItems, menuId: "collaboration-comment-menu" }))),
|
|
88
90
|
react_1.default.createElement(Box_1.default, { className: styles.body },
|
|
89
91
|
react_1.default.createElement(CommentTarget_1.CommentTarget, { comment: comment, className: styles.commentTarget }),
|
|
90
|
-
|
|
92
|
+
isEditing ? sendMessageArea : react_1.default.createElement(CommentContent_1.CommentContent, { comment: comment, className: styles.message }),
|
|
91
93
|
react_1.default.createElement(Box_1.default, { className: styles.buttons },
|
|
92
94
|
react_1.default.createElement(Link_1.default, { className: styles.button, onClick: onReply, component: "button" }, ui_i18n_1.default.text('Reply')),
|
|
93
95
|
comment.status === 'open' && (react_1.default.createElement(Link_1.default, { disabled: sending, className: styles.button, onClick: handleResolve, component: "button" }, ui_i18n_1.default.text('Resolve'))),
|
|
@@ -38,36 +38,38 @@ var Typography_1 = __importDefault(require("@material-ui/core/Typography"));
|
|
|
38
38
|
var Avatar_1 = require("../Avatar/Avatar");
|
|
39
39
|
var CommentContent_1 = require("../CommentContent/CommentContent");
|
|
40
40
|
var utils_1 = require("../utils");
|
|
41
|
-
var styles_1 = require("./styles");
|
|
42
41
|
var contexts_1 = require("../../../contexts");
|
|
43
42
|
var DropDownMenuButton_1 = __importDefault(require("../../DropDownMenuButton/DropDownMenuButton"));
|
|
44
43
|
var SmallIconButton_1 = require("../../SmallIconButton");
|
|
45
44
|
var SendMessageArea_1 = require("../SendMessageArea/SendMessageArea");
|
|
45
|
+
var styles_1 = require("./styles");
|
|
46
46
|
var RepliedComment = function (_a) {
|
|
47
47
|
var className = _a.className, reply = _a.reply, uri = _a.uri, comment = _a.comment, popperRef = _a.popperRef;
|
|
48
48
|
var inputRef = (0, react_1.useRef)();
|
|
49
|
-
var _b = (0, react_1.useState)(false), isEditingReply = _b[0], setIsEditingReply = _b[1];
|
|
50
49
|
var createdBy = reply.createdBy, action = reply.action, createdTime = reply.createdTime;
|
|
51
50
|
var username = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getUserName);
|
|
52
51
|
var canChangeReply = createdBy === username;
|
|
53
|
-
var
|
|
52
|
+
var _b = (0, react_1.useContext)(contexts_1.CollaborationContext), deleteReply = _b.deleteReply, updateCommentState = _b.updateCommentState, getCommentState = _b.getCommentState;
|
|
53
|
+
var commentUri = (0, utils_1.createEditedReplyUri)(comment, reply);
|
|
54
|
+
var isEditing = getCommentState(uri, commentUri).isEditing;
|
|
55
|
+
var updateIsEditingReply = (0, react_1.useCallback)(function (value) { return updateCommentState(uri, commentUri, { isEditing: value }); }, [commentUri, updateCommentState, uri]);
|
|
54
56
|
(0, react_1.useEffect)(function () {
|
|
55
|
-
if (
|
|
57
|
+
if (isEditing) {
|
|
56
58
|
inputRef.current.focus();
|
|
57
59
|
}
|
|
58
|
-
}, [
|
|
60
|
+
}, [isEditing]);
|
|
59
61
|
var styles = (0, styles_1.useStyles)();
|
|
60
62
|
var menuItems = (0, react_1.useMemo)(function () { return [
|
|
61
63
|
{
|
|
62
64
|
text: ui_i18n_1.default.text('Edit'),
|
|
63
|
-
onClick: function () { return
|
|
65
|
+
onClick: function () { return updateIsEditingReply(true); }
|
|
64
66
|
},
|
|
65
67
|
{
|
|
66
68
|
text: ui_i18n_1.default.text('Delete'),
|
|
67
69
|
onClick: function () { return deleteReply({ uri: uri, commentId: comment.commentId, reply: reply }); }
|
|
68
70
|
}
|
|
69
|
-
]; }, [deleteReply, uri, comment.commentId, reply]);
|
|
70
|
-
var sendMessageArea = (react_1.default.createElement(SendMessageArea_1.SendMessageArea, { inputRef: inputRef, popperRef: popperRef, uri: uri, onCancel: function () { return
|
|
71
|
+
]; }, [deleteReply, uri, comment.commentId, reply, updateIsEditingReply]);
|
|
72
|
+
var sendMessageArea = (react_1.default.createElement(SendMessageArea_1.SendMessageArea, { inputRef: inputRef, popperRef: popperRef, uri: uri, onCancel: function () { return updateIsEditingReply(false); }, isEditingReply: isEditing, reply: reply, comment: comment }));
|
|
71
73
|
return (react_1.default.createElement(Box_1.default, { className: (0, classnames_1.default)(styles.root, className) },
|
|
72
74
|
react_1.default.createElement(Avatar_1.Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
73
75
|
react_1.default.createElement(Box_1.default, { flexGrow: 1 },
|
|
@@ -76,7 +78,7 @@ var RepliedComment = function (_a) {
|
|
|
76
78
|
action === 'resolve' && (react_1.default.createElement(Typography_1.default, { className: styles.marked }, ui_i18n_1.default.text('Marked as resolved'))),
|
|
77
79
|
action === 'reopen' && react_1.default.createElement(Typography_1.default, { className: styles.marked }, ui_i18n_1.default.text('Re-opened'))),
|
|
78
80
|
action !== 'resolve' &&
|
|
79
|
-
(
|
|
81
|
+
(isEditing ? sendMessageArea : react_1.default.createElement(CommentContent_1.CommentContent, { className: styles.message, comment: reply })),
|
|
80
82
|
react_1.default.createElement(Typography_1.default, { className: styles.createdAt }, (0, utils_1.formatDate)(createdTime))),
|
|
81
83
|
canChangeReply && (react_1.default.createElement(DropDownMenuButton_1.default, { buttonComponent: SmallIconButton_1.SmallIconButtonWithTooltip, buttonProps: {
|
|
82
84
|
icon: MoreVert_1.default,
|
|
@@ -8,7 +8,7 @@ declare type Props = {
|
|
|
8
8
|
relatedObjectUris?: Comment['relatedObjectUris'];
|
|
9
9
|
popperRef?: React.RefObject<any>;
|
|
10
10
|
comment?: Comment;
|
|
11
|
-
reply?: Pick<Reply, 'content' | 'replyId'>;
|
|
11
|
+
reply?: Pick<Reply, 'content' | 'replyId' | 'namedUsers'>;
|
|
12
12
|
isEditingComment?: boolean;
|
|
13
13
|
isEditingReply?: boolean;
|
|
14
14
|
onCancel?: () => void;
|
|
@@ -38,8 +38,8 @@ var Button_1 = __importDefault(require("@material-ui/core/Button"));
|
|
|
38
38
|
var TextFieldWithMentions_1 = require("../TextFieldWithMentions/TextFieldWithMentions");
|
|
39
39
|
var Avatar_1 = require("../Avatar/Avatar");
|
|
40
40
|
var contexts_1 = require("../../../contexts");
|
|
41
|
+
var utils_1 = require("../utils");
|
|
41
42
|
var styles_1 = require("./styles");
|
|
42
|
-
var hooks_1 = require("../../../hooks");
|
|
43
43
|
var getPlaceholder = function (status) {
|
|
44
44
|
switch (status) {
|
|
45
45
|
case 'open':
|
|
@@ -59,31 +59,35 @@ var getButtonText = function (status, isEditingComment, isEditingReply) {
|
|
|
59
59
|
}
|
|
60
60
|
return ui_i18n_1.default.text('Comment');
|
|
61
61
|
};
|
|
62
|
+
var getDefaultCommentState = function (_a) {
|
|
63
|
+
var comment = _a.comment, reply = _a.reply, isEditingComment = _a.isEditingComment, isEditingReply = _a.isEditingReply;
|
|
64
|
+
var commentOrReply = isEditingComment ? comment : isEditingReply ? reply : null;
|
|
65
|
+
var _b = commentOrReply || {}, _c = _b.content, plainTextValue = _c === void 0 ? '' : _c, _d = _b.namedUsers, mentions = _d === void 0 ? [] : _d;
|
|
66
|
+
return {
|
|
67
|
+
value: (0, utils_1.transformPlainTextValueToValueWithMentions)(plainTextValue, mentions),
|
|
68
|
+
plainTextValue: plainTextValue,
|
|
69
|
+
mentions: mentions
|
|
70
|
+
};
|
|
71
|
+
};
|
|
62
72
|
var SendMessageArea = function (_a) {
|
|
63
73
|
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;
|
|
64
74
|
var isEditing = isEditingComment || isEditingReply;
|
|
65
75
|
var styles = (0, styles_1.useStyles)({ isEditing: isEditing });
|
|
76
|
+
var _b = (0, react_1.useState)(false), focused = _b[0], setFocused = _b[1];
|
|
66
77
|
var username = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getUserName);
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var _f = (0, react_1.useState)(false), focused = _f[0], setFocused = _f[1];
|
|
72
|
-
var safePromise = (0, hooks_1.useSafePromise)();
|
|
78
|
+
var _c = (0, react_1.useContext)(contexts_1.CollaborationContext), createReply = _c.createReply, createComment = _c.createComment, sending = _c.sending, editComment = _c.editComment, editReply = _c.editReply, getCommentState = _c.getCommentState, updateCommentState = _c.updateCommentState, clearCommentState = _c.clearCommentState;
|
|
79
|
+
var commentUri = (0, utils_1.createCommentUri)({ comment: comment, reply: reply, isEditingComment: isEditingComment, isEditingReply: isEditingReply });
|
|
80
|
+
var defaultCommentState = getDefaultCommentState({ comment: comment, reply: reply, isEditingComment: isEditingComment, isEditingReply: isEditingReply });
|
|
81
|
+
var _d = getCommentState(uri, commentUri), _e = _d.value, value = _e === void 0 ? defaultCommentState.value : _e, _f = _d.plainTextValue, plainTextValue = _f === void 0 ? defaultCommentState.plainTextValue : _f, _g = _d.mentions, mentions = _g === void 0 ? defaultCommentState.mentions : _g;
|
|
73
82
|
var hasValue = value.trim() !== '';
|
|
74
83
|
var shouldShowButtons = focused || hasValue;
|
|
75
84
|
var status = comment === null || comment === void 0 ? void 0 : comment.status;
|
|
76
|
-
var updateValue = function (value, plainTextValue, mentions) {
|
|
77
|
-
setMentions(mentions);
|
|
78
|
-
setValue(value);
|
|
79
|
-
setPlainTextValue(plainTextValue);
|
|
80
|
-
};
|
|
81
85
|
var clearValue = function () {
|
|
82
86
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
83
|
-
|
|
87
|
+
clearCommentState(uri, commentUri);
|
|
84
88
|
};
|
|
85
|
-
var handleChange = function (
|
|
86
|
-
|
|
89
|
+
var handleChange = function (value, plainTextValue, mentions) {
|
|
90
|
+
return updateCommentState(uri, commentUri, { value: value, plainTextValue: plainTextValue, mentions: mentions });
|
|
87
91
|
};
|
|
88
92
|
var handleCancel = function () { return clearValue(); };
|
|
89
93
|
var handleFocus = function () { return setFocused(true); };
|
|
@@ -141,26 +145,13 @@ var SendMessageArea = function (_a) {
|
|
|
141
145
|
}
|
|
142
146
|
]
|
|
143
147
|
]);
|
|
144
|
-
return
|
|
148
|
+
return request().then(clearValue).catch(console.log); //eslint-disable-line no-console
|
|
145
149
|
};
|
|
146
150
|
(0, react_1.useEffect)(function () {
|
|
147
151
|
if (popperRef) {
|
|
148
152
|
popperRef.current.update();
|
|
149
153
|
}
|
|
150
154
|
}, [popperRef, shouldShowButtons]);
|
|
151
|
-
(0, react_1.useEffect)(function () {
|
|
152
|
-
if (isEditingComment || isEditingReply) {
|
|
153
|
-
if (isEditingComment) {
|
|
154
|
-
setValue(comment.content);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
setValue(reply.content);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
clearValue();
|
|
162
|
-
}
|
|
163
|
-
}, [isEditingComment, isEditingReply]);
|
|
164
155
|
var buttonSize = isEditing ? 'small' : 'medium';
|
|
165
156
|
return (react_1.default.createElement(Box_1.default, { className: (0, classnames_1.default)(styles.root, className) },
|
|
166
157
|
react_1.default.createElement("form", { onSubmit: handleSubmit, className: styles.form },
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { Comment } from '@reltio/mdm-sdk';
|
|
1
|
+
import { Comment, Reply } from '@reltio/mdm-sdk';
|
|
2
2
|
export declare const getAbbreviationFromUserName: (username: string) => string;
|
|
3
3
|
export declare const getRelatedEntityUri: (comment: Pick<Comment, 'relatedObjectUris'>, entityUri: string) => string;
|
|
4
4
|
export declare const formatDate: (time: number) => string;
|
|
5
5
|
export declare const processMentions: (text: string, mentions: string[], processor?: (mention: string) => unknown, trigger?: string) => any[];
|
|
6
|
+
export declare const createNewCommentUri: () => string;
|
|
7
|
+
export declare const createNewReplyUri: (comment: Pick<Comment, 'commentId'>) => string;
|
|
8
|
+
export declare const createEditedCommentUri: (comment: Pick<Comment, 'commentId'>) => string;
|
|
9
|
+
export declare const createEditedReplyUri: (comment: Pick<Comment, 'commentId'>, reply: Pick<Reply, 'replyId'>) => string;
|
|
10
|
+
declare type CreateCommentUriProps = {
|
|
11
|
+
comment: Pick<Comment, 'commentId'> | null;
|
|
12
|
+
reply: Pick<Reply, 'replyId'> | null;
|
|
13
|
+
isEditingReply: boolean;
|
|
14
|
+
isEditingComment: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const createCommentUri: ({ comment, reply, isEditingComment, isEditingReply }: CreateCommentUriProps) => string;
|
|
17
|
+
export declare const transformPlainTextValueToValueWithMentions: (plainTextValue: string, mentions: string[]) => string;
|
|
18
|
+
export {};
|
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.processMentions = exports.formatDate = exports.getRelatedEntityUri = exports.getAbbreviationFromUserName = void 0;
|
|
6
|
+
exports.transformPlainTextValueToValueWithMentions = exports.createCommentUri = exports.createEditedReplyUri = exports.createEditedCommentUri = exports.createNewReplyUri = exports.createNewCommentUri = exports.processMentions = exports.formatDate = exports.getRelatedEntityUri = exports.getAbbreviationFromUserName = void 0;
|
|
7
7
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
8
|
+
var ramda_1 = require("ramda");
|
|
8
9
|
var getAbbreviationFromUserName = function (username) {
|
|
9
10
|
return username
|
|
10
11
|
.split('.')
|
|
@@ -51,3 +52,36 @@ var processMentions = function (text, mentions, processor, trigger) {
|
|
|
51
52
|
return arr;
|
|
52
53
|
};
|
|
53
54
|
exports.processMentions = processMentions;
|
|
55
|
+
var createNewCommentUri = function () { return 'comment/new'; };
|
|
56
|
+
exports.createNewCommentUri = createNewCommentUri;
|
|
57
|
+
var createNewReplyUri = function (comment) { return "comment/".concat(comment.commentId, "/reply/new"); };
|
|
58
|
+
exports.createNewReplyUri = createNewReplyUri;
|
|
59
|
+
var createEditedCommentUri = function (comment) { return "comment/".concat(comment.commentId); };
|
|
60
|
+
exports.createEditedCommentUri = createEditedCommentUri;
|
|
61
|
+
var createEditedReplyUri = function (comment, reply) {
|
|
62
|
+
return "comment/".concat(comment.commentId, "/reply/").concat(reply.replyId);
|
|
63
|
+
};
|
|
64
|
+
exports.createEditedReplyUri = createEditedReplyUri;
|
|
65
|
+
var createCommentUri = function (_a) {
|
|
66
|
+
var comment = _a.comment, reply = _a.reply, isEditingComment = _a.isEditingComment, isEditingReply = _a.isEditingReply;
|
|
67
|
+
if ((0, ramda_1.isNil)(comment)) {
|
|
68
|
+
return (0, exports.createNewCommentUri)();
|
|
69
|
+
}
|
|
70
|
+
if (isEditingComment) {
|
|
71
|
+
return (0, exports.createEditedCommentUri)(comment);
|
|
72
|
+
}
|
|
73
|
+
if (isEditingReply) {
|
|
74
|
+
return (0, exports.createEditedReplyUri)(comment, reply);
|
|
75
|
+
}
|
|
76
|
+
return (0, exports.createNewReplyUri)(comment);
|
|
77
|
+
};
|
|
78
|
+
exports.createCommentUri = createCommentUri;
|
|
79
|
+
var transformPlainTextValueToValueWithMentions = function (plainTextValue, mentions) {
|
|
80
|
+
var value = plainTextValue;
|
|
81
|
+
for (var _i = 0, mentions_1 = mentions; _i < mentions_1.length; _i++) {
|
|
82
|
+
var mention = mentions_1[_i];
|
|
83
|
+
value = value.split("+".concat(mention)).join("@[".concat(mention, "](").concat(mention, ")"));
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
};
|
|
87
|
+
exports.transformPlainTextValueToValueWithMentions = transformPlainTextValueToValueWithMentions;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
3
4
|
var getBarChartSettings = function (_a) {
|
|
4
5
|
var margin = _a.margin, isHorizontal = _a.isHorizontal, isLabelRotated = _a.isLabelRotated;
|
|
5
6
|
return {
|
|
@@ -31,6 +32,7 @@ var getBarChartSettings = function (_a) {
|
|
|
31
32
|
opacity: isHorizontal ? '0.87' : '0.54',
|
|
32
33
|
width: isHorizontal ? 150 : undefined
|
|
33
34
|
},
|
|
35
|
+
tickFormatter: mdm_sdk_1.formatNumberAsMetric,
|
|
34
36
|
stroke: '#666',
|
|
35
37
|
tickCount: 8,
|
|
36
38
|
mirror: isHorizontal
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
3
4
|
var getLineChartSettings = function (_a) {
|
|
4
5
|
var margin = _a.margin, isLabelRotated = _a.isLabelRotated;
|
|
5
6
|
return {
|
|
@@ -26,6 +27,7 @@ var getLineChartSettings = function (_a) {
|
|
|
26
27
|
opacity: '0.54',
|
|
27
28
|
width: undefined
|
|
28
29
|
},
|
|
30
|
+
tickFormatter: mdm_sdk_1.formatNumberAsMetric,
|
|
29
31
|
stroke: '#666',
|
|
30
32
|
tickCount: 8
|
|
31
33
|
},
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CollaborationObjectTypes, Comment, CommentsMap, Reply } from '@reltio/mdm-sdk';
|
|
2
|
+
import { CollaborationObjectTypes, Comment, CommentsMap, CommentState, Reply } from '@reltio/mdm-sdk';
|
|
3
3
|
export declare const CollaborationContext: React.Context<{
|
|
4
4
|
objectTypes?: CollaborationObjectTypes[];
|
|
5
5
|
commentsMap: CommentsMap;
|
|
6
6
|
comments: Comment[];
|
|
7
7
|
currentComment: Comment;
|
|
8
|
+
updateCommentState: (uri: string, commentUri: string, newState: CommentState) => void;
|
|
9
|
+
clearCommentState: (uri: string, commentUri: string) => void;
|
|
10
|
+
getCommentState: (uri: string, commentUri: string) => CommentState;
|
|
8
11
|
getComments: (uri: string, pageToken?: string) => void;
|
|
9
12
|
getCommentsCount: (objectIds: string[]) => void;
|
|
10
13
|
getComment: (commentId: Comment['commentId']) => void;
|
|
@@ -10,6 +10,9 @@ exports.CollaborationContext = react_1.default.createContext({
|
|
|
10
10
|
comments: [],
|
|
11
11
|
commentsMap: null,
|
|
12
12
|
currentComment: null,
|
|
13
|
+
updateCommentState: noop,
|
|
14
|
+
clearCommentState: noop,
|
|
15
|
+
getCommentState: function () { return ({}); },
|
|
13
16
|
getComment: noop,
|
|
14
17
|
getComments: function () { return new Promise(noop); },
|
|
15
18
|
getCommentsCount: noop,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollaborationObjectTypes, Comment, CommentsMap } from '@reltio/mdm-sdk';
|
|
1
|
+
import { CollaborationObjectTypes, Comment, CommentsMap, CommentState } from '@reltio/mdm-sdk';
|
|
2
2
|
declare type Props = {
|
|
3
3
|
objectIds?: string[];
|
|
4
4
|
objectTypes?: CollaborationObjectTypes[];
|
|
@@ -8,6 +8,9 @@ export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Pro
|
|
|
8
8
|
clearCurrentComment: () => void;
|
|
9
9
|
comments: Comment[];
|
|
10
10
|
commentsMap: CommentsMap;
|
|
11
|
+
getCommentState: (uri: string, commentUri: string) => any;
|
|
12
|
+
updateCommentState: (uri: string, commentUri: string, newState: CommentState) => void;
|
|
13
|
+
clearCommentState: (uri: string, commentUri: string) => void;
|
|
11
14
|
createComment: ({ content, namedUsers, objectType, uri, relatedObjectUris }: any) => Promise<void>;
|
|
12
15
|
createReply: ({ content, namedUsers, commentId, action, uri }: any) => Promise<void>;
|
|
13
16
|
currentComment: Comment;
|
|
@@ -53,6 +53,7 @@ var useCollaboration = function (_a) {
|
|
|
53
53
|
var _g = (0, react_1.useState)(null), currentComment = _g[0], setCurrentComment = _g[1];
|
|
54
54
|
var _h = (0, react_1.useState)(false), sending = _h[0], setSending = _h[1];
|
|
55
55
|
var _j = (0, react_1.useState)(false), loading = _j[0], setLoading = _j[1];
|
|
56
|
+
var _k = (0, react_1.useState)({}), collaborationStateMap = _k[0], setCollaborationStateMap = _k[1];
|
|
56
57
|
var addCommentsToCommentsMap = (0, react_1.useCallback)(function (commentsMap) {
|
|
57
58
|
setCommentsMap(function (currentCommentsMap) { return (__assign(__assign({}, currentCommentsMap), commentsMap)); });
|
|
58
59
|
}, []);
|
|
@@ -265,10 +266,24 @@ var useCollaboration = function (_a) {
|
|
|
265
266
|
var clearCurrentComment = (0, react_1.useCallback)(function () {
|
|
266
267
|
setCurrentComment(null);
|
|
267
268
|
}, []);
|
|
269
|
+
var getCommentState = function (uri, commentUri) { return (0, ramda_1.pathOr)({}, [uri, commentUri], collaborationStateMap); };
|
|
270
|
+
var clearCommentState = function (uri, commentUri) {
|
|
271
|
+
return setCollaborationStateMap((0, ramda_1.dissocPath)([uri, commentUri]));
|
|
272
|
+
};
|
|
273
|
+
var updateCommentState = function (uri, commentUri, newState) {
|
|
274
|
+
setCollaborationStateMap(function (prevCollaborationStateMap) {
|
|
275
|
+
var pathToCommentState = [uri, commentUri];
|
|
276
|
+
var prevCommentState = (0, ramda_1.path)(pathToCommentState, prevCollaborationStateMap);
|
|
277
|
+
return (0, ramda_1.assocPath)(pathToCommentState, (0, ramda_1.mergeRight)(prevCommentState, newState), prevCollaborationStateMap);
|
|
278
|
+
});
|
|
279
|
+
};
|
|
268
280
|
return {
|
|
269
281
|
clearCurrentComment: clearCurrentComment,
|
|
270
282
|
comments: comments,
|
|
271
283
|
commentsMap: commentsMap,
|
|
284
|
+
getCommentState: getCommentState,
|
|
285
|
+
updateCommentState: updateCommentState,
|
|
286
|
+
clearCommentState: clearCommentState,
|
|
272
287
|
createComment: createComment,
|
|
273
288
|
createReply: createReply,
|
|
274
289
|
currentComment: currentComment,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useContext,
|
|
1
|
+
import React, { useMemo, useContext, useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import i18n from 'ui-i18n';
|
|
4
4
|
import Link from '@material-ui/core/Link';
|
|
@@ -12,40 +12,42 @@ import { CommentTarget } from '../CommentTarget/CommentTarget';
|
|
|
12
12
|
import { CommentContent } from '../CommentContent/CommentContent';
|
|
13
13
|
import { Avatar } from '../Avatar/Avatar';
|
|
14
14
|
import { CollaborationContext } from '../../../contexts';
|
|
15
|
-
import { formatDate } from '../utils';
|
|
15
|
+
import { createEditedCommentUri, formatDate } from '../utils';
|
|
16
16
|
import { SendMessageArea } from '../SendMessageArea/SendMessageArea';
|
|
17
17
|
import { useStyles } from './styles';
|
|
18
18
|
export var Comment = function (_a) {
|
|
19
19
|
var onReply = _a.onReply, className = _a.className, uri = _a.uri, comment = _a.comment, relatedObjectUris = _a.relatedObjectUris, objectType = _a.objectType;
|
|
20
20
|
var styles = useStyles();
|
|
21
21
|
var inputRef = useRef();
|
|
22
|
-
var _b = useState(false), isEditingComment = _b[0], setIsEditingComment = _b[1];
|
|
23
22
|
var username = useSelector(mdm.selectors.getUserName);
|
|
24
23
|
var commentId = comment.commentId, createdBy = comment.createdBy, createdTime = comment.createdTime;
|
|
25
24
|
var canChangeComment = createdBy === username;
|
|
26
|
-
var
|
|
25
|
+
var _b = useContext(CollaborationContext), resolveThread = _b.resolveThread, reOpenThread = _b.reOpenThread, sending = _b.sending, deleteComment = _b.deleteComment, updateCommentState = _b.updateCommentState, getCommentState = _b.getCommentState;
|
|
26
|
+
var commentUri = createEditedCommentUri(comment);
|
|
27
|
+
var isEditing = getCommentState(uri, commentUri).isEditing;
|
|
28
|
+
var updateIsEditingComment = useCallback(function (value) { return updateCommentState(uri, commentUri, { isEditing: value }); }, [commentUri, updateCommentState, uri]);
|
|
27
29
|
useEffect(function () {
|
|
28
|
-
if (
|
|
30
|
+
if (isEditing) {
|
|
29
31
|
inputRef.current.focus();
|
|
30
32
|
}
|
|
31
|
-
}, [
|
|
33
|
+
}, [isEditing]);
|
|
32
34
|
var menuItems = useMemo(function () { return [
|
|
33
35
|
{
|
|
34
36
|
text: i18n.text('Edit'),
|
|
35
|
-
onClick: function () { return
|
|
37
|
+
onClick: function () { return updateIsEditingComment(true); }
|
|
36
38
|
},
|
|
37
39
|
{
|
|
38
40
|
text: i18n.text('Delete'),
|
|
39
41
|
onClick: function () { return deleteComment({ uri: uri, commentId: commentId }); }
|
|
40
42
|
}
|
|
41
|
-
]; }, [deleteComment, uri, commentId]);
|
|
43
|
+
]; }, [deleteComment, uri, commentId, updateIsEditingComment]);
|
|
42
44
|
var handleResolve = function () {
|
|
43
45
|
resolveThread({ commentId: commentId, uri: uri });
|
|
44
46
|
};
|
|
45
47
|
var handleReOpen = function () {
|
|
46
48
|
reOpenThread({ commentId: commentId, uri: uri });
|
|
47
49
|
};
|
|
48
|
-
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, onCancel: function () { return
|
|
50
|
+
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, uri: uri, relatedObjectUris: relatedObjectUris, objectType: objectType, onCancel: function () { return updateIsEditingComment(false); }, isEditingComment: isEditing, comment: comment }));
|
|
49
51
|
return (React.createElement(Box, { className: className },
|
|
50
52
|
React.createElement(Box, { className: styles.header },
|
|
51
53
|
React.createElement(Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
@@ -58,7 +60,7 @@ export var Comment = function (_a) {
|
|
|
58
60
|
}, popoverProps: { PopoverClasses: { root: styles.dropdownMenu } }, menuItems: menuItems, menuId: "collaboration-comment-menu" }))),
|
|
59
61
|
React.createElement(Box, { className: styles.body },
|
|
60
62
|
React.createElement(CommentTarget, { comment: comment, className: styles.commentTarget }),
|
|
61
|
-
|
|
63
|
+
isEditing ? sendMessageArea : React.createElement(CommentContent, { comment: comment, className: styles.message }),
|
|
62
64
|
React.createElement(Box, { className: styles.buttons },
|
|
63
65
|
React.createElement(Link, { className: styles.button, onClick: onReply, component: "button" }, i18n.text('Reply')),
|
|
64
66
|
comment.status === 'open' && (React.createElement(Link, { disabled: sending, className: styles.button, onClick: handleResolve, component: "button" }, i18n.text('Resolve'))),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useContext, useMemo,
|
|
1
|
+
import React, { useRef, useContext, useMemo, useEffect, useCallback } from 'react';
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import i18n from 'ui-i18n';
|
|
4
4
|
import classnames from 'classnames';
|
|
@@ -8,37 +8,39 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
|
8
8
|
import Typography from '@material-ui/core/Typography';
|
|
9
9
|
import { Avatar } from '../Avatar/Avatar';
|
|
10
10
|
import { CommentContent } from '../CommentContent/CommentContent';
|
|
11
|
-
import { formatDate } from '../utils';
|
|
12
|
-
import { useStyles } from './styles';
|
|
11
|
+
import { createEditedReplyUri, formatDate } from '../utils';
|
|
13
12
|
import { CollaborationContext } from '../../../contexts';
|
|
14
13
|
import DropDownMenuButton from '../../DropDownMenuButton/DropDownMenuButton';
|
|
15
14
|
import { SmallIconButtonWithTooltip } from '../../SmallIconButton';
|
|
16
15
|
import { SendMessageArea } from '../SendMessageArea/SendMessageArea';
|
|
16
|
+
import { useStyles } from './styles';
|
|
17
17
|
export var RepliedComment = function (_a) {
|
|
18
18
|
var className = _a.className, reply = _a.reply, uri = _a.uri, comment = _a.comment, popperRef = _a.popperRef;
|
|
19
19
|
var inputRef = useRef();
|
|
20
|
-
var _b = useState(false), isEditingReply = _b[0], setIsEditingReply = _b[1];
|
|
21
20
|
var createdBy = reply.createdBy, action = reply.action, createdTime = reply.createdTime;
|
|
22
21
|
var username = useSelector(mdm.selectors.getUserName);
|
|
23
22
|
var canChangeReply = createdBy === username;
|
|
24
|
-
var
|
|
23
|
+
var _b = useContext(CollaborationContext), deleteReply = _b.deleteReply, updateCommentState = _b.updateCommentState, getCommentState = _b.getCommentState;
|
|
24
|
+
var commentUri = createEditedReplyUri(comment, reply);
|
|
25
|
+
var isEditing = getCommentState(uri, commentUri).isEditing;
|
|
26
|
+
var updateIsEditingReply = useCallback(function (value) { return updateCommentState(uri, commentUri, { isEditing: value }); }, [commentUri, updateCommentState, uri]);
|
|
25
27
|
useEffect(function () {
|
|
26
|
-
if (
|
|
28
|
+
if (isEditing) {
|
|
27
29
|
inputRef.current.focus();
|
|
28
30
|
}
|
|
29
|
-
}, [
|
|
31
|
+
}, [isEditing]);
|
|
30
32
|
var styles = useStyles();
|
|
31
33
|
var menuItems = useMemo(function () { return [
|
|
32
34
|
{
|
|
33
35
|
text: i18n.text('Edit'),
|
|
34
|
-
onClick: function () { return
|
|
36
|
+
onClick: function () { return updateIsEditingReply(true); }
|
|
35
37
|
},
|
|
36
38
|
{
|
|
37
39
|
text: i18n.text('Delete'),
|
|
38
40
|
onClick: function () { return deleteReply({ uri: uri, commentId: comment.commentId, reply: reply }); }
|
|
39
41
|
}
|
|
40
|
-
]; }, [deleteReply, uri, comment.commentId, reply]);
|
|
41
|
-
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, popperRef: popperRef, uri: uri, onCancel: function () { return
|
|
42
|
+
]; }, [deleteReply, uri, comment.commentId, reply, updateIsEditingReply]);
|
|
43
|
+
var sendMessageArea = (React.createElement(SendMessageArea, { inputRef: inputRef, popperRef: popperRef, uri: uri, onCancel: function () { return updateIsEditingReply(false); }, isEditingReply: isEditing, reply: reply, comment: comment }));
|
|
42
44
|
return (React.createElement(Box, { className: classnames(styles.root, className) },
|
|
43
45
|
React.createElement(Avatar, { classes: { root: styles.avatar } }, createdBy),
|
|
44
46
|
React.createElement(Box, { flexGrow: 1 },
|
|
@@ -47,7 +49,7 @@ export var RepliedComment = function (_a) {
|
|
|
47
49
|
action === 'resolve' && (React.createElement(Typography, { className: styles.marked }, i18n.text('Marked as resolved'))),
|
|
48
50
|
action === 'reopen' && React.createElement(Typography, { className: styles.marked }, i18n.text('Re-opened'))),
|
|
49
51
|
action !== 'resolve' &&
|
|
50
|
-
(
|
|
52
|
+
(isEditing ? sendMessageArea : React.createElement(CommentContent, { className: styles.message, comment: reply })),
|
|
51
53
|
React.createElement(Typography, { className: styles.createdAt }, formatDate(createdTime))),
|
|
52
54
|
canChangeReply && (React.createElement(DropDownMenuButton, { buttonComponent: SmallIconButtonWithTooltip, buttonProps: {
|
|
53
55
|
icon: MoreVertIcon,
|
|
@@ -8,7 +8,7 @@ declare type Props = {
|
|
|
8
8
|
relatedObjectUris?: Comment['relatedObjectUris'];
|
|
9
9
|
popperRef?: React.RefObject<any>;
|
|
10
10
|
comment?: Comment;
|
|
11
|
-
reply?: Pick<Reply, 'content' | 'replyId'>;
|
|
11
|
+
reply?: Pick<Reply, 'content' | 'replyId' | 'namedUsers'>;
|
|
12
12
|
isEditingComment?: boolean;
|
|
13
13
|
isEditingReply?: boolean;
|
|
14
14
|
onCancel?: () => void;
|
|
@@ -9,8 +9,8 @@ import Button from '@material-ui/core/Button';
|
|
|
9
9
|
import { TextFieldWithMentions } from '../TextFieldWithMentions/TextFieldWithMentions';
|
|
10
10
|
import { Avatar } from '../Avatar/Avatar';
|
|
11
11
|
import { CollaborationContext } from '../../../contexts';
|
|
12
|
+
import { createCommentUri, transformPlainTextValueToValueWithMentions } from '../utils';
|
|
12
13
|
import { useStyles } from './styles';
|
|
13
|
-
import { useSafePromise } from '../../../hooks';
|
|
14
14
|
var getPlaceholder = function (status) {
|
|
15
15
|
switch (status) {
|
|
16
16
|
case 'open':
|
|
@@ -30,31 +30,35 @@ var getButtonText = function (status, isEditingComment, isEditingReply) {
|
|
|
30
30
|
}
|
|
31
31
|
return i18n.text('Comment');
|
|
32
32
|
};
|
|
33
|
+
var getDefaultCommentState = function (_a) {
|
|
34
|
+
var comment = _a.comment, reply = _a.reply, isEditingComment = _a.isEditingComment, isEditingReply = _a.isEditingReply;
|
|
35
|
+
var commentOrReply = isEditingComment ? comment : isEditingReply ? reply : null;
|
|
36
|
+
var _b = commentOrReply || {}, _c = _b.content, plainTextValue = _c === void 0 ? '' : _c, _d = _b.namedUsers, mentions = _d === void 0 ? [] : _d;
|
|
37
|
+
return {
|
|
38
|
+
value: transformPlainTextValueToValueWithMentions(plainTextValue, mentions),
|
|
39
|
+
plainTextValue: plainTextValue,
|
|
40
|
+
mentions: mentions
|
|
41
|
+
};
|
|
42
|
+
};
|
|
33
43
|
export var SendMessageArea = function (_a) {
|
|
34
44
|
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
45
|
var isEditing = isEditingComment || isEditingReply;
|
|
36
46
|
var styles = useStyles({ isEditing: isEditing });
|
|
47
|
+
var _b = useState(false), focused = _b[0], setFocused = _b[1];
|
|
37
48
|
var username = useSelector(mdm.selectors.getUserName);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var _f = useState(false), focused = _f[0], setFocused = _f[1];
|
|
43
|
-
var safePromise = useSafePromise();
|
|
49
|
+
var _c = useContext(CollaborationContext), createReply = _c.createReply, createComment = _c.createComment, sending = _c.sending, editComment = _c.editComment, editReply = _c.editReply, getCommentState = _c.getCommentState, updateCommentState = _c.updateCommentState, clearCommentState = _c.clearCommentState;
|
|
50
|
+
var commentUri = createCommentUri({ comment: comment, reply: reply, isEditingComment: isEditingComment, isEditingReply: isEditingReply });
|
|
51
|
+
var defaultCommentState = getDefaultCommentState({ comment: comment, reply: reply, isEditingComment: isEditingComment, isEditingReply: isEditingReply });
|
|
52
|
+
var _d = getCommentState(uri, commentUri), _e = _d.value, value = _e === void 0 ? defaultCommentState.value : _e, _f = _d.plainTextValue, plainTextValue = _f === void 0 ? defaultCommentState.plainTextValue : _f, _g = _d.mentions, mentions = _g === void 0 ? defaultCommentState.mentions : _g;
|
|
44
53
|
var hasValue = value.trim() !== '';
|
|
45
54
|
var shouldShowButtons = focused || hasValue;
|
|
46
55
|
var status = comment === null || comment === void 0 ? void 0 : comment.status;
|
|
47
|
-
var updateValue = function (value, plainTextValue, mentions) {
|
|
48
|
-
setMentions(mentions);
|
|
49
|
-
setValue(value);
|
|
50
|
-
setPlainTextValue(plainTextValue);
|
|
51
|
-
};
|
|
52
56
|
var clearValue = function () {
|
|
53
57
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
54
|
-
|
|
58
|
+
clearCommentState(uri, commentUri);
|
|
55
59
|
};
|
|
56
|
-
var handleChange = function (
|
|
57
|
-
|
|
60
|
+
var handleChange = function (value, plainTextValue, mentions) {
|
|
61
|
+
return updateCommentState(uri, commentUri, { value: value, plainTextValue: plainTextValue, mentions: mentions });
|
|
58
62
|
};
|
|
59
63
|
var handleCancel = function () { return clearValue(); };
|
|
60
64
|
var handleFocus = function () { return setFocused(true); };
|
|
@@ -112,26 +116,13 @@ export var SendMessageArea = function (_a) {
|
|
|
112
116
|
}
|
|
113
117
|
]
|
|
114
118
|
]);
|
|
115
|
-
return
|
|
119
|
+
return request().then(clearValue).catch(console.log); //eslint-disable-line no-console
|
|
116
120
|
};
|
|
117
121
|
useEffect(function () {
|
|
118
122
|
if (popperRef) {
|
|
119
123
|
popperRef.current.update();
|
|
120
124
|
}
|
|
121
125
|
}, [popperRef, shouldShowButtons]);
|
|
122
|
-
useEffect(function () {
|
|
123
|
-
if (isEditingComment || isEditingReply) {
|
|
124
|
-
if (isEditingComment) {
|
|
125
|
-
setValue(comment.content);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
setValue(reply.content);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
clearValue();
|
|
133
|
-
}
|
|
134
|
-
}, [isEditingComment, isEditingReply]);
|
|
135
126
|
var buttonSize = isEditing ? 'small' : 'medium';
|
|
136
127
|
return (React.createElement(Box, { className: classnames(styles.root, className) },
|
|
137
128
|
React.createElement("form", { onSubmit: handleSubmit, className: styles.form },
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { Comment } from '@reltio/mdm-sdk';
|
|
1
|
+
import { Comment, Reply } from '@reltio/mdm-sdk';
|
|
2
2
|
export declare const getAbbreviationFromUserName: (username: string) => string;
|
|
3
3
|
export declare const getRelatedEntityUri: (comment: Pick<Comment, 'relatedObjectUris'>, entityUri: string) => string;
|
|
4
4
|
export declare const formatDate: (time: number) => string;
|
|
5
5
|
export declare const processMentions: (text: string, mentions: string[], processor?: (mention: string) => unknown, trigger?: string) => any[];
|
|
6
|
+
export declare const createNewCommentUri: () => string;
|
|
7
|
+
export declare const createNewReplyUri: (comment: Pick<Comment, 'commentId'>) => string;
|
|
8
|
+
export declare const createEditedCommentUri: (comment: Pick<Comment, 'commentId'>) => string;
|
|
9
|
+
export declare const createEditedReplyUri: (comment: Pick<Comment, 'commentId'>, reply: Pick<Reply, 'replyId'>) => string;
|
|
10
|
+
declare type CreateCommentUriProps = {
|
|
11
|
+
comment: Pick<Comment, 'commentId'> | null;
|
|
12
|
+
reply: Pick<Reply, 'replyId'> | null;
|
|
13
|
+
isEditingReply: boolean;
|
|
14
|
+
isEditingComment: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const createCommentUri: ({ comment, reply, isEditingComment, isEditingReply }: CreateCommentUriProps) => string;
|
|
17
|
+
export declare const transformPlainTextValueToValueWithMentions: (plainTextValue: string, mentions: string[]) => string;
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import i18n from 'ui-i18n';
|
|
2
|
+
import { isNil } from 'ramda';
|
|
2
3
|
export var getAbbreviationFromUserName = function (username) {
|
|
3
4
|
return username
|
|
4
5
|
.split('.')
|
|
@@ -41,3 +42,30 @@ export var processMentions = function (text, mentions, processor, trigger) {
|
|
|
41
42
|
}
|
|
42
43
|
return arr;
|
|
43
44
|
};
|
|
45
|
+
export var createNewCommentUri = function () { return 'comment/new'; };
|
|
46
|
+
export var createNewReplyUri = function (comment) { return "comment/".concat(comment.commentId, "/reply/new"); };
|
|
47
|
+
export var createEditedCommentUri = function (comment) { return "comment/".concat(comment.commentId); };
|
|
48
|
+
export var createEditedReplyUri = function (comment, reply) {
|
|
49
|
+
return "comment/".concat(comment.commentId, "/reply/").concat(reply.replyId);
|
|
50
|
+
};
|
|
51
|
+
export var createCommentUri = function (_a) {
|
|
52
|
+
var comment = _a.comment, reply = _a.reply, isEditingComment = _a.isEditingComment, isEditingReply = _a.isEditingReply;
|
|
53
|
+
if (isNil(comment)) {
|
|
54
|
+
return createNewCommentUri();
|
|
55
|
+
}
|
|
56
|
+
if (isEditingComment) {
|
|
57
|
+
return createEditedCommentUri(comment);
|
|
58
|
+
}
|
|
59
|
+
if (isEditingReply) {
|
|
60
|
+
return createEditedReplyUri(comment, reply);
|
|
61
|
+
}
|
|
62
|
+
return createNewReplyUri(comment);
|
|
63
|
+
};
|
|
64
|
+
export var transformPlainTextValueToValueWithMentions = function (plainTextValue, mentions) {
|
|
65
|
+
var value = plainTextValue;
|
|
66
|
+
for (var _i = 0, mentions_1 = mentions; _i < mentions_1.length; _i++) {
|
|
67
|
+
var mention = mentions_1[_i];
|
|
68
|
+
value = value.split("+".concat(mention)).join("@[".concat(mention, "](").concat(mention, ")"));
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatNumberAsMetric } from '@reltio/mdm-sdk';
|
|
1
2
|
var getBarChartSettings = function (_a) {
|
|
2
3
|
var margin = _a.margin, isHorizontal = _a.isHorizontal, isLabelRotated = _a.isLabelRotated;
|
|
3
4
|
return {
|
|
@@ -29,6 +30,7 @@ var getBarChartSettings = function (_a) {
|
|
|
29
30
|
opacity: isHorizontal ? '0.87' : '0.54',
|
|
30
31
|
width: isHorizontal ? 150 : undefined
|
|
31
32
|
},
|
|
33
|
+
tickFormatter: formatNumberAsMetric,
|
|
32
34
|
stroke: '#666',
|
|
33
35
|
tickCount: 8,
|
|
34
36
|
mirror: isHorizontal
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatNumberAsMetric } from '@reltio/mdm-sdk';
|
|
1
2
|
var getLineChartSettings = function (_a) {
|
|
2
3
|
var margin = _a.margin, isLabelRotated = _a.isLabelRotated;
|
|
3
4
|
return {
|
|
@@ -24,6 +25,7 @@ var getLineChartSettings = function (_a) {
|
|
|
24
25
|
opacity: '0.54',
|
|
25
26
|
width: undefined
|
|
26
27
|
},
|
|
28
|
+
tickFormatter: formatNumberAsMetric,
|
|
27
29
|
stroke: '#666',
|
|
28
30
|
tickCount: 8
|
|
29
31
|
},
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CollaborationObjectTypes, Comment, CommentsMap, Reply } from '@reltio/mdm-sdk';
|
|
2
|
+
import { CollaborationObjectTypes, Comment, CommentsMap, CommentState, Reply } from '@reltio/mdm-sdk';
|
|
3
3
|
export declare const CollaborationContext: React.Context<{
|
|
4
4
|
objectTypes?: CollaborationObjectTypes[];
|
|
5
5
|
commentsMap: CommentsMap;
|
|
6
6
|
comments: Comment[];
|
|
7
7
|
currentComment: Comment;
|
|
8
|
+
updateCommentState: (uri: string, commentUri: string, newState: CommentState) => void;
|
|
9
|
+
clearCommentState: (uri: string, commentUri: string) => void;
|
|
10
|
+
getCommentState: (uri: string, commentUri: string) => CommentState;
|
|
8
11
|
getComments: (uri: string, pageToken?: string) => void;
|
|
9
12
|
getCommentsCount: (objectIds: string[]) => void;
|
|
10
13
|
getComment: (commentId: Comment['commentId']) => void;
|
|
@@ -4,6 +4,9 @@ export var CollaborationContext = React.createContext({
|
|
|
4
4
|
comments: [],
|
|
5
5
|
commentsMap: null,
|
|
6
6
|
currentComment: null,
|
|
7
|
+
updateCommentState: noop,
|
|
8
|
+
clearCommentState: noop,
|
|
9
|
+
getCommentState: function () { return ({}); },
|
|
7
10
|
getComment: noop,
|
|
8
11
|
getComments: function () { return new Promise(noop); },
|
|
9
12
|
getCommentsCount: noop,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollaborationObjectTypes, Comment, CommentsMap } from '@reltio/mdm-sdk';
|
|
1
|
+
import { CollaborationObjectTypes, Comment, CommentsMap, CommentState } from '@reltio/mdm-sdk';
|
|
2
2
|
declare type Props = {
|
|
3
3
|
objectIds?: string[];
|
|
4
4
|
objectTypes?: CollaborationObjectTypes[];
|
|
@@ -8,6 +8,9 @@ export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Pro
|
|
|
8
8
|
clearCurrentComment: () => void;
|
|
9
9
|
comments: Comment[];
|
|
10
10
|
commentsMap: CommentsMap;
|
|
11
|
+
getCommentState: (uri: string, commentUri: string) => any;
|
|
12
|
+
updateCommentState: (uri: string, commentUri: string, newState: CommentState) => void;
|
|
13
|
+
clearCommentState: (uri: string, commentUri: string) => void;
|
|
11
14
|
createComment: ({ content, namedUsers, objectType, uri, relatedObjectUris }: any) => Promise<void>;
|
|
12
15
|
createReply: ({ content, namedUsers, commentId, action, uri }: any) => Promise<void>;
|
|
13
16
|
currentComment: Comment;
|
|
@@ -20,7 +20,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
20
20
|
};
|
|
21
21
|
import { useCallback, useEffect, useState } from 'react';
|
|
22
22
|
import { useSelector } from 'react-redux';
|
|
23
|
-
import { andThen, fromPairs, map, otherwise, pipe, props, uniqBy, prop, propEq, when, always } from 'ramda';
|
|
23
|
+
import { andThen, fromPairs, map, otherwise, pipe, props, uniqBy, prop, propEq, when, always, assocPath, dissocPath, path, pathOr, mergeRight } from 'ramda';
|
|
24
24
|
import { createComment as createCommentRequest, createReply as createReplyRequest, getComment as getCommentRequest, getCommentsCount as getCommentsCountRequest, updateComment as updateCommentRequest, updateReply as updateReplyRequest, deleteComment as deleteCommentRequest, deleteReply as deleteReplyRequest, getComments as getCommentsRequest, isTempUri } from '@reltio/mdm-sdk';
|
|
25
25
|
import mdm from '@reltio/mdm-module';
|
|
26
26
|
var filterReplies = function (replyId, replies) { return replies.filter(function (reply) { return reply.replyId !== replyId; }); };
|
|
@@ -47,6 +47,7 @@ export var useCollaboration = function (_a) {
|
|
|
47
47
|
var _g = useState(null), currentComment = _g[0], setCurrentComment = _g[1];
|
|
48
48
|
var _h = useState(false), sending = _h[0], setSending = _h[1];
|
|
49
49
|
var _j = useState(false), loading = _j[0], setLoading = _j[1];
|
|
50
|
+
var _k = useState({}), collaborationStateMap = _k[0], setCollaborationStateMap = _k[1];
|
|
50
51
|
var addCommentsToCommentsMap = useCallback(function (commentsMap) {
|
|
51
52
|
setCommentsMap(function (currentCommentsMap) { return (__assign(__assign({}, currentCommentsMap), commentsMap)); });
|
|
52
53
|
}, []);
|
|
@@ -259,10 +260,24 @@ export var useCollaboration = function (_a) {
|
|
|
259
260
|
var clearCurrentComment = useCallback(function () {
|
|
260
261
|
setCurrentComment(null);
|
|
261
262
|
}, []);
|
|
263
|
+
var getCommentState = function (uri, commentUri) { return pathOr({}, [uri, commentUri], collaborationStateMap); };
|
|
264
|
+
var clearCommentState = function (uri, commentUri) {
|
|
265
|
+
return setCollaborationStateMap(dissocPath([uri, commentUri]));
|
|
266
|
+
};
|
|
267
|
+
var updateCommentState = function (uri, commentUri, newState) {
|
|
268
|
+
setCollaborationStateMap(function (prevCollaborationStateMap) {
|
|
269
|
+
var pathToCommentState = [uri, commentUri];
|
|
270
|
+
var prevCommentState = path(pathToCommentState, prevCollaborationStateMap);
|
|
271
|
+
return assocPath(pathToCommentState, mergeRight(prevCommentState, newState), prevCollaborationStateMap);
|
|
272
|
+
});
|
|
273
|
+
};
|
|
262
274
|
return {
|
|
263
275
|
clearCurrentComment: clearCurrentComment,
|
|
264
276
|
comments: comments,
|
|
265
277
|
commentsMap: commentsMap,
|
|
278
|
+
getCommentState: getCommentState,
|
|
279
|
+
updateCommentState: updateCommentState,
|
|
280
|
+
clearCommentState: clearCommentState,
|
|
266
281
|
createComment: createComment,
|
|
267
282
|
createReply: createReply,
|
|
268
283
|
currentComment: currentComment,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1328",
|
|
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
|
"@date-io/moment": "^1.3.5",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-module": "^1.4.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.1328",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1328",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|