@burdenoff/fluidgrids-fe-sdk 2026.1112.6 → 2026.1112.7

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 (32) hide show
  1. package/dist/{AiStudioPage-BSLdKT0H.js → AiStudioPage-QGTFaVpx.js} +1 -1
  2. package/dist/ConfirmActionDialog-D9Pir3bc.js +30 -0
  3. package/dist/DataTablesPage-0U89KNBt.js +2880 -0
  4. package/dist/{ExecutionDetailPage-B9eEep77.js → ExecutionDetailPage-D4Mdbzb2.js} +2 -1
  5. package/dist/{ExecutionsListPage-DuuPSVEj.js → ExecutionsListPage-g_SPxAGX.js} +2 -1
  6. package/dist/RunActionsMenu-DmO14hEE.js +106 -0
  7. package/dist/RunnersPage-CvAPHdfU.js +673 -0
  8. package/dist/{TemplatePreview-BFMsDQif.js → TemplatePreview-DY4GxnfC.js} +1 -1
  9. package/dist/{WorkflowBuilder-D9W8hQTO.js → WorkflowBuilder-Aslfa2vj.js} +1 -1
  10. package/dist/{WorkflowBuilder-B8PtcT0Q.js → WorkflowBuilder-DY1_KJiV.js} +1 -1
  11. package/dist/{agentTools-DlPHMfhA.js → agentTools-B8gnHFVM.js} +1 -1
  12. package/dist/{canvasNoteTools-CkAsMSvt.js → canvasNoteTools-Cj7MvVDH.js} +1 -1
  13. package/dist/executions.js +2 -2
  14. package/dist/{flow-builder-DUkCKl-S.js → flow-builder-dvqpKs8d.js} +5 -5
  15. package/dist/{index-u-kM0seP.d.ts → index-DNo9aFUT.d.ts} +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +13 -13
  18. package/dist/{node-detail-view-ApMQwQRQ.js → node-detail-view-ZnJ3Hvvo.js} +2 -2
  19. package/dist/{node-editor-tab-body-DIcmar84.js → node-editor-tab-body-BuiIr7VD.js} +1 -1
  20. package/dist/observability.d.ts +1 -1
  21. package/dist/{popover-DOeSGQOG.js → popover-mexhIFP3.js} +3 -0
  22. package/dist/{quick-config-panel-Pm5nkZVr.js → quick-config-panel-EV66lJOM.js} +2 -2
  23. package/dist/{schedule-panel-Dizqz9eA.js → schedule-panel-BeLfDNFh.js} +1 -1
  24. package/dist/{sidebar-node-editor-BNub2vUq.js → sidebar-node-editor-D85Moj5d.js} +2 -2
  25. package/dist/templates.js +1 -1
  26. package/dist/{useDurableParity-Cb9nOdE8.js → useDurableParity-04-5PTk2.js} +3 -101
  27. package/dist/workflow-builder.js +2 -2
  28. package/dist/workflow-pages.d.ts +1 -1
  29. package/dist/workflow-pages.js +7 -7
  30. package/package.json +1 -1
  31. package/dist/DataTablesPage-Dm-dzVPD.js +0 -1698
  32. package/dist/RunnersPage-D9Bgod_d.js +0 -467
@@ -1,1698 +0,0 @@
1
- "use client";
2
- import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
3
- import { t as EntityTagPicker } from "./EntityTagPicker-dxfzv8aO.js";
4
- import { t as TagFilterSelect } from "./TagFilterSelect-CqhxcDjh.js";
5
- import { _ as throwIfResultError, m as describeOperationError, n as getFluidGridsClient } from "./client-C9XSzSXr.js";
6
- import { a as useDataTableTagOverlay, n as tagLabel } from "./useEntityTags-D5C0tdLs.js";
7
- import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
8
- import { i as useOpenRequest, n as ACTION_PARAM_VALUES, r as useActionParam } from "./useActionParam-B0ebTZmg.js";
9
- import { i as SdkPermissionButton, s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-dcxg6zG6.js";
10
- import { t as FluidGridsDocsLink } from "./FluidGridsDocsLink-JxkBpOeb.js";
11
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
12
- import { useNavigate } from "react-router";
13
- import { jsx, jsxs } from "react/jsx-runtime";
14
- import { toast } from "sonner";
15
- import { gql } from "@apollo/client";
16
- import { Badge, Card, CardContent, CardDescription, CardHeader, CardTitle, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, IllustratedEmptyState, Input, Label, NextSteps, PagePurpose, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Textarea } from "@burdenoff/fe-libs/ui";
17
- import { Button as Button$1 } from "@burdenoff/fe-libs/button";
18
- import { ArrowDownToLine, ArrowLeft, ArrowUpFromLine, ChevronLeft, ChevronRight, Database, Pencil, Plus, RefreshCw, Search, Table2, Trash2 } from "lucide-react";
19
- import { TagBadge } from "@burdenoff/fe-libs/tag";
20
-
21
- // src/modules/data-tables/hooks/useDataTables.ts
22
- const DATA_TABLE_FIELDS = gql`
23
- fragment DataTableFields on DataTable {
24
- id
25
- workspaceId
26
- name
27
- description
28
- columns {
29
- key
30
- label
31
- type
32
- required
33
- defaultValue
34
- }
35
- rowCount
36
- sizeBytes
37
- createdAt
38
- updatedAt
39
- createdBy
40
- updatedBy
41
- }
42
- `;
43
- const DATA_TABLE_ROW_FIELDS = gql`
44
- fragment DataTableRowFields on DataTableRow {
45
- id
46
- tableId
47
- data
48
- createdAt
49
- updatedAt
50
- }
51
- `;
52
- const GET_DATA_TABLES = gql`
53
- ${DATA_TABLE_FIELDS}
54
- query GetDataTables($search: String, $limit: Int, $offset: Int) {
55
- dataTables(search: $search, limit: $limit, offset: $offset) {
56
- tables {
57
- ...DataTableFields
58
- }
59
- total
60
- }
61
- }
62
- `;
63
- const GET_DATA_TABLES_BY_TAG = gql`
64
- ${DATA_TABLE_FIELDS}
65
- query GetDataTablesByTag(
66
- $search: String
67
- $limit: Int
68
- $offset: Int
69
- $tagIds: [ID!]
70
- ) {
71
- dataTables(
72
- search: $search
73
- limit: $limit
74
- offset: $offset
75
- tagIds: $tagIds
76
- ) {
77
- tables {
78
- ...DataTableFields
79
- }
80
- total
81
- }
82
- }
83
- `;
84
- const GET_DATA_TABLE_ROWS = gql`
85
- ${DATA_TABLE_ROW_FIELDS}
86
- query GetDataTableRows($input: DataTableRowsQueryInput!) {
87
- dataTableRows(input: $input) {
88
- rows {
89
- ...DataTableRowFields
90
- }
91
- total
92
- }
93
- }
94
- `;
95
- const CREATE_DATA_TABLE = gql`
96
- ${DATA_TABLE_FIELDS}
97
- mutation CreateDataTable($input: CreateDataTableInput!) {
98
- createDataTable(input: $input) {
99
- success
100
- message
101
- table {
102
- ...DataTableFields
103
- }
104
- }
105
- }
106
- `;
107
- const UPDATE_DATA_TABLE = gql`
108
- ${DATA_TABLE_FIELDS}
109
- mutation UpdateDataTable($id: ID!, $input: UpdateDataTableInput!) {
110
- updateDataTable(id: $id, input: $input) {
111
- success
112
- message
113
- table {
114
- ...DataTableFields
115
- }
116
- }
117
- }
118
- `;
119
- const DELETE_DATA_TABLE = gql`
120
- mutation DeleteDataTable($id: ID!) {
121
- deleteDataTable(id: $id) {
122
- success
123
- message
124
- }
125
- }
126
- `;
127
- const INSERT_DATA_TABLE_ROW = gql`
128
- ${DATA_TABLE_ROW_FIELDS}
129
- mutation InsertDataTableRow($tableId: ID!, $data: JSON!) {
130
- insertDataTableRow(tableId: $tableId, data: $data) {
131
- success
132
- message
133
- row {
134
- ...DataTableRowFields
135
- }
136
- }
137
- }
138
- `;
139
- const UPDATE_DATA_TABLE_ROW = gql`
140
- ${DATA_TABLE_ROW_FIELDS}
141
- mutation UpdateDataTableRow($id: ID!, $data: JSON!) {
142
- updateDataTableRow(id: $id, data: $data) {
143
- success
144
- message
145
- row {
146
- ...DataTableRowFields
147
- }
148
- }
149
- }
150
- `;
151
- const DELETE_DATA_TABLE_ROWS = gql`
152
- mutation DeleteDataTableRows($tableId: ID!, $ids: [ID!]!) {
153
- deleteDataTableRows(tableId: $tableId, ids: $ids) {
154
- success
155
- message
156
- affected
157
- }
158
- }
159
- `;
160
- function toRow(row) {
161
- return {
162
- id: row.id,
163
- tableId: row.tableId,
164
- data: toRecord(row.data),
165
- createdAt: row.createdAt,
166
- updatedAt: row.updatedAt
167
- };
168
- }
169
- function toRecord(value) {
170
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
171
- }
172
- function operationError(error, fallback) {
173
- return new Error(describeOperationError(error, fallback));
174
- }
175
- /** The workspace's data tables, optionally narrowed by name and by one tag (G47). */
176
- function useDataTables(search, tagId) {
177
- const [tables, setTables] = useState([]);
178
- const [total, setTotal] = useState(0);
179
- const [loading, setLoading] = useState(true);
180
- const [error, setError] = useState(null);
181
- const fetchTables = useCallback(async () => {
182
- setLoading(true);
183
- setError(null);
184
- try {
185
- const result = throwIfResultError(await getFluidGridsClient().query({
186
- query: tagId ? GET_DATA_TABLES_BY_TAG : GET_DATA_TABLES,
187
- variables: {
188
- search: search?.trim() || void 0,
189
- limit: 200,
190
- offset: 0,
191
- ...tagId ? { tagIds: [tagId] } : {}
192
- },
193
- fetchPolicy: "network-only"
194
- }));
195
- setTables(result.data?.dataTables.tables ?? []);
196
- setTotal(result.data?.dataTables.total ?? 0);
197
- } catch (err) {
198
- setError(operationError(err, "Failed to load data tables"));
199
- } finally {
200
- setLoading(false);
201
- }
202
- }, [search, tagId]);
203
- useEffect(() => {
204
- fetchTables();
205
- }, [fetchTables]);
206
- return {
207
- tables,
208
- total,
209
- loading,
210
- error,
211
- refetch: fetchTables
212
- };
213
- }
214
- /** Largest page the service serves for a single `dataTableRows` request. */
215
- const DATA_TABLE_MAX_PAGE_SIZE = 5e3;
216
- async function queryRowsPage(tableId, limit, offset) {
217
- const response = throwIfResultError(await getFluidGridsClient().query({
218
- query: GET_DATA_TABLE_ROWS,
219
- variables: { input: {
220
- tableId,
221
- limit,
222
- offset
223
- } },
224
- fetchPolicy: "network-only"
225
- })).data?.dataTableRows;
226
- return {
227
- rows: response?.rows.map(toRow) ?? [],
228
- total: response?.total ?? 0
229
- };
230
- }
231
- /**
232
- * Fetch every row of a table in service-sized batches (used by CSV export so
233
- * it covers the whole table rather than the page currently on screen). A table
234
- * is capped at 50k rows server-side, so this is at most ten requests.
235
- */
236
- async function fetchAllDataTableRows(tableId) {
237
- const collected = [];
238
- let total = Number.POSITIVE_INFINITY;
239
- while (collected.length < total) {
240
- const page = await queryRowsPage(tableId, DATA_TABLE_MAX_PAGE_SIZE, collected.length);
241
- total = page.total;
242
- if (page.rows.length === 0) break;
243
- collected.push(...page.rows);
244
- }
245
- return collected;
246
- }
247
- function useDataTableRows(tableId, paging) {
248
- const { page, pageSize } = paging;
249
- const [rows, setRows] = useState([]);
250
- const [total, setTotal] = useState(0);
251
- const [loading, setLoading] = useState(false);
252
- const [error, setError] = useState(null);
253
- const fetchRows = useCallback(async () => {
254
- if (!tableId) {
255
- setRows([]);
256
- setTotal(0);
257
- setLoading(false);
258
- setError(null);
259
- return;
260
- }
261
- setLoading(true);
262
- setError(null);
263
- try {
264
- const response = await queryRowsPage(tableId, pageSize, page * pageSize);
265
- setRows(response.rows);
266
- setTotal(response.total);
267
- } catch (err) {
268
- setError(operationError(err, "Failed to load data table rows"));
269
- } finally {
270
- setLoading(false);
271
- }
272
- }, [
273
- tableId,
274
- page,
275
- pageSize
276
- ]);
277
- useEffect(() => {
278
- fetchRows();
279
- }, [fetchRows]);
280
- return {
281
- rows,
282
- total,
283
- loading,
284
- error,
285
- refetch: fetchRows
286
- };
287
- }
288
- function useCreateDataTable() {
289
- const [loading, setLoading] = useState(false);
290
- return {
291
- createDataTable: useCallback(async (input) => {
292
- setLoading(true);
293
- try {
294
- const response = throwIfResultError(await getFluidGridsClient().mutate({
295
- mutation: CREATE_DATA_TABLE,
296
- variables: { input }
297
- })).data?.createDataTable;
298
- if (!response?.success) throw new Error(response?.message || "Failed to create data table");
299
- return response.table ?? null;
300
- } finally {
301
- setLoading(false);
302
- }
303
- }, []),
304
- loading
305
- };
306
- }
307
- function useUpdateDataTable() {
308
- const [loading, setLoading] = useState(false);
309
- return {
310
- updateDataTable: useCallback(async (id, input) => {
311
- setLoading(true);
312
- try {
313
- const response = throwIfResultError(await getFluidGridsClient().mutate({
314
- mutation: UPDATE_DATA_TABLE,
315
- variables: {
316
- id,
317
- input
318
- }
319
- })).data?.updateDataTable;
320
- if (!response?.success) throw new Error(response?.message || "Failed to update data table");
321
- return response.table ?? null;
322
- } finally {
323
- setLoading(false);
324
- }
325
- }, []),
326
- loading
327
- };
328
- }
329
- function useDeleteDataTable() {
330
- const [loading, setLoading] = useState(false);
331
- return {
332
- deleteDataTable: useCallback(async (id) => {
333
- setLoading(true);
334
- try {
335
- const response = throwIfResultError(await getFluidGridsClient().mutate({
336
- mutation: DELETE_DATA_TABLE,
337
- variables: { id }
338
- })).data?.deleteDataTable;
339
- if (!response?.success) throw new Error(response?.message || "Failed to delete data table");
340
- return true;
341
- } finally {
342
- setLoading(false);
343
- }
344
- }, []),
345
- loading
346
- };
347
- }
348
- function useInsertDataTableRow() {
349
- const [loading, setLoading] = useState(false);
350
- return {
351
- insertDataTableRow: useCallback(async (tableId, data) => {
352
- setLoading(true);
353
- try {
354
- const response = throwIfResultError(await getFluidGridsClient().mutate({
355
- mutation: INSERT_DATA_TABLE_ROW,
356
- variables: {
357
- tableId,
358
- data
359
- }
360
- })).data?.insertDataTableRow;
361
- if (!response?.success) throw new Error(response?.message || "Failed to insert row");
362
- return response.row ? toRow(response.row) : null;
363
- } finally {
364
- setLoading(false);
365
- }
366
- }, []),
367
- loading
368
- };
369
- }
370
- function useUpdateDataTableRow() {
371
- const [loading, setLoading] = useState(false);
372
- return {
373
- updateDataTableRow: useCallback(async (id, data) => {
374
- setLoading(true);
375
- try {
376
- const response = throwIfResultError(await getFluidGridsClient().mutate({
377
- mutation: UPDATE_DATA_TABLE_ROW,
378
- variables: {
379
- id,
380
- data
381
- }
382
- })).data?.updateDataTableRow;
383
- if (!response?.success) throw new Error(response?.message || "Failed to update row");
384
- return response.row ? toRow(response.row) : null;
385
- } finally {
386
- setLoading(false);
387
- }
388
- }, []),
389
- loading
390
- };
391
- }
392
- function useDeleteDataTableRows() {
393
- const [loading, setLoading] = useState(false);
394
- return {
395
- deleteDataTableRows: useCallback(async (tableId, ids) => {
396
- setLoading(true);
397
- try {
398
- const response = throwIfResultError(await getFluidGridsClient().mutate({
399
- mutation: DELETE_DATA_TABLE_ROWS,
400
- variables: {
401
- tableId,
402
- ids
403
- }
404
- })).data?.deleteDataTableRows;
405
- if (!response?.success) throw new Error(response?.message || "Failed to delete rows");
406
- return response.affected;
407
- } finally {
408
- setLoading(false);
409
- }
410
- }, []),
411
- loading
412
- };
413
- }
414
-
415
- // src/modules/data-tables/utils/csv.ts
416
- /** Parse RFC 4180-style CSV while preserving quoted commas and line breaks. */
417
- function parseCsv(text) {
418
- const rows = [];
419
- let row = [];
420
- let cell = "";
421
- let quoted = false;
422
- for (let index = 0; index < text.length; index += 1) {
423
- const character = text[index];
424
- const next = text[index + 1];
425
- if (quoted) {
426
- if (character === "\"" && next === "\"") {
427
- cell += "\"";
428
- index += 1;
429
- } else if (character === "\"") quoted = false;
430
- else cell += character;
431
- continue;
432
- }
433
- if (character === "\"" && cell.length === 0) quoted = true;
434
- else if (character === ",") {
435
- row.push(cell);
436
- cell = "";
437
- } else if (character === "\n" || character === "\r") {
438
- if (character === "\r" && next === "\n") index += 1;
439
- row.push(cell);
440
- cell = "";
441
- if (row.some((value) => value.length > 0)) rows.push(row);
442
- row = [];
443
- } else cell += character;
444
- }
445
- if (quoted) throw new Error("CSV contains an unterminated quoted value");
446
- if (cell.length > 0 || row.length > 0) {
447
- row.push(cell);
448
- if (row.some((value) => value.length > 0)) rows.push(row);
449
- }
450
- return rows;
451
- }
452
- function parseValue(value, type) {
453
- if (value === "") return type === "STRING" ? "" : null;
454
- switch (type) {
455
- case "NUMBER": {
456
- const parsed = Number(value);
457
- if (!Number.isFinite(parsed)) throw new Error(`Expected a number, got "${value}"`);
458
- return parsed;
459
- }
460
- case "BOOLEAN": {
461
- const normalized = value.trim().toLowerCase();
462
- if (normalized === "true") return true;
463
- if (normalized === "false") return false;
464
- throw new Error(`Expected true or false, got "${value}"`);
465
- }
466
- case "JSON": try {
467
- return JSON.parse(value);
468
- } catch {
469
- throw new Error(`Expected valid JSON, got "${value}"`);
470
- }
471
- case "DATE":
472
- case "STRING": return value;
473
- }
474
- }
475
- /** Convert a CSV whose first row contains column keys into validated row data. */
476
- function csvToRows(text, columns) {
477
- const parsed = parseCsv(text);
478
- if (parsed.length < 2) return [];
479
- const headers = parsed[0].map((header) => header.trim());
480
- const columnByKey = new Map(columns.map((column) => [column.key, column]));
481
- const seen = /* @__PURE__ */ new Set();
482
- for (const header of headers) {
483
- if (!header || seen.has(header)) throw new Error("CSV must have unique, non-empty column headers");
484
- if (!columnByKey.has(header)) throw new Error(`CSV contains an unknown column "${header}"`);
485
- seen.add(header);
486
- }
487
- return parsed.slice(1).map((values, rowIndex) => {
488
- const row = {};
489
- headers.forEach((header, columnIndex) => {
490
- const column = columnByKey.get(header);
491
- if (!column) return;
492
- const rawValue = values[columnIndex] ?? "";
493
- try {
494
- row[header] = parseValue(rawValue, column.type);
495
- } catch (error) {
496
- const message = error instanceof Error ? error.message : "Invalid value";
497
- throw new Error(`Row ${rowIndex + 2}, ${column.label}: ${message}`);
498
- }
499
- });
500
- return row;
501
- });
502
- }
503
- function csvCell(value) {
504
- if (value === null || value === void 0) return "";
505
- const text = typeof value === "object" ? JSON.stringify(value) : String(value);
506
- return /[",\r\n]/.test(text) ? `"${text.replaceAll("\"", "\"\"")}"` : text;
507
- }
508
- /** Serialize table rows with a stable header matching the table schema. */
509
- function rowsToCsv(columns, rows) {
510
- return [columns.map((column) => csvCell(column.key)).join(","), ...rows.map((row) => columns.map((column) => csvCell(row.data[column.key])).join(","))].join("\r\n");
511
- }
512
-
513
- // src/modules/data-tables/utils/paging.ts
514
- /** Page sizes offered in the rows pager; the first entry is the default. */
515
- const ROW_PAGE_SIZES = [
516
- 50,
517
- 100,
518
- 250
519
- ];
520
- const DEFAULT_ROW_PAGE_SIZE = ROW_PAGE_SIZES[0];
521
- /** Number of pages needed for `total` rows; an empty table still has one page. */
522
- function pageCount(total, pageSize) {
523
- if (pageSize <= 0) return 1;
524
- return Math.max(1, Math.ceil(total / pageSize));
525
- }
526
- /**
527
- * Keep a zero-based page index inside the table. Needed after deleting rows,
528
- * when the page being viewed may no longer exist.
529
- */
530
- function clampPage(page, total, pageSize) {
531
- return Math.min(Math.max(page, 0), pageCount(total, pageSize) - 1);
532
- }
533
- /** One-based, inclusive `from`–`to` range of the rows shown on a page. */
534
- function pageRange(page, pageSize, shown) {
535
- if (shown <= 0) return {
536
- from: 0,
537
- to: 0
538
- };
539
- const from = page * pageSize + 1;
540
- return {
541
- from,
542
- to: from + shown - 1
543
- };
544
- }
545
-
546
- // src/modules/data-tables/pages/DataTablesPage.tsx
547
- var DataTablesPage_exports = /* @__PURE__ */ __exportAll({ DataTablesPage: () => DataTablesPage });
548
- const COLUMN_TYPES = [
549
- "STRING",
550
- "NUMBER",
551
- "BOOLEAN",
552
- "DATE",
553
- "JSON"
554
- ];
555
- function emptyColumn(index) {
556
- return {
557
- key: `column_${index}`,
558
- label: `Column ${index}`,
559
- type: "STRING",
560
- required: false
561
- };
562
- }
563
- function formatBytes(bytes) {
564
- if (bytes < 1024) return `${bytes} B`;
565
- if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
566
- return `${(bytes / 1048576).toFixed(1)} MB`;
567
- }
568
- function formatValue(value) {
569
- if (value === null || value === void 0) return "—";
570
- if (typeof value === "object") return JSON.stringify(value);
571
- return String(value);
572
- }
573
- function columnTypeLabel(type) {
574
- return type === "JSON" ? "JSON" : type[0] + type.slice(1).toLowerCase();
575
- }
576
- function asFormValue(value, type) {
577
- if (value === null || value === void 0) return "";
578
- if (type === "JSON") return JSON.stringify(value, null, 2);
579
- return String(value);
580
- }
581
- function parseFormValue(value, type) {
582
- if (type === "STRING" || type === "DATE") return value;
583
- if (value.trim() === "") return null;
584
- if (type === "NUMBER") {
585
- const number = Number(value);
586
- if (!Number.isFinite(number)) throw new Error(`"${value}" is not a number`);
587
- return number;
588
- }
589
- if (type === "BOOLEAN") {
590
- if (value === "true") return true;
591
- if (value === "false") return false;
592
- throw new Error("Boolean values must be true or false");
593
- }
594
- try {
595
- return JSON.parse(value);
596
- } catch {
597
- throw new Error("JSON values must contain valid JSON");
598
- }
599
- }
600
- function TableFormDialog({ open, table, onOpenChange, onSaved }) {
601
- const tr = useTr();
602
- const { createDataTable, loading: creating } = useCreateDataTable();
603
- const { updateDataTable, loading: updating } = useUpdateDataTable();
604
- const [name, setName] = useState("");
605
- const [description, setDescription] = useState("");
606
- const [columns, setColumns] = useState([]);
607
- const editing = table !== null;
608
- const saving = creating || updating;
609
- useEffect(() => {
610
- if (!open) return;
611
- setName(table?.name ?? "");
612
- setDescription(table?.description ?? "");
613
- setColumns(table?.columns.map((column) => ({
614
- key: column.key,
615
- label: column.label,
616
- type: column.type,
617
- required: column.required,
618
- ...column.defaultValue !== void 0 ? { defaultValue: column.defaultValue } : {}
619
- })) ?? [emptyColumn(1)]);
620
- }, [open, table]);
621
- const updateColumn = useCallback((index, patch) => {
622
- setColumns((current) => current.map((column, columnIndex) => columnIndex === index ? {
623
- ...column,
624
- ...patch
625
- } : column));
626
- }, []);
627
- const handleSubmit = useCallback(async () => {
628
- const trimmedName = name.trim();
629
- if (!trimmedName) {
630
- toast.error(tr("fluidgrids.dataTables.nameRequired", "Table name is required"));
631
- return;
632
- }
633
- if (columns.length === 0 || columns.some((column) => !column.key.trim() || !column.label.trim())) {
634
- toast.error(tr("fluidgrids.dataTables.columnsRequired", "Add at least one column with a key and label"));
635
- return;
636
- }
637
- const normalizedColumns = columns.map((column) => ({
638
- ...column,
639
- key: column.key.trim(),
640
- label: column.label.trim()
641
- }));
642
- if (new Set(normalizedColumns.map((column) => column.key)).size !== normalizedColumns.length) {
643
- toast.error(tr("fluidgrids.dataTables.uniqueKeys", "Column keys must be unique"));
644
- return;
645
- }
646
- try {
647
- const saved = editing ? await updateDataTable(table.id, {
648
- name: trimmedName,
649
- description: description.trim() || void 0,
650
- columns: normalizedColumns
651
- }) : await createDataTable({
652
- name: trimmedName,
653
- description: description.trim() || void 0,
654
- columns: normalizedColumns
655
- });
656
- toast.success(editing ? tr("fluidgrids.dataTables.updated", "Data table updated") : tr("fluidgrids.dataTables.created", "Data table created"));
657
- onSaved(saved);
658
- onOpenChange(false);
659
- } catch (error) {
660
- toast.error(describeOperationError(error, tr("fluidgrids.dataTables.saveFailed", "Failed to save data table")));
661
- }
662
- }, [
663
- columns,
664
- createDataTable,
665
- description,
666
- editing,
667
- name,
668
- onOpenChange,
669
- onSaved,
670
- table,
671
- tr,
672
- updateDataTable
673
- ]);
674
- return /* @__PURE__ */ jsx(Dialog, {
675
- open,
676
- onOpenChange,
677
- children: /* @__PURE__ */ jsxs(DialogContent, {
678
- className: "max-h-[90vh] max-w-3xl overflow-y-auto",
679
- children: [
680
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: editing ? tr("fluidgrids.dataTables.editTable", "Edit data table") : tr("fluidgrids.dataTables.newTable", "New data table") }) }),
681
- /* @__PURE__ */ jsxs("div", {
682
- className: "space-y-5 py-2",
683
- children: [/* @__PURE__ */ jsxs("div", {
684
- className: "grid gap-4 sm:grid-cols-2",
685
- children: [/* @__PURE__ */ jsxs("div", {
686
- className: "space-y-1.5",
687
- children: [/* @__PURE__ */ jsx(Label, {
688
- htmlFor: "data-table-name",
689
- children: tr("fluidgrids.dataTables.name", "Name")
690
- }), /* @__PURE__ */ jsx(Input, {
691
- id: "data-table-name",
692
- value: name,
693
- onChange: (event) => setName(event.target.value),
694
- placeholder: "contacts",
695
- autoFocus: true
696
- })]
697
- }), /* @__PURE__ */ jsxs("div", {
698
- className: "space-y-1.5",
699
- children: [/* @__PURE__ */ jsx(Label, {
700
- htmlFor: "data-table-description",
701
- children: tr("fluidgrids.dataTables.description", "Description")
702
- }), /* @__PURE__ */ jsx(Input, {
703
- id: "data-table-description",
704
- value: description,
705
- onChange: (event) => setDescription(event.target.value),
706
- placeholder: tr("fluidgrids.dataTables.descriptionPlaceholder", "Optional")
707
- })]
708
- })]
709
- }), /* @__PURE__ */ jsxs("div", {
710
- className: "space-y-3",
711
- children: [/* @__PURE__ */ jsxs("div", {
712
- className: "flex items-center justify-between gap-3",
713
- children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
714
- className: "text-sm font-semibold text-text-primary",
715
- children: tr("fluidgrids.dataTables.columns", "Columns")
716
- }), /* @__PURE__ */ jsx("p", {
717
- className: "text-xs text-text-secondary",
718
- children: tr("fluidgrids.dataTables.columnsHint", "Column keys are used by workflow nodes and must be unique.")
719
- })] }), /* @__PURE__ */ jsxs(Button$1, {
720
- type: "button",
721
- variant: "outline",
722
- size: "sm",
723
- onClick: () => setColumns((current) => [...current, emptyColumn(current.length + 1)]),
724
- children: [/* @__PURE__ */ jsx(Plus, {
725
- className: "mr-1.5 size-4",
726
- "aria-hidden": "true"
727
- }), tr("fluidgrids.dataTables.addColumn", "Add column")]
728
- })]
729
- }), /* @__PURE__ */ jsx("div", {
730
- className: "space-y-2",
731
- children: columns.map((column, index) => /* @__PURE__ */ jsxs("div", {
732
- className: "grid gap-2 rounded-md border border-border-secondary p-3 sm:grid-cols-[1fr_1fr_8rem_auto] sm:items-end",
733
- children: [
734
- /* @__PURE__ */ jsxs("div", {
735
- className: "space-y-1",
736
- children: [/* @__PURE__ */ jsx(Label, {
737
- htmlFor: `data-table-column-key-${index}`,
738
- children: tr("fluidgrids.dataTables.key", "Key")
739
- }), /* @__PURE__ */ jsx(Input, {
740
- id: `data-table-column-key-${index}`,
741
- value: column.key,
742
- onChange: (event) => updateColumn(index, { key: event.target.value })
743
- })]
744
- }),
745
- /* @__PURE__ */ jsxs("div", {
746
- className: "space-y-1",
747
- children: [/* @__PURE__ */ jsx(Label, {
748
- htmlFor: `data-table-column-label-${index}`,
749
- children: tr("fluidgrids.dataTables.label", "Label")
750
- }), /* @__PURE__ */ jsx(Input, {
751
- id: `data-table-column-label-${index}`,
752
- value: column.label,
753
- onChange: (event) => updateColumn(index, { label: event.target.value })
754
- })]
755
- }),
756
- /* @__PURE__ */ jsxs("div", {
757
- className: "space-y-1",
758
- children: [/* @__PURE__ */ jsx(Label, {
759
- htmlFor: `data-table-column-type-${index}`,
760
- children: tr("fluidgrids.dataTables.type", "Type")
761
- }), /* @__PURE__ */ jsx("select", {
762
- id: `data-table-column-type-${index}`,
763
- className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-text-primary",
764
- value: column.type,
765
- onChange: (event) => updateColumn(index, { type: event.target.value }),
766
- children: COLUMN_TYPES.map((type) => /* @__PURE__ */ jsx("option", {
767
- value: type,
768
- children: columnTypeLabel(type)
769
- }, type))
770
- })]
771
- }),
772
- /* @__PURE__ */ jsxs("div", {
773
- className: "flex items-center gap-2 pb-2 sm:flex-col sm:items-center sm:gap-1",
774
- children: [/* @__PURE__ */ jsxs("label", {
775
- className: "flex items-center gap-2 text-xs text-text-secondary",
776
- children: [/* @__PURE__ */ jsx("input", {
777
- type: "checkbox",
778
- checked: column.required ?? false,
779
- onChange: (event) => updateColumn(index, { required: event.target.checked })
780
- }), tr("fluidgrids.dataTables.required", "Required")]
781
- }), /* @__PURE__ */ jsx("button", {
782
- type: "button",
783
- className: "rounded p-1 text-text-secondary hover:bg-background-tertiary hover:text-text-primary disabled:opacity-40",
784
- onClick: () => setColumns((current) => current.filter((_, columnIndex) => columnIndex !== index)),
785
- disabled: columns.length === 1,
786
- title: tr("fluidgrids.dataTables.removeColumn", "Remove column"),
787
- "aria-label": tr("fluidgrids.dataTables.removeColumn", "Remove column"),
788
- children: /* @__PURE__ */ jsx(Trash2, {
789
- className: "size-4",
790
- "aria-hidden": "true"
791
- })
792
- })]
793
- })
794
- ]
795
- }, `${column.key}-${index}`))
796
- })]
797
- })]
798
- }),
799
- /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
800
- variant: "outline",
801
- onClick: () => onOpenChange(false),
802
- children: tr("fluidgrids.dataTables.cancel", "Cancel")
803
- }), /* @__PURE__ */ jsx(Button$1, {
804
- onClick: handleSubmit,
805
- disabled: saving,
806
- children: saving ? tr("fluidgrids.dataTables.saving", "Saving…") : tr("fluidgrids.dataTables.save", "Save table")
807
- })] })
808
- ]
809
- })
810
- });
811
- }
812
- function RowFormDialog({ open, table, row, onOpenChange, onSaved }) {
813
- const tr = useTr();
814
- const { insertDataTableRow, loading: inserting } = useInsertDataTableRow();
815
- const { updateDataTableRow, loading: updating } = useUpdateDataTableRow();
816
- const [values, setValues] = useState({});
817
- const editing = row !== null;
818
- const saving = inserting || updating;
819
- useEffect(() => {
820
- if (!open || !table) return;
821
- const next = {};
822
- for (const column of table.columns) next[column.key] = asFormValue(row?.data[column.key], column.type);
823
- setValues(next);
824
- }, [
825
- open,
826
- row,
827
- table
828
- ]);
829
- const handleSubmit = useCallback(async () => {
830
- if (!table) return;
831
- try {
832
- const data = {};
833
- for (const column of table.columns) {
834
- const value = values[column.key] ?? "";
835
- if (column.required && value.trim() === "") throw new Error(`${column.label} is required`);
836
- data[column.key] = parseFormValue(value, column.type);
837
- }
838
- if (editing && row) await updateDataTableRow(row.id, data);
839
- else await insertDataTableRow(table.id, data);
840
- toast.success(editing ? tr("fluidgrids.dataTables.rowUpdated", "Row updated") : tr("fluidgrids.dataTables.rowCreated", "Row added"));
841
- onSaved();
842
- onOpenChange(false);
843
- } catch (error) {
844
- toast.error(describeOperationError(error, tr("fluidgrids.dataTables.rowSaveFailed", "Failed to save row")));
845
- }
846
- }, [
847
- editing,
848
- insertDataTableRow,
849
- onOpenChange,
850
- onSaved,
851
- row,
852
- table,
853
- tr,
854
- updateDataTableRow,
855
- values
856
- ]);
857
- return /* @__PURE__ */ jsx(Dialog, {
858
- open,
859
- onOpenChange,
860
- children: /* @__PURE__ */ jsxs(DialogContent, {
861
- className: "max-h-[90vh] max-w-2xl overflow-y-auto",
862
- children: [
863
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: editing ? tr("fluidgrids.dataTables.editRow", "Edit row") : tr("fluidgrids.dataTables.addRow", "Add row") }) }),
864
- table && /* @__PURE__ */ jsx("div", {
865
- className: "space-y-4 py-2",
866
- children: table.columns.map((column) => /* @__PURE__ */ jsxs("div", {
867
- className: "space-y-1.5",
868
- children: [/* @__PURE__ */ jsxs(Label, {
869
- htmlFor: `data-table-row-${column.key}`,
870
- children: [
871
- column.label,
872
- /* @__PURE__ */ jsxs("span", {
873
- className: "ml-1 text-xs text-text-secondary",
874
- children: [
875
- "(",
876
- column.key,
877
- " · ",
878
- columnTypeLabel(column.type),
879
- ")"
880
- ]
881
- }),
882
- column.required && /* @__PURE__ */ jsx("span", {
883
- className: "ml-1 text-text-secondary",
884
- children: "*"
885
- })
886
- ]
887
- }), column.type === "JSON" ? /* @__PURE__ */ jsx(Textarea, {
888
- id: `data-table-row-${column.key}`,
889
- value: values[column.key] ?? "",
890
- onChange: (event) => setValues((current) => ({
891
- ...current,
892
- [column.key]: event.target.value
893
- })),
894
- rows: 4,
895
- placeholder: "{ }"
896
- }) : /* @__PURE__ */ jsx(Input, {
897
- id: `data-table-row-${column.key}`,
898
- type: column.type === "NUMBER" ? "number" : column.type === "DATE" ? "datetime-local" : "text",
899
- value: values[column.key] ?? "",
900
- onChange: (event) => setValues((current) => ({
901
- ...current,
902
- [column.key]: event.target.value
903
- }))
904
- })]
905
- }, column.key))
906
- }),
907
- /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
908
- variant: "outline",
909
- onClick: () => onOpenChange(false),
910
- children: tr("fluidgrids.dataTables.cancel", "Cancel")
911
- }), /* @__PURE__ */ jsx(Button$1, {
912
- onClick: handleSubmit,
913
- disabled: saving || !table,
914
- children: saving ? tr("fluidgrids.dataTables.saving", "Saving…") : tr("fluidgrids.dataTables.saveRow", "Save row")
915
- })] })
916
- ]
917
- })
918
- });
919
- }
920
- function TableRowsPanel({ table, onTableChanged, onEditTable, onDeleteTable, deletingTable, onTagsChanged }) {
921
- const tr = useTr();
922
- const { allowed: canTag } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE);
923
- const [page, setPage] = useState(0);
924
- const [pageSize, setPageSize] = useState(DEFAULT_ROW_PAGE_SIZE);
925
- const { rows, total, loading, error, refetch } = useDataTableRows(table.id, {
926
- page,
927
- pageSize
928
- });
929
- const { deleteDataTableRows, loading: deleting } = useDeleteDataTableRows();
930
- const { insertDataTableRow } = useInsertDataTableRow();
931
- const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
932
- const [rowDialogOpen, setRowDialogOpen] = useState(false);
933
- const [editingRow, setEditingRow] = useState(null);
934
- const [exporting, setExporting] = useState(false);
935
- const [importProgress, setImportProgress] = useState(null);
936
- const fileInputRef = useRef(null);
937
- const pages = pageCount(total, pageSize);
938
- const range = pageRange(page, pageSize, rows.length);
939
- useEffect(() => {
940
- if (loading) return;
941
- const clamped = clampPage(page, total, pageSize);
942
- if (clamped !== page) setPage(clamped);
943
- }, [
944
- loading,
945
- page,
946
- pageSize,
947
- total
948
- ]);
949
- useEffect(() => {
950
- setSelectedIds((current) => {
951
- const visible = new Set(rows.map((row) => row.id));
952
- return new Set([...current].filter((id) => visible.has(id)));
953
- });
954
- }, [rows]);
955
- const allVisibleSelected = rows.length > 0 && selectedIds.size === rows.length;
956
- const toggleAll = useCallback(() => {
957
- setSelectedIds(allVisibleSelected ? /* @__PURE__ */ new Set() : new Set(rows.map((row) => row.id)));
958
- }, [allVisibleSelected, rows]);
959
- const handleDeleteRows = useCallback(async () => {
960
- if (selectedIds.size === 0) return;
961
- if (!window.confirm(tr("fluidgrids.dataTables.confirmDeleteRows", `Delete ${selectedIds.size} selected row(s)?`))) return;
962
- try {
963
- const affected = await deleteDataTableRows(table.id, [...selectedIds]);
964
- toast.success(tr("fluidgrids.dataTables.rowsDeleted", `${affected} row(s) deleted`));
965
- setSelectedIds(/* @__PURE__ */ new Set());
966
- await refetch();
967
- onTableChanged();
968
- } catch (error) {
969
- toast.error(describeOperationError(error, tr("fluidgrids.dataTables.deleteRowsFailed", "Failed to delete rows")));
970
- }
971
- }, [
972
- deleteDataTableRows,
973
- onTableChanged,
974
- refetch,
975
- selectedIds,
976
- table.id,
977
- tr
978
- ]);
979
- const handleExport = useCallback(async () => {
980
- setExporting(true);
981
- try {
982
- const allRows = await fetchAllDataTableRows(table.id);
983
- const csv = rowsToCsv(table.columns, allRows);
984
- const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
985
- const url = URL.createObjectURL(blob);
986
- const anchor = document.createElement("a");
987
- anchor.href = url;
988
- anchor.download = `${table.name}.csv`;
989
- anchor.click();
990
- URL.revokeObjectURL(url);
991
- toast.success(tr("fluidgrids.dataTables.exported", `${allRows.length} row(s) exported to CSV`));
992
- } catch (error) {
993
- toast.error(describeOperationError(error, tr("fluidgrids.dataTables.exportFailed", "Failed to export CSV")));
994
- } finally {
995
- setExporting(false);
996
- }
997
- }, [
998
- table.columns,
999
- table.id,
1000
- table.name,
1001
- tr
1002
- ]);
1003
- const handleImport = useCallback(async (event) => {
1004
- const file = event.target.files?.[0];
1005
- event.target.value = "";
1006
- if (!file) return;
1007
- let inserted = 0;
1008
- try {
1009
- const importedRows = csvToRows(await file.text(), table.columns);
1010
- setImportProgress({
1011
- done: 0,
1012
- total: importedRows.length
1013
- });
1014
- for (const data of importedRows) {
1015
- await insertDataTableRow(table.id, data);
1016
- inserted += 1;
1017
- setImportProgress({
1018
- done: inserted,
1019
- total: importedRows.length
1020
- });
1021
- }
1022
- toast.success(tr("fluidgrids.dataTables.imported", `${inserted} row(s) imported`));
1023
- } catch (error) {
1024
- const reason = describeOperationError(error, tr("fluidgrids.dataTables.importFailed", "Failed to import CSV"));
1025
- toast.error(inserted > 0 ? tr("fluidgrids.dataTables.importPartial", `Import stopped after ${inserted} row(s): ${reason}`) : reason);
1026
- } finally {
1027
- setImportProgress(null);
1028
- setPage(0);
1029
- await refetch();
1030
- onTableChanged();
1031
- }
1032
- }, [
1033
- insertDataTableRow,
1034
- onTableChanged,
1035
- refetch,
1036
- table.columns,
1037
- table.id,
1038
- tr
1039
- ]);
1040
- const openNewRow = useCallback(() => {
1041
- setEditingRow(null);
1042
- setRowDialogOpen(true);
1043
- }, []);
1044
- const openEditRow = useCallback((row) => {
1045
- setEditingRow(row);
1046
- setRowDialogOpen(true);
1047
- }, []);
1048
- return /* @__PURE__ */ jsxs(Card, {
1049
- className: "min-w-0 border-border-secondary",
1050
- children: [
1051
- /* @__PURE__ */ jsxs(CardHeader, {
1052
- className: "gap-4 border-b border-border-secondary p-4 sm:p-5",
1053
- children: [/* @__PURE__ */ jsxs("div", {
1054
- className: "flex flex-wrap items-start justify-between gap-3",
1055
- children: [/* @__PURE__ */ jsxs("div", {
1056
- className: "min-w-0 flex-1 basis-64",
1057
- children: [
1058
- /* @__PURE__ */ jsxs(CardTitle, {
1059
- className: "flex items-center gap-2 text-lg",
1060
- children: [/* @__PURE__ */ jsx(Table2, {
1061
- className: "size-5 shrink-0 text-text-secondary",
1062
- "aria-hidden": "true"
1063
- }), /* @__PURE__ */ jsx("span", {
1064
- className: "truncate",
1065
- children: table.name
1066
- })]
1067
- }),
1068
- /* @__PURE__ */ jsx(CardDescription, {
1069
- className: "mt-1",
1070
- children: table.description || tr("fluidgrids.dataTables.noDescription", "No description")
1071
- }),
1072
- /* @__PURE__ */ jsx("div", {
1073
- className: "mt-3",
1074
- "data-testid": "data-table-tags",
1075
- children: /* @__PURE__ */ jsx(EntityTagPicker, {
1076
- entityType: "FLUIDGRIDS_DATA_TABLE",
1077
- entityId: table.id,
1078
- readOnly: !canTag,
1079
- onChange: onTagsChanged
1080
- })
1081
- })
1082
- ]
1083
- }), /* @__PURE__ */ jsxs("div", {
1084
- className: "flex shrink-0 items-center gap-2",
1085
- children: [/* @__PURE__ */ jsx(SdkPermissionButton, {
1086
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_UPDATE,
1087
- deniedTooltip: tr("fluidgrids.dataTables.editDeniedTooltip", "You don't have permission to edit data tables"),
1088
- children: /* @__PURE__ */ jsxs(Button$1, {
1089
- variant: "outline",
1090
- size: "sm",
1091
- className: "whitespace-nowrap",
1092
- onClick: onEditTable,
1093
- children: [/* @__PURE__ */ jsx(Pencil, {
1094
- className: "mr-1.5 size-4",
1095
- "aria-hidden": "true"
1096
- }), tr("fluidgrids.dataTables.editTable", "Edit table")]
1097
- })
1098
- }), /* @__PURE__ */ jsx(SdkPermissionButton, {
1099
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_DELETE,
1100
- deniedTooltip: tr("fluidgrids.dataTables.deleteDeniedTooltip", "You don't have permission to delete data tables"),
1101
- children: /* @__PURE__ */ jsxs(Button$1, {
1102
- variant: "outline",
1103
- size: "sm",
1104
- className: "whitespace-nowrap",
1105
- onClick: onDeleteTable,
1106
- disabled: deletingTable,
1107
- children: [/* @__PURE__ */ jsx(Trash2, {
1108
- className: "mr-1.5 size-4",
1109
- "aria-hidden": "true"
1110
- }), deletingTable ? tr("fluidgrids.dataTables.deleting", "Deleting…") : tr("fluidgrids.dataTables.deleteTable", "Delete table")]
1111
- })
1112
- })]
1113
- })]
1114
- }), /* @__PURE__ */ jsxs("div", {
1115
- className: "flex flex-wrap items-center justify-between gap-3",
1116
- children: [/* @__PURE__ */ jsxs("div", {
1117
- className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
1118
- children: [
1119
- /* @__PURE__ */ jsxs(Badge, {
1120
- variant: "outline",
1121
- children: [
1122
- total,
1123
- " ",
1124
- tr("fluidgrids.dataTables.rows", "rows")
1125
- ]
1126
- }),
1127
- /* @__PURE__ */ jsxs(Badge, {
1128
- variant: "outline",
1129
- children: [
1130
- table.columns.length,
1131
- " ",
1132
- tr("fluidgrids.dataTables.columns", "columns")
1133
- ]
1134
- }),
1135
- /* @__PURE__ */ jsx(Badge, {
1136
- variant: "outline",
1137
- children: formatBytes(table.sizeBytes)
1138
- }),
1139
- selectedIds.size > 0 && /* @__PURE__ */ jsx(SdkPermissionButton, {
1140
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_ROW_DELETE,
1141
- deniedTooltip: tr("fluidgrids.dataTables.deleteRowsDeniedTooltip", "You don't have permission to delete rows"),
1142
- children: /* @__PURE__ */ jsxs(Button$1, {
1143
- variant: "outline",
1144
- size: "sm",
1145
- className: "whitespace-nowrap",
1146
- onClick: handleDeleteRows,
1147
- disabled: deleting,
1148
- children: [/* @__PURE__ */ jsx(Trash2, {
1149
- className: "mr-1.5 size-4",
1150
- "aria-hidden": "true"
1151
- }), deleting ? tr("fluidgrids.dataTables.deleting", "Deleting…") : tr("fluidgrids.dataTables.deleteSelected", `Delete ${selectedIds.size} selected`)]
1152
- })
1153
- })
1154
- ]
1155
- }), /* @__PURE__ */ jsxs("div", {
1156
- className: "flex flex-wrap items-center gap-2",
1157
- children: [
1158
- /* @__PURE__ */ jsx(SdkPermissionButton, {
1159
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_ROW_CREATE,
1160
- deniedTooltip: tr("fluidgrids.dataTables.addRowDeniedTooltip", "You don't have permission to add rows"),
1161
- children: /* @__PURE__ */ jsxs(Button$1, {
1162
- size: "sm",
1163
- className: "whitespace-nowrap",
1164
- onClick: openNewRow,
1165
- disabled: importProgress !== null,
1166
- children: [/* @__PURE__ */ jsx(Plus, {
1167
- className: "mr-1.5 size-4",
1168
- "aria-hidden": "true"
1169
- }), tr("fluidgrids.dataTables.addRow", "Add row")]
1170
- })
1171
- }),
1172
- /* @__PURE__ */ jsx(SdkPermissionButton, {
1173
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_ROW_CREATE,
1174
- deniedTooltip: tr("fluidgrids.dataTables.importDeniedTooltip", "You don't have permission to import rows"),
1175
- children: /* @__PURE__ */ jsxs(Button$1, {
1176
- variant: "outline",
1177
- size: "sm",
1178
- className: "whitespace-nowrap",
1179
- onClick: () => fileInputRef.current?.click(),
1180
- disabled: importProgress !== null,
1181
- children: [/* @__PURE__ */ jsx(ArrowUpFromLine, {
1182
- className: "mr-1.5 size-4",
1183
- "aria-hidden": "true"
1184
- }), importProgress ? tr("fluidgrids.dataTables.importing", `Importing ${importProgress.done} / ${importProgress.total}…`) : tr("fluidgrids.dataTables.import", "Import CSV")]
1185
- })
1186
- }),
1187
- /* @__PURE__ */ jsx("input", {
1188
- ref: fileInputRef,
1189
- type: "file",
1190
- accept: ".csv,text/csv",
1191
- className: "hidden",
1192
- onChange: handleImport
1193
- }),
1194
- /* @__PURE__ */ jsxs(Button$1, {
1195
- variant: "outline",
1196
- size: "sm",
1197
- className: "whitespace-nowrap",
1198
- onClick: handleExport,
1199
- disabled: total === 0 || exporting,
1200
- children: [/* @__PURE__ */ jsx(ArrowDownToLine, {
1201
- className: "mr-1.5 size-4",
1202
- "aria-hidden": "true"
1203
- }), exporting ? tr("fluidgrids.dataTables.exporting", "Exporting…") : tr("fluidgrids.dataTables.export", "Export CSV")]
1204
- })
1205
- ]
1206
- })]
1207
- })]
1208
- }),
1209
- /* @__PURE__ */ jsxs(CardContent, {
1210
- className: "p-0",
1211
- children: [
1212
- error && /* @__PURE__ */ jsx("div", {
1213
- className: "m-4 rounded-md border border-border-secondary bg-background-secondary p-3 text-sm text-text-secondary",
1214
- children: error.message
1215
- }),
1216
- /* @__PURE__ */ jsx("div", {
1217
- className: "overflow-x-auto",
1218
- children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
1219
- /* @__PURE__ */ jsx(TableHead, {
1220
- className: "w-10",
1221
- children: /* @__PURE__ */ jsx("input", {
1222
- type: "checkbox",
1223
- checked: allVisibleSelected,
1224
- onChange: toggleAll,
1225
- "aria-label": tr("fluidgrids.dataTables.selectAll", "Select all rows on this page")
1226
- })
1227
- }),
1228
- /* @__PURE__ */ jsx(TableHead, { children: tr("fluidgrids.dataTables.rowId", "Row") }),
1229
- table.columns.map((column) => /* @__PURE__ */ jsx(TableHead, { children: column.label }, column.key)),
1230
- /* @__PURE__ */ jsx(TableHead, {
1231
- className: "text-right",
1232
- children: tr("fluidgrids.dataTables.actions", "Actions")
1233
- })
1234
- ] }) }), /* @__PURE__ */ jsxs(TableBody, { children: [
1235
- loading && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
1236
- colSpan: table.columns.length + 3,
1237
- className: "py-10 text-center text-text-secondary",
1238
- children: tr("fluidgrids.dataTables.loadingRows", "Loading rows…")
1239
- }) }),
1240
- !loading && rows.length === 0 && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
1241
- colSpan: table.columns.length + 3,
1242
- className: "py-10 text-center text-text-secondary",
1243
- children: tr("fluidgrids.dataTables.emptyRows", "No rows yet. Add a row or import a CSV to get started.")
1244
- }) }),
1245
- !loading && rows.map((row) => /* @__PURE__ */ jsxs(TableRow, { children: [
1246
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("input", {
1247
- type: "checkbox",
1248
- checked: selectedIds.has(row.id),
1249
- onChange: () => setSelectedIds((current) => {
1250
- const next = new Set(current);
1251
- if (next.has(row.id)) next.delete(row.id);
1252
- else next.add(row.id);
1253
- return next;
1254
- }),
1255
- "aria-label": tr("fluidgrids.dataTables.selectRow", "Select row")
1256
- }) }),
1257
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("code", {
1258
- className: "text-xs text-text-secondary",
1259
- children: row.id.slice(0, 8)
1260
- }) }),
1261
- table.columns.map((column) => /* @__PURE__ */ jsx(TableCell, {
1262
- className: "max-w-[16rem] truncate text-sm",
1263
- title: formatValue(row.data[column.key]),
1264
- children: formatValue(row.data[column.key])
1265
- }, column.key)),
1266
- /* @__PURE__ */ jsx(TableCell, {
1267
- className: "text-right",
1268
- children: /* @__PURE__ */ jsx(SdkPermissionButton, {
1269
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_ROW_UPDATE,
1270
- deniedTooltip: tr("fluidgrids.dataTables.editRowDeniedTooltip", "You don't have permission to edit rows"),
1271
- children: /* @__PURE__ */ jsx(Button$1, {
1272
- variant: "ghost",
1273
- size: "icon",
1274
- onClick: () => openEditRow(row),
1275
- title: tr("fluidgrids.dataTables.editRow", "Edit row"),
1276
- "aria-label": tr("fluidgrids.dataTables.editRow", "Edit row"),
1277
- children: /* @__PURE__ */ jsx(Pencil, {
1278
- className: "size-4",
1279
- "aria-hidden": "true"
1280
- })
1281
- })
1282
- })
1283
- })
1284
- ] }, row.id))
1285
- ] })] })
1286
- }),
1287
- total > 0 && /* @__PURE__ */ jsxs("div", {
1288
- className: "flex flex-wrap items-center justify-between gap-3 border-t border-border-secondary px-4 py-3 text-xs text-text-secondary",
1289
- children: [/* @__PURE__ */ jsx("span", {
1290
- "aria-live": "polite",
1291
- children: tr("fluidgrids.dataTables.showingRange", `Showing ${range.from}–${range.to} of ${total}`)
1292
- }), /* @__PURE__ */ jsxs("div", {
1293
- className: "flex flex-wrap items-center gap-3",
1294
- children: [
1295
- /* @__PURE__ */ jsxs("label", {
1296
- className: "flex items-center gap-2",
1297
- children: [/* @__PURE__ */ jsx("span", { children: tr("fluidgrids.dataTables.rowsPerPage", "Rows per page") }), /* @__PURE__ */ jsx("select", {
1298
- className: "h-8 rounded-md border border-input bg-background px-2 text-xs text-text-primary",
1299
- value: pageSize,
1300
- onChange: (event) => {
1301
- setPageSize(Number(event.target.value));
1302
- setPage(0);
1303
- },
1304
- children: ROW_PAGE_SIZES.map((size) => /* @__PURE__ */ jsx("option", {
1305
- value: size,
1306
- children: size
1307
- }, size))
1308
- })]
1309
- }),
1310
- /* @__PURE__ */ jsx("span", { children: tr("fluidgrids.dataTables.pageOf", `Page ${page + 1} of ${pages}`) }),
1311
- /* @__PURE__ */ jsxs("div", {
1312
- className: "flex items-center gap-1",
1313
- children: [/* @__PURE__ */ jsx(Button$1, {
1314
- variant: "outline",
1315
- size: "icon",
1316
- className: "size-8",
1317
- onClick: () => setPage((current) => Math.max(current - 1, 0)),
1318
- disabled: page === 0 || loading,
1319
- title: tr("fluidgrids.dataTables.prevPage", "Previous page"),
1320
- "aria-label": tr("fluidgrids.dataTables.prevPage", "Previous page"),
1321
- children: /* @__PURE__ */ jsx(ChevronLeft, {
1322
- className: "size-4",
1323
- "aria-hidden": "true"
1324
- })
1325
- }), /* @__PURE__ */ jsx(Button$1, {
1326
- variant: "outline",
1327
- size: "icon",
1328
- className: "size-8",
1329
- onClick: () => setPage((current) => Math.min(current + 1, pages - 1)),
1330
- disabled: page >= pages - 1 || loading,
1331
- title: tr("fluidgrids.dataTables.nextPage", "Next page"),
1332
- "aria-label": tr("fluidgrids.dataTables.nextPage", "Next page"),
1333
- children: /* @__PURE__ */ jsx(ChevronRight, {
1334
- className: "size-4",
1335
- "aria-hidden": "true"
1336
- })
1337
- })]
1338
- })
1339
- ]
1340
- })]
1341
- })
1342
- ]
1343
- }),
1344
- /* @__PURE__ */ jsx(RowFormDialog, {
1345
- open: rowDialogOpen,
1346
- table,
1347
- row: editingRow,
1348
- onOpenChange: setRowDialogOpen,
1349
- onSaved: async () => {
1350
- await refetch();
1351
- onTableChanged();
1352
- }
1353
- })
1354
- ]
1355
- });
1356
- }
1357
- function DataTablesPage() {
1358
- const tr = useTr();
1359
- const navigate = useNavigate();
1360
- const createTablePermission = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.DATA_TABLE_CREATE);
1361
- const canCreateTable = createTablePermission.allowed;
1362
- const [searchInput, setSearchInput] = useState("");
1363
- const [search, setSearch] = useState("");
1364
- const [tagFilter, setTagFilter] = useState("");
1365
- const { tables, total, loading, error, refetch } = useDataTables(search, tagFilter);
1366
- const { tagsById, refetch: refetchTags } = useDataTableTagOverlay();
1367
- const { deleteDataTable, loading: deleting } = useDeleteDataTable();
1368
- const [selectedId, setSelectedId] = useState(null);
1369
- const [tableDialogOpen, setTableDialogOpen] = useState(false);
1370
- const [editingTable, setEditingTable] = useState(null);
1371
- const newTableRequest = useActionParam(ACTION_PARAM_VALUES.new, createTablePermission);
1372
- const openCreateTable = useCallback(() => {
1373
- setEditingTable(null);
1374
- setTableDialogOpen(true);
1375
- }, []);
1376
- useOpenRequest(newTableRequest.requested, openCreateTable, newTableRequest.handled);
1377
- const selectedTable = useMemo(() => tables.find((table) => table.id === selectedId) ?? null, [selectedId, tables]);
1378
- useEffect(() => {
1379
- if (tables.length === 0) {
1380
- setSelectedId(null);
1381
- return;
1382
- }
1383
- if (!selectedId || !tables.some((table) => table.id === selectedId)) setSelectedId(tables[0].id);
1384
- }, [selectedId, tables]);
1385
- const refresh = useCallback(async () => {
1386
- await refetch();
1387
- }, [refetch]);
1388
- const handleTagsChanged = useCallback(() => {
1389
- refetchTags();
1390
- if (tagFilter) refetch();
1391
- }, [
1392
- refetch,
1393
- refetchTags,
1394
- tagFilter
1395
- ]);
1396
- const handleDeleteTable = useCallback(async () => {
1397
- if (!selectedTable) return;
1398
- if (!window.confirm(tr("fluidgrids.dataTables.confirmDeleteTable", `Delete table "${selectedTable.name}" and all of its rows?`))) return;
1399
- try {
1400
- await deleteDataTable(selectedTable.id);
1401
- toast.success(tr("fluidgrids.dataTables.deleted", "Data table deleted"));
1402
- setSelectedId(null);
1403
- await refetch();
1404
- } catch (error) {
1405
- toast.error(describeOperationError(error, tr("fluidgrids.dataTables.deleteFailed", "Failed to delete data table")));
1406
- }
1407
- }, [
1408
- deleteDataTable,
1409
- refetch,
1410
- selectedTable,
1411
- tr
1412
- ]);
1413
- const handleTableSaved = useCallback((table) => {
1414
- if (table) setSelectedId(table.id);
1415
- refetch();
1416
- }, [refetch]);
1417
- const submitSearch = useCallback((event) => {
1418
- event.preventDefault();
1419
- setSearch(searchInput);
1420
- }, [searchInput]);
1421
- return /* @__PURE__ */ jsxs("div", {
1422
- className: "min-h-screen bg-background-primary p-4 pb-24 sm:p-6 sm:pb-24",
1423
- children: [/* @__PURE__ */ jsxs("div", {
1424
- className: "mx-auto flex max-w-[1500px] flex-col gap-5",
1425
- children: [
1426
- /* @__PURE__ */ jsxs("div", {
1427
- className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",
1428
- "data-tour": "fluidgrids-data-tables-header",
1429
- children: [/* @__PURE__ */ jsxs("div", { children: [
1430
- /* @__PURE__ */ jsxs("div", {
1431
- className: "mb-2 flex items-center gap-2 text-sm text-text-secondary",
1432
- children: [/* @__PURE__ */ jsx(Database, {
1433
- className: "size-4",
1434
- "aria-hidden": "true"
1435
- }), tr("fluidgrids.dataTables.workflowData", "Workflow data")]
1436
- }),
1437
- /* @__PURE__ */ jsx("h1", {
1438
- className: "text-2xl font-bold text-text-primary sm:text-3xl",
1439
- children: tr("fluidgrids.dataTables.pageTitle", "Data Tables")
1440
- }),
1441
- /* @__PURE__ */ jsx(PagePurpose, {
1442
- icon: /* @__PURE__ */ jsx(Database, {
1443
- className: "size-4",
1444
- "aria-hidden": "true"
1445
- }),
1446
- children: tr("fluidgrids.dataTables.pageSubtitle", "Use Data Tables as lightweight persistent storage for workflow state, lookups, and records shared across runs.")
1447
- }),
1448
- /* @__PURE__ */ jsx(FluidGridsDocsLink, {
1449
- topic: "dataTables",
1450
- className: "mt-1"
1451
- })
1452
- ] }), /* @__PURE__ */ jsxs("div", {
1453
- className: "flex flex-wrap gap-2",
1454
- children: [/* @__PURE__ */ jsxs(Button$1, {
1455
- variant: "outline",
1456
- onClick: () => navigate("../list"),
1457
- children: [/* @__PURE__ */ jsx(ArrowLeft, {
1458
- className: "mr-2 size-4",
1459
- "aria-hidden": "true"
1460
- }), tr("fluidgrids.dataTables.backToWorkflows", "Back to Workflows")]
1461
- }), /* @__PURE__ */ jsx(SdkPermissionButton, {
1462
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_CREATE,
1463
- deniedTooltip: tr("fluidgrids.dataTables.createDeniedTooltip", "You don't have permission to create data tables"),
1464
- children: /* @__PURE__ */ jsxs(Button$1, {
1465
- onClick: () => {
1466
- setEditingTable(null);
1467
- setTableDialogOpen(true);
1468
- },
1469
- "data-tour": "fluidgrids-data-tables-create",
1470
- children: [/* @__PURE__ */ jsx(Plus, {
1471
- className: "mr-2 size-4",
1472
- "aria-hidden": "true"
1473
- }), tr("fluidgrids.dataTables.newTable", "New data table")]
1474
- })
1475
- })]
1476
- })]
1477
- }),
1478
- /* @__PURE__ */ jsx(NextSteps, {
1479
- storageKey: "data-tables",
1480
- title: tr("fluidgrids.dataTables.nextStepsTitle", "How to use Data Tables"),
1481
- steps: [
1482
- {
1483
- id: "create",
1484
- label: tr("fluidgrids.dataTables.nextStepCreateLabel", "Create a table"),
1485
- description: tr("fluidgrids.dataTables.nextStepCreateDescription", "Define typed columns for the records your workflow needs."),
1486
- icon: /* @__PURE__ */ jsx(Plus, {
1487
- className: "size-4",
1488
- "aria-hidden": "true"
1489
- }),
1490
- onClick: canCreateTable ? () => {
1491
- setEditingTable(null);
1492
- setTableDialogOpen(true);
1493
- } : void 0
1494
- },
1495
- {
1496
- id: "connect",
1497
- label: tr("fluidgrids.dataTables.nextStepConnectLabel", "Connect it to a workflow"),
1498
- description: tr("fluidgrids.dataTables.nextStepConnectDescription", "Add a Data Table node to get, insert, update, upsert, or delete rows."),
1499
- icon: /* @__PURE__ */ jsx(Table2, {
1500
- className: "size-4",
1501
- "aria-hidden": "true"
1502
- }),
1503
- onClick: () => navigate("../list")
1504
- },
1505
- {
1506
- id: "reuse",
1507
- label: tr("fluidgrids.dataTables.nextStepReuseLabel", "Reuse data across runs"),
1508
- description: tr("fluidgrids.dataTables.nextStepReuseDescription", "Use saved status, cursors, lookups, and deduplication keys on later runs."),
1509
- icon: /* @__PURE__ */ jsx(RefreshCw, {
1510
- className: "size-4",
1511
- "aria-hidden": "true"
1512
- })
1513
- }
1514
- ]
1515
- }),
1516
- /* @__PURE__ */ jsxs("div", {
1517
- className: "grid gap-5 xl:grid-cols-[minmax(16rem,22rem)_minmax(0,1fr)]",
1518
- children: [
1519
- /* @__PURE__ */ jsxs(Card, {
1520
- className: "h-fit border-border-secondary",
1521
- "data-tour": "fluidgrids-data-tables-list",
1522
- children: [/* @__PURE__ */ jsxs(CardHeader, {
1523
- className: "gap-3 border-b border-border-secondary p-4",
1524
- children: [
1525
- /* @__PURE__ */ jsxs("div", {
1526
- className: "flex items-center justify-between gap-2",
1527
- children: [/* @__PURE__ */ jsx(CardTitle, {
1528
- className: "text-base",
1529
- children: tr("fluidgrids.dataTables.tables", "Tables")
1530
- }), /* @__PURE__ */ jsx(Badge, {
1531
- variant: "outline",
1532
- children: total
1533
- })]
1534
- }),
1535
- /* @__PURE__ */ jsxs("form", {
1536
- className: "flex gap-2",
1537
- onSubmit: submitSearch,
1538
- children: [/* @__PURE__ */ jsxs("div", {
1539
- className: "relative min-w-0 flex-1",
1540
- children: [/* @__PURE__ */ jsx(Search, {
1541
- className: "pointer-events-none absolute left-2.5 top-2.5 size-4 text-text-secondary",
1542
- "aria-hidden": "true"
1543
- }), /* @__PURE__ */ jsx(Input, {
1544
- className: "pl-8",
1545
- value: searchInput,
1546
- onChange: (event) => setSearchInput(event.target.value),
1547
- placeholder: tr("fluidgrids.dataTables.search", "Search tables"),
1548
- "aria-label": tr("fluidgrids.dataTables.search", "Search tables")
1549
- })]
1550
- }), /* @__PURE__ */ jsx(Button$1, {
1551
- type: "submit",
1552
- variant: "outline",
1553
- size: "sm",
1554
- children: tr("fluidgrids.dataTables.searchAction", "Search")
1555
- })]
1556
- }),
1557
- /* @__PURE__ */ jsx(TagFilterSelect, {
1558
- value: tagFilter,
1559
- onChange: setTagFilter,
1560
- className: "w-full"
1561
- })
1562
- ]
1563
- }), /* @__PURE__ */ jsxs(CardContent, {
1564
- className: "max-h-72 overflow-y-auto p-2 xl:max-h-[36rem]",
1565
- children: [
1566
- loading && /* @__PURE__ */ jsx("p", {
1567
- className: "p-4 text-sm text-text-secondary",
1568
- children: tr("fluidgrids.dataTables.loading", "Loading tables…")
1569
- }),
1570
- !loading && tables.length === 0 && tagFilter && /* @__PURE__ */ jsx("p", {
1571
- className: "p-4 text-sm text-text-secondary",
1572
- children: tr("fluidgrids.dataTables.noTablesWithTag", "No tables carry this tag.")
1573
- }),
1574
- !loading && tables.length === 0 && !tagFilter && /* @__PURE__ */ jsx(IllustratedEmptyState, {
1575
- className: "py-8",
1576
- illustration: "onboarding",
1577
- title: tr("fluidgrids.dataTables.empty", "Create your first Data Table"),
1578
- description: tr("fluidgrids.dataTables.emptyHint", "Give your workflows a shared place to store typed records across runs."),
1579
- action: /* @__PURE__ */ jsx(SdkPermissionButton, {
1580
- permission: FLUIDGRIDS_PERMISSIONS.DATA_TABLE_CREATE,
1581
- deniedTooltip: tr("fluidgrids.dataTables.createDeniedTooltip", "You don't have permission to create data tables"),
1582
- children: /* @__PURE__ */ jsxs(Button$1, {
1583
- size: "sm",
1584
- onClick: () => {
1585
- setEditingTable(null);
1586
- setTableDialogOpen(true);
1587
- },
1588
- children: [/* @__PURE__ */ jsx(Plus, {
1589
- className: "mr-2 size-4",
1590
- "aria-hidden": "true"
1591
- }), tr("fluidgrids.dataTables.createFirstTable", "Create a table")]
1592
- })
1593
- })
1594
- }),
1595
- !loading && tables.map((table) => /* @__PURE__ */ jsxs("button", {
1596
- type: "button",
1597
- onClick: () => setSelectedId(table.id),
1598
- className: `mb-1 flex w-full items-start justify-between gap-3 rounded-md px-3 py-3 text-left transition-colors ${selectedId === table.id ? "bg-background-tertiary text-text-primary" : "text-text-secondary hover:bg-background-secondary hover:text-text-primary"}`,
1599
- children: [/* @__PURE__ */ jsxs("span", {
1600
- className: "min-w-0",
1601
- children: [
1602
- /* @__PURE__ */ jsx("span", {
1603
- className: "block truncate text-sm font-medium",
1604
- children: table.name
1605
- }),
1606
- /* @__PURE__ */ jsxs("span", {
1607
- className: "mt-1 block text-xs text-text-secondary",
1608
- children: [
1609
- table.rowCount,
1610
- " ",
1611
- tr("fluidgrids.dataTables.rows", "rows"),
1612
- " ·",
1613
- " ",
1614
- table.columns.length,
1615
- " ",
1616
- tr("fluidgrids.dataTables.columns", "columns")
1617
- ]
1618
- }),
1619
- (tagsById[table.id] ?? []).length > 0 && /* @__PURE__ */ jsx("span", {
1620
- className: "mt-1.5 flex flex-wrap gap-1",
1621
- children: (tagsById[table.id] ?? []).map((assignment) => /* @__PURE__ */ jsx(TagBadge, {
1622
- id: assignment.tagId,
1623
- label: tagLabel(assignment),
1624
- color: assignment.tagInfo?.color ?? void 0,
1625
- size: "sm"
1626
- }, assignment.tagId))
1627
- })
1628
- ]
1629
- }), /* @__PURE__ */ jsx(Table2, {
1630
- className: "mt-0.5 size-4 shrink-0",
1631
- "aria-hidden": "true"
1632
- })]
1633
- }, table.id))
1634
- ]
1635
- })]
1636
- }),
1637
- error && !selectedTable && /* @__PURE__ */ jsx(Card, {
1638
- className: "border-border-secondary",
1639
- children: /* @__PURE__ */ jsxs(CardContent, {
1640
- className: "p-6 text-sm text-text-secondary",
1641
- children: [/* @__PURE__ */ jsx("p", { children: error.message }), /* @__PURE__ */ jsxs(Button$1, {
1642
- className: "mt-4",
1643
- variant: "outline",
1644
- onClick: () => void refresh(),
1645
- children: [/* @__PURE__ */ jsx(RefreshCw, {
1646
- className: "mr-2 size-4",
1647
- "aria-hidden": "true"
1648
- }), tr("fluidgrids.dataTables.retry", "Try again")]
1649
- })]
1650
- })
1651
- }),
1652
- !error && !selectedTable && !loading && /* @__PURE__ */ jsx(Card, {
1653
- className: "border-border-secondary",
1654
- children: /* @__PURE__ */ jsxs(CardContent, {
1655
- className: "flex min-h-[22rem] flex-col items-center justify-center p-6 text-center",
1656
- children: [
1657
- /* @__PURE__ */ jsx(Database, {
1658
- className: "mb-3 size-10 text-text-secondary",
1659
- "aria-hidden": "true"
1660
- }),
1661
- /* @__PURE__ */ jsx("h2", {
1662
- className: "text-lg font-semibold text-text-primary",
1663
- children: tr("fluidgrids.dataTables.selectTitle", "Select a data table")
1664
- }),
1665
- /* @__PURE__ */ jsx("p", {
1666
- className: "mt-1 max-w-sm text-sm text-text-secondary",
1667
- children: tr("fluidgrids.dataTables.selectDescription", "Choose a table to view and edit its rows, or create your first table.")
1668
- })
1669
- ]
1670
- })
1671
- }),
1672
- selectedTable && /* @__PURE__ */ jsx("div", {
1673
- className: "min-w-0",
1674
- children: /* @__PURE__ */ jsx(TableRowsPanel, {
1675
- table: selectedTable,
1676
- onTableChanged: refresh,
1677
- onEditTable: () => {
1678
- setEditingTable(selectedTable);
1679
- setTableDialogOpen(true);
1680
- },
1681
- onDeleteTable: handleDeleteTable,
1682
- deletingTable: deleting,
1683
- onTagsChanged: handleTagsChanged
1684
- }, selectedTable.id)
1685
- })
1686
- ]
1687
- })
1688
- ]
1689
- }), /* @__PURE__ */ jsx(TableFormDialog, {
1690
- open: tableDialogOpen,
1691
- table: editingTable,
1692
- onOpenChange: setTableDialogOpen,
1693
- onSaved: handleTableSaved
1694
- })]
1695
- });
1696
- }
1697
-
1698
- export { rowsToCsv as a, useDataTables as c, useInsertDataTableRow as d, useUpdateDataTable as f, parseCsv as i, useDeleteDataTable as l, DataTablesPage_exports as n, useCreateDataTable as o, useUpdateDataTableRow as p, csvToRows as r, useDataTableRows as s, DataTablesPage as t, useDeleteDataTableRows as u };