blixify-ui-web 1.2.268 → 1.3.0
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/lib/components/data/dataTemplate/activityComposer.d.ts +2 -6
- package/lib/components/data/dataTemplate/activityComposer.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/activityComposer.js +41 -16
- package/lib/components/data/dataTemplate/activityComposer.js.map +1 -1
- package/lib/components/data/dataTemplate/activityModal.js +254 -150
- package/lib/components/data/dataTemplate/activityModal.js.map +1 -1
- package/lib/components/data/dataTemplate/activityReplies.d.ts +28 -25
- package/lib/components/data/dataTemplate/activityReplies.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/activityReplies.js +87 -119
- package/lib/components/data/dataTemplate/activityReplies.js.map +1 -1
- package/lib/components/data/dataTemplate/dataStateModel.d.ts +10 -4
- package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
- package/lib/tail.css +1 -1
- package/package.json +1 -1
|
@@ -96,7 +96,6 @@ var activityComposer_1 = require("./activityComposer");
|
|
|
96
96
|
var activityMentions_1 = require("./activityMentions");
|
|
97
97
|
var activityImported_1 = require("./activityImported");
|
|
98
98
|
var activityChanges_1 = require("./activityChanges");
|
|
99
|
-
var modal_1 = require("../../display/modal");
|
|
100
99
|
var activityAttachments_1 = require("./activityAttachments");
|
|
101
100
|
var activityAvatar_1 = require("./activityAvatar");
|
|
102
101
|
var activityReplies_1 = require("./activityReplies");
|
|
@@ -164,19 +163,17 @@ var ActivityPanel = function (props) {
|
|
|
164
163
|
var _0 = (0, react_1.useState)(""), attachmentError = _0[0], setAttachmentError = _0[1];
|
|
165
164
|
var _1 = (0, react_1.useState)(""), busyLabel = _1[0], setBusyLabel = _1[1];
|
|
166
165
|
var _2 = (0, react_1.useState)(null), deleteRecord = _2[0], setDeleteRecord = _2[1];
|
|
166
|
+
// INFO: the top-level comments on the page now; their replies are read apart
|
|
167
167
|
var _3 = (0, react_1.useState)([]), commentIds = _3[0], setCommentIds = _3[1];
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
var
|
|
171
|
-
var
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
var
|
|
175
|
-
var
|
|
176
|
-
var
|
|
177
|
-
var _11 = (0, react_1.useState)(true), listLoading = _11[0], setListLoading = _11[1];
|
|
178
|
-
var _12 = (0, react_1.useState)([]), recordIds = _12[0], setRecordIds = _12[1];
|
|
179
|
-
var _13 = (0, react_1.useState)(""), recordFilter = _13[0], setRecordFilter = _13[1];
|
|
168
|
+
var _4 = (0, react_1.useState)(null), replyTo = _4[0], setReplyTo = _4[1];
|
|
169
|
+
// INFO: threads opened past their latest replies with "View previous replies"
|
|
170
|
+
var _5 = (0, react_1.useState)([]), expandedThreads = _5[0], setExpandedThreads = _5[1];
|
|
171
|
+
var _6 = (0, react_1.useState)({}), authors = _6[0], setAuthors = _6[1];
|
|
172
|
+
var _7 = (0, react_1.useState)([]), authorIds = _7[0], setAuthorIds = _7[1];
|
|
173
|
+
var _8 = (0, react_1.useState)(null), rowCount = _8[0], setRowCount = _8[1];
|
|
174
|
+
var _9 = (0, react_1.useState)(true), listLoading = _9[0], setListLoading = _9[1];
|
|
175
|
+
var _10 = (0, react_1.useState)([]), recordIds = _10[0], setRecordIds = _10[1];
|
|
176
|
+
var _11 = (0, react_1.useState)(""), recordFilter = _11[0], setRecordFilter = _11[1];
|
|
180
177
|
var activeRecordId = props.dataId || recordFilter;
|
|
181
178
|
var titleColumn = (_c = (_b = config === null || config === void 0 ? void 0 : config.recordTitleColumn) !== null && _b !== void 0 ? _b : props.recordTitleColumn) !== null && _c !== void 0 ? _c : "title";
|
|
182
179
|
var recordScope = (_d = props.recordQuery) !== null && _d !== void 0 ? _d : [];
|
|
@@ -219,34 +216,37 @@ var ActivityPanel = function (props) {
|
|
|
219
216
|
var reactionEmojis = ((_h = config === null || config === void 0 ? void 0 : config.reactionEmojis) === null || _h === void 0 ? void 0 : _h.length)
|
|
220
217
|
? config.reactionEmojis
|
|
221
218
|
: activityReactions_1.DEFAULT_REACTION_EMOJIS;
|
|
219
|
+
var repliesEnabled = !!(commentsEnabled && (config === null || config === void 0 ? void 0 : config.enableReplies));
|
|
220
|
+
// INFO: replies sit in threads, except in Mentions me, which lists the
|
|
221
|
+
// comments and replies that name you flat, newest first
|
|
222
|
+
var threaded = repliesEnabled && !mentionsOnly;
|
|
223
|
+
var threads = (0, activityReplies_1.useActivityThreads)({
|
|
224
|
+
enabled: threaded && activeTab === "comments",
|
|
225
|
+
devSettings: props.devSettings,
|
|
226
|
+
commentCollectionId: config === null || config === void 0 ? void 0 : config.commentCollectionId,
|
|
227
|
+
collectionId: props.collectionId,
|
|
228
|
+
threadIds: commentIds,
|
|
229
|
+
});
|
|
230
|
+
var replies = Object.values(threads.byThread).flat();
|
|
231
|
+
var replyIds = replies
|
|
232
|
+
.map(function (each) { var _a, _b; return String((_b = (_a = each === null || each === void 0 ? void 0 : each._id) !== null && _a !== void 0 ? _a : each === null || each === void 0 ? void 0 : each.id) !== null && _b !== void 0 ? _b : ""); })
|
|
233
|
+
.filter(Boolean);
|
|
234
|
+
var replyUserIds = replies
|
|
235
|
+
.map(function (each) { return each === null || each === void 0 ? void 0 : each.userId; })
|
|
236
|
+
.filter(function (each) { return typeof each === "string" && !!each; });
|
|
222
237
|
var reactions = (0, activityReactions_1.useActivityReactions)({
|
|
223
238
|
enabled: reactionsEnabled && activeTab === "comments",
|
|
224
239
|
devSettings: props.devSettings,
|
|
225
240
|
reactionCollectionId: config === null || config === void 0 ? void 0 : config.reactionCollectionId,
|
|
226
241
|
collectionId: props.collectionId,
|
|
227
242
|
currentUserId: config === null || config === void 0 ? void 0 : config.currentUserId,
|
|
228
|
-
commentIds: commentIds,
|
|
243
|
+
commentIds: __spreadArray(__spreadArray([], commentIds, true), replyIds, true),
|
|
229
244
|
onError: function (message) { return setError(message); },
|
|
230
245
|
});
|
|
231
|
-
var repliesEnabled = !!(commentsEnabled && (config === null || config === void 0 ? void 0 : config.enableReplies));
|
|
232
|
-
var quotes = (0, activityReplies_1.useActivityQuotes)({
|
|
233
|
-
enabled: repliesEnabled && activeTab === "comments",
|
|
234
|
-
devSettings: props.devSettings,
|
|
235
|
-
commentCollectionId: config === null || config === void 0 ? void 0 : config.commentCollectionId,
|
|
236
|
-
collectionId: props.collectionId,
|
|
237
|
-
known: pageComments,
|
|
238
|
-
ids: Object.values(pageComments)
|
|
239
|
-
.map(function (each) { var _a; return (_a = each === null || each === void 0 ? void 0 : each.replyTo) === null || _a === void 0 ? void 0 : _a.commentId; })
|
|
240
|
-
.filter(function (each) { return typeof each === "string" && !!each; }),
|
|
241
|
-
});
|
|
242
|
-
var quotedComments = __assign(__assign({}, quotes.fetched), pageComments);
|
|
243
|
-
var quoteUserIds = Object.values(quotedComments)
|
|
244
|
-
.map(function (each) { return each === null || each === void 0 ? void 0 : each.userId; })
|
|
245
|
-
.filter(function (each) { return typeof each === "string" && !!each; });
|
|
246
246
|
var reactionUserIds = Array.from(new Set(Object.values(reactions.byComment).flatMap(function (list) {
|
|
247
247
|
return list.map(function (reaction) { return reaction.userId; });
|
|
248
248
|
})));
|
|
249
|
-
var nameIdsKey = JSON.stringify(Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], authorIds, true), reactionUserIds, true),
|
|
249
|
+
var nameIdsKey = JSON.stringify(Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], authorIds, true), reactionUserIds, true), replyUserIds, true))));
|
|
250
250
|
var collectionId = isComments
|
|
251
251
|
? config === null || config === void 0 ? void 0 : config.commentCollectionId
|
|
252
252
|
: config === null || config === void 0 ? void 0 : config.logsCollectionId;
|
|
@@ -256,6 +256,24 @@ var ActivityPanel = function (props) {
|
|
|
256
256
|
mounted.current = false;
|
|
257
257
|
};
|
|
258
258
|
}, []);
|
|
259
|
+
// INFO: a reply or an edit is drawn inside its thread. When that thread
|
|
260
|
+
// leaves the page (page or filter changed), the box would go with it and the
|
|
261
|
+
// top box stays hidden, leaving nowhere to type, so the draft is closed.
|
|
262
|
+
// INFO: in the flat Mentions me list a draft sits under its own comment, so
|
|
263
|
+
// it is that comment, not its thread, that has to stay on the page
|
|
264
|
+
(0, react_1.useEffect)(function () {
|
|
265
|
+
var _a, _b;
|
|
266
|
+
if (!repliesEnabled || listLoading)
|
|
267
|
+
return;
|
|
268
|
+
var editingId = editing ? String((_b = (_a = editing._id) !== null && _a !== void 0 ? _a : editing.id) !== null && _b !== void 0 ? _b : "") : "";
|
|
269
|
+
var editingThread = editing ? String(editing.threadId || editingId) : "";
|
|
270
|
+
var replyGone = !!replyTo &&
|
|
271
|
+
!commentIds.includes(threaded ? replyTo.threadId : replyTo.id);
|
|
272
|
+
var editGone = !!editingId && !commentIds.includes(threaded ? editingThread : editingId);
|
|
273
|
+
if (replyGone || editGone)
|
|
274
|
+
handleResetDraft();
|
|
275
|
+
/* eslint-disable-next-line */
|
|
276
|
+
}, [commentIds, listLoading, repliesEnabled, threaded]);
|
|
259
277
|
(0, react_1.useEffect)(function () {
|
|
260
278
|
var cancelled = false;
|
|
261
279
|
var handleLoadAuthors = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -338,23 +356,55 @@ var ActivityPanel = function (props) {
|
|
|
338
356
|
!(config === null || config === void 0 ? void 0 : config.currentUserId) ||
|
|
339
357
|
record.userId === config.currentUserId;
|
|
340
358
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
359
|
+
// INFO: one draft is open at a time — the top box, a reply under a thread or
|
|
360
|
+
// an edit in place — so moving to another asks before dropping what is typed
|
|
361
|
+
var handleConfirmDiscard = function () {
|
|
362
|
+
return !(draft.trim() || pendingFiles.length > 0) ||
|
|
363
|
+
window.confirm("Discard the comment you are writing?");
|
|
364
|
+
};
|
|
365
|
+
var handleStartReply = function (record, threadId) {
|
|
366
|
+
var _a, _b, _c;
|
|
367
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
368
|
+
if ((replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === id)
|
|
351
369
|
return;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
370
|
+
if (!handleConfirmDiscard())
|
|
371
|
+
return;
|
|
372
|
+
var name = handleRecordAuthorName(record);
|
|
373
|
+
// INFO: a reply to a reply starts by naming the person answered, as on
|
|
374
|
+
// Facebook; a reply to the thread's own comment, or to yourself, does not
|
|
375
|
+
var named = id !== threadId &&
|
|
376
|
+
!!record.userId &&
|
|
377
|
+
record.userId !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
378
|
+
name !== record.userId;
|
|
379
|
+
var prefill = named
|
|
380
|
+
? (0, activityReplies_1.handleRenderReplyMention)(name, record.userId)
|
|
381
|
+
: { value: "", mentions: [] };
|
|
382
|
+
handleResetDraft();
|
|
383
|
+
setError("");
|
|
384
|
+
setDraft(prefill.value);
|
|
385
|
+
setMentions(prefill.mentions);
|
|
386
|
+
setReplyTo({
|
|
387
|
+
id: id,
|
|
388
|
+
threadId: threadId,
|
|
389
|
+
userId: (_b = record.userId) !== null && _b !== void 0 ? _b : null,
|
|
390
|
+
itemId: (_c = record.itemId) !== null && _c !== void 0 ? _c : null,
|
|
391
|
+
name: name,
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
var handleStartEdit = function (record) {
|
|
395
|
+
var _a, _b, _c, _d;
|
|
396
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
397
|
+
if (String((_c = (_b = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _b !== void 0 ? _b : editing === null || editing === void 0 ? void 0 : editing.id) !== null && _c !== void 0 ? _c : "") === id)
|
|
398
|
+
return;
|
|
399
|
+
if (!handleConfirmDiscard())
|
|
400
|
+
return;
|
|
401
|
+
var text = String((_d = record.comment) !== null && _d !== void 0 ? _d : "");
|
|
402
|
+
handleResetDraft();
|
|
403
|
+
setEditing(record);
|
|
404
|
+
setDraft(text);
|
|
405
|
+
setMentions((0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []));
|
|
406
|
+
setKeptAttachments(Array.isArray(record.attachments) ? record.attachments : []);
|
|
407
|
+
setError("");
|
|
358
408
|
};
|
|
359
409
|
var handlePickFiles = function (picked) {
|
|
360
410
|
var next = (0, activityAttachments_1.handleAddAttachmentFiles)(pendingFiles, picked, keptAttachments.length, attachmentLimits);
|
|
@@ -524,7 +574,12 @@ var ActivityPanel = function (props) {
|
|
|
524
574
|
attachments = __spreadArray(__spreadArray([], kept, true), uploaded, true);
|
|
525
575
|
comment = __assign(__assign(__assign(__assign({ comment: draft, mentions: savedMentions, mentionedUserIds: mentionedUserIds }, (editing ? {} : { userId: userId })), { collectionId: props.collectionId, itemId: itemId }), (attachmentsConfig || attachments.length ? { attachments: attachments } : {})), (editing
|
|
526
576
|
? { updatedAt: new Date() }
|
|
527
|
-
: __assign((_e = {}, _e[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId, _e.createdAt = new Date(), _e), (replyTo
|
|
577
|
+
: __assign((_e = {}, _e[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId, _e.createdAt = new Date(), _e), (replyTo
|
|
578
|
+
? {
|
|
579
|
+
replyTo: { commentId: replyTo.id },
|
|
580
|
+
threadId: replyTo.threadId,
|
|
581
|
+
}
|
|
582
|
+
: {}))));
|
|
528
583
|
_u.label = 9;
|
|
529
584
|
case 9:
|
|
530
585
|
_u.trys.push([9, 16, 17, 18]);
|
|
@@ -556,8 +611,11 @@ var ActivityPanel = function (props) {
|
|
|
556
611
|
// Notification delivery still runs if the panel was closed during the save.
|
|
557
612
|
if (mounted.current) {
|
|
558
613
|
handleResetDraft();
|
|
559
|
-
//
|
|
560
|
-
|
|
614
|
+
// INFO: a reply, made or edited, changes only its thread; a new
|
|
615
|
+
// top-level comment sorts onto page one; an edit keeps the page
|
|
616
|
+
if (answered || (editing === null || editing === void 0 ? void 0 : editing.threadId))
|
|
617
|
+
threads.handleRefresh();
|
|
618
|
+
else if (editing)
|
|
561
619
|
(_q = listRef.current) === null || _q === void 0 ? void 0 : _q.handleRefreshCurrentPage();
|
|
562
620
|
else
|
|
563
621
|
(_r = listRef.current) === null || _r === void 0 ? void 0 : _r.handleRefresh();
|
|
@@ -574,7 +632,9 @@ var ActivityPanel = function (props) {
|
|
|
574
632
|
return id !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
575
633
|
!((_a = editing === null || editing === void 0 ? void 0 : editing.mentionedUserIds) !== null && _a !== void 0 ? _a : []).includes(id);
|
|
576
634
|
});
|
|
577
|
-
replyRecipient = (answered === null || answered === void 0 ? void 0 : answered.userId) &&
|
|
635
|
+
replyRecipient = (answered === null || answered === void 0 ? void 0 : answered.userId) &&
|
|
636
|
+
answered.userId !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
637
|
+
!recipients.includes(answered.userId)
|
|
578
638
|
? answered
|
|
579
639
|
: null;
|
|
580
640
|
unconnected = __spreadArray(__spreadArray([], (recipients.length && !(config === null || config === void 0 ? void 0 : config.onMention) ? ["Mentions"] : []), true), (replyRecipient && !(config === null || config === void 0 ? void 0 : config.onReply) ? ["Reply"] : []), true);
|
|
@@ -606,6 +666,7 @@ var ActivityPanel = function (props) {
|
|
|
606
666
|
userId: userId,
|
|
607
667
|
replyToCommentId: replyRecipient.id,
|
|
608
668
|
replyToUserId: replyRecipient.userId,
|
|
669
|
+
threadId: replyRecipient.threadId,
|
|
609
670
|
},
|
|
610
671
|
});
|
|
611
672
|
return [4 /*yield*/, handleNotify(pings)];
|
|
@@ -652,13 +713,21 @@ var ActivityPanel = function (props) {
|
|
|
652
713
|
});
|
|
653
714
|
if (!mounted.current)
|
|
654
715
|
return [2 /*return*/];
|
|
655
|
-
|
|
716
|
+
// INFO: the draft goes with the comment it edits or the thread it replies in
|
|
717
|
+
if (((_d = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _d !== void 0 ? _d : editing === null || editing === void 0 ? void 0 : editing.id) === deleteId ||
|
|
718
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.threadId) === deleteId ||
|
|
719
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === deleteId)
|
|
656
720
|
handleResetDraft();
|
|
657
721
|
setDeleteId("");
|
|
658
|
-
setDeleteRecord(null);
|
|
659
722
|
setNotice("Comment deleted.");
|
|
660
|
-
//
|
|
661
|
-
|
|
723
|
+
// INFO: a reply leaves the page as it is. A top-level comment goes with
|
|
724
|
+
// its thread, which the backend deletes; deleting the last row on a
|
|
725
|
+
// later page would hide the feed's paginator, so the list starts over.
|
|
726
|
+
if (deleteRecord === null || deleteRecord === void 0 ? void 0 : deleteRecord.threadId)
|
|
727
|
+
threads.handleRefresh();
|
|
728
|
+
else
|
|
729
|
+
(_e = listRef.current) === null || _e === void 0 ? void 0 : _e.handleRefresh();
|
|
730
|
+
setDeleteRecord(null);
|
|
662
731
|
return [3 /*break*/, 5];
|
|
663
732
|
case 3:
|
|
664
733
|
_a = _f.sent();
|
|
@@ -674,9 +743,61 @@ var ActivityPanel = function (props) {
|
|
|
674
743
|
}
|
|
675
744
|
});
|
|
676
745
|
}); };
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
746
|
+
// INFO: one composer and one draft. It sits at the top for a new comment,
|
|
747
|
+
// under a thread for a reply, and in place of the comment being edited.
|
|
748
|
+
var renderComposer = function () {
|
|
749
|
+
var _a;
|
|
750
|
+
return (react_1.default.createElement(activityComposer_1.ActivityComposer, { value: draft, mentions: mentions, members: members !== null && members !== void 0 ? members : [], darkMode: props.darkMode, busy: busy || !!pendingPing, editing: !!editing, busyLabel: busyLabel || undefined, replyingTo: !editing && replyTo ? replyTo.name : undefined, focusToken: editing
|
|
751
|
+
? "edit:".concat((_a = editing._id) !== null && _a !== void 0 ? _a : editing.id)
|
|
752
|
+
: replyTo
|
|
753
|
+
? "reply:".concat(replyTo.id)
|
|
754
|
+
: undefined, attachments: attachmentsConfig
|
|
755
|
+
? {
|
|
756
|
+
files: pendingFiles,
|
|
757
|
+
existing: keptAttachments,
|
|
758
|
+
error: attachmentError,
|
|
759
|
+
maxFiles: attachmentLimits.maxFiles,
|
|
760
|
+
onPick: handlePickFiles,
|
|
761
|
+
onRemoveFile: function (index) {
|
|
762
|
+
setPendingFiles(function (previous) {
|
|
763
|
+
return previous.filter(function (_, each) { return each !== index; });
|
|
764
|
+
});
|
|
765
|
+
setAttachmentError("");
|
|
766
|
+
},
|
|
767
|
+
onRemoveExisting: function (index) {
|
|
768
|
+
return setKeptAttachments(function (previous) {
|
|
769
|
+
return previous.filter(function (_, each) { return each !== index; });
|
|
770
|
+
});
|
|
771
|
+
},
|
|
772
|
+
}
|
|
773
|
+
: undefined, onChange: function (value, selectedMentions) {
|
|
774
|
+
setDraft(value);
|
|
775
|
+
setMentions(selectedMentions);
|
|
776
|
+
}, onSubmit: handleSubmit, onCancel: handleResetDraft }));
|
|
777
|
+
};
|
|
778
|
+
var renderDeleteConfirm = function (record) {
|
|
779
|
+
var _a, _b, _c;
|
|
780
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
781
|
+
var replyCount = record.threadId
|
|
782
|
+
? 0
|
|
783
|
+
: ((_c = (_b = threads.byThread[id]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0);
|
|
784
|
+
return (react_1.default.createElement("div", { role: "alert", className: "flex flex-wrap items-center gap-3 rounded-lg border border-red-200 p-3 text-sm" },
|
|
785
|
+
react_1.default.createElement("span", null, replyCount
|
|
786
|
+
? "Delete this comment and its ".concat(replyCount, " ").concat(replyCount === 1 ? "reply" : "replies", "?")
|
|
787
|
+
: "Delete this comment?"),
|
|
788
|
+
react_1.default.createElement(textButton_1.TextButton, { text: "Confirm delete", disable: busy, className: "!text-red-500 hover:!text-red-600", onClick: handleDelete }),
|
|
789
|
+
react_1.default.createElement(textButton_1.TextButton, { text: "Cancel", disable: busy, className: "!font-normal !text-inherit hover:underline", onClick: function () {
|
|
790
|
+
setDeleteId("");
|
|
791
|
+
setDeleteRecord(null);
|
|
792
|
+
} })));
|
|
793
|
+
};
|
|
794
|
+
// INFO: threadId is the thread the comment sits in; a top-level comment has none
|
|
795
|
+
var renderComment = function (record, threadId) {
|
|
796
|
+
var _a, _b, _c, _d;
|
|
797
|
+
var id = (_a = record._id) !== null && _a !== void 0 ? _a : record.id;
|
|
798
|
+
if (editing && String((_b = editing._id) !== null && _b !== void 0 ? _b : editing.id) === String(id))
|
|
799
|
+
return renderComposer();
|
|
800
|
+
var text = String((_c = record.comment) !== null && _c !== void 0 ? _c : "");
|
|
680
801
|
var savedMentions = (0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []);
|
|
681
802
|
var parts = [];
|
|
682
803
|
var cursor = 0;
|
|
@@ -686,49 +807,33 @@ var ActivityPanel = function (props) {
|
|
|
686
807
|
cursor = mention.end;
|
|
687
808
|
});
|
|
688
809
|
parts.push(text.slice(cursor));
|
|
689
|
-
var id = (_b = record._id) !== null && _b !== void 0 ? _b : record.id;
|
|
690
|
-
var quoted = ((_c = record.replyTo) === null || _c === void 0 ? void 0 : _c.commentId)
|
|
691
|
-
? quotedComments[String(record.replyTo.commentId)]
|
|
692
|
-
: undefined;
|
|
693
810
|
var canEdit = handleIsOwnComment(record);
|
|
694
811
|
var canDelete = canEdit || !!(config === null || config === void 0 ? void 0 : config.canModerate);
|
|
695
|
-
return (react_1.default.createElement("div", { id: id ? "activity-comment-".concat(id) : undefined, className: "space-y-2
|
|
696
|
-
repliesEnabled && ((_d = record.replyTo) === null || _d === void 0 ? void 0 : _d.commentId) && (react_1.default.createElement(activityReplies_1.ActivityQuote, { name: quoted ? handleRecordAuthorName(quoted) : "Original comment", line: quoted ? (0, activityReplies_1.handleDescribeQuoteLine)(quoted) : "", deleted: !quoted && quotes.gone.includes(String(record.replyTo.commentId)), darkMode: props.darkMode, onOpen: function () { return handleJumpToComment(String(record.replyTo.commentId)); } })),
|
|
812
|
+
return (react_1.default.createElement("div", { id: id ? "activity-comment-".concat(id) : undefined, className: "space-y-2" },
|
|
697
813
|
text && react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words" }, parts),
|
|
698
814
|
Array.isArray(record.attachments) && record.attachments.length > 0 && (react_1.default.createElement(activityAttachments_1.ActivityAttachmentList, { attachments: record.attachments, getUrl: attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.getUrl, darkMode: props.darkMode })),
|
|
699
|
-
reactionsEnabled && id && (react_1.default.createElement(activityReactions_1.ActivityReactionBar, { summaries: (0, activityReactions_1.handleSummariseReactions)((
|
|
815
|
+
reactionsEnabled && id && (react_1.default.createElement(activityReactions_1.ActivityReactionBar, { summaries: (0, activityReactions_1.handleSummariseReactions)((_d = reactions.byComment[String(id)]) !== null && _d !== void 0 ? _d : [], config === null || config === void 0 ? void 0 : config.currentUserId), emojis: reactionEmojis, authorName: handleAuthorName, authorImage: handleAuthorImage, darkMode: props.darkMode, onToggle: function (emoji) {
|
|
700
816
|
var _a;
|
|
701
817
|
return reactions.handleToggle({ id: String(id), itemId: (_a = record.itemId) !== null && _a !== void 0 ? _a : null }, emoji);
|
|
702
818
|
} })),
|
|
703
819
|
react_1.default.createElement("div", { className: "flex gap-3 text-xs text-gray-500" },
|
|
704
820
|
record.updatedAt && react_1.default.createElement("span", null, "Edited"),
|
|
705
821
|
repliesEnabled && id && (react_1.default.createElement(textButton_1.TextButton, { text: "Reply", disable: busy || !!pendingPing, className: "!font-normal !text-inherit hover:underline", onClick: function (event) {
|
|
706
|
-
var _a, _b;
|
|
707
822
|
event.stopPropagation();
|
|
708
|
-
|
|
709
|
-
setReplyTo({
|
|
710
|
-
id: String(id),
|
|
711
|
-
userId: (_a = record.userId) !== null && _a !== void 0 ? _a : null,
|
|
712
|
-
itemId: (_b = record.itemId) !== null && _b !== void 0 ? _b : null,
|
|
713
|
-
name: handleRecordAuthorName(record),
|
|
714
|
-
line: (0, activityReplies_1.handleDescribeQuoteLine)(record),
|
|
715
|
-
});
|
|
823
|
+
handleStartReply(record, threadId !== null && threadId !== void 0 ? threadId : (0, activityReplies_1.handleResolveThreadId)(record));
|
|
716
824
|
} })),
|
|
717
825
|
canEdit && (react_1.default.createElement(textButton_1.TextButton, { text: "Edit", disable: busy || !!pendingPing, className: "!font-normal !text-inherit hover:underline", onClick: function (event) {
|
|
718
826
|
event.stopPropagation();
|
|
719
|
-
|
|
720
|
-
setDraft(text);
|
|
721
|
-
setMentions(savedMentions);
|
|
722
|
-
setKeptAttachments(Array.isArray(record.attachments) ? record.attachments : []);
|
|
723
|
-
setPendingFiles([]);
|
|
724
|
-
setAttachmentError("");
|
|
725
|
-
setError("");
|
|
827
|
+
handleStartEdit(record);
|
|
726
828
|
} })),
|
|
727
829
|
canDelete && (react_1.default.createElement(textButton_1.TextButton, { text: "Delete", disable: busy || !!pendingPing, className: "!font-normal !text-inherit hover:underline", onClick: function (event) {
|
|
728
830
|
event.stopPropagation();
|
|
729
831
|
setDeleteId(id);
|
|
730
832
|
setDeleteRecord(record);
|
|
731
|
-
} })))
|
|
833
|
+
} }))),
|
|
834
|
+
deleteId &&
|
|
835
|
+
String(deleteId) === String(id) &&
|
|
836
|
+
renderDeleteConfirm(record)));
|
|
732
837
|
};
|
|
733
838
|
var renderRecordTitle = function (record) {
|
|
734
839
|
var _a;
|
|
@@ -738,25 +843,68 @@ var ActivityPanel = function (props) {
|
|
|
738
843
|
(_a = props.onOpenRecord) === null || _a === void 0 ? void 0 : _a.call(props, record.itemId);
|
|
739
844
|
} }, recordTitles[record.itemId])) : (react_1.default.createElement("p", { className: "break-words text-xs text-gray-500" }, (_a = recordTitles[record.itemId]) !== null && _a !== void 0 ? _a : "Data ".concat(record.itemId, " (unavailable)")))) : (react_1.default.createElement("p", { className: "text-xs text-gray-500" }, "Collection discussion"));
|
|
740
845
|
};
|
|
846
|
+
// INFO: the author, when, and the tool an imported comment came from
|
|
847
|
+
var renderCommentHeading = function (record) {
|
|
848
|
+
var date = record.createdAt ? (0, dayjs_1.default)(record.createdAt) : null;
|
|
849
|
+
var importedFrom = (0, activityImported_1.handleRenderImportedFrom)(record.importedFrom);
|
|
850
|
+
var muted = "text-xs font-normal ".concat(props.darkMode ? "text-gray-400" : "text-gray-500");
|
|
851
|
+
return (react_1.default.createElement("span", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1" },
|
|
852
|
+
react_1.default.createElement("span", null, handleRecordAuthorName(record)),
|
|
853
|
+
(date === null || date === void 0 ? void 0 : date.isValid()) && (react_1.default.createElement("time", { className: muted, dateTime: date.toISOString(), title: date.format("YYYY-MM-DD HH:mm:ss") }, (0, activityImported_1.handleRenderActivityDate)(date))),
|
|
854
|
+
importedFrom && react_1.default.createElement("span", { className: muted }, importedFrom)));
|
|
855
|
+
};
|
|
856
|
+
var renderReply = function (reply, threadId) {
|
|
857
|
+
var _a;
|
|
858
|
+
return (react_1.default.createElement("li", { key: String((_a = reply._id) !== null && _a !== void 0 ? _a : reply.id), "data-testid": "activity-reply", className: "flex min-w-0 gap-2" },
|
|
859
|
+
react_1.default.createElement(activityAvatar_1.ActivityAvatar, { id: reply.userId, name: handleRecordAuthorName(reply), image: handleAuthorImage(reply.userId), className: "h-6 w-6 sm:h-7 sm:w-7", darkMode: props.darkMode }),
|
|
860
|
+
react_1.default.createElement("div", { className: "min-w-0 flex-1 space-y-1" },
|
|
861
|
+
react_1.default.createElement("p", { className: "text-sm font-medium" }, renderCommentHeading(reply)),
|
|
862
|
+
renderComment(reply, threadId))));
|
|
863
|
+
};
|
|
864
|
+
// INFO: as on Facebook, a thread shows its latest replies under "View
|
|
865
|
+
// previous replies", and the box for a reply opens at the bottom of it
|
|
866
|
+
var renderThread = function (root) {
|
|
867
|
+
var _a, _b;
|
|
868
|
+
var threadId = String((_a = root._id) !== null && _a !== void 0 ? _a : root.id);
|
|
869
|
+
var list = (_b = threads.byThread[threadId]) !== null && _b !== void 0 ? _b : [];
|
|
870
|
+
var composing = !editing && (replyTo === null || replyTo === void 0 ? void 0 : replyTo.threadId) === threadId;
|
|
871
|
+
if (!list.length && !composing)
|
|
872
|
+
return null;
|
|
873
|
+
var hidden = expandedThreads.includes(threadId)
|
|
874
|
+
? 0
|
|
875
|
+
: Math.max(0, list.length - activityReplies_1.VISIBLE_REPLIES);
|
|
876
|
+
return (react_1.default.createElement("div", { "data-testid": "activity-thread", className: "space-y-3 border-l-2 pl-3 ".concat(props.darkMode ? "border-gray-700" : "border-gray-100") },
|
|
877
|
+
hidden > 0 && (react_1.default.createElement(textButton_1.TextButton, { text: "View ".concat(hidden, " previous ").concat(hidden === 1 ? "reply" : "replies"), className: "!text-xs", onClick: function (event) {
|
|
878
|
+
event.stopPropagation();
|
|
879
|
+
setExpandedThreads(function (previous) { return __spreadArray(__spreadArray([], previous, true), [threadId], false); });
|
|
880
|
+
} })),
|
|
881
|
+
list.length > 0 && (react_1.default.createElement("ul", { "aria-label": "Replies to ".concat(handleRecordAuthorName(root)), className: "space-y-3" }, list.slice(hidden).map(function (reply) { return renderReply(reply, threadId); }))),
|
|
882
|
+
composing && renderComposer()));
|
|
883
|
+
};
|
|
741
884
|
var renderFeedData = function (records) {
|
|
742
|
-
return records
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
885
|
+
return records
|
|
886
|
+
// INFO: replies are drawn in their threads; this keeps one out of the
|
|
887
|
+
// feed for a backend that does not filter on replyTo
|
|
888
|
+
.filter(function (record) { return !threaded || !record.replyTo; })
|
|
889
|
+
.map(function (record) {
|
|
890
|
+
var _a, _b;
|
|
891
|
+
return ({
|
|
748
892
|
id: (_a = record._id) !== null && _a !== void 0 ? _a : record.id,
|
|
749
893
|
desc: null,
|
|
750
|
-
title: (
|
|
751
|
-
|
|
752
|
-
(date === null || date === void 0 ? void 0 : date.isValid()) && (react_1.default.createElement("time", { className: "text-xs font-normal ".concat(props.darkMode ? "text-gray-400" : "text-gray-500"), dateTime: date.toISOString(), title: date.format("YYYY-MM-DD HH:mm:ss") }, (0, activityImported_1.handleRenderActivityDate)(date))),
|
|
753
|
-
importedFrom && (react_1.default.createElement("span", { className: "text-xs font-normal ".concat(props.darkMode ? "text-gray-400" : "text-gray-500") }, importedFrom)))),
|
|
754
|
-
icon: (react_1.default.createElement(activityAvatar_1.ActivityAvatar, { id: record.userId, name: name, image: handleAuthorImage(record.userId), className: "h-7 w-7 sm:h-9 sm:w-9", darkMode: props.darkMode })),
|
|
894
|
+
title: renderCommentHeading(record),
|
|
895
|
+
icon: (react_1.default.createElement(activityAvatar_1.ActivityAvatar, { id: record.userId, name: handleRecordAuthorName(record), image: handleAuthorImage(record.userId), className: "h-7 w-7 sm:h-9 sm:w-9", darkMode: props.darkMode })),
|
|
755
896
|
iconClass: "",
|
|
756
|
-
content: (react_1.default.createElement("div", { className: "space-y-
|
|
757
|
-
renderRecordTitle(record),
|
|
758
|
-
|
|
759
|
-
|
|
897
|
+
content: (react_1.default.createElement("div", { className: "space-y-3" },
|
|
898
|
+
!activeRecordId && renderRecordTitle(record),
|
|
899
|
+
!threaded && record.replyTo && (react_1.default.createElement("p", { className: "text-xs text-gray-500" }, "Reply in a thread")),
|
|
900
|
+
renderComment(record),
|
|
901
|
+
threaded && renderThread(record),
|
|
902
|
+
!threaded &&
|
|
903
|
+
repliesEnabled &&
|
|
904
|
+
!editing &&
|
|
905
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === String((_b = record._id) !== null && _b !== void 0 ? _b : record.id) &&
|
|
906
|
+
renderComposer())),
|
|
907
|
+
});
|
|
760
908
|
});
|
|
761
909
|
};
|
|
762
910
|
// INFO: logs render as a flat, one-row-per-field list instead of feed cards
|
|
@@ -770,11 +918,13 @@ var ActivityPanel = function (props) {
|
|
|
770
918
|
};
|
|
771
919
|
if (!commentsEnabled && !logsEnabled)
|
|
772
920
|
return null;
|
|
773
|
-
var filters = __spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
921
|
+
var filters = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
774
922
|
{ type: "=", queryId: "collectionId", value: props.collectionId }
|
|
775
923
|
], (activeRecordId
|
|
776
924
|
? [{ type: "=", queryId: "itemId", value: activeRecordId }]
|
|
777
|
-
: []), true), ((_j = (isComments ? config === null || config === void 0 ? void 0 : config.commentQuery : config === null || config === void 0 ? void 0 : config.logQuery)) !== null && _j !== void 0 ? _j : []), true), (
|
|
925
|
+
: []), true), ((_j = (isComments ? config === null || config === void 0 ? void 0 : config.commentQuery : config === null || config === void 0 ? void 0 : config.logQuery)) !== null && _j !== void 0 ? _j : []), true), (isComments && threaded
|
|
926
|
+
? [{ type: "exists", queryId: "replyTo", value: false }]
|
|
927
|
+
: []), true), (mentionsOnly
|
|
778
928
|
? [
|
|
779
929
|
{
|
|
780
930
|
type: "in",
|
|
@@ -885,46 +1035,7 @@ var ActivityPanel = function (props) {
|
|
|
885
1035
|
setPendingPings([]);
|
|
886
1036
|
setNotice("Comment saved. Notification retry dismissed.");
|
|
887
1037
|
} }))))),
|
|
888
|
-
isComments &&
|
|
889
|
-
? {
|
|
890
|
-
files: pendingFiles,
|
|
891
|
-
existing: keptAttachments,
|
|
892
|
-
error: attachmentError,
|
|
893
|
-
maxFiles: attachmentLimits.maxFiles,
|
|
894
|
-
onPick: handlePickFiles,
|
|
895
|
-
onRemoveFile: function (index) {
|
|
896
|
-
setPendingFiles(function (previous) {
|
|
897
|
-
return previous.filter(function (_, each) { return each !== index; });
|
|
898
|
-
});
|
|
899
|
-
setAttachmentError("");
|
|
900
|
-
},
|
|
901
|
-
onRemoveExisting: function (index) {
|
|
902
|
-
return setKeptAttachments(function (previous) {
|
|
903
|
-
return previous.filter(function (_, each) { return each !== index; });
|
|
904
|
-
});
|
|
905
|
-
},
|
|
906
|
-
}
|
|
907
|
-
: undefined, onChange: function (value, selectedMentions) {
|
|
908
|
-
setDraft(value);
|
|
909
|
-
setMentions(selectedMentions);
|
|
910
|
-
}, onSubmit: handleSubmit, onCancel: handleResetDraft })),
|
|
911
|
-
deleteId && (react_1.default.createElement("div", { role: "alert", className: "flex flex-wrap items-center gap-3 rounded-lg border border-red-200 p-3 text-sm" },
|
|
912
|
-
react_1.default.createElement("span", null, "Delete this comment?"),
|
|
913
|
-
react_1.default.createElement(textButton_1.TextButton, { text: "Confirm delete", disable: busy, className: "!text-red-500 hover:!text-red-600", onClick: handleDelete }),
|
|
914
|
-
react_1.default.createElement(textButton_1.TextButton, { text: "Cancel", disable: busy, className: "!font-normal !text-inherit hover:underline", onClick: function () {
|
|
915
|
-
setDeleteId("");
|
|
916
|
-
setDeleteRecord(null);
|
|
917
|
-
} }))),
|
|
918
|
-
react_1.default.createElement(modal_1.Modal, { open: !!quoteView, title: "Original comment", maxWidth: "2xl", darkMode: props.darkMode, onClose: function () { return setQuoteView(null); }, renderContent: function () {
|
|
919
|
-
return quoteView ? (react_1.default.createElement("div", { className: "space-y-2" },
|
|
920
|
-
react_1.default.createElement("p", { className: "text-sm font-medium" },
|
|
921
|
-
handleRecordAuthorName(quoteView),
|
|
922
|
-
quoteView.createdAt &&
|
|
923
|
-
(0, dayjs_1.default)(quoteView.createdAt).isValid() && (react_1.default.createElement("span", { className: "ml-2 text-xs font-normal text-gray-500" }, (0, activityImported_1.handleRenderActivityDate)(quoteView.createdAt)))),
|
|
924
|
-
quoteView.comment && (react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words text-sm" }, String(quoteView.comment))),
|
|
925
|
-
Array.isArray(quoteView.attachments) &&
|
|
926
|
-
quoteView.attachments.length > 0 && (react_1.default.createElement(activityAttachments_1.ActivityAttachmentList, { attachments: quoteView.attachments, getUrl: attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.getUrl, darkMode: props.darkMode })))) : null;
|
|
927
|
-
} }),
|
|
1038
|
+
isComments && !editing && !replyTo && renderComposer(),
|
|
928
1039
|
react_1.default.createElement(dataWrapper_1.DataTemplateWrapper, { key: JSON.stringify([activeTab, filters]), ref: listRef, title: "", type: "list", collectionId: collectionId !== null && collectionId !== void 0 ? collectionId : "", schema: isComments ? commentModel : logsModel, workspace: {
|
|
929
1040
|
apiEndpoint: props.devSettings.dbEndpoint,
|
|
930
1041
|
apiEndpointType: props.devSettings.server,
|
|
@@ -940,19 +1051,12 @@ var ActivityPanel = function (props) {
|
|
|
940
1051
|
bareListHandleLoading: setListLoading,
|
|
941
1052
|
bareListHandleData: function (records) {
|
|
942
1053
|
var _a;
|
|
943
|
-
|
|
1054
|
+
// INFO: replies sit in their threads, so a backend that ignores the
|
|
1055
|
+
// replyTo filter must not make an empty feed look full
|
|
1056
|
+
var feed = records.filter(function (record) { return !isComments || !threaded || !record.replyTo; });
|
|
1057
|
+
setRowCount(feed.length);
|
|
944
1058
|
if (isComments) {
|
|
945
|
-
var
|
|
946
|
-
records.forEach(function (record) {
|
|
947
|
-
var _a;
|
|
948
|
-
byId_1[String((_a = record._id) !== null && _a !== void 0 ? _a : record.id)] = record;
|
|
949
|
-
});
|
|
950
|
-
setPageComments(function (previous) {
|
|
951
|
-
return JSON.stringify(previous) === JSON.stringify(byId_1)
|
|
952
|
-
? previous
|
|
953
|
-
: byId_1;
|
|
954
|
-
});
|
|
955
|
-
var ids_1 = records
|
|
1059
|
+
var ids_1 = feed
|
|
956
1060
|
.map(function (record) { var _a, _b; return String((_b = (_a = record._id) !== null && _a !== void 0 ? _a : record.id) !== null && _b !== void 0 ? _b : ""); })
|
|
957
1061
|
.filter(Boolean);
|
|
958
1062
|
setCommentIds(function (previous) {
|