mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 07:42:39 +02:00
feat: enhance metadata viewing in DocumentsTableShell with on-demand fetching and loading state
This commit is contained in:
parent
c19aa5fa99
commit
c706b5f417
2 changed files with 51 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { FileJson } from "lucide-react";
|
||||
import { FileJson, Loader2 } from "lucide-react";
|
||||
import React from "react";
|
||||
import { defaultStyles, JsonView } from "react-json-view-lite";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
|
@ -17,6 +17,7 @@ interface JsonMetadataViewerProps {
|
|||
trigger?: React.ReactNode;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
export function JsonMetadataViewer({
|
||||
|
|
@ -25,6 +26,7 @@ export function JsonMetadataViewer({
|
|||
trigger,
|
||||
open,
|
||||
onOpenChange,
|
||||
loading,
|
||||
}: JsonMetadataViewerProps) {
|
||||
// Ensure metadata is a valid object
|
||||
const jsonData = React.useMemo(() => {
|
||||
|
|
@ -54,7 +56,13 @@ export function JsonMetadataViewer({
|
|||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="mt-2 sm:mt-4 p-2 sm:p-4 bg-muted/30 rounded-md text-xs sm:text-sm">
|
||||
<JsonView data={jsonData} style={defaultStyles} />
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : (
|
||||
<JsonView data={jsonData} style={defaultStyles} />
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue