@agent-native/core 0.133.1 → 0.133.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +22 -5
- package/corpus/core/src/client/use-action.ts +6 -0
- package/corpus/core/src/integrations/webhook-handler.ts +7 -0
- package/corpus/core/src/scripts/call-agent.ts +29 -2
- package/corpus/templates/content/actions/_batch-utils.ts +33 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +173 -81
- package/corpus/templates/content/actions/_content-files.ts +31 -21
- package/corpus/templates/content/actions/_database-source-utils.ts +653 -155
- package/corpus/templates/content/actions/_database-utils.ts +535 -41
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +291 -240
- package/corpus/templates/content/actions/add-database-item.ts +15 -1
- package/corpus/templates/content/actions/attach-content-database-source.ts +156 -58
- package/corpus/templates/content/actions/bind-content-database-source-field.ts +2 -2
- package/corpus/templates/content/actions/cancel-prepared-builder-source-update.ts +4 -1
- package/corpus/templates/content/actions/delete-database-items.ts +8 -2
- package/corpus/templates/content/actions/disconnect-content-database-source.ts +2 -2
- package/corpus/templates/content/actions/duplicate-database-item.ts +15 -1
- package/corpus/templates/content/actions/duplicate-database-items.ts +19 -1
- package/corpus/templates/content/actions/execute-builder-source-execution.ts +2 -1
- package/corpus/templates/content/actions/get-content-database.ts +12 -64
- package/corpus/templates/content/actions/move-database-item.ts +4 -1
- package/corpus/templates/content/actions/prepare-builder-source-execution.ts +1 -1
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +4 -8
- package/corpus/templates/content/actions/preview-content-database-source-attach.ts +92 -0
- package/corpus/templates/content/actions/process-builder-body-hydration.ts +2 -1
- package/corpus/templates/content/actions/query-content-database-items.ts +64 -0
- package/corpus/templates/content/actions/refresh-content-database-source.ts +7 -0
- package/corpus/templates/content/actions/review-content-database-source-change-set.ts +1 -1
- package/corpus/templates/content/actions/set-content-database-source-write-mode.ts +1 -1
- package/corpus/templates/content/actions/stage-builder-revision.ts +1 -1
- package/corpus/templates/content/actions/update-content-database-personal-view.ts +29 -3
- package/corpus/templates/content/actions/update-content-database-view.ts +1 -1
- package/corpus/templates/content/actions/validate-builder-source-execution.ts +1 -1
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +3 -22
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +267 -105
- package/corpus/templates/content/app/components/editor/database/sidebar.tsx +1 -34
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +159 -4
- package/corpus/templates/content/app/components/sidebar/DocumentTreeItem.tsx +4 -211
- package/corpus/templates/content/app/hooks/use-content-database.ts +285 -24
- package/corpus/templates/content/app/hooks/use-document-properties.ts +7 -6
- package/corpus/templates/content/app/i18n-data.ts +10 -0
- package/corpus/templates/content/changelog/2026-07-29-large-databases-keep-useful-rows-visible.md +6 -0
- package/corpus/templates/content/changelog/2026-07-30-builder-source-columns-now-appear-immediately-when-connected.md +6 -0
- package/corpus/templates/content/changelog/2026-07-30-deleting-a-page-no-longer-leaves-the-content-sidebar-unrespo.md +6 -0
- package/corpus/templates/content/changelog/2026-07-30-large-builder-backed-tables-show-useful-rows-sooner-and-fini.md +6 -0
- package/corpus/templates/content/changelog/2026-08-01-large-builder-databases-now-show-rows-immediately-and-finish.md +6 -0
- package/corpus/templates/content/e2e/playwright.config.ts +2 -1
- package/corpus/templates/content/parity/matrix.md +2 -1
- package/corpus/templates/content/parity/matrix.ts +25 -0
- package/corpus/templates/content/shared/api.ts +54 -4
- package/corpus/templates/content/shared/database-query.ts +359 -0
- package/dist/a2a/client.d.ts +9 -1
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +12 -4
- package/dist/a2a/client.js.map +1 -1
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +6 -0
- package/dist/client/use-action.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +3 -0
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +24 -2
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
- package/src/a2a/client.ts +22 -5
- package/src/client/use-action.ts +6 -0
- package/src/integrations/webhook-handler.ts +7 -0
- package/src/scripts/call-agent.ts +29 -2
|
@@ -21,16 +21,6 @@ import {
|
|
|
21
21
|
import { useEffect, useState, type MouseEvent, type ReactNode } from "react";
|
|
22
22
|
import { Link } from "react-router";
|
|
23
23
|
|
|
24
|
-
import {
|
|
25
|
-
AlertDialog,
|
|
26
|
-
AlertDialogAction,
|
|
27
|
-
AlertDialogCancel,
|
|
28
|
-
AlertDialogContent,
|
|
29
|
-
AlertDialogDescription,
|
|
30
|
-
AlertDialogFooter,
|
|
31
|
-
AlertDialogHeader,
|
|
32
|
-
AlertDialogTitle,
|
|
33
|
-
} from "@/components/ui/alert-dialog";
|
|
34
24
|
import { Button } from "@/components/ui/button";
|
|
35
25
|
import {
|
|
36
26
|
Collapsible,
|
|
@@ -727,7 +717,6 @@ function DatabaseSidebarRow({
|
|
|
727
717
|
};
|
|
728
718
|
}) {
|
|
729
719
|
const t = useT();
|
|
730
|
-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
731
720
|
const canEdit = item.document.canEdit !== false;
|
|
732
721
|
const canManage =
|
|
733
722
|
item.document.canManage === true ||
|
|
@@ -858,7 +847,7 @@ function DatabaseSidebarRow({
|
|
|
858
847
|
{canManage && onDeleteItem ? (
|
|
859
848
|
<DropdownMenuItem
|
|
860
849
|
className="text-destructive focus:text-destructive"
|
|
861
|
-
onSelect={() =>
|
|
850
|
+
onSelect={() => onDeleteItem(item)}
|
|
862
851
|
>
|
|
863
852
|
<IconTrash className="me-2 size-4" />
|
|
864
853
|
{t("database.delete")}
|
|
@@ -903,28 +892,6 @@ function DatabaseSidebarRow({
|
|
|
903
892
|
</div>
|
|
904
893
|
)}
|
|
905
894
|
</div>
|
|
906
|
-
|
|
907
|
-
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
|
|
908
|
-
<AlertDialogContent>
|
|
909
|
-
<AlertDialogHeader>
|
|
910
|
-
<AlertDialogTitle>
|
|
911
|
-
{t("sidebar.deletePageQuestion")}
|
|
912
|
-
</AlertDialogTitle>
|
|
913
|
-
<AlertDialogDescription>
|
|
914
|
-
{t("sidebar.deletePageDescription", { title })}
|
|
915
|
-
</AlertDialogDescription>
|
|
916
|
-
</AlertDialogHeader>
|
|
917
|
-
<AlertDialogFooter>
|
|
918
|
-
<AlertDialogCancel>{t("comments.cancel")}</AlertDialogCancel>
|
|
919
|
-
<AlertDialogAction
|
|
920
|
-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
921
|
-
onClick={() => onDeleteItem?.(item)}
|
|
922
|
-
>
|
|
923
|
-
{t("database.delete")}
|
|
924
|
-
</AlertDialogAction>
|
|
925
|
-
</AlertDialogFooter>
|
|
926
|
-
</AlertDialogContent>
|
|
927
|
-
</AlertDialog>
|
|
928
895
|
</>
|
|
929
896
|
);
|
|
930
897
|
}
|
|
@@ -222,6 +222,18 @@ const SIDEBAR_SECTION_COLLAPSE_STORAGE_KEY =
|
|
|
222
222
|
const TRASH_COLLAPSED_DEFAULT_MIGRATION_KEY =
|
|
223
223
|
"content-sidebar-trash-collapsed-default-v2";
|
|
224
224
|
const CONTENT_SIDEBAR_STATE_VERSION = 1 as const;
|
|
225
|
+
|
|
226
|
+
function afterBodyPointerUnlock(callback: () => void) {
|
|
227
|
+
const run = () => {
|
|
228
|
+
if (document.body.style.pointerEvents === "none") {
|
|
229
|
+
window.requestAnimationFrame(run);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
callback();
|
|
233
|
+
};
|
|
234
|
+
window.requestAnimationFrame(run);
|
|
235
|
+
}
|
|
236
|
+
|
|
225
237
|
interface ContentSidebarStateSnapshot {
|
|
226
238
|
version: typeof CONTENT_SIDEBAR_STATE_VERSION;
|
|
227
239
|
expandedWorkspaceIds: string[];
|
|
@@ -309,10 +321,80 @@ function withPersonalSidebarOrder(
|
|
|
309
321
|
};
|
|
310
322
|
}
|
|
311
323
|
|
|
324
|
+
const INITIAL_EXPANDED_WORKSPACE_READ_DELAY_MS = 250;
|
|
325
|
+
const DATABASE_PAGE_READY_FALLBACK_MS = 15_000;
|
|
326
|
+
const DATABASE_ROWS_VISIBLE_EVENT = "content-database-rows-visible";
|
|
327
|
+
|
|
328
|
+
function useDeferredFilesDatabaseId(
|
|
329
|
+
databaseId: string,
|
|
330
|
+
expanded: boolean,
|
|
331
|
+
deferUntilDocumentId: string | null,
|
|
332
|
+
) {
|
|
333
|
+
const previouslyExpanded = useRef(expanded);
|
|
334
|
+
const [ready, setReady] = useState(false);
|
|
335
|
+
|
|
336
|
+
useEffect(() => {
|
|
337
|
+
const wasExpanded = previouslyExpanded.current;
|
|
338
|
+
previouslyExpanded.current = expanded;
|
|
339
|
+
if (!expanded) {
|
|
340
|
+
setReady(false);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (!wasExpanded) {
|
|
344
|
+
setReady(true);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (deferUntilDocumentId) {
|
|
349
|
+
if (
|
|
350
|
+
window.document.documentElement.dataset
|
|
351
|
+
.contentDatabaseRowsVisibleDocumentId === deferUntilDocumentId
|
|
352
|
+
) {
|
|
353
|
+
setReady(true);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
setReady(false);
|
|
357
|
+
const handleRowsVisible = (event: Event) => {
|
|
358
|
+
if (
|
|
359
|
+
(event as CustomEvent<{ documentId?: string }>).detail?.documentId ===
|
|
360
|
+
deferUntilDocumentId
|
|
361
|
+
) {
|
|
362
|
+
setReady(true);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
window.addEventListener(DATABASE_ROWS_VISIBLE_EVENT, handleRowsVisible);
|
|
366
|
+
const fallback = window.setTimeout(
|
|
367
|
+
() => setReady(true),
|
|
368
|
+
DATABASE_PAGE_READY_FALLBACK_MS,
|
|
369
|
+
);
|
|
370
|
+
return () => {
|
|
371
|
+
window.removeEventListener(
|
|
372
|
+
DATABASE_ROWS_VISIBLE_EVENT,
|
|
373
|
+
handleRowsVisible,
|
|
374
|
+
);
|
|
375
|
+
window.clearTimeout(fallback);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// An already-expanded workspace can contain thousands of files. Give the
|
|
380
|
+
// selected page's critical read one turn before starting that inventory;
|
|
381
|
+
// direct expansion remains immediate.
|
|
382
|
+
setReady(false);
|
|
383
|
+
const timeout = window.setTimeout(
|
|
384
|
+
() => setReady(true),
|
|
385
|
+
INITIAL_EXPANDED_WORKSPACE_READ_DELAY_MS,
|
|
386
|
+
);
|
|
387
|
+
return () => window.clearTimeout(timeout);
|
|
388
|
+
}, [databaseId, deferUntilDocumentId, expanded]);
|
|
389
|
+
|
|
390
|
+
return expanded && ready ? databaseId : null;
|
|
391
|
+
}
|
|
392
|
+
|
|
312
393
|
function WorkspaceSidebarItem({
|
|
313
394
|
space,
|
|
314
395
|
selected,
|
|
315
396
|
expanded,
|
|
397
|
+
deferInitialReadUntilDocumentId,
|
|
316
398
|
reorder,
|
|
317
399
|
createDocumentPending,
|
|
318
400
|
activeDocumentId,
|
|
@@ -329,6 +411,7 @@ function WorkspaceSidebarItem({
|
|
|
329
411
|
space: ContentSpaceSummary;
|
|
330
412
|
selected: boolean;
|
|
331
413
|
expanded: boolean;
|
|
414
|
+
deferInitialReadUntilDocumentId: string | null;
|
|
332
415
|
reorder?: ContentFilesSidebarRenderReorder;
|
|
333
416
|
createDocumentPending: boolean;
|
|
334
417
|
activeDocumentId: string | null;
|
|
@@ -349,7 +432,11 @@ function WorkspaceSidebarItem({
|
|
|
349
432
|
onToggleFavorite: (item: ContentDatabaseItem) => void;
|
|
350
433
|
}) {
|
|
351
434
|
const t = useT();
|
|
352
|
-
const activeFilesDatabaseId =
|
|
435
|
+
const activeFilesDatabaseId = useDeferredFilesDatabaseId(
|
|
436
|
+
space.filesDatabaseId,
|
|
437
|
+
expanded,
|
|
438
|
+
deferInitialReadUntilDocumentId,
|
|
439
|
+
);
|
|
353
440
|
const filesDatabase = useContentDatabaseById(activeFilesDatabaseId);
|
|
354
441
|
const filesDatabaseData = isContentDatabaseUnavailable(filesDatabase.data)
|
|
355
442
|
? undefined
|
|
@@ -906,6 +993,11 @@ export function DocumentSidebar({
|
|
|
906
993
|
}, [setStoredCollapsedSections]);
|
|
907
994
|
const [removeLocalFilesDialogOpen, setRemoveLocalFilesDialogOpen] =
|
|
908
995
|
useState(false);
|
|
996
|
+
const [pendingDelete, setPendingDelete] = useState<{
|
|
997
|
+
id: string;
|
|
998
|
+
title: string;
|
|
999
|
+
} | null>(null);
|
|
1000
|
+
const confirmedDeleteIdRef = useRef<string | null>(null);
|
|
909
1001
|
const settingsActive = location.pathname.startsWith("/settings");
|
|
910
1002
|
const sensors = useSensors(
|
|
911
1003
|
useSensor(PointerSensor, {
|
|
@@ -1258,6 +1350,12 @@ export function DocumentSidebar({
|
|
|
1258
1350
|
],
|
|
1259
1351
|
);
|
|
1260
1352
|
|
|
1353
|
+
const requestDelete = useCallback((id: string, title: string) => {
|
|
1354
|
+
afterBodyPointerUnlock(() => {
|
|
1355
|
+
setPendingDelete({ id, title });
|
|
1356
|
+
});
|
|
1357
|
+
}, []);
|
|
1358
|
+
|
|
1261
1359
|
const handleReorderPage = useCallback(
|
|
1262
1360
|
async (id: string, overId: string) => {
|
|
1263
1361
|
if (id === overId) return;
|
|
@@ -1520,7 +1618,7 @@ export function DocumentSidebar({
|
|
|
1520
1618
|
}}
|
|
1521
1619
|
onCreateChildPage={(parentId) => handleCreatePage(parentId)}
|
|
1522
1620
|
onCreateChildDatabase={(parentId) => handleCreateDatabase(parentId)}
|
|
1523
|
-
onDelete={
|
|
1621
|
+
onDelete={requestDelete}
|
|
1524
1622
|
onToggleFavorite={handleToggleFavorite}
|
|
1525
1623
|
/>
|
|
1526
1624
|
))}
|
|
@@ -1805,6 +1903,12 @@ export function DocumentSidebar({
|
|
|
1805
1903
|
space={space}
|
|
1806
1904
|
selected={selectedSpace?.id === space.id}
|
|
1807
1905
|
expanded={expandedWorkspaceIds.includes(space.id)}
|
|
1906
|
+
deferInitialReadUntilDocumentId={
|
|
1907
|
+
activeDocumentId &&
|
|
1908
|
+
databaseDocuments.some((document) => document.id === activeDocumentId)
|
|
1909
|
+
? activeDocumentId
|
|
1910
|
+
: null
|
|
1911
|
+
}
|
|
1808
1912
|
reorder={reorder}
|
|
1809
1913
|
createDocumentPending={createDocument.isPending}
|
|
1810
1914
|
activeDocumentId={activeDocumentId}
|
|
@@ -1832,7 +1936,12 @@ export function DocumentSidebar({
|
|
|
1832
1936
|
onCreateChildDatabase={(nextSpace, item) =>
|
|
1833
1937
|
void handleCreateDatabase(item.document.id, nextSpace.id)
|
|
1834
1938
|
}
|
|
1835
|
-
onDeleteItem={(item) =>
|
|
1939
|
+
onDeleteItem={(item) =>
|
|
1940
|
+
requestDelete(
|
|
1941
|
+
item.document.id,
|
|
1942
|
+
item.document.title || t("sidebar.untitled"),
|
|
1943
|
+
)
|
|
1944
|
+
}
|
|
1836
1945
|
onToggleFavorite={(item) =>
|
|
1837
1946
|
handleToggleFavorite(item.document.id, !item.document.isFavorite)
|
|
1838
1947
|
}
|
|
@@ -2348,7 +2457,10 @@ export function DocumentSidebar({
|
|
|
2348
2457
|
void handleCreateDatabase(item.document.id)
|
|
2349
2458
|
}
|
|
2350
2459
|
onDeleteItem={(item) =>
|
|
2351
|
-
|
|
2460
|
+
requestDelete(
|
|
2461
|
+
item.document.id,
|
|
2462
|
+
item.document.title || t("sidebar.untitled"),
|
|
2463
|
+
)
|
|
2352
2464
|
}
|
|
2353
2465
|
onToggleFavorite={(item) =>
|
|
2354
2466
|
handleToggleFavorite(item.document.id, false)
|
|
@@ -2416,6 +2528,49 @@ export function DocumentSidebar({
|
|
|
2416
2528
|
onMouseDown={handleMouseDown}
|
|
2417
2529
|
/>
|
|
2418
2530
|
)}
|
|
2531
|
+
<AlertDialog
|
|
2532
|
+
open={pendingDelete !== null}
|
|
2533
|
+
onOpenChange={(open) => {
|
|
2534
|
+
if (open) return;
|
|
2535
|
+
setPendingDelete(null);
|
|
2536
|
+
const confirmedDeleteId = confirmedDeleteIdRef.current;
|
|
2537
|
+
confirmedDeleteIdRef.current = null;
|
|
2538
|
+
if (confirmedDeleteId) {
|
|
2539
|
+
afterBodyPointerUnlock(() => {
|
|
2540
|
+
void handleDelete(confirmedDeleteId);
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
}}
|
|
2544
|
+
>
|
|
2545
|
+
<AlertDialogContent>
|
|
2546
|
+
<AlertDialogHeader>
|
|
2547
|
+
<AlertDialogTitle>
|
|
2548
|
+
{t("sidebar.deletePageQuestion")}
|
|
2549
|
+
</AlertDialogTitle>
|
|
2550
|
+
<AlertDialogDescription>
|
|
2551
|
+
{pendingDelete
|
|
2552
|
+
? t("sidebar.deletePageDescription", {
|
|
2553
|
+
title: pendingDelete.title,
|
|
2554
|
+
})
|
|
2555
|
+
: null}
|
|
2556
|
+
</AlertDialogDescription>
|
|
2557
|
+
</AlertDialogHeader>
|
|
2558
|
+
<AlertDialogFooter>
|
|
2559
|
+
<AlertDialogCancel>{t("comments.cancel")}</AlertDialogCancel>
|
|
2560
|
+
<AlertDialogAction
|
|
2561
|
+
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
2562
|
+
disabled={
|
|
2563
|
+
deleteDocument.isPending || deleteContentDatabase.isPending
|
|
2564
|
+
}
|
|
2565
|
+
onClick={() => {
|
|
2566
|
+
confirmedDeleteIdRef.current = pendingDelete?.id ?? null;
|
|
2567
|
+
}}
|
|
2568
|
+
>
|
|
2569
|
+
{t("database.delete")}
|
|
2570
|
+
</AlertDialogAction>
|
|
2571
|
+
</AlertDialogFooter>
|
|
2572
|
+
</AlertDialogContent>
|
|
2573
|
+
</AlertDialog>
|
|
2419
2574
|
<AlertDialog
|
|
2420
2575
|
open={removeLocalFilesDialogOpen}
|
|
2421
2576
|
onOpenChange={setRemoveLocalFilesDialogOpen}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
verticalListSortingStrategy,
|
|
7
7
|
} from "@dnd-kit/sortable";
|
|
8
8
|
import { CSS } from "@dnd-kit/utilities";
|
|
9
|
-
import type {
|
|
9
|
+
import type { DocumentTreeNode } from "@shared/api";
|
|
10
10
|
import {
|
|
11
11
|
IconChevronRight,
|
|
12
12
|
IconDatabase,
|
|
@@ -19,16 +19,6 @@ import {
|
|
|
19
19
|
} from "@tabler/icons-react";
|
|
20
20
|
import { useState } from "react";
|
|
21
21
|
|
|
22
|
-
import {
|
|
23
|
-
AlertDialog,
|
|
24
|
-
AlertDialogAction,
|
|
25
|
-
AlertDialogCancel,
|
|
26
|
-
AlertDialogContent,
|
|
27
|
-
AlertDialogDescription,
|
|
28
|
-
AlertDialogFooter,
|
|
29
|
-
AlertDialogHeader,
|
|
30
|
-
AlertDialogTitle,
|
|
31
|
-
} from "@/components/ui/alert-dialog";
|
|
32
22
|
import {
|
|
33
23
|
DropdownMenu,
|
|
34
24
|
DropdownMenuContent,
|
|
@@ -53,7 +43,7 @@ interface DocumentTreeItemProps {
|
|
|
53
43
|
onSelect: (id: string) => void;
|
|
54
44
|
onCreateChildPage: (parentId: string) => void;
|
|
55
45
|
onCreateChildDatabase: (parentId: string) => void;
|
|
56
|
-
onDelete: (id: string) => void;
|
|
46
|
+
onDelete: (id: string, title: string) => void;
|
|
57
47
|
onToggleFavorite: (id: string, isFavorite: boolean) => void;
|
|
58
48
|
}
|
|
59
49
|
|
|
@@ -88,178 +78,6 @@ export function DocumentSidebarIcon({
|
|
|
88
78
|
return <IconFileText size={14} className="text-muted-foreground" />;
|
|
89
79
|
}
|
|
90
80
|
|
|
91
|
-
export function FavoriteDocumentItem({
|
|
92
|
-
document,
|
|
93
|
-
active,
|
|
94
|
-
sidebarWidth,
|
|
95
|
-
onSelect,
|
|
96
|
-
onCreateChildPage,
|
|
97
|
-
onCreateChildDatabase,
|
|
98
|
-
onRemoveFavorite,
|
|
99
|
-
onDelete,
|
|
100
|
-
}: {
|
|
101
|
-
document: Document;
|
|
102
|
-
active: boolean;
|
|
103
|
-
sidebarWidth?: number;
|
|
104
|
-
onSelect: () => void;
|
|
105
|
-
onCreateChildPage: () => void;
|
|
106
|
-
onCreateChildDatabase: () => void;
|
|
107
|
-
onRemoveFavorite: () => void;
|
|
108
|
-
onDelete: () => void;
|
|
109
|
-
}) {
|
|
110
|
-
const t = useT();
|
|
111
|
-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
112
|
-
const canEdit = document.canEdit !== false;
|
|
113
|
-
const canManage =
|
|
114
|
-
document.canManage === true ||
|
|
115
|
-
document.accessRole === "owner" ||
|
|
116
|
-
document.accessRole === "admin";
|
|
117
|
-
const canCreateChild = canEdit && document.source?.mode !== "local-files";
|
|
118
|
-
const title = document.title || t("sidebar.untitled");
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<div
|
|
122
|
-
className={cn(
|
|
123
|
-
"group relative flex min-w-0 cursor-pointer items-center gap-1.5 rounded-md py-[5px] pe-2 text-sm",
|
|
124
|
-
active
|
|
125
|
-
? "font-semibold text-foreground"
|
|
126
|
-
: "text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
127
|
-
)}
|
|
128
|
-
style={{
|
|
129
|
-
paddingInlineStart: "26px",
|
|
130
|
-
width:
|
|
131
|
-
sidebarWidth === undefined
|
|
132
|
-
? undefined
|
|
133
|
-
: `${Math.max(0, sidebarWidth)}px`,
|
|
134
|
-
}}
|
|
135
|
-
aria-label={title}
|
|
136
|
-
>
|
|
137
|
-
<button
|
|
138
|
-
type="button"
|
|
139
|
-
className="absolute inset-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
140
|
-
aria-label={`Open ${title}`}
|
|
141
|
-
onClick={onSelect}
|
|
142
|
-
/>
|
|
143
|
-
<span className="pointer-events-none relative flex h-5 w-5 shrink-0 items-center justify-center text-center">
|
|
144
|
-
<DocumentSidebarIcon document={document} />
|
|
145
|
-
</span>
|
|
146
|
-
<span className="pointer-events-none relative min-w-0 flex-1 truncate pe-12">
|
|
147
|
-
{title}
|
|
148
|
-
</span>
|
|
149
|
-
<div
|
|
150
|
-
className={cn(
|
|
151
|
-
"pointer-events-none absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 rounded-md bg-accent px-0.5 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100",
|
|
152
|
-
active && "text-accent-foreground",
|
|
153
|
-
)}
|
|
154
|
-
onPointerDown={(event) => event.stopPropagation()}
|
|
155
|
-
onClick={(event) => event.stopPropagation()}
|
|
156
|
-
>
|
|
157
|
-
{(canEdit || canManage) && (
|
|
158
|
-
<DropdownMenu>
|
|
159
|
-
<DropdownMenuTrigger asChild>
|
|
160
|
-
<button
|
|
161
|
-
type="button"
|
|
162
|
-
className="flex h-6 w-6 items-center justify-center rounded hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
163
|
-
aria-label={`More actions for ${title}`}
|
|
164
|
-
onClick={(event) => event.stopPropagation()}
|
|
165
|
-
>
|
|
166
|
-
<IconDots size={14} />
|
|
167
|
-
</button>
|
|
168
|
-
</DropdownMenuTrigger>
|
|
169
|
-
<DropdownMenuContent align="start" className="w-48">
|
|
170
|
-
{canEdit && (
|
|
171
|
-
<DropdownMenuItem
|
|
172
|
-
onClick={(event) => {
|
|
173
|
-
event.stopPropagation();
|
|
174
|
-
onRemoveFavorite();
|
|
175
|
-
}}
|
|
176
|
-
>
|
|
177
|
-
<IconStar size={14} className="me-2 fill-current" />
|
|
178
|
-
{t("sidebar.unpinFromSidebar")}
|
|
179
|
-
</DropdownMenuItem>
|
|
180
|
-
)}
|
|
181
|
-
{canEdit && canManage && <DropdownMenuSeparator />}
|
|
182
|
-
{canManage && (
|
|
183
|
-
<DropdownMenuItem
|
|
184
|
-
className="text-destructive"
|
|
185
|
-
onClick={(event) => {
|
|
186
|
-
event.stopPropagation();
|
|
187
|
-
setDeleteDialogOpen(true);
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
<IconTrash size={14} className="me-2" />
|
|
191
|
-
{t("database.delete")}
|
|
192
|
-
</DropdownMenuItem>
|
|
193
|
-
)}
|
|
194
|
-
</DropdownMenuContent>
|
|
195
|
-
</DropdownMenu>
|
|
196
|
-
)}
|
|
197
|
-
{canCreateChild && (
|
|
198
|
-
<DropdownMenu>
|
|
199
|
-
<Tooltip>
|
|
200
|
-
<TooltipTrigger asChild>
|
|
201
|
-
<DropdownMenuTrigger asChild>
|
|
202
|
-
<button
|
|
203
|
-
type="button"
|
|
204
|
-
className="flex h-7 w-7 items-center justify-center rounded hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
205
|
-
aria-label={t("sidebar.addChildTo", { title })}
|
|
206
|
-
onClick={(event) => event.stopPropagation()}
|
|
207
|
-
>
|
|
208
|
-
<IconPlus size={14} />
|
|
209
|
-
</button>
|
|
210
|
-
</DropdownMenuTrigger>
|
|
211
|
-
</TooltipTrigger>
|
|
212
|
-
<TooltipContent>{t("sidebar.addChild")}</TooltipContent>
|
|
213
|
-
</Tooltip>
|
|
214
|
-
<DropdownMenuContent align="start" className="w-44">
|
|
215
|
-
<DropdownMenuItem
|
|
216
|
-
onClick={(event) => {
|
|
217
|
-
event.stopPropagation();
|
|
218
|
-
onCreateChildPage();
|
|
219
|
-
}}
|
|
220
|
-
>
|
|
221
|
-
<IconFileText className="me-2 size-4" />
|
|
222
|
-
{t("sidebar.page")}
|
|
223
|
-
</DropdownMenuItem>
|
|
224
|
-
<DropdownMenuItem
|
|
225
|
-
onClick={(event) => {
|
|
226
|
-
event.stopPropagation();
|
|
227
|
-
onCreateChildDatabase();
|
|
228
|
-
}}
|
|
229
|
-
>
|
|
230
|
-
<IconDatabase className="me-2 size-4" />
|
|
231
|
-
{t("sidebar.database")}
|
|
232
|
-
</DropdownMenuItem>
|
|
233
|
-
</DropdownMenuContent>
|
|
234
|
-
</DropdownMenu>
|
|
235
|
-
)}
|
|
236
|
-
</div>
|
|
237
|
-
|
|
238
|
-
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
|
|
239
|
-
<AlertDialogContent>
|
|
240
|
-
<AlertDialogHeader>
|
|
241
|
-
<AlertDialogTitle>
|
|
242
|
-
{t("sidebar.deletePageQuestion")}
|
|
243
|
-
</AlertDialogTitle>
|
|
244
|
-
<AlertDialogDescription>
|
|
245
|
-
{t("sidebar.deletePageDescription", { title })}
|
|
246
|
-
</AlertDialogDescription>
|
|
247
|
-
</AlertDialogHeader>
|
|
248
|
-
<AlertDialogFooter>
|
|
249
|
-
<AlertDialogCancel>{t("comments.cancel")}</AlertDialogCancel>
|
|
250
|
-
<AlertDialogAction
|
|
251
|
-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
252
|
-
onClick={onDelete}
|
|
253
|
-
>
|
|
254
|
-
{t("database.delete")}
|
|
255
|
-
</AlertDialogAction>
|
|
256
|
-
</AlertDialogFooter>
|
|
257
|
-
</AlertDialogContent>
|
|
258
|
-
</AlertDialog>
|
|
259
|
-
</div>
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
81
|
export function DocumentTreeItem({
|
|
264
82
|
node,
|
|
265
83
|
depth,
|
|
@@ -286,7 +104,6 @@ export function DocumentTreeItem({
|
|
|
286
104
|
node.accessRole === "admin";
|
|
287
105
|
const hasMenuActions = canEdit || canManage;
|
|
288
106
|
const canCreateChild = canEdit && !isLocalFileNode;
|
|
289
|
-
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
290
107
|
const [contextSheetOpen, setContextSheetOpen] = useState(false);
|
|
291
108
|
const indent = depth * 12 + 12;
|
|
292
109
|
const rowWidth =
|
|
@@ -439,9 +256,9 @@ export function DocumentTreeItem({
|
|
|
439
256
|
{canManage && (
|
|
440
257
|
<DropdownMenuItem
|
|
441
258
|
className="text-destructive"
|
|
442
|
-
|
|
259
|
+
onSelect={(e) => {
|
|
443
260
|
e.stopPropagation();
|
|
444
|
-
|
|
261
|
+
onDelete(node.id, node.title || t("sidebar.untitled"));
|
|
445
262
|
}}
|
|
446
263
|
>
|
|
447
264
|
<IconTrash size={14} className="me-2" />
|
|
@@ -534,30 +351,6 @@ export function DocumentTreeItem({
|
|
|
534
351
|
))}
|
|
535
352
|
</SortableContext>
|
|
536
353
|
)}
|
|
537
|
-
|
|
538
|
-
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
|
|
539
|
-
<AlertDialogContent>
|
|
540
|
-
<AlertDialogHeader>
|
|
541
|
-
<AlertDialogTitle>
|
|
542
|
-
{t("sidebar.deletePageQuestion")}
|
|
543
|
-
</AlertDialogTitle>
|
|
544
|
-
<AlertDialogDescription>
|
|
545
|
-
{t("sidebar.deletePageDescription", {
|
|
546
|
-
title: node.title || t("sidebar.untitled"),
|
|
547
|
-
})}
|
|
548
|
-
</AlertDialogDescription>
|
|
549
|
-
</AlertDialogHeader>
|
|
550
|
-
<AlertDialogFooter>
|
|
551
|
-
<AlertDialogCancel>{t("comments.cancel")}</AlertDialogCancel>
|
|
552
|
-
<AlertDialogAction
|
|
553
|
-
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
554
|
-
onClick={() => onDelete(node.id)}
|
|
555
|
-
>
|
|
556
|
-
{t("database.delete")}
|
|
557
|
-
</AlertDialogAction>
|
|
558
|
-
</AlertDialogFooter>
|
|
559
|
-
</AlertDialogContent>
|
|
560
|
-
</AlertDialog>
|
|
561
354
|
</div>
|
|
562
355
|
);
|
|
563
356
|
}
|