diff --git a/src/app/(main)/(admin)/indexes/[id]/[part]/page.tsx b/src/app/(main)/(admin)/indexes/[id]/[part]/page.tsx
index ca82334e..bdf90570 100644
--- a/src/app/(main)/(admin)/indexes/[id]/[part]/page.tsx
+++ b/src/app/(main)/(admin)/indexes/[id]/[part]/page.tsx
@@ -12,7 +12,7 @@ import dynamic from 'next/dynamic';
import { type ReactElement, Suspense } from 'react';
const GraphEditor = dynamic(() => import('@/components/graph/GraphEditor').then(m => m.GraphEditor), { ssr: false });
-const GraphEntitiesTable = dynamic(() => import('@/components/graph/GraphEntitiesTable').then(m => m.GraphEntitiesTable), { ssr: false });
+const GraphCreateEntity = dynamic(() => import('@/components/graph/GraphCreateEntity').then(m => m.GraphCreateEntity), { ssr: false });
export default function Page ({ params }: PageProps<{ part: string }>) {
const index = useIndex();
@@ -52,7 +52,7 @@ export default function Page ({ params }: PageProps<{ part: string }>) {
case 'graph-entities':
el = (
}>
-
+
);
break;
diff --git a/src/components/graph/GraphCreateEntity.tsx b/src/components/graph/GraphCreateEntity.tsx
new file mode 100644
index 00000000..48965129
--- /dev/null
+++ b/src/components/graph/GraphCreateEntity.tsx
@@ -0,0 +1,169 @@
+import { createSynopsisEntity, type Entity } from '@/components/graph/api';
+import { JsonEditor } from '@/components/graph/components/JsonEditor';
+import { SearchEntity } from '@/components/graph/components/SearchEntity';
+import { SearchEntityById } from '@/components/graph/components/SearchEntityById';
+import { useEntities } from '@/components/graph/selectEntities';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Textarea } from '@/components/ui/textarea';
+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
+import type { Index } from '@/core/repositories/index_';
+import { cn } from '@/lib/utils';
+import { zodResolver } from '@hookform/resolvers/zod';
+import { Loader2Icon, Maximize2Icon } from 'lucide-react';
+import type monaco from 'monaco-editor';
+import { useRouter } from 'next/navigation';
+import { type ReactNode, useRef } from 'react';
+import { useForm } from 'react-hook-form';
+import z from 'zod';
+
+export function GraphCreateEntity ({ index, className }: { index: Index, className?: string }) {
+ const useEntitiesReturns = useEntities();
+ const { clearSelection, ...useEntitiesRequired } = useEntitiesReturns;
+ const { selectedEntities } = useEntitiesRequired;
+ const router = useRouter();
+
+ return (
+
+
+ {
+ const createdEntity = await createSynopsisEntity(data);
+ router.push(`/indexes/${index.id}/graph-editor?query=entity:${createdEntity.id}`);
+ }}
+ onClearSelection={clearSelection}
+ afterEntities={(
+ <>
+
+
+ >
+ )}
+ />
+
+
+ );
+}
+
+function CreateEntityForm ({ className, entities, onSubmit, onClearSelection, afterEntities }: { className?: string, entities: Entity[], onSubmit: (data: z.infer & { meta: any, entities: number[] }) => Promise, onClearSelection: (id?: number) => void, afterEntities?: ReactNode }) {
+ const form = useForm>({
+ resolver: zodResolver(createEntitySchema),
+ defaultValues: {
+ name: '',
+ description: '',
+ topic: '',
+ },
+ });
+ const metaRef = useRef(null);
+
+ const handleSubmit = form.handleSubmit(async values => onSubmit({
+ ...values,
+ meta: JSON.parse(metaRef.current!.getValue()),
+ entities: entities.map(entity => Number(entity.id)),
+ }));
+
+ const containerRef = useRef(null);
+
+ const handleClickFullscreen = () => {
+ containerRef.current?.requestFullscreen();
+ };
+
+ return (
+
+
+ );
+}
+
+const createEntitySchema = z.object({
+ name: z.string().min(1).regex(/\S/),
+ description: z.string().min(1).regex(/\S/),
+ topic: z.string().min(1).regex(/\S/),
+});
diff --git a/src/components/graph/GraphEntitiesTable.tsx b/src/components/graph/GraphEntitiesTable.tsx
deleted file mode 100644
index 36680d72..00000000
--- a/src/components/graph/GraphEntitiesTable.tsx
+++ /dev/null
@@ -1,414 +0,0 @@
-import { metadataCell } from '@/components/cells/metadata';
-import { createSynopsisEntity, type Entity, handleServerEntity, type ServerEntity } from '@/components/graph/api';
-import { JsonEditor } from '@/components/graph/components/JsonEditor';
-import { Loader } from '@/components/loader';
-import { Badge } from '@/components/ui/badge';
-import { Button } from '@/components/ui/button';
-import { Checkbox } from '@/components/ui/checkbox';
-import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
-import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import { Label } from '@/components/ui/label';
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
-import { Textarea } from '@/components/ui/textarea';
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
-import type { Index } from '@/core/repositories/index_';
-import { fetcher } from '@/lib/fetch';
-import { cn } from '@/lib/utils';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { TooltipArrow } from '@radix-ui/react-tooltip';
-import { type ColumnDef, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
-import type { RowSelectionState } from '@tanstack/table-core';
-import { createColumnHelper } from '@tanstack/table-core';
-import isHotkey from 'is-hotkey';
-import { Maximize2Icon, PlusIcon } from 'lucide-react';
-import type monaco from 'monaco-editor';
-import { useRouter } from 'next/navigation';
-import { type ReactNode, useMemo, useRef, useState } from 'react';
-import { useForm } from 'react-hook-form';
-import useSWR from 'swr';
-import z from 'zod';
-
-export function GraphEntitiesTable ({ index, className }: { index: Index, className?: string }) {
- const { filter, setFilter, table, selectedEntities, isLoading, clearSelection, error } = useGraphEntitiesTable();
- const router = useRouter();
-
- return (
-
-
-
{
- const createdEntity = await createSynopsisEntity(data);
- router.push(`/indexes/${index.id}/graph-editor?query=entity:${createdEntity.id}`);
- }}
- onClearSelection={clearSelection}
- afterEntities={(
-
- )}
- />
-
-
- );
-}
-
-function TableFilterForm ({ className, filter, onFilterChange, disabled }: { className?: string, filter: TableFilter, onFilterChange: (filter: TableFilter) => void, disabled?: boolean }) {
- const form = useForm({
- values: filter,
- resolver: zodResolver(tableFilterSchema),
- disabled,
- defaultValues: {
- query: '',
- top_k: undefined,
- },
- });
-
- return (
-
-
- );
-}
-
-function CreateEntityForm ({ className, entities, onSubmit, onClearSelection, afterEntities }: { className?: string, entities: Entity[], onSubmit: (data: z.infer & { meta: any, entities: number[] }) => Promise, onClearSelection: (id?: number) => void, afterEntities?: ReactNode }) {
- const form = useForm>({
- resolver: zodResolver(createEntitySchema),
- defaultValues: {
- name: '',
- description: '',
- topic: '',
- },
- });
- const metaRef = useRef(null);
-
- const handleSubmit = form.handleSubmit(async values => onSubmit({
- ...values,
- meta: JSON.parse(metaRef.current!.getValue()),
- entities: entities.map(entity => Number(entity.id)),
- }));
-
- const containerRef = useRef(null);
-
- const handleClickFullscreen = () => {
- containerRef.current?.requestFullscreen();
- };
-
- return (
-
-
- );
-}
-
-type TableFilter = {
- query: string;
- top_k?: number
-}
-
-const tableFilterSchema = z.object({
- query: z.string(),
- top_k: z.coerce.number().optional(),
-});
-
-const createEntitySchema = z.object({
- name: z.string().min(1).regex(/\S/),
- description: z.string().min(1).regex(/\S/),
- topic: z.string().min(1).regex(/\S/),
-});
-
-function shouldFetch (filter: TableFilter) {
- return !!filter.query.trim();
-}
-
-function useGraphEntitiesTable () {
- const [filter, setFilter] = useState(() => ({ query: '', top_k: undefined }));
-
- const [rowSelection, setRowSelection] = useState({});
- const entityMap = useRef