Dashboard 1.0
This commit is contained in:
1 parent
51ffafeeda
commit
24ccc179a6
12 files changed
+384
-206
No files matched your search
@@ -54,56 +54,41 @@ const mainNav: {
|
||||
permission?: string;
|
||||
}[] = [
|
||||
{ title: "Dashboard", url: "/", icon: DashboardSquare02Icon, end: true, permission: "overview" },
|
||||
{ title: "Logs", url: "/logs", icon: ComputerTerminal01Icon, permission: "logs" },
|
||||
{ title: "Settings", url: "/settings", icon: Settings02Icon, permission: "settings.view" },
|
||||
{ title: "Addons", url: "/addons", icon: PackageIcon, permission: "settings.view" },
|
||||
{ title: "Users", url: "/users", icon: UserMultiple02Icon, permission: "users.view" },
|
||||
];
|
||||
|
||||
const sections: {
|
||||
label: string;
|
||||
items: { title: string; url: string; icon: IconSvgElement }[];
|
||||
items: { title: string; url: string; icon: IconSvgElement; permission?: string }[];
|
||||
}[] = [
|
||||
{
|
||||
label: "Tickets & support",
|
||||
label: "Configuration",
|
||||
items: [
|
||||
{
|
||||
title: "Ticket system",
|
||||
url: "/configs?file=ticket-panel",
|
||||
icon: Ticket01Icon,
|
||||
},
|
||||
{
|
||||
title: "Bot config",
|
||||
url: "/configs?file=supportbot",
|
||||
icon: BotIcon,
|
||||
},
|
||||
{ title: "Transcripts", url: "/transcripts", icon: File02Icon },
|
||||
{ title: "Bot Settings", url: "/configs?file=supportbot", icon: BotIcon },
|
||||
{ title: "Commands", url: "/configs?file=commands", icon: CommandIcon },
|
||||
{ title: "Messages", url: "/configs?file=messages", icon: Message01Icon },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Community",
|
||||
label: "Features",
|
||||
items: [
|
||||
{
|
||||
title: "Messages",
|
||||
url: "/configs?file=messages",
|
||||
icon: Message01Icon,
|
||||
},
|
||||
{
|
||||
title: "AI assistant",
|
||||
url: "/configs?file=supportbot-ai",
|
||||
icon: AiBrain01Icon,
|
||||
},
|
||||
{ title: "Ticket System", url: "/configs?file=ticket-panel", icon: Ticket01Icon },
|
||||
{ title: "AI Assistant", url: "/configs?file=supportbot-ai", icon: AiBrain01Icon },
|
||||
{ title: "Transcripts", url: "/transcripts", icon: File02Icon, permission: "transcripts" },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Server control",
|
||||
label: "Management",
|
||||
items: [
|
||||
{ title: "commands.yml", url: "/configs?file=commands", icon: CommandIcon },
|
||||
{
|
||||
title: "Staff roles",
|
||||
url: "/configs?file=supportbot",
|
||||
icon: UserMultiple02Icon,
|
||||
},
|
||||
{ title: "Users", url: "/users", icon: UserMultiple02Icon, permission: "users.view" },
|
||||
{ title: "Staff Roles", url: "/configs?file=supportbot", icon: UserMultiple02Icon },
|
||||
{ title: "Console Logs", url: "/logs", icon: ComputerTerminal01Icon, permission: "logs" },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "System",
|
||||
items: [
|
||||
{ title: "Addon Manager", url: "/addons", icon: PackageIcon, permission: "settings.view" },
|
||||
{ title: "Dashboard Settings", url: "/settings", icon: Settings02Icon, permission: "settings.view" },
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -140,16 +125,13 @@ export function AppSidebar() {
|
||||
.map((section) => ({
|
||||
...section,
|
||||
items: section.items.filter((item) => {
|
||||
if (item.permission) {
|
||||
return hasPermission(permissions, item.permission);
|
||||
}
|
||||
const file = configFileFromUrl(item.url);
|
||||
if (file && item.url.includes("/configs")) {
|
||||
return canViewConfig(permissions, file);
|
||||
}
|
||||
if (item.url === "/transcripts") {
|
||||
return hasPermission(permissions, "transcripts");
|
||||
}
|
||||
if (item.url === "/commands") {
|
||||
return canViewConfig(permissions, "commands");
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
}))
|
||||
@@ -236,7 +218,7 @@ export function AppSidebar() {
|
||||
<SidebarMenu>
|
||||
{section.items.map((item) => {
|
||||
const file = configFileFromUrl(item.url);
|
||||
const isActive =
|
||||
const isConfigActive =
|
||||
Boolean(file) &&
|
||||
activeFile === file &&
|
||||
item.url.includes("/configs");
|
||||
@@ -245,8 +227,8 @@ export function AppSidebar() {
|
||||
<SidebarMenuButton asChild tooltip={item.title}>
|
||||
<NavLink
|
||||
to={item.url}
|
||||
className={cn(
|
||||
isActive && "bg-sidebar-accent font-medium",
|
||||
className={({ isActive }) => cn(
|
||||
(isActive || isConfigActive) && "bg-sidebar-accent font-medium",
|
||||
)}
|
||||
>
|
||||
<Icon icon={item.icon} size={18} />
|
||||
|
||||
@@ -18,6 +18,7 @@ import { mergeSchemaWithData } from "@/lib/merge-config-schema";
|
||||
import { useAuth } from "@/context/AuthContext";
|
||||
import { notifyConfigSave } from "@/lib/notify-config-save";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import Editor from "@monaco-editor/react";
|
||||
import { ConfigFieldInput } from "./config-field";
|
||||
import { CommandsEditor } from "./commands-editor";
|
||||
|
||||
@@ -295,13 +296,22 @@ export function ConfigVisualEditor({ configFile }: ConfigVisualEditorProps) {
|
||||
or any option not in Visual mode.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Textarea
|
||||
<CardContent className="h-[min(520px,60vh)] overflow-hidden rounded-b-xl border-t border-border p-0">
|
||||
<Editor
|
||||
height="100%"
|
||||
language="yaml"
|
||||
theme="vs-dark"
|
||||
value={rawYaml}
|
||||
disabled={readOnly}
|
||||
onChange={(e) => setRawYaml(e.target.value)}
|
||||
className="min-h-[min(520px,60vh)] font-mono text-xs leading-relaxed"
|
||||
spellCheck={false}
|
||||
onChange={(value) => setRawYaml(value || "")}
|
||||
options={{
|
||||
readOnly: readOnly,
|
||||
minimap: { enabled: false },
|
||||
fontSize: 13,
|
||||
wordWrap: "on",
|
||||
scrollBeyondLastLine: false,
|
||||
padding: { top: 16 },
|
||||
tabSize: 2,
|
||||
}}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -107,85 +107,15 @@ export default function Configs() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-[220px_1fr]">
|
||||
<Card className="h-fit border-border bg-card">
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
Configuration files
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<ScrollArea className="h-[min(400px,50vh)]">
|
||||
<ul className="space-y-3 p-2">
|
||||
{allowedMainFiles.length > 0 ? (
|
||||
<li>
|
||||
<p className="px-3 pb-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80">
|
||||
Core
|
||||
</p>
|
||||
<ul className="space-y-0.5">
|
||||
{allowedMainFiles.map((file) => (
|
||||
<li key={file}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => selectFile(file)}
|
||||
className={cn(
|
||||
"w-full rounded-lg px-3 py-2.5 text-left text-sm transition-colors",
|
||||
file === active
|
||||
? "bg-primary/15 font-medium text-primary"
|
||||
: "text-muted-foreground hover:bg-secondary hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{file}.yml
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
) : null}
|
||||
|
||||
{allowedAddonFiles.length > 0 ? (
|
||||
<li>
|
||||
<p className="px-3 pb-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80">
|
||||
Addons
|
||||
</p>
|
||||
<ul className="space-y-0.5">
|
||||
{allowedAddonFiles.map((file) => {
|
||||
const key = addonConfigFileParam(file);
|
||||
return (
|
||||
<li key={file}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => selectFile(key)}
|
||||
className={cn(
|
||||
"w-full rounded-lg px-3 py-2.5 text-left text-sm transition-colors",
|
||||
key === active
|
||||
? "bg-primary/15 font-medium text-primary"
|
||||
: "text-muted-foreground hover:bg-secondary hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{file}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</li>
|
||||
) : null}
|
||||
</ul>
|
||||
</ScrollArea>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<div className="min-w-0">
|
||||
{isAddonActive && activeAddonFilename ? (
|
||||
<AddonConfigEditor
|
||||
key={activeAddonFilename}
|
||||
filename={activeAddonFilename}
|
||||
/>
|
||||
) : (
|
||||
<ConfigVisualEditor key={active} configFile={active} />
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
{isAddonActive && activeAddonFilename ? (
|
||||
<AddonConfigEditor
|
||||
key={activeAddonFilename}
|
||||
filename={activeAddonFilename}
|
||||
/>
|
||||
) : (
|
||||
<ConfigVisualEditor key={active} configFile={active} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { useMemo } from "react";
|
||||
import { BotIcon } from "@hugeicons/core-free-icons";
|
||||
import { Navigate, useSearchParams } from "react-router-dom";
|
||||
import { Icon } from "@/components/icon";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -42,48 +40,53 @@ export default function Login() {
|
||||
if (!loading && isAuthenticated) return <Navigate to="/" replace />;
|
||||
|
||||
return (
|
||||
<div className="flex min-h-svh items-center justify-center bg-background p-4">
|
||||
<Card className="w-full max-w-md border-border bg-card">
|
||||
<CardHeader className="space-y-4">
|
||||
<div className="flex items-center gap-3">
|
||||
{branding.hasFavicon && branding.faviconUrl ? (
|
||||
<img
|
||||
src={`${branding.faviconUrl}${branding.updatedAt ? `?v=${branding.updatedAt}` : ""}`}
|
||||
alt=""
|
||||
className="size-11 rounded-xl object-contain"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex size-11 items-center justify-center rounded-xl bg-primary text-primary-foreground">
|
||||
<Icon icon={BotIcon} size={22} />
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<CardTitle className="text-xl">{branding.title}</CardTitle>
|
||||
<CardDescription>Sign in to your dashboard</CardDescription>
|
||||
</div>
|
||||
<div className="relative flex min-h-svh items-center justify-center bg-[#0c0c10] p-4 overflow-hidden">
|
||||
<Card className="relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-card/30 p-2 shadow-2xl backdrop-blur-2xl">
|
||||
<div className="absolute inset-0 bg-gradient-to-br from-white/5 to-transparent pointer-events-none"></div>
|
||||
<CardHeader className="space-y-6 pt-10 pb-4 text-center">
|
||||
<div className="mx-auto flex size-28 items-center justify-center overflow-hidden rounded-3xl bg-white/5 p-4 shadow-inner ring-1 ring-white/10 transition-transform duration-500 hover:scale-105">
|
||||
<img
|
||||
src="/logo.png"
|
||||
alt="SupportBot Logo"
|
||||
className="h-full w-full object-contain drop-shadow-xl"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<CardTitle className="bg-gradient-to-br from-white to-white/50 bg-clip-text text-3xl font-extrabold tracking-tight text-transparent">
|
||||
{branding.title || "SupportBot"}
|
||||
</CardTitle>
|
||||
<CardDescription className="mt-2 text-base font-medium text-white/50">
|
||||
Sign in to your dashboard
|
||||
</CardDescription>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Sign in with Discord. Your application credentials and allowed user
|
||||
IDs are configured in{" "}
|
||||
<code className="rounded-md bg-secondary px-1.5 py-0.5 text-xs text-foreground">
|
||||
Configs/api.yml
|
||||
</code>
|
||||
.
|
||||
</p>
|
||||
<CardContent className="space-y-6 pb-10">
|
||||
<div className="text-center space-y-1">
|
||||
<p className="text-sm font-medium text-white/50">
|
||||
Securely authenticate using your Discord account.
|
||||
</p>
|
||||
<p className="text-xs text-white/30">
|
||||
Credentials are configured in <code className="rounded bg-white/5 px-1 py-0.5 text-white/40">Configs/api.yml</code>
|
||||
</p>
|
||||
</div>
|
||||
{error ? (
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
<Alert variant="destructive" className="border-red-500/50 bg-red-500/10 text-red-200 backdrop-blur-md">
|
||||
<AlertDescription className="font-medium">{error}</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
<Button
|
||||
type="button"
|
||||
className="w-full"
|
||||
className="group relative w-full overflow-hidden rounded-2xl bg-primary px-8 py-6 text-base font-bold text-primary-foreground shadow-[0_0_20px_rgba(var(--primary),0.3)] transition-all duration-300 hover:scale-[1.02] hover:shadow-[0_0_30px_rgba(var(--primary),0.5)] active:scale-95"
|
||||
disabled={loading}
|
||||
onClick={loginWithDiscord}
|
||||
>
|
||||
{loading ? "Checking session…" : "Continue with Discord"}
|
||||
<div className="absolute inset-0 translate-x-[-100%] bg-gradient-to-r from-transparent via-white/20 to-transparent transition-transform duration-1000 group-hover:translate-x-[100%]"></div>
|
||||
<span className="relative flex items-center justify-center gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 127.14 96.36" fill="currentColor">
|
||||
<path d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1,105.25,105.25,0,0,0,32.19-16.14c2.64-27.38-4.51-51.11-19.32-72.15ZM42.68,68.22c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C52.34,63.32,48.09,68.22,42.68,68.22Zm41.76,0c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C84.44,63.32,80.19,68.22,84.44,68.22Z"/>
|
||||
</svg>
|
||||
{loading ? "Authenticating..." : "Continue with Discord"}
|
||||
</span>
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in new issue
Block a user