Added mantisbase logo

This commit is contained in:
2025-12-14 01:28:50 +03:00
parent 592657e0dc
commit f3821ab557
9 changed files with 418 additions and 446 deletions

View File

@@ -14,7 +14,8 @@ export default function RootLayout({
return (
<html lang="en">
<head>
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/mantisbase.svg" type="image/svg+xml" />
<link rel="alternate icon" href="/favicon.ico" />
</head>
<body>{children}</body>
</html>

View File

@@ -2,6 +2,7 @@
import * as React from "react"
import { Table, Settings, Shield, LogOut, FileText, RefreshCw, ExternalLink, AlertTriangle } from "lucide-react"
import { Logo } from "./logo"
import {
Sidebar,
SidebarContent,
@@ -278,7 +279,7 @@ export function AdminDashboard({ token, onLogout }: AdminDashboardProps) {
<SidebarHeader className="border-b p-0 w-full">
<div className="flex h-16 w-full items-center justify-center">
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-primary text-primary-foreground">
<Shield className="h-6 w-6" />
<Logo className="h-6 w-6" size={24} />
</div>
</div>
</SidebarHeader>

View File

@@ -234,6 +234,7 @@ export function DatabaseSection({ apiClient, tables, onTablesUpdate }: DatabaseS
const updatedTables = tables.map((t) => (t.id === updatedTable.id ? updatedTable : t))
onTablesUpdate(updatedTables)
}}
onTablesUpdate={onTablesUpdate}
/>
) : (
<div className="flex items-center justify-center h-full">

View File

@@ -1,7 +1,7 @@
"use client"
import * as React from "react"
import { Plus, Trash2, Cog, X, ChevronDown } from "lucide-react"
import { Plus, Trash2, Cog, X, ChevronDown, ChevronUp, GripVertical, Lock, AlertTriangle } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
@@ -15,14 +15,27 @@ import {
DrawerHeader,
DrawerTitle,
} from "@/components/ui/drawer"
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Textarea } from "@/components/ui/textarea"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
import { Checkbox } from "@/components/ui/checkbox"
import type { ApiClient, TableMetadata } from "@/lib/api"
import { dataTypes } from "@/lib/constants"
import { useToast } from "@/hooks/use-toast"
import { useRouter } from "@/lib/router"
import { cn } from "@/lib/utils"
interface TableConfigDrawerProps {
table: TableMetadata
@@ -30,6 +43,7 @@ interface TableConfigDrawerProps {
open: boolean
onClose: () => void
onTableUpdate: (table: TableMetadata) => void
onTablesUpdate?: (tables: TableMetadata[]) => void
}
// The update structure for tables is a s follows
@@ -48,7 +62,7 @@ interface TableConfigDrawerProps {
*/
// NOTE: We don't support changing of field names yet!
export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpdate }: TableConfigDrawerProps) {
export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpdate, onTablesUpdate }: TableConfigDrawerProps) {
const [columns, setColumns] = React.useState<any[]>([])
const [rules, setRules] = React.useState<{
list: { mode: string; expr: string }
@@ -66,9 +80,15 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
const [isLoading, setIsLoading] = React.useState(false)
const [activeTab, setActiveTab] = React.useState("schema")
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
const [systemFieldsCollapsed, setSystemFieldsCollapsed] = React.useState(true)
const [deletedColumns, setDeletedColumns] = React.useState<string[]>([]) // Track deleted field names
const [expandedFields, setExpandedFields] = React.useState<Set<string>>(new Set())
const [deletedColumns, setDeletedColumns] = React.useState<string[]>([]) // Track deleted field names
const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false)
const [isDeleting, setIsDeleting] = React.useState(false)
const { toast } = useToast()
const { navigate } = useRouter()
// Get unique key for field (use id if exists, otherwise generate one)
const getFieldKey = (field: any, index: number) => field.id || `temp-${index}`
React.useEffect(() => {
if (open) {
@@ -112,7 +132,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
},
})
setHasUnsavedChanges(false)
setSystemFieldsCollapsed(true)
setExpandedFields(new Set())
setDeletedColumns([])
}
}, [open, table])
@@ -313,6 +333,63 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
}
}
const handleDeleteSchema = async () => {
setIsDeleting(true)
try {
const res: any = await apiClient.call(`/api/v1/schemas/${table.schema.name}`, {
method: "DELETE",
})
if (res?.error?.length > 0) throw res.error
// Fetch updated tables list
if (onTablesUpdate) {
const response: any = await apiClient.call("/api/v1/schemas")
if (response?.error?.length > 0) throw response.error
let updatedTables: TableMetadata[] = []
if (Array.isArray(response)) {
updatedTables = response
} else if (response?.data && Array.isArray(response.data)) {
updatedTables = response.data
}
onTablesUpdate(updatedTables)
}
toast({
title: "Entity Deleted",
description: `The entity '${table.schema.name}' has been deleted successfully.`,
duration: 3000,
})
// Navigate to entities list or another entity
navigate("/entities", undefined, undefined)
onClose()
} catch (error: any) {
toast({
variant: "destructive",
title: "Error",
description: error?.message || "Failed to delete entity",
duration: 5000,
})
} finally {
setIsDeleting(false)
setDeleteDialogOpen(false)
}
}
const toggleFieldExpanded = (fieldKey: string) => {
setExpandedFields((prev) => {
const next = new Set(prev)
if (next.has(fieldKey)) {
next.delete(fieldKey)
} else {
next.add(fieldKey)
}
return next
})
}
return (
<Drawer open={open} onOpenChange={handleClose}>
<DrawerContent side="right" className="w-[900px] max-w-[95vw]">
@@ -339,17 +416,9 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
</TabsList>
<TabsContent value="schema" className="space-y-6">
<div className="flex items-center justify-between">
<div>
<h4 className="text-lg font-medium">Table Structure</h4>
<p className="text-sm text-muted-foreground">Modify columns and their properties</p>
</div>
{table.schema.type !== "view" && (
<Button type="button" variant="outline" size="sm" onClick={addColumn}>
<Plus className="h-4 w-4 mr-2" />
Add Column
</Button>
)}
<div>
<Label className="text-base font-medium">Fields</Label>
<p className="text-sm text-muted-foreground">Define the fields for your entity</p>
</div>
{table.schema.type === "view" ? (
@@ -362,432 +431,191 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
</ScrollArea>
</div>
) : (
<>
{/* System Fields - Collapsible */}
{columns.filter((col) => isSystemColumn(col)).length > 0 && (
<Collapsible
open={!systemFieldsCollapsed}
onOpenChange={(open) => setSystemFieldsCollapsed(!open)}
>
<CollapsibleTrigger asChild>
<Button variant="ghost" className="w-full justify-between p-2 mb-4">
<span className="text-sm font-medium">
System Fields ({columns.filter((col) => isSystemColumn(col)).length})
</span>
<ChevronDown
className={`h-4 w-4 transition-transform ${systemFieldsCollapsed ? "" : "rotate-180"}`}
/>
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 mb-6">
{columns.map((column, index) => {
const isSystem = isSystemColumn(column)
if (!isSystem) return null
return (
<div key={index} className="border rounded-lg bg-muted/50">
<div className="p-4 space-y-4">
{/* Basic Info */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="md:col-span-2">
<Label className="text-sm font-medium mb-2 block">Column Name</Label>
<div className="flex items-center gap-2">
<Input
placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Basic Properties */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`primary-${index}`}
checked={column.primaryKey}
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`primary-${index}`} className="text-sm">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={column.required}
onChange={(e) => updateColumn(index, "required", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input
placeholder="Default value"
value={column.defaultValue || ""}
onChange={(e) => updateColumn(index, "defaultValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
value={column.maxValue || ""}
onChange={(e) => updateColumn(index, "maxValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Min Length</Label>
<Input
type="number"
placeholder="Min length"
value={column.minValue || ""}
onChange={(e) => updateColumn(index, "minValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">
Auto Generate Pattern
</Label>
<Input
placeholder="Auto Generate Pattern"
value={column.autoGeneratePattern || ""}
onChange={(e) =>
updateColumn(index, "autoGeneratePattern", e.target.value)
}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Validator</Label>
<Textarea
placeholder="Column validator"
value={column.validator || ""}
onChange={(e) => updateColumn(index, "validator", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Description</Label>
<Textarea
placeholder="Column description"
value={column.description || ""}
onChange={(e) => updateColumn(index, "description", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
</CollapsibleContent>
</Collapsible>
{/* Delete Button */}
<div className="flex justify-end pt-2 border-t">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`}
>
<Trash2 className="h-4 w-4 mr-2" />
Remove Column
</Button>
</div>
</div>
<div className="space-y-3">
{columns.map((column, index) => {
const fieldKey = getFieldKey(column, index)
const isSystem = isSystemColumn(column)
return (
<div
key={fieldKey}
className={cn(
"border rounded-lg p-4 space-y-3 transition-colors",
isSystem && "bg-muted/30 border-muted"
)}
>
{/* Field Header - Name and Type */}
<div className="flex items-center gap-3">
<GripVertical className="h-4 w-4 text-muted-foreground cursor-move flex-shrink-0" />
{isSystem && (
<Lock className="h-4 w-4 text-muted-foreground flex-shrink-0" />
)}
<div className="flex-1 grid grid-cols-2 gap-3">
<div>
<Input
placeholder="Field name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
)
})}
</CollapsibleContent>
</Collapsible>
)}
{/* Regular Fields */}
<div className="space-y-4">
{columns.map((column, index) => {
const isSystem = isSystemColumn(column)
if (isSystem) return null // Skip system fields as they're in collapsible section
return (
<div key={index} className="border rounded-lg">
<div className="p-4 space-y-4">
{/* Basic Info */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="md:col-span-2">
<Label className="text-sm font-medium mb-2 block">Column Name</Label>
<div className="flex items-center gap-2">
<Input
placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Basic Properties */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`primary-${index}`}
checked={column.primaryKey}
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`primary-${index}`} className="text-sm">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={column.required}
onChange={(e) => updateColumn(index, "required", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input
placeholder="Default value"
value={column.defaultValue || ""}
onChange={(e) => updateColumn(index, "defaultValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
value={column.maxValue || ""}
onChange={(e) => updateColumn(index, "maxValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Min Length</Label>
<Input
type="number"
placeholder="Min length"
value={column.minValue || ""}
onChange={(e) => updateColumn(index, "minValue", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Auto Generate Pattern</Label>
<Input
placeholder="Auto Generate Pattern"
value={column.autoGeneratePattern || ""}
onChange={(e) => updateColumn(index, "autoGeneratePattern", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Validator</Label>
<Textarea
placeholder="Column validator"
value={column.validator || ""}
onChange={(e) => updateColumn(index, "validator", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Description</Label>
<Textarea
placeholder="Column description"
value={column.description || ""}
onChange={(e) => updateColumn(index, "description", e.target.value)}
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
</CollapsibleContent>
</Collapsible>
{/* Delete Button */}
<div className="flex justify-end pt-2 border-t">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`}
<div>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<Trash2 className="h-4 w-4 mr-2" />
Remove Column
</Button>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{!isSystem && (
<Button
type="button"
variant="ghost"
size="icon"
onClick={() => removeColumn(index)}
className="flex-shrink-0"
>
<Trash2 className="h-4 w-4" />
</Button>
)}
{isSystem && (
<Badge variant="outline" className="text-xs flex-shrink-0">
System
</Badge>
)}
</div>
)
})}
</div>
</>
{/* Collapsible Advanced Options */}
{!isSystem && (
<Collapsible open={expandedFields.has(fieldKey)} onOpenChange={() => toggleFieldExpanded(fieldKey)}>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between">
<span className="text-xs text-muted-foreground">Advanced Options</span>
{expandedFields.has(fieldKey) ? (
<ChevronUp className="h-4 w-4" />
) : (
<ChevronDown className="h-4 w-4" />
)}
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-3 pt-2">
<div className="grid grid-cols-3 gap-3">
<div className="flex items-center space-x-2">
<Checkbox
id={`pk-${fieldKey}`}
checked={column.primaryKey}
onCheckedChange={(checked) => updateColumn(index, "primaryKey", checked as boolean)}
/>
<Label htmlFor={`pk-${fieldKey}`} className="text-xs cursor-pointer">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id={`unique-${fieldKey}`}
checked={column.unique || false}
onCheckedChange={(checked) => updateColumn(index, "unique", checked as boolean)}
/>
<Label htmlFor={`unique-${fieldKey}`} className="text-xs cursor-pointer">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id={`required-${fieldKey}`}
checked={column.required || false}
onCheckedChange={(checked) => updateColumn(index, "required", checked as boolean)}
/>
<Label htmlFor={`required-${fieldKey}`} className="text-xs cursor-pointer">
Required
</Label>
</div>
</div>
<div className="grid grid-cols-2 gap-3">
<div className="space-y-1">
<Label htmlFor={`min-${fieldKey}`} className="text-xs">
Min Value
</Label>
<Input
id={`min-${fieldKey}`}
type="number"
placeholder="Min"
value={column.minValue || ""}
onChange={(e) =>
updateColumn(index, "minValue", e.target.value ? Number.parseFloat(e.target.value) : null)
}
className="h-8 text-xs"
/>
</div>
<div className="space-y-1">
<Label htmlFor={`max-${fieldKey}`} className="text-xs">
Max Value
</Label>
<Input
id={`max-${fieldKey}`}
type="number"
placeholder="Max"
value={column.maxValue || ""}
onChange={(e) =>
updateColumn(index, "maxValue", e.target.value ? Number.parseFloat(e.target.value) : null)
}
className="h-8 text-xs"
/>
</div>
</div>
<div className="space-y-1">
<Label htmlFor={`default-${fieldKey}`} className="text-xs">
Default Value
</Label>
<Input
id={`default-${fieldKey}`}
placeholder="Default value"
value={column.defaultValue || ""}
onChange={(e) => updateColumn(index, "defaultValue", e.target.value || null)}
className="h-8 text-xs"
/>
</div>
<div className="space-y-1">
<Label htmlFor={`validator-${fieldKey}`} className="text-xs">
Validator
</Label>
<Input
id={`validator-${fieldKey}`}
placeholder="Validator pattern"
value={column.validator || ""}
onChange={(e) => updateColumn(index, "validator", e.target.value || null)}
className="h-8 text-xs"
/>
</div>
</CollapsibleContent>
</Collapsible>
)}
</div>
)
})}
{/* Add Field Button */}
<Button
type="button"
variant="outline"
className="w-full border-dashed"
onClick={addColumn}
>
<Plus className="h-4 w-4 mr-2" />
Add Field
</Button>
</div>
)}
{table.schema.type !== "view" && (
@@ -1049,15 +877,52 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
</ScrollArea>
</div>
<DrawerFooter>
<DrawerFooter className="flex-col gap-3 sm:flex-row">
{activeTab === "schema" && (
<Button
type="button"
variant="destructive"
onClick={() => setDeleteDialogOpen(true)}
disabled={isDeleting}
className="w-full sm:w-auto"
>
<Trash2 className="h-4 w-4 mr-2" />
Delete Entity
</Button>
)}
<Button
onClick={activeTab === "schema" ? handleSaveSchema : handleSaveRules}
disabled={isLoading}
className="w-full"
className="w-full sm:flex-1"
>
{isLoading ? "Saving..." : `Save ${activeTab === "schema" ? "Schema" : "Rules"}`}
</Button>
</DrawerFooter>
{/* Delete Confirmation Dialog */}
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle className="flex items-center gap-2">
<AlertTriangle className="h-5 w-5 text-destructive" />
Delete Entity
</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to delete the entity <strong>"{table.schema.name}"</strong>? This action cannot be undone and will permanently delete all data associated with this entity.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={isDeleting}>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={handleDeleteSchema}
disabled={isDeleting}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{isDeleting ? "Deleting..." : "Delete"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</DrawerContent>
</Drawer>
)

View File

@@ -22,9 +22,10 @@ interface TableDetailViewProps {
onBack?: () => void
apiClient: ApiClient
onTableUpdate: (table: TableMetadata) => void
onTablesUpdate?: (tables: TableMetadata[]) => void
}
export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: TableDetailViewProps) {
export function TableDetailView({ table, onBack, apiClient, onTableUpdate, onTablesUpdate }: TableDetailViewProps) {
const [tableData, setTableData] = React.useState<any[]>([])
const [currentPage, setCurrentPage] = React.useState(1)
const [totalPages, setTotalPages] = React.useState(1)
@@ -467,6 +468,7 @@ export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: Tab
open={configOpen}
onClose={() => setConfigOpen(false)}
onTableUpdate={onTableUpdate}
onTablesUpdate={onTablesUpdate}
/>
<TableRecordDocsDrawer table={table} open={docsOpen} onClose={() => setDocsOpen(false)} />

View File

@@ -1,7 +1,8 @@
"use client"
import * as React from "react"
import { Eye, EyeOff, Shield } from "lucide-react"
import { Eye, EyeOff } from "lucide-react"
import { Logo } from "./logo"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
@@ -42,7 +43,7 @@ export function LoginForm({ onLogin }: LoginFormProps) {
<Card className="w-full max-w-md">
<CardHeader className="text-center">
<div className="flex justify-center mb-4">
<Shield className="h-12 w-12 text-primary" />
<Logo className="h-12 w-12 text-primary" size={48} />
</div>
<CardTitle className="text-2xl">Mantis Admin</CardTitle>
<CardDescription>Sign in to access the admin dashboard</CardDescription>

49
components/logo.tsx Normal file
View File

@@ -0,0 +1,49 @@
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
interface LogoProps {
className?: string
size?: number
}
export function Logo({ className, size = 40 }: LogoProps) {
return (
<svg
width={size}
height={size}
viewBox="0 0 40.018326 43.557034"
className={cn("transition-colors", className)}
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<g transform="translate(-76.752395,-70.247194)">
<g transform="matrix(0.35277778,0,0,0.35277778,27.80232,86.453883)">
<g
clipPath="url(#5346413700)"
transform="translate(138.6038,-57.494913)"
style={{ fill: "currentColor" }}
>
<path
d="m 106.50391,11.554688 c -6.05469,0.04297 -14.179691,10.277343 -21.875004,27.5625 -1.28125,2.878906 -2.332031,5.316406 -2.332031,5.414062 0,0.542969 0.507813,-0.109375 2.09375,-2.699219 2.585937,-4.226562 9.738281,-11.082031 15.195313,-14.558593 10.179692,-6.492188 11.945312,-7.71875 12.808592,-8.90625 0.80469,-1.101563 0.83594,-1.398438 0.29297,-2.710938 -0.75,-1.804688 -4.23047,-4.117188 -6.18359,-4.101562 z m -99.199222,0.09375 c -0.417969,-0.01172 -0.824219,0.01953 -1.222657,0.09375 -2.214843,0.414062 -5.316406,3.375 -5.316406,5.074218 0,1.722656 1.6875,3.203125 8.199219,7.195313 2.964844,1.820312 6.773437,4.328125 8.460937,5.570312 4.101563,3.019531 10.363281,9.683594 12.359375,13.152344 0.886719,1.539063 1.6875,2.730469 1.773438,2.648437 0.08984,-0.08203 -0.914063,-2.601562 -2.230469,-5.59375 C 21.503906,21.996094 13.535156,11.859375 7.304688,11.648438 Z m 9.121093,34.699218 C 12.449219,46.324219 11.773438,46.453125 9,47.769531 2.671875,50.765625 0.144531,54.5625 0.152344,61.0625 c 0.019531,11.21875 8.820312,22.660156 20.476562,26.621094 0.476563,0.160156 0.867188,1.039062 1.074219,2.414062 1.042969,6.945313 4.808594,14.824224 9.351563,19.542974 l 3.339843,3.47265 -0.757812,3.1211 c -1.0625,4.3789 -0.671875,9.55078 0.96875,12.83984 1.136719,2.27344 4.152343,5.91797 4.898437,5.91797 0.175782,0 0.113282,-0.87891 -0.132812,-1.95703 -0.742188,-3.23047 -0.277344,-10.46094 0.796875,-12.29688 0.5,-0.85937 1.128906,-1.63672 1.394531,-1.72265 0.265625,-0.0898 0.933594,0.64062 1.484375,1.625 1.378906,2.44921 4.738281,5.44531 7.609375,6.78125 2.859375,1.33203 8.238281,1.53906 11.367188,0.43359 2.898437,-1.02344 6.117187,-3.58984 8.085937,-6.44531 0.960937,-1.39844 1.933594,-2.53907 2.15625,-2.53907 0.226563,0 0.859375,0.98438 1.40625,2.1875 1.070313,2.34766 1.386719,8.00782 0.671875,11.99219 l -0.351562,1.97266 1.082031,-0.70703 c 1.464843,-0.96094 3.859375,-4.36719 4.769531,-6.78516 0.972656,-2.58984 0.964844,-9.46094 -0.01172,-12.54687 -0.703125,-2.21875 -0.695312,-2.28907 0.296875,-2.95313 4.992188,-3.34375 10.484375,-13.671875 12.097656,-22.753906 0.179688,-1.019532 0.570313,-1.730469 0.945313,-1.730469 1.3125,0 6.492187,-2.796875 9.152346,-4.941406 11.87109,-9.570313 15.03906,-26.179688 6.23047,-32.671875 -3.58203,-2.636719 -6.55078,-3.554688 -11.515629,-3.554688 -4.9375,0 -7.9375,0.910156 -11.984374,3.632813 l -2.300782,1.546875 -2.875,-1.292969 c -6.164062,-2.773437 -8.011718,-3.011719 -23.144531,-3.019531 -12.996094,0 -14.035156,0.05859 -17.417969,1.039062 -1.976562,0.574219 -4.617187,1.558594 -5.859375,2.191406 L 31.191406,51.625 28.574219,49.949219 C 24.332031,47.234375 21.4375,46.375 16.425781,46.347656 Z m 81.507813,3.996094 c 4.492186,0.02734 9.109376,1.824219 10.648436,4.3125 3.35938,5.441406 0.0195,16.671875 -7.08984,23.820312 -4.656252,4.683594 -10.949221,7.691407 -16.089846,7.691407 -1.558594,0 -1.621094,-0.07031 -2.320313,-2.648438 -2.726562,-10.050781 -2.640625,-18.355469 0.25,-24.683593 2.289063,-5.003907 6.328125,-7.675782 12.691407,-8.394532 0.628906,-0.07031 1.269531,-0.101562 1.910156,-0.09766 z m -81.160156,0.0625 c 0.675781,0.03516 1.34375,0.109375 2.003906,0.226562 4.390625,0.769532 8.398437,2.910157 10.113281,5.398438 2.839844,4.128906 3.402344,6.542969 3.367187,14.472656 -0.02734,6.003906 -0.210937,7.800782 -1.136718,11.285156 L 30.015625,85.9375 28.175781,86.03125 C 27.160156,86.085938 25.21875,85.824219 23.855469,85.449219 15.117188,83.0625 7.386719,75.117188 4.675781,65.734375 3.597656,62 3.855469,56.324219 5.1875,54.53125 c 2.007812,-2.710938 6.871094,-4.371094 11.585938,-4.125 z m 40.390624,1.222656 c 13.476563,0.0078 18.050782,0.535156 19.800782,2.285156 1.011718,1.011719 0.953125,1.398438 -1.082032,7.011719 -0.898437,2.484375 -0.914062,2.800781 -0.269531,5.859375 0.65625,3.136719 0.558594,5.371094 -0.320312,7.085938 -0.234375,0.457031 -2.089844,2.632812 -4.121094,4.835937 C 64.328125,86.121094 60.019531,92.335938 57.070312,99.0625 56.71875,99.867188 56.554688,99.976562 56.535156,99.429688 56.476562,98.03125 52.625,91.058594 49.953125,87.527344 48.527344,85.640625 45.28125,81.761719 42.738281,78.914062 37.785156,73.355469 37.222656,72.171875 37.816406,68.519531 38.675781,63.203125 38.65625,62.386719 37.621094,60.09375 37.0625,58.855469 36.421875,57.242188 36.203125,56.511719 35.015625,52.5625 39.082031,51.617188 57.164062,51.628906 Z M 47.023438,107.79297 c 0.847656,-0.0312 2.066406,0.66797 3.304687,1.98047 3.746094,3.96875 3.710937,4.27734 -0.273437,2.21484 -2.8125,-1.45312 -4.394532,-2.93359 -3.933594,-3.68359 0.203125,-0.32813 0.515625,-0.4961 0.902344,-0.51172 z m 19.289062,0.0234 c 2.121094,0 1.578125,1.55859 -1.125,3.22265 -2.78125,1.71094 -4.539062,2.44141 -4.539062,1.88672 0,-0.21875 0.996093,-1.45703 2.210937,-2.7539 1.601563,-1.70704 2.554687,-2.35547 3.453125,-2.35547 z m 0,0"
fill="currentColor"
fillOpacity="1"
fillRule="nonzero"
/>
</g>
</g>
</g>
<defs>
<clipPath id="5346413700">
<path
d="M 0.0742188,11.554688 H 113.92578 V 135.14062 H 0.0742188 Z m 0,0"
clipRule="nonzero"
/>
</clipPath>
</defs>
</svg>
)
}

View File

@@ -1,7 +1,8 @@
"use client"
import * as React from "react"
import { Eye, EyeOff, Shield, CheckCircle2 } from "lucide-react"
import { Eye, EyeOff, CheckCircle2 } from "lucide-react"
import { Logo } from "./logo"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
@@ -90,7 +91,7 @@ export function SetupForm({ token, onSetupComplete }: SetupFormProps) {
<Card className="w-full max-w-md">
<CardHeader className="text-center">
<div className="flex justify-center mb-4">
<Shield className="h-12 w-12 text-primary" />
<Logo className="h-12 w-12 text-primary" size={48} />
</div>
<CardTitle className="text-2xl">Setup Admin Account</CardTitle>
<CardDescription>Create your first admin account to get started</CardDescription>

51
public/mantisbase.svg Normal file
View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="40.018326mm"
height="43.557034mm"
viewBox="0 0 40.018326 43.557034"
version="1.1"
id="svg1"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"><inkscape:page
x="0"
y="0"
width="40.018326"
height="43.557034"
id="page2"
margin="0"
bleed="0" /></sodipodi:namedview><defs
id="defs1"><clipPath
id="5346413700"><path
d="M 0.0742188,11.554688 H 113.92578 V 135.14062 H 0.0742188 Z m 0,0"
clip-rule="nonzero"
id="path2" /></clipPath></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-76.752395,-70.247194)"><g
id="g2"
transform="matrix(0.35277778,0,0,0.35277778,27.80232,86.453883)"><g
clip-path="url(#5346413700)"
id="g4"
style="fill:#000000"
transform="translate(138.6038,-57.494913)"><path
fill="#ffffff"
d="m 106.50391,11.554688 c -6.05469,0.04297 -14.179691,10.277343 -21.875004,27.5625 -1.28125,2.878906 -2.332031,5.316406 -2.332031,5.414062 0,0.542969 0.507813,-0.109375 2.09375,-2.699219 2.585937,-4.226562 9.738281,-11.082031 15.195313,-14.558593 10.179692,-6.492188 11.945312,-7.71875 12.808592,-8.90625 0.80469,-1.101563 0.83594,-1.398438 0.29297,-2.710938 -0.75,-1.804688 -4.23047,-4.117188 -6.18359,-4.101562 z m -99.199222,0.09375 c -0.417969,-0.01172 -0.824219,0.01953 -1.222657,0.09375 -2.214843,0.414062 -5.316406,3.375 -5.316406,5.074218 0,1.722656 1.6875,3.203125 8.199219,7.195313 2.964844,1.820312 6.773437,4.328125 8.460937,5.570312 4.101563,3.019531 10.363281,9.683594 12.359375,13.152344 0.886719,1.539063 1.6875,2.730469 1.773438,2.648437 0.08984,-0.08203 -0.914063,-2.601562 -2.230469,-5.59375 C 21.503906,21.996094 13.535156,11.859375 7.304688,11.648438 Z m 9.121093,34.699218 C 12.449219,46.324219 11.773438,46.453125 9,47.769531 2.671875,50.765625 0.144531,54.5625 0.152344,61.0625 c 0.019531,11.21875 8.820312,22.660156 20.476562,26.621094 0.476563,0.160156 0.867188,1.039062 1.074219,2.414062 1.042969,6.945313 4.808594,14.824224 9.351563,19.542974 l 3.339843,3.47265 -0.757812,3.1211 c -1.0625,4.3789 -0.671875,9.55078 0.96875,12.83984 1.136719,2.27344 4.152343,5.91797 4.898437,5.91797 0.175782,0 0.113282,-0.87891 -0.132812,-1.95703 -0.742188,-3.23047 -0.277344,-10.46094 0.796875,-12.29688 0.5,-0.85937 1.128906,-1.63672 1.394531,-1.72265 0.265625,-0.0898 0.933594,0.64062 1.484375,1.625 1.378906,2.44921 4.738281,5.44531 7.609375,6.78125 2.859375,1.33203 8.238281,1.53906 11.367188,0.43359 2.898437,-1.02344 6.117187,-3.58984 8.085937,-6.44531 0.960937,-1.39844 1.933594,-2.53907 2.15625,-2.53907 0.226563,0 0.859375,0.98438 1.40625,2.1875 1.070313,2.34766 1.386719,8.00782 0.671875,11.99219 l -0.351562,1.97266 1.082031,-0.70703 c 1.464843,-0.96094 3.859375,-4.36719 4.769531,-6.78516 0.972656,-2.58984 0.964844,-9.46094 -0.01172,-12.54687 -0.703125,-2.21875 -0.695312,-2.28907 0.296875,-2.95313 4.992188,-3.34375 10.484375,-13.671875 12.097656,-22.753906 0.179688,-1.019532 0.570313,-1.730469 0.945313,-1.730469 1.3125,0 6.492187,-2.796875 9.152346,-4.941406 11.87109,-9.570313 15.03906,-26.179688 6.23047,-32.671875 -3.58203,-2.636719 -6.55078,-3.554688 -11.515629,-3.554688 -4.9375,0 -7.9375,0.910156 -11.984374,3.632813 l -2.300782,1.546875 -2.875,-1.292969 c -6.164062,-2.773437 -8.011718,-3.011719 -23.144531,-3.019531 -12.996094,0 -14.035156,0.05859 -17.417969,1.039062 -1.976562,0.574219 -4.617187,1.558594 -5.859375,2.191406 L 31.191406,51.625 28.574219,49.949219 C 24.332031,47.234375 21.4375,46.375 16.425781,46.347656 Z m 81.507813,3.996094 c 4.492186,0.02734 9.109376,1.824219 10.648436,4.3125 3.35938,5.441406 0.0195,16.671875 -7.08984,23.820312 -4.656252,4.683594 -10.949221,7.691407 -16.089846,7.691407 -1.558594,0 -1.621094,-0.07031 -2.320313,-2.648438 -2.726562,-10.050781 -2.640625,-18.355469 0.25,-24.683593 2.289063,-5.003907 6.328125,-7.675782 12.691407,-8.394532 0.628906,-0.07031 1.269531,-0.101562 1.910156,-0.09766 z m -81.160156,0.0625 c 0.675781,0.03516 1.34375,0.109375 2.003906,0.226562 4.390625,0.769532 8.398437,2.910157 10.113281,5.398438 2.839844,4.128906 3.402344,6.542969 3.367187,14.472656 -0.02734,6.003906 -0.210937,7.800782 -1.136718,11.285156 L 30.015625,85.9375 28.175781,86.03125 C 27.160156,86.085938 25.21875,85.824219 23.855469,85.449219 15.117188,83.0625 7.386719,75.117188 4.675781,65.734375 3.597656,62 3.855469,56.324219 5.1875,54.53125 c 2.007812,-2.710938 6.871094,-4.371094 11.585938,-4.125 z m 40.390624,1.222656 c 13.476563,0.0078 18.050782,0.535156 19.800782,2.285156 1.011718,1.011719 0.953125,1.398438 -1.082032,7.011719 -0.898437,2.484375 -0.914062,2.800781 -0.269531,5.859375 0.65625,3.136719 0.558594,5.371094 -0.320312,7.085938 -0.234375,0.457031 -2.089844,2.632812 -4.121094,4.835937 C 64.328125,86.121094 60.019531,92.335938 57.070312,99.0625 56.71875,99.867188 56.554688,99.976562 56.535156,99.429688 56.476562,98.03125 52.625,91.058594 49.953125,87.527344 48.527344,85.640625 45.28125,81.761719 42.738281,78.914062 37.785156,73.355469 37.222656,72.171875 37.816406,68.519531 38.675781,63.203125 38.65625,62.386719 37.621094,60.09375 37.0625,58.855469 36.421875,57.242188 36.203125,56.511719 35.015625,52.5625 39.082031,51.617188 57.164062,51.628906 Z M 47.023438,107.79297 c 0.847656,-0.0312 2.066406,0.66797 3.304687,1.98047 3.746094,3.96875 3.710937,4.27734 -0.273437,2.21484 -2.8125,-1.45312 -4.394532,-2.93359 -3.933594,-3.68359 0.203125,-0.32813 0.515625,-0.4961 0.902344,-0.51172 z m 19.289062,0.0234 c 2.121094,0 1.578125,1.55859 -1.125,3.22265 -2.78125,1.71094 -4.539062,2.44141 -4.539062,1.88672 0,-0.21875 0.996093,-1.45703 2.210937,-2.7539 1.601563,-1.70704 2.554687,-2.35547 3.453125,-2.35547 z m 0,0"
fill-opacity="1"
fill-rule="nonzero"
id="path4"
style="fill:#000000" /></g></g></g></svg>

After

Width:  |  Height:  |  Size: 6.3 KiB