Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(app): refactor pages to follow same style

dextmorgn84fc821d9381
diff --git a/flowsint-app/src/components/layout/page-layout.tsx b/flowsint-app/src/components/layout/page-layout.tsx
new file mode 100644
index 00000000..968fd4f4
--- /dev/null
+++ b/flowsint-app/src/components/layout/page-layout.tsx
@@ -0,0 +1,43 @@
+import React from 'react'
+
+interface PageLayoutProps {
+ title: string
+ description?: string
+ actions?: React.ReactNode
+ children: React.ReactNode
+ isLoading?: boolean
+ loadingComponent?: React.ReactNode
+ error?: Error | null
+ errorComponent?: React.ReactNode
+}
+
+export function PageLayout({
+ title,
+ description,
+ actions,
+ children,
+ isLoading,
+ loadingComponent,
+ error,
+ errorComponent
+}: PageLayoutProps) {
+ return (
+ <div className="h-full w-full overflow-y-auto bg-background">
+ <div className="border-b border-border z-10">
+ <div className="max-w-7xl mx-auto p-8">
+ <div className="flex items-center justify-between">
+ <div className="space-y-1">
+ <h1 className="text-2xl font-bold text-foreground">{title}</h1>
+ {description && <p className="text-muted-foreground">{description}</p>}
+ </div>
+ {actions && <div className="flex items-center gap-2">{actions}</div>}
+ </div>
+ </div>
+ </div>
+
+ <div className="max-w-7xl mx-auto p-8 space-y-8">
+ {isLoading ? loadingComponent : error ? errorComponent : children}
+ </div>
+ </div>
+ )
+}
diff --git a/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx b/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
index 8633bcca..39fffdcd 100644
--- a/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.custom-types.index.tsx
@@ -13,6 +13,7 @@ import ErrorState from '@/components/shared/error-state'
import { toast } from 'sonner'
import { useState } from 'react'
import { useConfirm } from '@/components/use-confirm-dialog'
+import { PageLayout } from '@/components/layout/page-layout'
export const Route = createFileRoute('/_auth/dashboard/custom-types/')({
component: CustomTypesPage
@@ -73,41 +74,36 @@ function CustomTypesPage() {
const archivedTypes = customTypes?.filter((t) => t.status === 'archived') || []
return (
- <div className="h-full w-full overflow-y-auto bg-background">
- <div className="border-b border-border z-10">
- <div className="max-w-7xl mx-auto p-8">
- <div className="flex items-center justify-between">
- <div className="space-y-1">
- <h1 className="text-3xl font-bold text-foreground">Custom types</h1>
- <p className="text-muted-foreground">Create and manage your custom data types.</p>
- </div>
- <div className="flex items-center gap-2">
- <Button
- size="sm"
- // @ts-ignore
- onClick={() => navigate({ to: '/dashboard/custom-types/new' })}
- >
- <PlusIcon className="w-4 h-4 mr-2" />
- New custom type
- </Button>
- </div>
- </div>
+ <PageLayout
+ title="Custom types"
+ description="Create and manage your custom data types."
+ isLoading={isLoading}
+ loadingComponent={
+ <div className="p-2">
+ <SkeletonList rowCount={6} mode="card" />
</div>
- </div>
-
- <div className="max-w-7xl mx-auto p-8 space-y-8">
- {isLoading ? (
- <div className="p-2">
- <SkeletonList rowCount={6} mode="card" />
- </div>
- ) : error ? (
- <ErrorState
- title="Couldn't load custom types"
- description="Something went wrong while fetching data. Please try again."
- error={error}
- onRetry={() => refetch()}
- />
- ) : !customTypes?.length ? (
+ }
+ error={error}
+ errorComponent={
+ <ErrorState
+ title="Couldn't load custom types"
+ description="Something went wrong while fetching data. Please try again."
+ error={error}
+ onRetry={() => refetch()}
+ />
+ }
+ actions={
+ <Button
+ size="sm"
+ // @ts-ignore
+ onClick={() => navigate({ to: '/dashboard/custom-types/new' })}
+ >
+ <PlusIcon className="w-4 h-4 mr-2" />
+ New custom type
+ </Button>
+ }
+ >
+ {!customTypes?.length ? (
<div className="flex flex-col items-center justify-center py-12 text-center">
<div className="rounded-full bg-muted/50 p-4 mb-4">
<FileX className="w-8 h-8 text-muted-foreground" />
@@ -151,8 +147,7 @@ function CustomTypesPage() {
</TabsContent>
</Tabs>
)}
- </div>
- </div>
+ </PageLayout>
)
}
diff --git a/flowsint-app/src/routes/_auth.dashboard.flows.index.tsx b/flowsint-app/src/routes/_auth.dashboard.flows.index.tsx
index 84813b7f..9c0eaa76 100644
--- a/flowsint-app/src/routes/_auth.dashboard.flows.index.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.flows.index.tsx
@@ -11,6 +11,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import NewFlow from '@/components/flows/new-flow'
import { flowService } from '@/api/flow-service'
import ErrorState from '@/components/shared/error-state'
+import { PageLayout } from '@/components/layout/page-layout'
interface Flow {
id: string
@@ -53,38 +54,35 @@ function FlowPage() {
const allCategories = ['All', ...categories, 'Uncategorized']
return (
- <div className="h-full w-full overflow-y-auto bg-background">
- <div className="border-b border-border z-10">
- <div className="max-w-7xl mx-auto p-8">
- <div className="flex items-center justify-between">
- <div className="space-y-1">
- <h1 className="text-3xl font-bold text-foreground">Flows</h1>
- <p className="text-muted-foreground">Create and manage your flow flows.</p>
- </div>
- <div className="flex items-center gap-2">
- <NewFlow>
- <Button size="sm" data-tour-id="create-flow">
- <PlusIcon className="w-4 h-4 mr-2" />
- New flow
- </Button>
- </NewFlow>
- </div>
- </div>
+ <PageLayout
+ title="Flows"
+ description="Create and manage your flow flows."
+ isLoading={isLoading}
+ loadingComponent={
+ <div className="p-2">
+ <SkeletonList rowCount={6} mode="card" />
</div>
- </div>
- <div className="max-w-7xl mx-auto p-8 space-y-8" style={{ containerType: 'inline-size' }}>
- {isLoading ? (
- <div className="p-2">
- <SkeletonList rowCount={6} mode="card" />
- </div>
- ) : error ? (
- <ErrorState
- title="Couldn't load flows"
- description="Something went wrong while fetching data. Please try again."
- error={error}
- onRetry={() => refetch()}
- />
- ) : !flows?.length ? (
+ }
+ error={error}
+ errorComponent={
+ <ErrorState
+ title="Couldn't load flows"
+ description="Something went wrong while fetching data. Please try again."
+ error={error}
+ onRetry={() => refetch()}
+ />
+ }
+ actions={
+ <NewFlow>
+ <Button size="sm" data-tour-id="create-flow">
+ <PlusIcon className="w-4 h-4 mr-2" />
+ New flow
+ </Button>
+ </NewFlow>
+ }
+ >
+ <div style={{ containerType: 'inline-size' }}>
+ {!flows?.length ? (
<div className="flex flex-col items-center justify-center py-12 text-center">
<div className="rounded-full bg-muted/50 p-4 mb-4">
<FileX className="w-8 h-8 text-muted-foreground" />
@@ -168,6 +166,6 @@ function FlowPage() {
</Tabs>
)}
</div>
- </div>
+ </PageLayout>
)
}
diff --git a/flowsint-app/src/routes/_auth.dashboard.vault.tsx b/flowsint-app/src/routes/_auth.dashboard.vault.tsx
index 43926f62..c24696f8 100644
--- a/flowsint-app/src/routes/_auth.dashboard.vault.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.vault.tsx
@@ -31,6 +31,7 @@ import Loader from '@/components/loader'
import { type Key as KeyType } from '@/types/key'
import { queryKeys } from '@/api/query-keys'
import ErrorState from '@/components/shared/error-state'
+import { PageLayout } from '@/components/layout/page-layout'
export const Route = createFileRoute('/_auth/dashboard/vault')({
component: VaultPage
})
@@ -101,62 +102,29 @@ function VaultPage() {
}
}
- if (keysLoading) {
- return (
- <div className="h-full w-full px-12 py-12 bg-background overflow-auto">
- <div className="max-w-7xl mx-auto flex h-full flex-col gap-12 items-center justify-start">
- <div className="w-full">
- <h1 className="font-semibold text-2xl">Vault</h1>
- <p className="opacity-60 mt-3">Manage your API keys for third-party services.</p>
- </div>
- <div className="w-full h-full flex items-center justify-center">
- <Loader />
- </div>
- </div>
- </div>
- )
- }
-
- if (keysError) {
- return (
- <div className="h-full w-full px-12 py-12 bg-background overflow-auto">
- <div className="max-w-7xl mx-auto flex h-full flex-col gap-12 items-center justify-start">
- <div className="w-full">
- <h1 className="font-semibold text-2xl">Vault</h1>
- <p className="opacity-60 mt-3">Manage your API keys for third-party services.</p>
- </div>
- <div className="w-full h-full flex items-center justify-center">
- <ErrorState
- title="Couldn't load keys"
- description="Something went wrong while fetching data. Please try again."
- error={keysError}
- onRetry={() => refetch()}
- />
- </div>
- </div>
- </div>
- )
- }
-
return (
- <div className="h-full w-full px-12 py-12 bg-background overflow-auto">
- <div className="max-w-7xl mx-auto flex flex-col gap-12 items-center justify-start">
- <div className="w-full flex justify-between items-center">
- <div>
- <h1 className="font-semibold text-3xl bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent">
- Vault
- </h1>
- <p className="text-muted-foreground mt-2">
- Securely manage your API keys for third-party services.
- </p>
- </div>
- <Dialog open={isAddDialogOpen} onOpenChange={setIsAddDialogOpen}>
- <DialogTrigger asChild>
- <Button>
- <Plus className="w-5 h-5" />
- Add API Key
- </Button>
- </DialogTrigger>
+ <PageLayout
+ title="Vault"
+ description="Securely manage your API keys for third-party services."
+ isLoading={keysLoading}
+ loadingComponent={<Loader />}
+ error={keysError}
+ errorComponent={
+ <ErrorState
+ title="Couldn't load keys"
+ description="Something went wrong while fetching data. Please try again."
+ error={keysError}
+ onRetry={() => refetch()}
+ />
+ }
+ actions={
+ <Dialog open={isAddDialogOpen} onOpenChange={setIsAddDialogOpen}>
+ <DialogTrigger asChild>
+ <Button size="sm">
+ <Plus className="w-4 h-4 mr-2" />
+ Add API Key
+ </Button>
+ </DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Add API Key</DialogTitle>
@@ -202,10 +170,10 @@ function VaultPage() {
</Button>
</DialogFooter>
</DialogContent>
- </Dialog>
- </div>
-
- <div className="w-full">
+ </Dialog>
+ }
+ >
+ <div className="w-full">
{keys.length === 0 ? (
<Card className="border-2 border-dashed border-primary/20 bg-gradient-to-br from-primary/5 via-background to-accent/5">
<CardContent className="flex flex-col items-center justify-center py-20 px-8">
@@ -243,7 +211,7 @@ function VaultPage() {
</div>
<Button onClick={() => setIsAddDialogOpen(true)}>
- <Plus className="w-5 h-5 mr-2" />
+ <Plus className="w-4 h-4 mr-2" />
Add Your First Key
</Button>
</div>
@@ -342,9 +310,8 @@ function VaultPage() {
</CardContent>
</Card>
)}
- </div>
</div>
- </div>
+ </PageLayout>
)
}