blixify-ui-web 1.2.138 → 1.2.140

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.
Files changed (44) hide show
  1. package/lib/components/data/dataTemplate/activityChanges.d.ts +8 -0
  2. package/lib/components/data/dataTemplate/activityChanges.d.ts.map +1 -0
  3. package/lib/components/data/dataTemplate/activityChanges.js +92 -0
  4. package/lib/components/data/dataTemplate/activityChanges.js.map +1 -0
  5. package/lib/components/data/dataTemplate/activityComposer.d.ts +17 -0
  6. package/lib/components/data/dataTemplate/activityComposer.d.ts.map +1 -0
  7. package/lib/components/data/dataTemplate/activityComposer.js +154 -0
  8. package/lib/components/data/dataTemplate/activityComposer.js.map +1 -0
  9. package/lib/components/data/dataTemplate/activityMentions.d.ts +4 -0
  10. package/lib/components/data/dataTemplate/activityMentions.d.ts.map +1 -0
  11. package/lib/components/data/dataTemplate/activityMentions.js +67 -0
  12. package/lib/components/data/dataTemplate/activityMentions.js.map +1 -0
  13. package/lib/components/data/dataTemplate/activityModal.d.ts +9 -24
  14. package/lib/components/data/dataTemplate/activityModal.d.ts.map +1 -1
  15. package/lib/components/data/dataTemplate/activityModal.js +492 -392
  16. package/lib/components/data/dataTemplate/activityModal.js.map +1 -1
  17. package/lib/components/data/dataTemplate/activityRecords.d.ts +10 -0
  18. package/lib/components/data/dataTemplate/activityRecords.d.ts.map +1 -0
  19. package/lib/components/data/dataTemplate/activityRecords.js +165 -0
  20. package/lib/components/data/dataTemplate/activityRecords.js.map +1 -0
  21. package/lib/components/data/dataTemplate/dataStateModel.d.ts +22 -0
  22. package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
  23. package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
  24. package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
  25. package/lib/components/data/dataTemplate/index.js +171 -154
  26. package/lib/components/data/dataTemplate/index.js.map +1 -1
  27. package/lib/components/data/updateModule.d.ts.map +1 -1
  28. package/lib/components/data/updateModule.js +15 -3
  29. package/lib/components/data/updateModule.js.map +1 -1
  30. package/lib/components/display/newTable/index.d.ts +2 -0
  31. package/lib/components/display/newTable/index.d.ts.map +1 -1
  32. package/lib/components/display/newTable/index.js +185 -156
  33. package/lib/components/display/newTable/index.js.map +1 -1
  34. package/lib/components/input/datePicker/index.d.ts.map +1 -1
  35. package/lib/components/input/datePicker/index.js +23 -10
  36. package/lib/components/input/datePicker/index.js.map +1 -1
  37. package/lib/components/input/select/index.d.ts.map +1 -1
  38. package/lib/components/input/select/index.js +16 -4
  39. package/lib/components/input/select/index.js.map +1 -1
  40. package/lib/components/input/textInput/index.d.ts.map +1 -1
  41. package/lib/components/input/textInput/index.js +15 -7
  42. package/lib/components/input/textInput/index.js.map +1 -1
  43. package/lib/tail.css +2 -2
  44. package/package.json +1 -1
@@ -1,19 +1,15 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
15
10
  };
16
- })();
11
+ return __assign.apply(this, arguments);
12
+ };
17
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
14
  if (k2 === undefined) k2 = k;
19
15
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -89,404 +85,508 @@ Object.defineProperty(exports, "__esModule", { value: true });
89
85
  exports.ActivityModal = void 0;
90
86
  var solid_1 = require("@heroicons/react/24/solid");
91
87
  var axios_1 = __importDefault(require("axios"));
92
- var dayjs_1 = __importDefault(require("../../dayjs"));
93
88
  var react_1 = __importStar(require("react"));
94
- var list_1 = require("../../display/list");
95
- var tabs_1 = require("../../navigation/tabs");
89
+ var uuid_1 = require("uuid");
90
+ var dayjs_1 = __importDefault(require("../../dayjs"));
91
+ var buttonGroup_1 = require("../../action/buttonGroup");
92
+ var chatBase_1 = require("../../chat/chatBase");
96
93
  var dataWrapper_1 = require("../dataWrapper");
97
- var ActivityModal = /** @class */ (function (_super) {
98
- __extends(ActivityModal, _super);
99
- function ActivityModal() {
100
- var _a, _b, _c;
101
- var _this = _super.apply(this, arguments) || this;
102
- _this.dataTemplateRef = (0, react_1.createRef)();
103
- _this.state = {
104
- type: ((_a = _this.props.activityLog) === null || _a === void 0 ? void 0 : _a.enableComments) &&
105
- _this.props.activityLog.commentCollectionId
106
- ? "comments"
107
- : "logs",
108
- commentViewType: "list",
109
- commentDataId: "",
110
- logsViewType: "list",
111
- logsDataId: "",
112
- userData: [],
113
- userLoading: false,
94
+ var writeQuery_1 = require("../writeQuery");
95
+ var utils_1 = require("../utils");
96
+ var activityComposer_1 = require("./activityComposer");
97
+ var activityMentions_1 = require("./activityMentions");
98
+ var activityChanges_1 = require("./activityChanges");
99
+ var select_1 = require("../../input/select");
100
+ var activityRecords_1 = require("./activityRecords");
101
+ var commentModel = [
102
+ { id: "comment", name: "Comment", type: "textArea" },
103
+ { id: "userId", name: "Author", type: "string" },
104
+ { id: "createdAt", name: "Created", type: "date" },
105
+ ];
106
+ var logsModel = [
107
+ { id: "type", name: "Type", type: "string" },
108
+ { id: "userId", name: "Author", type: "string" },
109
+ { id: "createdAt", name: "Created", type: "date" },
110
+ { id: "values", name: "Changes", type: "object" },
111
+ ];
112
+ // Drafts, author caches and paging belong to one record and authenticated endpoint.
113
+ var ActivityModal = function (props) {
114
+ var _a, _b, _c;
115
+ return (react_1.default.createElement(ActivityPanel, __assign({ key: JSON.stringify([
116
+ props.collectionId,
117
+ props.dataId,
118
+ props.initialTab,
119
+ props.devSettings.dbEndpoint,
120
+ props.devSettings.dbUserToken,
121
+ props.devSettings.dbAPIToken,
122
+ props.devSettings.server,
123
+ props.recordQuery,
124
+ props.recordTitleColumn,
125
+ (_a = props.activityLog) === null || _a === void 0 ? void 0 : _a.commentCollectionId,
126
+ (_b = props.activityLog) === null || _b === void 0 ? void 0 : _b.logsCollectionId,
127
+ (_c = props.activityLog) === null || _c === void 0 ? void 0 : _c.currentUserId,
128
+ ]) }, props)));
129
+ };
130
+ exports.ActivityModal = ActivityModal;
131
+ var ActivityPanel = function (props) {
132
+ var _a, _b, _c, _d, _e, _f, _g;
133
+ var config = props.activityLog;
134
+ var commentsEnabled = !!((config === null || config === void 0 ? void 0 : config.enableComments) && config.commentCollectionId);
135
+ var logsEnabled = !!((config === null || config === void 0 ? void 0 : config.enableLogs) && config.logsCollectionId);
136
+ var _h = (0, react_1.useState)((_a = props.initialTab) !== null && _a !== void 0 ? _a : (commentsEnabled ? "comments" : "logs")), tab = _h[0], setTab = _h[1];
137
+ var _j = (0, react_1.useState)("all"), logType = _j[0], setLogType = _j[1];
138
+ var activeTab = tab === "comments" && commentsEnabled
139
+ ? "comments"
140
+ : logsEnabled
141
+ ? "logs"
142
+ : "comments";
143
+ var _k = (0, react_1.useState)(""), draft = _k[0], setDraft = _k[1];
144
+ var _l = (0, react_1.useState)([]), mentions = _l[0], setMentions = _l[1];
145
+ var _m = (0, react_1.useState)(null), editing = _m[0], setEditing = _m[1];
146
+ var _o = (0, react_1.useState)(""), deleteId = _o[0], setDeleteId = _o[1];
147
+ var _p = (0, react_1.useState)(false), busy = _p[0], setBusy = _p[1];
148
+ var _q = (0, react_1.useState)(""), error = _q[0], setError = _q[1];
149
+ var _r = (0, react_1.useState)(""), notice = _r[0], setNotice = _r[1];
150
+ var _s = (0, react_1.useState)(null), pendingPing = _s[0], setPendingPing = _s[1];
151
+ var _t = (0, react_1.useState)({}), authors = _t[0], setAuthors = _t[1];
152
+ var _u = (0, react_1.useState)([]), authorIds = _u[0], setAuthorIds = _u[1];
153
+ var _v = (0, react_1.useState)(null), rowCount = _v[0], setRowCount = _v[1];
154
+ var _w = (0, react_1.useState)([]), recordIds = _w[0], setRecordIds = _w[1];
155
+ var _x = (0, react_1.useState)(""), recordFilter = _x[0], setRecordFilter = _x[1];
156
+ var activeRecordId = props.dataId || recordFilter;
157
+ 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";
158
+ var recordScope = (_d = props.recordQuery) !== null && _d !== void 0 ? _d : [];
159
+ var recordLookup = (0, activityRecords_1.useActivityRecords)(props.devSettings, props.collectionId, titleColumn, recordScope, Array.from(new Set(__spreadArray(__spreadArray([], recordIds, true), (activeRecordId ? [activeRecordId] : []), true))), false);
160
+ var recordSearch = (0, activityRecords_1.useActivityRecords)(props.devSettings, props.collectionId, titleColumn, recordScope, [], !props.dataId);
161
+ var recordTitles = __assign(__assign({}, recordLookup.titles), recordSearch.titles);
162
+ var listRef = (0, react_1.useRef)(null);
163
+ var saving = (0, react_1.useRef)(false);
164
+ var mounted = (0, react_1.useRef)(true);
165
+ var members = props.devSettings.organisationMembers;
166
+ var isComments = activeTab === "comments";
167
+ var collectionId = isComments
168
+ ? config === null || config === void 0 ? void 0 : config.commentCollectionId
169
+ : config === null || config === void 0 ? void 0 : config.logsCollectionId;
170
+ (0, react_1.useEffect)(function () {
171
+ mounted.current = true;
172
+ return function () {
173
+ mounted.current = false;
114
174
  };
115
- _this.commentModel = [
116
- { id: "comment", name: "Comment", type: "textArea" },
117
- {
118
- id: "userId",
119
- name: "User ID",
120
- type: "string",
121
- defaultValue: (_c = (_b = _this.props.activityLog) === null || _b === void 0 ? void 0 : _b.currentUserId) !== null && _c !== void 0 ? _c : "",
122
- hideForm: true,
123
- disabled: true,
124
- },
125
- {
126
- id: "itemId",
127
- name: "Item ID",
128
- type: "string",
129
- defaultValue: _this.props.dataId,
130
- hideForm: true,
131
- optional: true,
132
- disabled: true,
133
- },
134
- {
135
- id: "collectionId",
136
- name: "Collection ID",
137
- type: "string",
138
- defaultValue: _this.props.collectionId,
139
- hideForm: true,
140
- optional: true,
141
- disabled: true,
142
- },
143
- {
144
- id: "createdAt",
145
- name: "Created At",
146
- type: "date",
147
- defaultValue: (0, dayjs_1.default)().toDate(),
148
- hideForm: true,
149
- optional: true,
150
- disabled: true,
151
- },
152
- ];
153
- _this.logsModel = [
154
- {
155
- id: "type",
156
- type: "list",
157
- name: "Type",
158
- listSelection: ["create", "update", "delete"],
159
- },
160
- {
161
- id: "collectionId",
162
- name: "Collection ID",
163
- type: "string",
164
- defaultValue: _this.props.collectionId,
165
- hide: true,
166
- hideForm: true,
167
- disabled: true,
168
- },
169
- {
170
- id: "itemId",
171
- type: "string",
172
- name: "Item ID",
173
- defaultValue: _this.props.dataId,
174
- },
175
- { id: "values", type: "object", name: "Values" },
176
- { id: "userId", type: "string", name: "User ID" },
177
- { id: "userRole", type: "string", name: "User Role" },
178
- { id: "organisationId", type: "string", name: "Organisation ID" },
179
- {
180
- id: "createdAt",
181
- name: "Created At",
182
- type: "date",
183
- defaultValue: (0, dayjs_1.default)().toDate(),
184
- hide: true,
185
- hideForm: true,
186
- disabled: true,
187
- },
188
- ];
189
- //INFO : rows repeat the same authors — dedupe ids and cache per session so
190
- // each user is fetched once instead of once per row
191
- _this.userCache = {};
192
- _this.handleRetrieveUser = function (userIds) { return __awaiter(_this, void 0, void 0, function () {
193
- var uniqueIds, missingIds, err_1, userList;
194
- var _this = this;
195
- var _a;
196
- return __generator(this, function (_b) {
197
- switch (_b.label) {
175
+ }, []);
176
+ (0, react_1.useEffect)(function () {
177
+ var cancelled = false;
178
+ var handleLoadAuthors = function () { return __awaiter(void 0, void 0, void 0, function () {
179
+ var missing, names;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
198
182
  case 0:
199
- this.setState({ userLoading: true });
200
- uniqueIds = Array.from(new Set(userIds)).filter(function (eachId) { return eachId; });
201
- if (!(uniqueIds.length > 0 && ((_a = this.props.activityLog) === null || _a === void 0 ? void 0 : _a.userAPIEndpoint))) return [3 /*break*/, 4];
202
- _b.label = 1;
203
- case 1:
204
- _b.trys.push([1, 3, , 4]);
205
- missingIds = uniqueIds.filter(function (eachId) { return !(eachId in _this.userCache); });
206
- return [4 /*yield*/, Promise.all(missingIds.map(function (eachId) { return __awaiter(_this, void 0, void 0, function () {
207
- var userRes;
208
- var _a, _b, _c;
183
+ if (!(config === null || config === void 0 ? void 0 : config.userAPIEndpoint))
184
+ return [2 /*return*/];
185
+ missing = authorIds.filter(function (id) { return !authors[id] && !(members === null || members === void 0 ? void 0 : members.some(function (member) { return member.key === id; })); });
186
+ return [4 /*yield*/, Promise.all(missing.map(function (id) { return __awaiter(void 0, void 0, void 0, function () {
187
+ var response, data, _a;
188
+ var _b, _c;
209
189
  return __generator(this, function (_d) {
210
190
  switch (_d.label) {
211
- case 0: return [4 /*yield*/, axios_1.default.post((_b = (_a = this.props.activityLog) === null || _a === void 0 ? void 0 : _a.userAPIEndpoint) !== null && _b !== void 0 ? _b : "", { selectedUserId: eachId })];
191
+ case 0:
192
+ _d.trys.push([0, 2, , 3]);
193
+ return [4 /*yield*/, axios_1.default.post(config.userAPIEndpoint, {
194
+ selectedUserId: id,
195
+ })];
212
196
  case 1:
213
- userRes = _d.sent();
214
- if (userRes && ((_c = userRes === null || userRes === void 0 ? void 0 : userRes.data) === null || _c === void 0 ? void 0 : _c.data)) {
215
- this.userCache[eachId] = Array.isArray(userRes.data.data)
216
- ? userRes.data.data[0]
217
- : userRes.data.data;
218
- }
219
- return [2 /*return*/];
197
+ response = _d.sent();
198
+ data = Array.isArray((_b = response.data) === null || _b === void 0 ? void 0 : _b.data)
199
+ ? response.data.data[0]
200
+ : (_c = response.data) === null || _c === void 0 ? void 0 : _c.data;
201
+ return [2 /*return*/, [id, (data === null || data === void 0 ? void 0 : data.name) || id]];
202
+ case 2:
203
+ _a = _d.sent();
204
+ return [2 /*return*/, [id, id]];
205
+ case 3: return [2 /*return*/];
220
206
  }
221
207
  });
222
208
  }); }))];
223
- case 2:
224
- _b.sent();
225
- return [3 /*break*/, 4];
226
- case 3:
227
- err_1 = _b.sent();
228
- return [3 /*break*/, 4];
229
- case 4:
230
- userList = uniqueIds
231
- .map(function (eachId) { return _this.userCache[eachId]; })
232
- .filter(function (eachUser) { return eachUser; });
233
- this.setState({ userData: userList, userLoading: false });
209
+ case 1:
210
+ names = _a.sent();
211
+ if (!cancelled && names.length)
212
+ setAuthors(function (previous) { return (__assign(__assign({}, previous), Object.fromEntries(names))); });
234
213
  return [2 /*return*/];
235
214
  }
236
215
  });
237
216
  }); };
238
- _this.renderLogList = function (_, prettierData, loading) {
239
- var dataList = [];
240
- prettierData.map(function (eachData) {
241
- var _a, _b, _c, _d;
242
- var hasDifference = false;
243
- var tagBgColor = "bg-green-50";
244
- var tagTextColor = "text-green-500";
245
- if (eachData.type === "update") {
246
- tagBgColor = "bg-blue-50";
247
- tagTextColor = "text-blue-500";
248
- }
249
- else if (eachData.type === "delete") {
250
- tagBgColor = "bg-red-50";
251
- tagTextColor = "text-red-500";
252
- }
253
- var userFound = (_a = _this.state.userData) === null || _a === void 0 ? void 0 : _a.find(function (eachUser) { return eachUser._id === eachData.userId; });
254
- var userName = (_b = eachData.userId) !== null && _b !== void 0 ? _b : "User not found";
255
- if (userFound && (userFound === null || userFound === void 0 ? void 0 : userFound.name)) {
256
- userName = userFound.name;
257
- if (eachData.userRole) {
258
- userName += " (".concat(eachData.userRole, ")");
259
- }
260
- }
261
- var eachDataElement = {
262
- id: eachData._id,
263
- title: userName,
264
- date: "Date: " + eachData.createdAt,
265
- dataId: "Data ID: " + ((_c = eachData.itemId) !== null && _c !== void 0 ? _c : ""),
266
- };
267
- if (eachData.values) {
268
- eachDataElement["changes"] = (react_1.default.createElement("p", { className: "mt-6 font-semibold text-primary-500" }, "Changes:"));
269
- Object.keys(eachData.values).forEach(function (eachKey) {
270
- var _a;
271
- var selectedValue = (_a = eachData.values) === null || _a === void 0 ? void 0 : _a[eachKey];
272
- if (selectedValue) {
273
- var columnId = selectedValue.columnId === "title"
274
- ? "Data Title"
275
- : selectedValue.columnId;
276
- if (eachData.type === "create" || eachData.type === "delete") {
277
- eachDataElement[columnId] = (react_1.default.createElement("p", null,
278
- selectedValue.columnId,
279
- " :",
280
- " ",
281
- react_1.default.createElement("span", null, JSON.stringify(selectedValue.newValue))));
282
- }
283
- else if (eachData.type === "update") {
284
- if (JSON.stringify(selectedValue.newValue) !==
285
- JSON.stringify(selectedValue.oldValue)) {
286
- hasDifference = true;
287
- eachDataElement[columnId] = (react_1.default.createElement("div", { className: "flex flex-col space-y-2 bg-white border rounded-md p-4" },
288
- react_1.default.createElement("p", { className: "font-bold text-primary-500" },
289
- "Column ID: ",
290
- selectedValue.columnId),
291
- react_1.default.createElement("div", { className: "break-all space-y-2" },
292
- react_1.default.createElement("p", null,
293
- "New Value :",
294
- " ",
295
- react_1.default.createElement("span", null, JSON.stringify(selectedValue.newValue))),
296
- react_1.default.createElement("p", null,
297
- "Old Value :",
298
- " ",
299
- react_1.default.createElement("span", null, JSON.stringify(selectedValue.oldValue))))));
300
- }
301
- }
302
- }
303
- });
304
- }
305
- eachDataElement["action"] = (react_1.default.createElement("div", null,
306
- react_1.default.createElement("p", { className: "rounded-full ".concat(tagBgColor, " px-2 text-xs font-semibold leading-5 ").concat(tagTextColor) }, (_d = eachData.type) === null || _d === void 0 ? void 0 : _d.toUpperCase())));
307
- if (eachData.type === "update" && hasDifference)
308
- dataList.push(eachDataElement);
309
- else if (eachData.type === "create" || eachData.type === "delete")
310
- dataList.push(eachDataElement);
311
- return null;
312
- });
313
- return (react_1.default.createElement(list_1.List, { className: "mb-4", list: dataList, loading: loading, hidePagination: true }));
217
+ handleLoadAuthors();
218
+ return function () {
219
+ cancelled = true;
314
220
  };
315
- _this.renderTabContent = function (type) {
316
- var _a, _b, _c, _d, _e, _f;
317
- var dtViewType = "list";
318
- var dtDataId = "";
319
- var schema = [];
320
- var allEditable = false;
321
- var collectionId = "";
322
- var viewSettings = undefined;
323
- var bareListComponent = undefined;
324
- var additionalQuery = [];
325
- var bareListFilterQuery = [
326
- {
327
- type: "=",
328
- queryId: "collectionId",
329
- value: _this.props.collectionId,
330
- },
331
- ];
332
- if (_this.props.dataId) {
333
- bareListFilterQuery.push({
334
- type: "=",
335
- queryId: "itemId",
336
- value: _this.props.dataId,
337
- });
221
+ }, [authorIds, authors, members, config === null || config === void 0 ? void 0 : config.userAPIEndpoint]);
222
+ var handleAuthorName = function (id) {
223
+ var _a;
224
+ return ((_a = members === null || members === void 0 ? void 0 : members.find(function (member) { return member.key === id; })) === null || _a === void 0 ? void 0 : _a.label) ||
225
+ authors[id !== null && id !== void 0 ? id : ""] ||
226
+ id ||
227
+ "Unknown author";
228
+ };
229
+ var handleResetDraft = function () {
230
+ setDraft("");
231
+ setMentions([]);
232
+ setEditing(null);
233
+ };
234
+ var handleWrite = function (type, data) { return __awaiter(void 0, void 0, void 0, function () {
235
+ var query, result;
236
+ var _a;
237
+ return __generator(this, function (_b) {
238
+ switch (_b.label) {
239
+ case 0:
240
+ query = new writeQuery_1.WriteQuery({
241
+ dbModule: axios_1.default,
242
+ dbType: props.devSettings.server,
243
+ dbCollection: (_a = config === null || config === void 0 ? void 0 : config.commentCollectionId) !== null && _a !== void 0 ? _a : "",
244
+ dbEndpoint: props.devSettings.dbEndpoint,
245
+ dbAPIToken: props.devSettings.dbAPIToken,
246
+ dbUserToken: props.devSettings.dbUserToken,
247
+ });
248
+ return [4 /*yield*/, query.call(type, data)];
249
+ case 1:
250
+ result = _b.sent();
251
+ if (result === false)
252
+ throw new Error("Comment was not saved");
253
+ return [2 /*return*/, result];
338
254
  }
339
- var bareUpdateColumnType = undefined;
340
- var bareUpdatePrefill = [];
341
- var hideSearch = false;
342
- switch (type) {
343
- case "comments":
344
- if (_this.state.commentViewType === "update" &&
345
- _this.state.commentDataId === "new") {
346
- schema = [{ id: "comment", name: "Comment", type: "textArea" }];
255
+ });
256
+ }); };
257
+ var handleNotify = function (event) { return __awaiter(void 0, void 0, void 0, function () {
258
+ var _a;
259
+ return __generator(this, function (_b) {
260
+ switch (_b.label) {
261
+ case 0:
262
+ if (!(config === null || config === void 0 ? void 0 : config.onMention) || !event.mentionedUserIds.length)
263
+ return [2 /*return*/];
264
+ _b.label = 1;
265
+ case 1:
266
+ _b.trys.push([1, 3, , 4]);
267
+ return [4 /*yield*/, config.onMention(event)];
268
+ case 2:
269
+ _b.sent();
270
+ if (mounted.current) {
271
+ setPendingPing(null);
272
+ setNotice("Comment saved and mention notifications sent.");
347
273
  }
348
- else
349
- schema = _this.commentModel;
350
- dtViewType = _this.state.commentViewType;
351
- dtDataId = _this.state.commentDataId;
352
- allEditable = true;
353
- collectionId = (_b = (_a = _this.props.activityLog) === null || _a === void 0 ? void 0 : _a.commentCollectionId) !== null && _b !== void 0 ? _b : "";
354
- viewSettings = {
355
- feedsSettings: {
356
- customFeedsData: function (_, prettierData) {
357
- var dataList = [];
358
- prettierData.map(function (eachData) {
359
- var _a, _b;
360
- var userFound = (_a = _this.state.userData) === null || _a === void 0 ? void 0 : _a.find(function (eachUser) { return eachUser._id === eachData.userId; });
361
- dataList.push({
362
- id: eachData._id,
363
- title: react_1.default.createElement("h1", null, (_b = userFound === null || userFound === void 0 ? void 0 : userFound.name) !== null && _b !== void 0 ? _b : eachData.userId),
364
- content: react_1.default.createElement("p", null, eachData.comment),
365
- desc: react_1.default.createElement("p", null, eachData.createdAt),
366
- icon: react_1.default.createElement(solid_1.ChatBubbleLeftIcon, { className: "h-5 w-5 text-white" }),
367
- iconClass: "bg-primary-500",
368
- });
369
- return null;
370
- });
371
- return dataList;
372
- },
373
- },
374
- };
375
- bareUpdateColumnType = "one";
376
- bareUpdatePrefill = function (data) {
377
- var _a, _b, _c, _d, _e, _f, _g;
378
- return [
379
- {
380
- key: "userId",
381
- value: (_c = (_a = data === null || data === void 0 ? void 0 : data.userId) !== null && _a !== void 0 ? _a : (_b = _this.props.activityLog) === null || _b === void 0 ? void 0 : _b.currentUserId) !== null && _c !== void 0 ? _c : null,
382
- },
383
- {
384
- key: "itemId",
385
- value: (_e = (_d = data === null || data === void 0 ? void 0 : data.itemId) !== null && _d !== void 0 ? _d : _this.props.dataId) !== null && _e !== void 0 ? _e : null,
386
- },
387
- {
388
- key: "collectionId",
389
- value: (_f = data === null || data === void 0 ? void 0 : data.collectionId) !== null && _f !== void 0 ? _f : _this.props.collectionId,
390
- },
391
- {
392
- key: "createdAt",
393
- value: (_g = data === null || data === void 0 ? void 0 : data.createdAt) !== null && _g !== void 0 ? _g : (0, dayjs_1.default)().toDate(),
394
- },
395
- ];
396
- };
397
- if ((_c = _this.props.activityLog) === null || _c === void 0 ? void 0 : _c.commentQuery) {
398
- bareListFilterQuery = __spreadArray(__spreadArray([], bareListFilterQuery, true), _this.props.activityLog.commentQuery, true);
274
+ return [3 /*break*/, 4];
275
+ case 3:
276
+ _a = _b.sent();
277
+ if (mounted.current) {
278
+ setPendingPing(event);
279
+ setNotice("Comment saved, but mention notifications could not be sent. Retry notifications without posting again.");
399
280
  }
400
- break;
401
- case "logs":
402
- schema = _this.logsModel;
403
- dtViewType = _this.state.logsViewType;
404
- dtDataId = _this.state.logsDataId;
405
- collectionId = (_e = (_d = _this.props.activityLog) === null || _d === void 0 ? void 0 : _d.logsCollectionId) !== null && _e !== void 0 ? _e : "";
406
- hideSearch = true;
407
- viewSettings = { listImage: "image" };
408
- bareListComponent = function (data, prettierData, loading) {
409
- return _this.renderLogList(data, prettierData, loading);
410
- };
411
- if ((_f = _this.props.activityLog) === null || _f === void 0 ? void 0 : _f.logQuery) {
412
- bareListFilterQuery = __spreadArray(__spreadArray([], bareListFilterQuery, true), _this.props.activityLog.logQuery, true);
281
+ return [3 /*break*/, 4];
282
+ case 4: return [2 /*return*/];
283
+ }
284
+ });
285
+ }); };
286
+ var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
287
+ var commentId, savedMentions, mentionedUserIds, userId, comment, result, savedId, recipients, _a;
288
+ var _b;
289
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
290
+ return __generator(this, function (_m) {
291
+ switch (_m.label) {
292
+ case 0:
293
+ if (saving.current || !draft.trim() || !commentsEnabled || pendingPing)
294
+ return [2 /*return*/];
295
+ saving.current = true;
296
+ setBusy(true);
297
+ setError("");
298
+ setNotice("");
299
+ commentId = (_d = (_c = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _c !== void 0 ? _c : editing === null || editing === void 0 ? void 0 : editing.id) !== null && _d !== void 0 ? _d : (0, uuid_1.v4)();
300
+ savedMentions = (0, activityMentions_1.handleValidMentions)(draft, mentions);
301
+ mentionedUserIds = Array.from(new Set(savedMentions.map(function (mention) { return mention.userId; })));
302
+ userId = (_f = (_e = editing === null || editing === void 0 ? void 0 : editing.userId) !== null && _e !== void 0 ? _e : config === null || config === void 0 ? void 0 : config.currentUserId) !== null && _f !== void 0 ? _f : null;
303
+ comment = __assign({ comment: draft, mentions: savedMentions, mentionedUserIds: mentionedUserIds, userId: userId, collectionId: props.collectionId, itemId: editing ? ((_g = editing.itemId) !== null && _g !== void 0 ? _g : null) : activeRecordId || null }, (editing
304
+ ? { updatedAt: new Date() }
305
+ : (_b = {},
306
+ _b[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId,
307
+ _b.createdAt = new Date(),
308
+ _b)));
309
+ _m.label = 1;
310
+ case 1:
311
+ _m.trys.push([1, 4, 5, 6]);
312
+ return [4 /*yield*/, handleWrite(editing ? "update" : "create", {
313
+ id: commentId,
314
+ data: comment,
315
+ })];
316
+ case 2:
317
+ result = _m.sent();
318
+ savedId = !editing && typeof result === "string"
319
+ ? result
320
+ : !editing && Array.isArray(result)
321
+ ? ((_h = result[0]) !== null && _h !== void 0 ? _h : commentId)
322
+ : commentId;
323
+ // Notification delivery still runs if the panel was closed during the save.
324
+ if (mounted.current) {
325
+ handleResetDraft();
326
+ // New comments sort onto page one; edits retain the reader's page.
327
+ if (editing)
328
+ (_j = listRef.current) === null || _j === void 0 ? void 0 : _j.handleRefreshCurrentPage();
329
+ else
330
+ (_k = listRef.current) === null || _k === void 0 ? void 0 : _k.handleRefresh();
331
+ setNotice("Comment saved.");
413
332
  }
414
- additionalQuery = [
415
- {
416
- type: "list",
417
- value: "type",
418
- options: ["create", "update", "delete"],
419
- },
420
- ];
421
- break;
333
+ recipients = mentionedUserIds.filter(function (id) {
334
+ var _a;
335
+ return id !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
336
+ !((_a = editing === null || editing === void 0 ? void 0 : editing.mentionedUserIds) !== null && _a !== void 0 ? _a : []).includes(id);
337
+ });
338
+ if (mounted.current && recipients.length && !(config === null || config === void 0 ? void 0 : config.onMention))
339
+ setNotice("Comment saved. Mentions recorded; notifications are not connected.");
340
+ return [4 /*yield*/, handleNotify({
341
+ commentId: savedId,
342
+ commentCollectionId: (_l = config === null || config === void 0 ? void 0 : config.commentCollectionId) !== null && _l !== void 0 ? _l : "",
343
+ collectionId: props.collectionId,
344
+ itemId: comment.itemId,
345
+ comment: comment.comment,
346
+ userId: userId,
347
+ mentionedUserIds: recipients,
348
+ })];
349
+ case 3:
350
+ _m.sent();
351
+ return [3 /*break*/, 6];
352
+ case 4:
353
+ _a = _m.sent();
354
+ if (mounted.current)
355
+ setError("Could not save your comment. Your draft is still here; please try again.");
356
+ return [3 /*break*/, 6];
357
+ case 5:
358
+ saving.current = false;
359
+ if (mounted.current)
360
+ setBusy(false);
361
+ return [7 /*endfinally*/];
362
+ case 6: return [2 /*return*/];
422
363
  }
423
- return (react_1.default.createElement("div", { className: "w-full" },
424
- react_1.default.createElement(dataWrapper_1.DataTemplateWrapper, { ref: _this.dataTemplateRef, title: "", type: dtViewType, id: dtDataId, collectionId: collectionId, schema: schema, workspace: {
425
- apiEndpoint: _this.props.devSettings.dbEndpoint,
426
- apiEndpointToken: _this.props.devSettings.dbAPIToken,
427
- apiEndpointType: _this.props.devSettings.server,
428
- apiUserToken: _this.props.devSettings.dbUserToken,
429
- assetEndpoint: _this.props.devSettings.imageEndpoint,
430
- assetUploadEndpoint: _this.props.devSettings.uploadEndpoint,
431
- }, additionalQuery: additionalQuery, edit: {
432
- allEditable: allEditable,
433
- deleteBtn: _this.state.type === "comments",
434
- }, sort: { sortId: "createdAt", type: "desc" }, organise: { hideSearch: hideSearch, breadcrumbType: "button" }, bareSettings: {
435
- bareListFilterQuery: bareListFilterQuery,
436
- bareListHandleData: function (data) {
437
- var userIds = data.map(function (eachData) { return eachData.userId; });
438
- _this.handleRetrieveUser(userIds);
439
- },
440
- bareListComponent: bareListComponent,
441
- bareUpdateColumnType: bareUpdateColumnType,
442
- bareUpdatePrefill: bareUpdatePrefill,
443
- }, handleNavigate: function (type, selectedId) {
444
- if (_this.state.type === "comments") {
445
- _this.setState({
446
- commentDataId: selectedId,
447
- commentViewType: type,
448
- });
449
- }
450
- }, viewSettings: viewSettings })));
451
- };
452
- return _this;
453
- }
454
- ActivityModal.prototype.render = function () {
455
- var _this = this;
456
- var _a, _b, _c, _d;
457
- var tabList = [];
458
- if (((_a = this.props.activityLog) === null || _a === void 0 ? void 0 : _a.enableComments) &&
459
- ((_b = this.props.activityLog) === null || _b === void 0 ? void 0 : _b.commentCollectionId))
460
- tabList.push({ id: "comments", name: "Comments", href: "#" });
461
- if (((_c = this.props.activityLog) === null || _c === void 0 ? void 0 : _c.enableLogs) &&
462
- ((_d = this.props.activityLog) === null || _d === void 0 ? void 0 : _d.logsCollectionId))
463
- tabList.push({ id: "logs", name: "Logs", href: "#" });
464
- return (react_1.default.createElement("div", { className: "flex flex-col p-4 space-y-3 w-full" },
465
- react_1.default.createElement("p", { className: "text-base" },
466
- "You're viewing ",
467
- this.state.type,
468
- " from",
469
- " ",
470
- this.props.dataId
471
- ? " Data Id : ".concat(this.props.dataId)
472
- : "all data of ".concat(this.props.title)),
473
- react_1.default.createElement(tabs_1.Tabs, { tabs: tabList, selectedId: this.state.type, onClick: function (id) {
474
- if (id === "comments" || id === "logs") {
475
- _this.setState({
476
- type: id,
477
- commentViewType: "list",
478
- commentDataId: "",
479
- logsViewType: "list",
480
- logsDataId: "",
481
- }, function () {
364
+ });
365
+ }); };
366
+ var handleDelete = function () { return __awaiter(void 0, void 0, void 0, function () {
367
+ var _a;
368
+ var _b, _c;
369
+ return __generator(this, function (_d) {
370
+ switch (_d.label) {
371
+ case 0:
372
+ if (saving.current || !deleteId)
373
+ return [2 /*return*/];
374
+ saving.current = true;
375
+ setBusy(true);
376
+ setError("");
377
+ _d.label = 1;
378
+ case 1:
379
+ _d.trys.push([1, 3, 4, 5]);
380
+ return [4 /*yield*/, handleWrite("delete", { id: deleteId })];
381
+ case 2:
382
+ _d.sent();
383
+ if (!mounted.current)
384
+ return [2 /*return*/];
385
+ if (((_b = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _b !== void 0 ? _b : editing === null || editing === void 0 ? void 0 : editing.id) === deleteId)
386
+ handleResetDraft();
387
+ setDeleteId("");
388
+ setNotice("Comment deleted.");
389
+ // Deleting the last row on a later page would hide the feed's paginator.
390
+ (_c = listRef.current) === null || _c === void 0 ? void 0 : _c.handleRefresh();
391
+ return [3 /*break*/, 5];
392
+ case 3:
393
+ _a = _d.sent();
394
+ if (mounted.current)
395
+ setError("Could not delete the comment. Please try again.");
396
+ return [3 /*break*/, 5];
397
+ case 4:
398
+ saving.current = false;
399
+ if (mounted.current)
400
+ setBusy(false);
401
+ return [7 /*endfinally*/];
402
+ case 5: return [2 /*return*/];
403
+ }
404
+ });
405
+ }); };
406
+ var renderComment = function (record) {
407
+ var _a, _b;
408
+ var text = String((_a = record.comment) !== null && _a !== void 0 ? _a : "");
409
+ var savedMentions = (0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []);
410
+ var parts = [];
411
+ var cursor = 0;
412
+ savedMentions.forEach(function (mention) {
413
+ parts.push(text.slice(cursor, mention.start));
414
+ parts.push(react_1.default.createElement("span", { key: mention.start, className: "rounded bg-primary-50 px-0.5 font-medium text-primary-700" }, text.slice(mention.start, mention.end)));
415
+ cursor = mention.end;
416
+ });
417
+ parts.push(text.slice(cursor));
418
+ var id = (_b = record._id) !== null && _b !== void 0 ? _b : record.id;
419
+ return (react_1.default.createElement("div", { className: "space-y-2" },
420
+ react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words" }, parts),
421
+ react_1.default.createElement("div", { className: "flex gap-3 text-xs text-gray-500" },
422
+ record.updatedAt && react_1.default.createElement("span", null, "Edited"),
423
+ react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
424
+ event.stopPropagation();
425
+ setEditing(record);
426
+ setDraft(text);
427
+ setMentions(savedMentions);
428
+ setError("");
429
+ } }, "Edit"),
430
+ react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
431
+ event.stopPropagation();
432
+ setDeleteId(id);
433
+ } }, "Delete"))));
434
+ };
435
+ var renderFeedData = function (records) {
436
+ return records.map(function (record) {
437
+ var _a, _b, _c, _d;
438
+ var name = handleAuthorName(record.userId);
439
+ var date = record.createdAt ? (0, dayjs_1.default)(record.createdAt) : null;
440
+ var count = (0, activityChanges_1.handleActivityChanges)(record).length;
441
+ var action = record.type === "update"
442
+ ? "updated ".concat(count, " field").concat(count === 1 ? "" : "s")
443
+ : record.type === "create"
444
+ ? "created this record"
445
+ : record.type === "delete"
446
+ ? "deleted this record"
447
+ : ((_a = record.type) !== null && _a !== void 0 ? _a : "Activity");
448
+ return {
449
+ id: (_b = record._id) !== null && _b !== void 0 ? _b : record.id,
450
+ desc: null,
451
+ title: (react_1.default.createElement("span", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1" },
452
+ react_1.default.createElement("span", null, isComments
453
+ ? name
454
+ : "".concat(name).concat(record.userRole ? " (".concat(record.userRole, ")") : "", " ").concat(action)),
455
+ (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") }, date.format("MMM D, HH:mm"))))),
456
+ icon: isComments ? ((0, chatBase_1.renderChatAvatar)({ id: record.userId, name: name }, "h-7 w-7 sm:h-9 sm:w-9", props.darkMode)) : (react_1.default.createElement(solid_1.ClockIcon, { className: "h-4 w-4 text-primary-500" })),
457
+ iconClass: isComments
458
+ ? ""
459
+ : props.darkMode
460
+ ? "bg-gray-800"
461
+ : "bg-primary-50",
462
+ content: (react_1.default.createElement("div", { className: "space-y-2" },
463
+ record.itemId ? (props.onOpenRecord && recordTitles[record.itemId] ? (react_1.default.createElement("button", { type: "button", className: "text-left text-xs font-medium text-primary-500 break-words", onClick: function (event) {
482
464
  var _a;
483
- (_a = _this.dataTemplateRef.current) === null || _a === void 0 ? void 0 : _a.handleRefresh();
484
- });
485
- }
486
- } }),
487
- this.renderTabContent(this.state.type)));
465
+ event.stopPropagation();
466
+ (_a = props.onOpenRecord) === null || _a === void 0 ? void 0 : _a.call(props, record.itemId);
467
+ } }, recordTitles[record.itemId])) : (react_1.default.createElement("p", { className: "break-words text-xs text-gray-500" }, (_c = recordTitles[record.itemId]) !== null && _c !== void 0 ? _c : "Data ".concat(record.itemId, " (unavailable)")))) : (react_1.default.createElement("p", { className: "text-xs text-gray-500" }, "Collection discussion")),
468
+ isComments ? (renderComment(record)) : (react_1.default.createElement(activityChanges_1.ActivityChanges, { key: (_d = record._id) !== null && _d !== void 0 ? _d : record.id, record: record, darkMode: props.darkMode, showRecord: false })))),
469
+ };
470
+ });
488
471
  };
489
- return ActivityModal;
490
- }(react_1.Component));
491
- exports.ActivityModal = ActivityModal;
472
+ if (!commentsEnabled && !logsEnabled)
473
+ return null;
474
+ var filters = __spreadArray(__spreadArray(__spreadArray([
475
+ { type: "=", queryId: "collectionId", value: props.collectionId }
476
+ ], (activeRecordId
477
+ ? [{ type: "=", queryId: "itemId", value: activeRecordId }]
478
+ : []), true), ((_e = (isComments ? config === null || config === void 0 ? void 0 : config.commentQuery : config === null || config === void 0 ? void 0 : config.logQuery)) !== null && _e !== void 0 ? _e : []), true), (!isComments && logType !== "all"
479
+ ? [{ type: "=", queryId: "type", value: logType }]
480
+ : []), true);
481
+ return (react_1.default.createElement("div", { className: "min-w-0 space-y-4 p-1 sm:p-3 ".concat(props.darkMode ? "text-gray-100" : "text-gray-800") },
482
+ react_1.default.createElement("div", { className: "flex flex-wrap items-center justify-between gap-3" },
483
+ react_1.default.createElement(buttonGroup_1.ButtonGroup, { darkMode: props.darkMode, size: "small", selectedId: activeTab, selection: __spreadArray(__spreadArray([], (commentsEnabled ? [{ id: "comments", name: "Comments" }] : []), true), (logsEnabled ? [{ id: "logs", name: "Logs" }] : []), true), onClick: function (nextTab) {
484
+ if (nextTab === activeTab)
485
+ return;
486
+ setRowCount(null);
487
+ setTab(nextTab);
488
+ } }),
489
+ react_1.default.createElement("span", { className: "text-xs text-gray-500" }, activeRecordId
490
+ ? "Activity for ".concat((_f = recordTitles[activeRecordId]) !== null && _f !== void 0 ? _f : activeRecordId)
491
+ : "All activity in ".concat(props.title))),
492
+ !props.dataId && (react_1.default.createElement("div", null,
493
+ react_1.default.createElement(select_1.Select, { id: "activity-record-filter", label: "Filter by data", value: recordFilter, darkMode: props.darkMode, disabled: busy || !!pendingPing, options: __spreadArray(__spreadArray([
494
+ { key: "", label: "All data" }
495
+ ], recordSearch.options, true), (recordFilter &&
496
+ !recordSearch.options.some(function (option) { return option.key === recordFilter; })
497
+ ? [
498
+ {
499
+ key: recordFilter,
500
+ label: (_g = recordTitles[recordFilter]) !== null && _g !== void 0 ? _g : recordFilter,
501
+ },
502
+ ]
503
+ : []), true), onSearch: recordSearch.setSearch, onChange: function (id) {
504
+ if (id === recordFilter)
505
+ return;
506
+ if (draft.trim() &&
507
+ !window.confirm("Discard this comment draft and change the data filter?"))
508
+ return;
509
+ handleResetDraft();
510
+ setDeleteId("");
511
+ setNotice("");
512
+ setError("");
513
+ setRowCount(null);
514
+ setRecordFilter(id);
515
+ } }),
516
+ recordSearch.searchError && (react_1.default.createElement("p", { role: "status", className: "text-xs text-gray-500" }, "Data search is unavailable. Activity is still shown below.")))),
517
+ !isComments && (react_1.default.createElement(buttonGroup_1.ButtonGroup, { darkMode: props.darkMode, size: "small", selectedId: logType, selection: [
518
+ { id: "all", name: "All" },
519
+ { id: "create", name: "Created" },
520
+ { id: "update", name: "Updated" },
521
+ { id: "delete", name: "Deleted" },
522
+ ], onClick: function (nextType) {
523
+ if (nextType === logType)
524
+ return;
525
+ setRowCount(null);
526
+ setLogType(nextType);
527
+ } })),
528
+ error && (react_1.default.createElement("p", { role: "alert", className: "text-sm text-red-500" }, error)),
529
+ notice && (react_1.default.createElement("div", { role: "status", className: "space-y-2 text-sm" },
530
+ react_1.default.createElement("p", null, notice),
531
+ pendingPing && (react_1.default.createElement("div", { className: "flex gap-3" },
532
+ react_1.default.createElement("button", { type: "button", disabled: busy, className: "font-medium text-primary-500", onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
533
+ return __generator(this, function (_a) {
534
+ switch (_a.label) {
535
+ case 0:
536
+ if (saving.current)
537
+ return [2 /*return*/];
538
+ saving.current = true;
539
+ setBusy(true);
540
+ return [4 /*yield*/, handleNotify(pendingPing)];
541
+ case 1:
542
+ _a.sent();
543
+ saving.current = false;
544
+ if (mounted.current)
545
+ setBusy(false);
546
+ return [2 /*return*/];
547
+ }
548
+ });
549
+ }); } }, "Retry notifications"),
550
+ react_1.default.createElement("button", { type: "button", disabled: busy, onClick: function () {
551
+ setPendingPing(null);
552
+ setNotice("Comment saved. Notification retry dismissed.");
553
+ } }, "Dismiss"))))),
554
+ isComments && (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, onChange: function (value, selectedMentions) {
555
+ setDraft(value);
556
+ setMentions(selectedMentions);
557
+ }, onSubmit: handleSubmit, onCancel: handleResetDraft })),
558
+ 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" },
559
+ react_1.default.createElement("span", null, "Delete this comment?"),
560
+ react_1.default.createElement("button", { type: "button", disabled: busy, className: "font-medium text-red-500", onClick: handleDelete }, "Confirm delete"),
561
+ react_1.default.createElement("button", { type: "button", disabled: busy, onClick: function () { return setDeleteId(""); } }, "Cancel"))),
562
+ 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: {
563
+ apiEndpoint: props.devSettings.dbEndpoint,
564
+ apiEndpointType: props.devSettings.server,
565
+ apiEndpointToken: props.devSettings.dbAPIToken,
566
+ apiUserToken: props.devSettings.dbUserToken,
567
+ assetEndpoint: props.devSettings.imageEndpoint,
568
+ }, devSettings: props.devSettings, edit: { allEditable: false, createBtn: false, deleteBtn: false }, sort: { sortId: "createdAt", type: "desc" }, organise: { hideSearch: true, darkMode: props.darkMode }, bareSettings: {
569
+ bareNewDTW: true,
570
+ bareListFilterQuery: filters,
571
+ bareListHandleData: function (records) {
572
+ setRowCount(records.length);
573
+ var itemIds = Array.from(new Set(records.map(function (record) { return record.itemId; }).filter(Boolean)));
574
+ setRecordIds(function (previous) {
575
+ return JSON.stringify(previous) === JSON.stringify(itemIds)
576
+ ? previous
577
+ : itemIds;
578
+ });
579
+ var ids = Array.from(new Set(records.map(function (record) { return record.userId; }).filter(Boolean)));
580
+ setAuthorIds(function (previous) {
581
+ return JSON.stringify(previous) === JSON.stringify(ids) ? previous : ids;
582
+ });
583
+ },
584
+ }, viewSettings: { feedsSettings: { customFeedsData: renderFeedData } }, renderSettings: {
585
+ renderListUI: function (_actions, _filters, data) { return (react_1.default.createElement(react_1.default.Fragment, null,
586
+ data,
587
+ rowCount === 0 && (react_1.default.createElement("p", { className: "py-8 text-center text-sm text-gray-500" }, isComments
588
+ ? "No comments yet. Start the conversation above."
589
+ : "No logs match this view.")))); },
590
+ } })));
591
+ };
492
592
  //# sourceMappingURL=activityModal.js.map