Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
refactor(layouts): extract DetailTwoPanelLayout, consume in the 4 detail pages
Sergey Kozyrenko7c8f017b2724
diff --git a/frontend/src/components/shared/detail-two-panel-layout.tsx b/frontend/src/components/shared/detail-two-panel-layout.tsxnew file mode 100644index 00000000..72e02fea--- /dev/null+++ b/frontend/src/components/shared/detail-two-panel-layout.tsx@@ -0,0 +1,47 @@+import type { ReactNode } from 'react';++import { GripVertical } from 'lucide-react';++import { Card, CardContent } from '@/components/ui/card';+import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';++interface DetailTwoPanelLayoutProps {+ left: ReactNode;+ right: ReactNode;+ rightClassName?: string;+}++export function DetailTwoPanelLayout({+ left,+ right,+ rightClassName = 'flex h-full min-h-0 flex-col overflow-y-auto p-4',+}: DetailTwoPanelLayoutProps) {+ return (+ <div className="flex min-h-0 w-full max-w-full flex-1 overflow-hidden">+ <ResizablePanelGroup+ className="w-full"+ orientation="horizontal"+ >+ <ResizablePanel+ defaultSize={45}+ minSize={30}+ >+ <div className="h-full min-h-0 overflow-y-auto">+ <Card className="mx-auto min-h-full w-full max-w-2xl rounded-none border-0">+ <CardContent className="flex flex-col gap-6 py-6">{left}</CardContent>+ </Card>+ </div>+ </ResizablePanel>+ <ResizableHandle withHandle>+ <GripVertical className="size-4" />+ </ResizableHandle>+ <ResizablePanel+ defaultSize={55}+ minSize={30}+ >+ <div className={rightClassName}>{right}</div>+ </ResizablePanel>+ </ResizablePanelGroup>+ </div>+ );+}diff --git a/frontend/src/features/knowledges/knowledge-form-layout.tsx b/frontend/src/features/knowledges/knowledge-form-layout.tsxindex 3aa51a45..49ae51cb 100644--- a/frontend/src/features/knowledges/knowledge-form-layout.tsx+++ b/frontend/src/features/knowledges/knowledge-form-layout.tsx@@ -1,12 +1,9 @@import type { Control } from 'react-hook-form';-import { GripVertical } from 'lucide-react';-import type { KnowledgeDocumentFragmentFragment } from '@/graphql/types';+import { DetailTwoPanelLayout } from '@/components/shared/detail-two-panel-layout';import { Badge } from '@/components/ui/badge';-import { Card, CardContent } from '@/components/ui/card';-import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';import type { FormValues } from './knowledge-form';@@ -25,51 +22,38 @@ interface KnowledgeIntroBlockProps {knowledge?: KnowledgeDocumentFragmentFragment | null;}-export function KnowledgeFormLayoutDesktop({ control, isNew, isSaving, knowledge, viewMode }: KnowledgeFormLayoutProps) {+export function KnowledgeFormLayoutDesktop({+ control,+ isNew,+ isSaving,+ knowledge,+ viewMode,+}: KnowledgeFormLayoutProps) {return (- <div className="flex min-h-0 w-full max-w-full flex-1 overflow-hidden">- <ResizablePanelGroup- className="w-full"- orientation="horizontal"- >- <ResizablePanel- defaultSize={45}- minSize={30}- >- <div className="h-full min-h-0 overflow-y-auto">- <Card className="mx-auto min-h-full w-full max-w-2xl rounded-none border-0">- <CardContent className="flex flex-col gap-6 py-6">- <KnowledgeIntroBlock- isNew={isNew}- knowledge={knowledge}- />- <KnowledgeMetaFields- control={control}- isNew={isNew}- isSaving={isSaving}- />- </CardContent>- </Card>- </div>- </ResizablePanel>- <ResizableHandle withHandle>- <GripVertical className="size-4" />- </ResizableHandle>- <ResizablePanel- defaultSize={55}- minSize={30}- >- <div className="flex h-full min-h-0 flex-col overflow-hidden p-4">- <KnowledgeContentField- control={control}- fillParent- isSaving={isSaving}- viewMode={viewMode}- />- </div>- </ResizablePanel>- </ResizablePanelGroup>- </div>+ <DetailTwoPanelLayout+ left={+ <>+ <KnowledgeIntroBlock+ isNew={isNew}+ knowledge={knowledge}+ />+ <KnowledgeMetaFields+ control={control}+ isNew={isNew}+ isSaving={isSaving}+ />+ </>+ }+ right={+ <KnowledgeContentField+ control={control}+ fillParent+ isSaving={isSaving}+ viewMode={viewMode}+ />+ }+ rightClassName="flex h-full min-h-0 flex-col overflow-hidden p-4"+ />);}diff --git a/frontend/src/pages/settings/settings-prompt.tsx b/frontend/src/pages/settings/settings-prompt.tsxindex edc642a1..2c4326b0 100644--- a/frontend/src/pages/settings/settings-prompt.tsx+++ b/frontend/src/pages/settings/settings-prompt.tsx@@ -9,7 +9,6 @@ import {Ellipsis,FileDiff,FileText,- GripVertical,Loader2,RotateCcw,Save,@@ -62,12 +61,12 @@ import {AppHeaderTitle,} from '@/components/layouts/app/app-header';import ConfirmationDialog from '@/components/shared/confirmation-dialog';+import { DetailTwoPanelLayout } from '@/components/shared/detail-two-panel-layout';import { findVariableUseRanges, VARIABLE_RE, variableProbe } from '@/components/shared/editor-variable-highlight';import { UnsavedChangesDialog, useUnsavedChangesGuard } from '@/components/shared/unsaved-changes';import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';-import { Card, CardContent } from '@/components/ui/card';import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';import {DropdownMenu,@@ -78,7 +77,6 @@ import {} from '@/components/ui/dropdown-menu';import { Form, FormControl, FormItem, FormLabel, FormMessage } from '@/components/ui/form';import { FormSubmitButton } from '@/components/ui/form-submit-button';-import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';import { StatusCard } from '@/components/ui/status-card';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import { Textarea } from '@/components/ui/textarea';@@ -1069,35 +1067,15 @@ function SettingsPrompt() {value={activeTab}>{isDesktop ? (- <div className="flex min-h-0 w-full max-w-full flex-1 overflow-hidden">- <ResizablePanelGroup- className="w-full"- orientation="horizontal"- >- <ResizablePanel- defaultSize={45}- minSize={30}- >- <div className="h-full min-h-0 overflow-y-auto">- <Card className="mx-auto min-h-full w-full max-w-2xl rounded-none border-0">- <CardContent className="flex flex-col gap-6 py-6">- {promptMeta}- {variablesPanel}- </CardContent>- </Card>- </div>- </ResizablePanel>- <ResizableHandle withHandle>- <GripVertical className="size-4" />- </ResizableHandle>- <ResizablePanel- defaultSize={55}- minSize={30}- >- <div className="flex h-full min-h-0 flex-col overflow-y-auto p-4">{promptEditor}</div>- </ResizablePanel>- </ResizablePanelGroup>- </div>+ <DetailTwoPanelLayout+ left={+ <>+ {promptMeta}+ {variablesPanel}+ </>+ }+ right={promptEditor}+ />) : (<div className="flex min-h-0 flex-1 flex-col gap-4 p-4">{promptMeta}diff --git a/frontend/src/pages/settings/settings-provider.tsx b/frontend/src/pages/settings/settings-provider.tsxindex 1c63cc25..6246a7e4 100644--- a/frontend/src/pages/settings/settings-provider.tsx+++ b/frontend/src/pages/settings/settings-provider.tsx@@ -7,7 +7,6 @@ import {ChevronsUpDown,Clock,Ellipsis,- GripVertical,Lightbulb,Loader2,Play,@@ -41,11 +40,11 @@ import {AppHeaderTitle,} from '@/components/layouts/app/app-header';import ConfirmationDialog from '@/components/shared/confirmation-dialog';+import { DetailTwoPanelLayout } from '@/components/shared/detail-two-panel-layout';import { UnsavedChangesDialog, useUnsavedChangesGuard } from '@/components/shared/unsaved-changes';import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';-import { Card, CardContent } from '@/components/ui/card';import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command';import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';import {@@ -59,7 +58,6 @@ import { FormSubmitButton } from '@/components/ui/form-submit-button';import { Input } from '@/components/ui/input';import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/components/ui/input-group';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';-import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';import { StatusCard } from '@/components/ui/status-card';import {@@ -1880,32 +1878,11 @@ function SettingsProvider() {onSubmit={handleFormSubmit(handleSubmit)}>{isDesktop ? (- <div className="flex min-h-0 w-full max-w-full flex-1 overflow-hidden">- <ResizablePanelGroup- className="w-full"- orientation="horizontal"- >- <ResizablePanel- defaultSize={45}- minSize={30}- >- <div className="h-full min-h-0 overflow-y-auto">- <Card className="mx-auto min-h-full w-full max-w-2xl rounded-none border-0">- <CardContent className="flex flex-col gap-6 py-6">{metaFields}</CardContent>- </Card>- </div>- </ResizablePanel>- <ResizableHandle withHandle>- <GripVertical className="size-4" />- </ResizableHandle>- <ResizablePanel- defaultSize={55}- minSize={30}- >- <div className="h-full min-h-0 overflow-y-auto p-4">{agentConfigs}</div>- </ResizablePanel>- </ResizablePanelGroup>- </div>+ <DetailTwoPanelLayout+ left={metaFields}+ right={agentConfigs}+ rightClassName="h-full min-h-0 overflow-y-auto p-4"+ />) : (<div className="flex min-h-0 flex-1 flex-col gap-4 p-4">{metaFields}diff --git a/frontend/src/pages/templates/template.tsx b/frontend/src/pages/templates/template.tsxindex 5686e31a..75f28775 100644--- a/frontend/src/pages/templates/template.tsx+++ b/frontend/src/pages/templates/template.tsx@@ -2,19 +2,7 @@ import type { ReactNode } from 'react';import { skipToken, useQuery } from '@apollo/client/react';import { zodResolver } from '@hookform/resolvers/zod';-import {- ChevronDown,- Code,- Ellipsis,- FileSymlink,- FileText,- GripVertical,- Loader2,- Pencil,- Save,- Trash,- Type,-} from 'lucide-react';+import { ChevronDown, Code, Ellipsis, FileSymlink, FileText, Loader2, Pencil, Save, Trash, Type } from 'lucide-react';import { lazy, Suspense, useCallback, useMemo, useState } from 'react';import { useForm } from 'react-hook-form';import { useNavigate, useParams } from 'react-router-dom';@@ -28,6 +16,7 @@ import {DetailNavigationSheet,DetailNavigationToolbar,} from '@/components/shared/detail-navigation';+import { DetailTwoPanelLayout } from '@/components/shared/detail-two-panel-layout';import { InlineEditInput, useInlineEdit } from '@/components/shared/inline-edit';import { UnsavedChangesDialog, useUnsavedChangesGuard } from '@/components/shared/unsaved-changes';import { Badge } from '@/components/ui/badge';@@ -45,7 +34,6 @@ import {import { Form, FormControl, FormField, FormItem } from '@/components/ui/form';import { FormSubmitButton } from '@/components/ui/form-submit-button';import { Input } from '@/components/ui/input';-import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';import { Spinner } from '@/components/ui/spinner';import { Textarea } from '@/components/ui/textarea';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';@@ -503,7 +491,9 @@ function Template() {className="min-w-24"onCloseAutoFocus={handleDropdownCloseAutoFocus}>- <DropdownMenuItem onClick={() => setViewMode((mode) => (mode === 'code' ? 'plain' : 'code'))}>+ <DropdownMenuItem+ onClick={() => setViewMode((mode) => (mode === 'code' ? 'plain' : 'code'))}+ >{viewMode === 'code' ? <Type className="size-4" /> : <Code className="size-4" />}{viewMode === 'code' ? 'Plain text' : 'Code editor'}</DropdownMenuItem>@@ -744,36 +734,16 @@ function Template() {onSubmit={handleFormSubmit(handleSubmit)}>{isDesktop ? (- <div className="flex min-h-0 w-full max-w-full flex-1 overflow-hidden">- <ResizablePanelGroup- className="w-full"- orientation="horizontal"- >- <ResizablePanel- defaultSize={45}- minSize={30}- >- <div className="h-full min-h-0 overflow-y-auto">- <Card className="mx-auto min-h-full w-full max-w-2xl rounded-none border-0">- <CardContent className="flex flex-col gap-6 py-6">- {introBlock}- {titleField}- {presetsPanel}- </CardContent>- </Card>- </div>- </ResizablePanel>- <ResizableHandle withHandle>- <GripVertical className="size-4" />- </ResizableHandle>- <ResizablePanel- defaultSize={55}- minSize={30}- >- <div className="flex h-full min-h-0 flex-col overflow-y-auto p-4">{textEditor}</div>- </ResizablePanel>- </ResizablePanelGroup>- </div>+ <DetailTwoPanelLayout+ left={+ <>+ {introBlock}+ {titleField}+ {presetsPanel}+ </>+ }+ right={textEditor}+ />) : (<div className="flex min-h-0 flex-1 flex-col gap-4 p-4">{introBlock}