blixify-ui-web 1.2.268 → 1.3.1
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.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/activityModal.js +281 -147
- 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/activityViews.d.ts +62 -0
- package/lib/components/data/dataTemplate/activityViews.d.ts.map +1 -0
- package/lib/components/data/dataTemplate/activityViews.js +583 -0
- package/lib/components/data/dataTemplate/activityViews.js.map +1 -0
- package/lib/components/data/dataTemplate/dataStateModel.d.ts +33 -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 +2 -2
- package/package.json +1 -1
|
@@ -96,10 +96,10 @@ 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");
|
|
102
|
+
var activityViews_1 = require("./activityViews");
|
|
103
103
|
var activityReactions_1 = require("./activityReactions");
|
|
104
104
|
var select_1 = require("../../input/select");
|
|
105
105
|
var activityRecords_1 = require("./activityRecords");
|
|
@@ -164,19 +164,17 @@ var ActivityPanel = function (props) {
|
|
|
164
164
|
var _0 = (0, react_1.useState)(""), attachmentError = _0[0], setAttachmentError = _0[1];
|
|
165
165
|
var _1 = (0, react_1.useState)(""), busyLabel = _1[0], setBusyLabel = _1[1];
|
|
166
166
|
var _2 = (0, react_1.useState)(null), deleteRecord = _2[0], setDeleteRecord = _2[1];
|
|
167
|
+
// INFO: the top-level comments on the page now; their replies are read apart
|
|
167
168
|
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];
|
|
169
|
+
var _4 = (0, react_1.useState)(null), replyTo = _4[0], setReplyTo = _4[1];
|
|
170
|
+
// INFO: threads opened past their latest replies with "View previous replies"
|
|
171
|
+
var _5 = (0, react_1.useState)([]), expandedThreads = _5[0], setExpandedThreads = _5[1];
|
|
172
|
+
var _6 = (0, react_1.useState)({}), authors = _6[0], setAuthors = _6[1];
|
|
173
|
+
var _7 = (0, react_1.useState)([]), authorIds = _7[0], setAuthorIds = _7[1];
|
|
174
|
+
var _8 = (0, react_1.useState)(null), rowCount = _8[0], setRowCount = _8[1];
|
|
175
|
+
var _9 = (0, react_1.useState)(true), listLoading = _9[0], setListLoading = _9[1];
|
|
176
|
+
var _10 = (0, react_1.useState)([]), recordIds = _10[0], setRecordIds = _10[1];
|
|
177
|
+
var _11 = (0, react_1.useState)(""), recordFilter = _11[0], setRecordFilter = _11[1];
|
|
180
178
|
var activeRecordId = props.dataId || recordFilter;
|
|
181
179
|
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
180
|
var recordScope = (_d = props.recordQuery) !== null && _d !== void 0 ? _d : [];
|
|
@@ -219,34 +217,60 @@ var ActivityPanel = function (props) {
|
|
|
219
217
|
var reactionEmojis = ((_h = config === null || config === void 0 ? void 0 : config.reactionEmojis) === null || _h === void 0 ? void 0 : _h.length)
|
|
220
218
|
? config.reactionEmojis
|
|
221
219
|
: activityReactions_1.DEFAULT_REACTION_EMOJIS;
|
|
220
|
+
var repliesEnabled = !!(commentsEnabled && (config === null || config === void 0 ? void 0 : config.enableReplies));
|
|
221
|
+
// INFO: replies sit in threads, except in Mentions me, which lists the
|
|
222
|
+
// comments and replies that name you flat, newest first
|
|
223
|
+
var threaded = repliesEnabled && !mentionsOnly;
|
|
224
|
+
var threads = (0, activityReplies_1.useActivityThreads)({
|
|
225
|
+
enabled: threaded && activeTab === "comments",
|
|
226
|
+
devSettings: props.devSettings,
|
|
227
|
+
commentCollectionId: config === null || config === void 0 ? void 0 : config.commentCollectionId,
|
|
228
|
+
collectionId: props.collectionId,
|
|
229
|
+
threadIds: commentIds,
|
|
230
|
+
});
|
|
231
|
+
var replies = Object.values(threads.byThread).flat();
|
|
232
|
+
var replyIds = replies
|
|
233
|
+
.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 : ""); })
|
|
234
|
+
.filter(Boolean);
|
|
235
|
+
var replyUserIds = replies
|
|
236
|
+
.map(function (each) { return each === null || each === void 0 ? void 0 : each.userId; })
|
|
237
|
+
.filter(function (each) { return typeof each === "string" && !!each; });
|
|
222
238
|
var reactions = (0, activityReactions_1.useActivityReactions)({
|
|
223
239
|
enabled: reactionsEnabled && activeTab === "comments",
|
|
224
240
|
devSettings: props.devSettings,
|
|
225
241
|
reactionCollectionId: config === null || config === void 0 ? void 0 : config.reactionCollectionId,
|
|
226
242
|
collectionId: props.collectionId,
|
|
227
243
|
currentUserId: config === null || config === void 0 ? void 0 : config.currentUserId,
|
|
228
|
-
commentIds: commentIds,
|
|
244
|
+
commentIds: __spreadArray(__spreadArray([], commentIds, true), replyIds, true),
|
|
229
245
|
onError: function (message) { return setError(message); },
|
|
230
246
|
});
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
247
|
+
var viewsEnabled = !!(commentsEnabled &&
|
|
248
|
+
(config === null || config === void 0 ? void 0 : config.enableViews) &&
|
|
249
|
+
config.viewCollectionId &&
|
|
250
|
+
config.currentUserId);
|
|
251
|
+
var views = (0, activityViews_1.useActivityViews)({
|
|
252
|
+
enabled: viewsEnabled && activeTab === "comments",
|
|
234
253
|
devSettings: props.devSettings,
|
|
235
|
-
|
|
254
|
+
viewCollectionId: config === null || config === void 0 ? void 0 : config.viewCollectionId,
|
|
236
255
|
collectionId: props.collectionId,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
256
|
+
currentUserId: config === null || config === void 0 ? void 0 : config.currentUserId,
|
|
257
|
+
itemId: activeRecordId || undefined,
|
|
258
|
+
commentIds: __spreadArray(__spreadArray([], commentIds, true), replyIds, true),
|
|
259
|
+
});
|
|
260
|
+
// INFO: the comments on screen, by id, for the observer to say which was seen
|
|
261
|
+
var seenComments = (0, react_1.useRef)(new Map());
|
|
262
|
+
var handleWatchSeen = (0, activityViews_1.useSeenObserver)(viewsEnabled && activeTab === "comments", function (commentId) {
|
|
263
|
+
var comment = seenComments.current.get(commentId);
|
|
264
|
+
if (comment)
|
|
265
|
+
views.handleSeen(__assign({ id: commentId }, comment));
|
|
266
|
+
});
|
|
267
|
+
var viewUserIds = Object.values(views.byComment).flatMap(function (list) {
|
|
268
|
+
return list.map(function (view) { return view.userId; });
|
|
241
269
|
});
|
|
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
270
|
var reactionUserIds = Array.from(new Set(Object.values(reactions.byComment).flatMap(function (list) {
|
|
247
271
|
return list.map(function (reaction) { return reaction.userId; });
|
|
248
272
|
})));
|
|
249
|
-
var nameIdsKey = JSON.stringify(Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], authorIds, true), reactionUserIds, true),
|
|
273
|
+
var nameIdsKey = JSON.stringify(Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], authorIds, true), reactionUserIds, true), replyUserIds, true), viewUserIds, true))));
|
|
250
274
|
var collectionId = isComments
|
|
251
275
|
? config === null || config === void 0 ? void 0 : config.commentCollectionId
|
|
252
276
|
: config === null || config === void 0 ? void 0 : config.logsCollectionId;
|
|
@@ -256,6 +280,24 @@ var ActivityPanel = function (props) {
|
|
|
256
280
|
mounted.current = false;
|
|
257
281
|
};
|
|
258
282
|
}, []);
|
|
283
|
+
// INFO: a reply or an edit is drawn inside its thread. When that thread
|
|
284
|
+
// leaves the page (page or filter changed), the box would go with it and the
|
|
285
|
+
// top box stays hidden, leaving nowhere to type, so the draft is closed.
|
|
286
|
+
// INFO: in the flat Mentions me list a draft sits under its own comment, so
|
|
287
|
+
// it is that comment, not its thread, that has to stay on the page
|
|
288
|
+
(0, react_1.useEffect)(function () {
|
|
289
|
+
var _a, _b;
|
|
290
|
+
if (!repliesEnabled || listLoading)
|
|
291
|
+
return;
|
|
292
|
+
var editingId = editing ? String((_b = (_a = editing._id) !== null && _a !== void 0 ? _a : editing.id) !== null && _b !== void 0 ? _b : "") : "";
|
|
293
|
+
var editingThread = editing ? String(editing.threadId || editingId) : "";
|
|
294
|
+
var replyGone = !!replyTo &&
|
|
295
|
+
!commentIds.includes(threaded ? replyTo.threadId : replyTo.id);
|
|
296
|
+
var editGone = !!editingId && !commentIds.includes(threaded ? editingThread : editingId);
|
|
297
|
+
if (replyGone || editGone)
|
|
298
|
+
handleResetDraft();
|
|
299
|
+
/* eslint-disable-next-line */
|
|
300
|
+
}, [commentIds, listLoading, repliesEnabled, threaded]);
|
|
259
301
|
(0, react_1.useEffect)(function () {
|
|
260
302
|
var cancelled = false;
|
|
261
303
|
var handleLoadAuthors = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -338,23 +380,55 @@ var ActivityPanel = function (props) {
|
|
|
338
380
|
!(config === null || config === void 0 ? void 0 : config.currentUserId) ||
|
|
339
381
|
record.userId === config.currentUserId;
|
|
340
382
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
383
|
+
// INFO: one draft is open at a time — the top box, a reply under a thread or
|
|
384
|
+
// an edit in place — so moving to another asks before dropping what is typed
|
|
385
|
+
var handleConfirmDiscard = function () {
|
|
386
|
+
return !(draft.trim() || pendingFiles.length > 0) ||
|
|
387
|
+
window.confirm("Discard the comment you are writing?");
|
|
388
|
+
};
|
|
389
|
+
var handleStartReply = function (record, threadId) {
|
|
390
|
+
var _a, _b, _c;
|
|
391
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
392
|
+
if ((replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === id)
|
|
351
393
|
return;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
394
|
+
if (!handleConfirmDiscard())
|
|
395
|
+
return;
|
|
396
|
+
var name = handleRecordAuthorName(record);
|
|
397
|
+
// INFO: a reply to a reply starts by naming the person answered, as on
|
|
398
|
+
// Facebook; a reply to the thread's own comment, or to yourself, does not
|
|
399
|
+
var named = id !== threadId &&
|
|
400
|
+
!!record.userId &&
|
|
401
|
+
record.userId !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
402
|
+
name !== record.userId;
|
|
403
|
+
var prefill = named
|
|
404
|
+
? (0, activityReplies_1.handleRenderReplyMention)(name, record.userId)
|
|
405
|
+
: { value: "", mentions: [] };
|
|
406
|
+
handleResetDraft();
|
|
407
|
+
setError("");
|
|
408
|
+
setDraft(prefill.value);
|
|
409
|
+
setMentions(prefill.mentions);
|
|
410
|
+
setReplyTo({
|
|
411
|
+
id: id,
|
|
412
|
+
threadId: threadId,
|
|
413
|
+
userId: (_b = record.userId) !== null && _b !== void 0 ? _b : null,
|
|
414
|
+
itemId: (_c = record.itemId) !== null && _c !== void 0 ? _c : null,
|
|
415
|
+
name: name,
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
var handleStartEdit = function (record) {
|
|
419
|
+
var _a, _b, _c, _d;
|
|
420
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
421
|
+
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)
|
|
422
|
+
return;
|
|
423
|
+
if (!handleConfirmDiscard())
|
|
424
|
+
return;
|
|
425
|
+
var text = String((_d = record.comment) !== null && _d !== void 0 ? _d : "");
|
|
426
|
+
handleResetDraft();
|
|
427
|
+
setEditing(record);
|
|
428
|
+
setDraft(text);
|
|
429
|
+
setMentions((0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []));
|
|
430
|
+
setKeptAttachments(Array.isArray(record.attachments) ? record.attachments : []);
|
|
431
|
+
setError("");
|
|
358
432
|
};
|
|
359
433
|
var handlePickFiles = function (picked) {
|
|
360
434
|
var next = (0, activityAttachments_1.handleAddAttachmentFiles)(pendingFiles, picked, keptAttachments.length, attachmentLimits);
|
|
@@ -524,7 +598,12 @@ var ActivityPanel = function (props) {
|
|
|
524
598
|
attachments = __spreadArray(__spreadArray([], kept, true), uploaded, true);
|
|
525
599
|
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
600
|
? { updatedAt: new Date() }
|
|
527
|
-
: __assign((_e = {}, _e[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId, _e.createdAt = new Date(), _e), (replyTo
|
|
601
|
+
: __assign((_e = {}, _e[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId, _e.createdAt = new Date(), _e), (replyTo
|
|
602
|
+
? {
|
|
603
|
+
replyTo: { commentId: replyTo.id },
|
|
604
|
+
threadId: replyTo.threadId,
|
|
605
|
+
}
|
|
606
|
+
: {}))));
|
|
528
607
|
_u.label = 9;
|
|
529
608
|
case 9:
|
|
530
609
|
_u.trys.push([9, 16, 17, 18]);
|
|
@@ -556,8 +635,11 @@ var ActivityPanel = function (props) {
|
|
|
556
635
|
// Notification delivery still runs if the panel was closed during the save.
|
|
557
636
|
if (mounted.current) {
|
|
558
637
|
handleResetDraft();
|
|
559
|
-
//
|
|
560
|
-
|
|
638
|
+
// INFO: a reply, made or edited, changes only its thread; a new
|
|
639
|
+
// top-level comment sorts onto page one; an edit keeps the page
|
|
640
|
+
if (answered || (editing === null || editing === void 0 ? void 0 : editing.threadId))
|
|
641
|
+
threads.handleRefresh();
|
|
642
|
+
else if (editing)
|
|
561
643
|
(_q = listRef.current) === null || _q === void 0 ? void 0 : _q.handleRefreshCurrentPage();
|
|
562
644
|
else
|
|
563
645
|
(_r = listRef.current) === null || _r === void 0 ? void 0 : _r.handleRefresh();
|
|
@@ -574,7 +656,9 @@ var ActivityPanel = function (props) {
|
|
|
574
656
|
return id !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
575
657
|
!((_a = editing === null || editing === void 0 ? void 0 : editing.mentionedUserIds) !== null && _a !== void 0 ? _a : []).includes(id);
|
|
576
658
|
});
|
|
577
|
-
replyRecipient = (answered === null || answered === void 0 ? void 0 : answered.userId) &&
|
|
659
|
+
replyRecipient = (answered === null || answered === void 0 ? void 0 : answered.userId) &&
|
|
660
|
+
answered.userId !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
|
|
661
|
+
!recipients.includes(answered.userId)
|
|
578
662
|
? answered
|
|
579
663
|
: null;
|
|
580
664
|
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 +690,7 @@ var ActivityPanel = function (props) {
|
|
|
606
690
|
userId: userId,
|
|
607
691
|
replyToCommentId: replyRecipient.id,
|
|
608
692
|
replyToUserId: replyRecipient.userId,
|
|
693
|
+
threadId: replyRecipient.threadId,
|
|
609
694
|
},
|
|
610
695
|
});
|
|
611
696
|
return [4 /*yield*/, handleNotify(pings)];
|
|
@@ -652,13 +737,21 @@ var ActivityPanel = function (props) {
|
|
|
652
737
|
});
|
|
653
738
|
if (!mounted.current)
|
|
654
739
|
return [2 /*return*/];
|
|
655
|
-
|
|
740
|
+
// INFO: the draft goes with the comment it edits or the thread it replies in
|
|
741
|
+
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 ||
|
|
742
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.threadId) === deleteId ||
|
|
743
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === deleteId)
|
|
656
744
|
handleResetDraft();
|
|
657
745
|
setDeleteId("");
|
|
658
|
-
setDeleteRecord(null);
|
|
659
746
|
setNotice("Comment deleted.");
|
|
660
|
-
//
|
|
661
|
-
|
|
747
|
+
// INFO: a reply leaves the page as it is. A top-level comment goes with
|
|
748
|
+
// its thread, which the backend deletes; deleting the last row on a
|
|
749
|
+
// later page would hide the feed's paginator, so the list starts over.
|
|
750
|
+
if (deleteRecord === null || deleteRecord === void 0 ? void 0 : deleteRecord.threadId)
|
|
751
|
+
threads.handleRefresh();
|
|
752
|
+
else
|
|
753
|
+
(_e = listRef.current) === null || _e === void 0 ? void 0 : _e.handleRefresh();
|
|
754
|
+
setDeleteRecord(null);
|
|
662
755
|
return [3 /*break*/, 5];
|
|
663
756
|
case 3:
|
|
664
757
|
_a = _f.sent();
|
|
@@ -674,9 +767,61 @@ var ActivityPanel = function (props) {
|
|
|
674
767
|
}
|
|
675
768
|
});
|
|
676
769
|
}); };
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
770
|
+
// INFO: one composer and one draft. It sits at the top for a new comment,
|
|
771
|
+
// under a thread for a reply, and in place of the comment being edited.
|
|
772
|
+
var renderComposer = function () {
|
|
773
|
+
var _a;
|
|
774
|
+
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
|
|
775
|
+
? "edit:".concat((_a = editing._id) !== null && _a !== void 0 ? _a : editing.id)
|
|
776
|
+
: replyTo
|
|
777
|
+
? "reply:".concat(replyTo.id)
|
|
778
|
+
: undefined, attachments: attachmentsConfig
|
|
779
|
+
? {
|
|
780
|
+
files: pendingFiles,
|
|
781
|
+
existing: keptAttachments,
|
|
782
|
+
error: attachmentError,
|
|
783
|
+
maxFiles: attachmentLimits.maxFiles,
|
|
784
|
+
onPick: handlePickFiles,
|
|
785
|
+
onRemoveFile: function (index) {
|
|
786
|
+
setPendingFiles(function (previous) {
|
|
787
|
+
return previous.filter(function (_, each) { return each !== index; });
|
|
788
|
+
});
|
|
789
|
+
setAttachmentError("");
|
|
790
|
+
},
|
|
791
|
+
onRemoveExisting: function (index) {
|
|
792
|
+
return setKeptAttachments(function (previous) {
|
|
793
|
+
return previous.filter(function (_, each) { return each !== index; });
|
|
794
|
+
});
|
|
795
|
+
},
|
|
796
|
+
}
|
|
797
|
+
: undefined, onChange: function (value, selectedMentions) {
|
|
798
|
+
setDraft(value);
|
|
799
|
+
setMentions(selectedMentions);
|
|
800
|
+
}, onSubmit: handleSubmit, onCancel: handleResetDraft }));
|
|
801
|
+
};
|
|
802
|
+
var renderDeleteConfirm = function (record) {
|
|
803
|
+
var _a, _b, _c;
|
|
804
|
+
var id = String((_a = record._id) !== null && _a !== void 0 ? _a : record.id);
|
|
805
|
+
var replyCount = record.threadId
|
|
806
|
+
? 0
|
|
807
|
+
: ((_c = (_b = threads.byThread[id]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0);
|
|
808
|
+
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" },
|
|
809
|
+
react_1.default.createElement("span", null, replyCount
|
|
810
|
+
? "Delete this comment and its ".concat(replyCount, " ").concat(replyCount === 1 ? "reply" : "replies", "?")
|
|
811
|
+
: "Delete this comment?"),
|
|
812
|
+
react_1.default.createElement(textButton_1.TextButton, { text: "Confirm delete", disable: busy, className: "!text-red-500 hover:!text-red-600", onClick: handleDelete }),
|
|
813
|
+
react_1.default.createElement(textButton_1.TextButton, { text: "Cancel", disable: busy, className: "!font-normal !text-inherit hover:underline", onClick: function () {
|
|
814
|
+
setDeleteId("");
|
|
815
|
+
setDeleteRecord(null);
|
|
816
|
+
} })));
|
|
817
|
+
};
|
|
818
|
+
// INFO: threadId is the thread the comment sits in; a top-level comment has none
|
|
819
|
+
var renderComment = function (record, threadId) {
|
|
820
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
821
|
+
var id = (_a = record._id) !== null && _a !== void 0 ? _a : record.id;
|
|
822
|
+
if (editing && String((_b = editing._id) !== null && _b !== void 0 ? _b : editing.id) === String(id))
|
|
823
|
+
return renderComposer();
|
|
824
|
+
var text = String((_c = record.comment) !== null && _c !== void 0 ? _c : "");
|
|
680
825
|
var savedMentions = (0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []);
|
|
681
826
|
var parts = [];
|
|
682
827
|
var cursor = 0;
|
|
@@ -686,49 +831,39 @@ var ActivityPanel = function (props) {
|
|
|
686
831
|
cursor = mention.end;
|
|
687
832
|
});
|
|
688
833
|
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
834
|
var canEdit = handleIsOwnComment(record);
|
|
694
835
|
var canDelete = canEdit || !!(config === null || config === void 0 ? void 0 : config.canModerate);
|
|
695
|
-
|
|
696
|
-
|
|
836
|
+
if (viewsEnabled && id)
|
|
837
|
+
seenComments.current.set(String(id), {
|
|
838
|
+
itemId: (_d = record.itemId) !== null && _d !== void 0 ? _d : null,
|
|
839
|
+
authorId: (_e = record.userId) !== null && _e !== void 0 ? _e : null,
|
|
840
|
+
});
|
|
841
|
+
return (react_1.default.createElement("div", { id: id ? "activity-comment-".concat(id) : undefined, ref: viewsEnabled && id ? handleWatchSeen(String(id)) : undefined, className: "space-y-2" },
|
|
697
842
|
text && react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words" }, parts),
|
|
698
843
|
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)((
|
|
844
|
+
reactionsEnabled && id && (react_1.default.createElement(activityReactions_1.ActivityReactionBar, { summaries: (0, activityReactions_1.handleSummariseReactions)((_f = reactions.byComment[String(id)]) !== null && _f !== void 0 ? _f : [], config === null || config === void 0 ? void 0 : config.currentUserId), emojis: reactionEmojis, authorName: handleAuthorName, authorImage: handleAuthorImage, darkMode: props.darkMode, onToggle: function (emoji) {
|
|
700
845
|
var _a;
|
|
701
846
|
return reactions.handleToggle({ id: String(id), itemId: (_a = record.itemId) !== null && _a !== void 0 ? _a : null }, emoji);
|
|
702
847
|
} })),
|
|
703
848
|
react_1.default.createElement("div", { className: "flex gap-3 text-xs text-gray-500" },
|
|
704
849
|
record.updatedAt && react_1.default.createElement("span", null, "Edited"),
|
|
705
850
|
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
851
|
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
|
-
});
|
|
852
|
+
handleStartReply(record, threadId !== null && threadId !== void 0 ? threadId : (0, activityReplies_1.handleResolveThreadId)(record));
|
|
716
853
|
} })),
|
|
717
854
|
canEdit && (react_1.default.createElement(textButton_1.TextButton, { text: "Edit", disable: busy || !!pendingPing, className: "!font-normal !text-inherit hover:underline", onClick: function (event) {
|
|
718
855
|
event.stopPropagation();
|
|
719
|
-
|
|
720
|
-
setDraft(text);
|
|
721
|
-
setMentions(savedMentions);
|
|
722
|
-
setKeptAttachments(Array.isArray(record.attachments) ? record.attachments : []);
|
|
723
|
-
setPendingFiles([]);
|
|
724
|
-
setAttachmentError("");
|
|
725
|
-
setError("");
|
|
856
|
+
handleStartEdit(record);
|
|
726
857
|
} })),
|
|
858
|
+
viewsEnabled && id && (react_1.default.createElement(activityViews_1.ActivitySeenBy, { viewers: (0, activityViews_1.handleListViewers)((_g = views.byComment[String(id)]) !== null && _g !== void 0 ? _g : [], record.userId), authorName: handleAuthorName, authorImage: handleAuthorImage, darkMode: props.darkMode })),
|
|
727
859
|
canDelete && (react_1.default.createElement(textButton_1.TextButton, { text: "Delete", disable: busy || !!pendingPing, className: "!font-normal !text-inherit hover:underline", onClick: function (event) {
|
|
728
860
|
event.stopPropagation();
|
|
729
861
|
setDeleteId(id);
|
|
730
862
|
setDeleteRecord(record);
|
|
731
|
-
} })))
|
|
863
|
+
} }))),
|
|
864
|
+
deleteId &&
|
|
865
|
+
String(deleteId) === String(id) &&
|
|
866
|
+
renderDeleteConfirm(record)));
|
|
732
867
|
};
|
|
733
868
|
var renderRecordTitle = function (record) {
|
|
734
869
|
var _a;
|
|
@@ -738,25 +873,68 @@ var ActivityPanel = function (props) {
|
|
|
738
873
|
(_a = props.onOpenRecord) === null || _a === void 0 ? void 0 : _a.call(props, record.itemId);
|
|
739
874
|
} }, 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
875
|
};
|
|
876
|
+
// INFO: the author, when, and the tool an imported comment came from
|
|
877
|
+
var renderCommentHeading = function (record) {
|
|
878
|
+
var date = record.createdAt ? (0, dayjs_1.default)(record.createdAt) : null;
|
|
879
|
+
var importedFrom = (0, activityImported_1.handleRenderImportedFrom)(record.importedFrom);
|
|
880
|
+
var muted = "text-xs font-normal ".concat(props.darkMode ? "text-gray-400" : "text-gray-500");
|
|
881
|
+
return (react_1.default.createElement("span", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1" },
|
|
882
|
+
react_1.default.createElement("span", null, handleRecordAuthorName(record)),
|
|
883
|
+
(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))),
|
|
884
|
+
importedFrom && react_1.default.createElement("span", { className: muted }, importedFrom)));
|
|
885
|
+
};
|
|
886
|
+
var renderReply = function (reply, threadId) {
|
|
887
|
+
var _a;
|
|
888
|
+
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" },
|
|
889
|
+
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 }),
|
|
890
|
+
react_1.default.createElement("div", { className: "min-w-0 flex-1 space-y-1" },
|
|
891
|
+
react_1.default.createElement("p", { className: "text-sm font-medium" }, renderCommentHeading(reply)),
|
|
892
|
+
renderComment(reply, threadId))));
|
|
893
|
+
};
|
|
894
|
+
// INFO: as on Facebook, a thread shows its latest replies under "View
|
|
895
|
+
// previous replies", and the box for a reply opens at the bottom of it
|
|
896
|
+
var renderThread = function (root) {
|
|
897
|
+
var _a, _b;
|
|
898
|
+
var threadId = String((_a = root._id) !== null && _a !== void 0 ? _a : root.id);
|
|
899
|
+
var list = (_b = threads.byThread[threadId]) !== null && _b !== void 0 ? _b : [];
|
|
900
|
+
var composing = !editing && (replyTo === null || replyTo === void 0 ? void 0 : replyTo.threadId) === threadId;
|
|
901
|
+
if (!list.length && !composing)
|
|
902
|
+
return null;
|
|
903
|
+
var hidden = expandedThreads.includes(threadId)
|
|
904
|
+
? 0
|
|
905
|
+
: Math.max(0, list.length - activityReplies_1.VISIBLE_REPLIES);
|
|
906
|
+
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") },
|
|
907
|
+
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) {
|
|
908
|
+
event.stopPropagation();
|
|
909
|
+
setExpandedThreads(function (previous) { return __spreadArray(__spreadArray([], previous, true), [threadId], false); });
|
|
910
|
+
} })),
|
|
911
|
+
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); }))),
|
|
912
|
+
composing && renderComposer()));
|
|
913
|
+
};
|
|
741
914
|
var renderFeedData = function (records) {
|
|
742
|
-
return records
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
915
|
+
return records
|
|
916
|
+
// INFO: replies are drawn in their threads; this keeps one out of the
|
|
917
|
+
// feed for a backend that does not filter on replyTo
|
|
918
|
+
.filter(function (record) { return !threaded || !record.replyTo; })
|
|
919
|
+
.map(function (record) {
|
|
920
|
+
var _a, _b;
|
|
921
|
+
return ({
|
|
748
922
|
id: (_a = record._id) !== null && _a !== void 0 ? _a : record.id,
|
|
749
923
|
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 })),
|
|
924
|
+
title: renderCommentHeading(record),
|
|
925
|
+
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
926
|
iconClass: "",
|
|
756
|
-
content: (react_1.default.createElement("div", { className: "space-y-
|
|
757
|
-
renderRecordTitle(record),
|
|
758
|
-
|
|
759
|
-
|
|
927
|
+
content: (react_1.default.createElement("div", { className: "space-y-3" },
|
|
928
|
+
!activeRecordId && renderRecordTitle(record),
|
|
929
|
+
!threaded && record.replyTo && (react_1.default.createElement("p", { className: "text-xs text-gray-500" }, "Reply in a thread")),
|
|
930
|
+
renderComment(record),
|
|
931
|
+
threaded && renderThread(record),
|
|
932
|
+
!threaded &&
|
|
933
|
+
repliesEnabled &&
|
|
934
|
+
!editing &&
|
|
935
|
+
(replyTo === null || replyTo === void 0 ? void 0 : replyTo.id) === String((_b = record._id) !== null && _b !== void 0 ? _b : record.id) &&
|
|
936
|
+
renderComposer())),
|
|
937
|
+
});
|
|
760
938
|
});
|
|
761
939
|
};
|
|
762
940
|
// INFO: logs render as a flat, one-row-per-field list instead of feed cards
|
|
@@ -770,11 +948,13 @@ var ActivityPanel = function (props) {
|
|
|
770
948
|
};
|
|
771
949
|
if (!commentsEnabled && !logsEnabled)
|
|
772
950
|
return null;
|
|
773
|
-
var filters = __spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
951
|
+
var filters = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
774
952
|
{ type: "=", queryId: "collectionId", value: props.collectionId }
|
|
775
953
|
], (activeRecordId
|
|
776
954
|
? [{ 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), (
|
|
955
|
+
: []), 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
|
|
956
|
+
? [{ type: "exists", queryId: "replyTo", value: false }]
|
|
957
|
+
: []), true), (mentionsOnly
|
|
778
958
|
? [
|
|
779
959
|
{
|
|
780
960
|
type: "in",
|
|
@@ -885,46 +1065,7 @@ var ActivityPanel = function (props) {
|
|
|
885
1065
|
setPendingPings([]);
|
|
886
1066
|
setNotice("Comment saved. Notification retry dismissed.");
|
|
887
1067
|
} }))))),
|
|
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
|
-
} }),
|
|
1068
|
+
isComments && !editing && !replyTo && renderComposer(),
|
|
928
1069
|
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
1070
|
apiEndpoint: props.devSettings.dbEndpoint,
|
|
930
1071
|
apiEndpointType: props.devSettings.server,
|
|
@@ -940,19 +1081,12 @@ var ActivityPanel = function (props) {
|
|
|
940
1081
|
bareListHandleLoading: setListLoading,
|
|
941
1082
|
bareListHandleData: function (records) {
|
|
942
1083
|
var _a;
|
|
943
|
-
|
|
1084
|
+
// INFO: replies sit in their threads, so a backend that ignores the
|
|
1085
|
+
// replyTo filter must not make an empty feed look full
|
|
1086
|
+
var feed = records.filter(function (record) { return !isComments || !threaded || !record.replyTo; });
|
|
1087
|
+
setRowCount(feed.length);
|
|
944
1088
|
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
|
|
1089
|
+
var ids_1 = feed
|
|
956
1090
|
.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
1091
|
.filter(Boolean);
|
|
958
1092
|
setCommentIds(function (previous) {
|