openadminjs 0.1.24 → 0.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -81
- package/dist/adapt-package-manager.d.ts +3 -0
- package/dist/adapt-package-manager.js +118 -0
- package/dist/create-project.d.ts +77 -2
- package/dist/create-project.js +685 -224
- package/dist/db-commands.d.ts +20 -0
- package/dist/db-commands.js +75 -0
- package/dist/detect-package-manager.d.ts +8 -0
- package/dist/detect-package-manager.js +37 -0
- package/dist/doctor.d.ts +26 -0
- package/dist/doctor.js +232 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +476 -166
- package/dist/render-schema.d.ts +3 -0
- package/dist/render-schema.js +33 -0
- package/dist/resource-slug.d.ts +1 -0
- package/dist/resource-slug.js +7 -0
- package/dist/runtime-mode.d.ts +16 -0
- package/dist/runtime-mode.js +138 -0
- package/dist/secrets.d.ts +24 -0
- package/dist/secrets.js +93 -0
- package/dist/security.d.ts +13 -0
- package/dist/security.js +168 -0
- package/dist/upgrade.d.ts +10 -0
- package/dist/upgrade.js +133 -0
- package/dist/validate-name.d.ts +33 -0
- package/dist/validate-name.js +206 -0
- package/package.json +39 -11
- package/template/.dockerignore +15 -0
- package/template/.env.production.example +5 -0
- package/template/Dockerfile +12 -0
- package/template/README.md +23 -3
- package/template/apps/admin/app/api/auth/login/route.ts +9 -9
- package/template/apps/admin/app/api/auth/logout/route.ts +11 -3
- package/template/apps/admin/app/api/auth/oidc/callback/route.ts +19 -0
- package/template/apps/admin/app/api/auth/oidc/start/route.ts +11 -0
- package/template/apps/admin/app/api/auth/oidc/status/route.ts +6 -0
- package/template/apps/admin/app/api/auth/refresh/route.ts +18 -11
- package/template/apps/admin/app/api/backend/[...path]/route.ts +48 -0
- package/template/apps/admin/app/api-tokens/page.tsx +39 -39
- package/template/apps/admin/app/assistant/page.tsx +11 -0
- package/template/apps/admin/app/dashboard/page.tsx +45 -462
- package/template/apps/admin/app/globals.css +52 -16
- package/template/apps/admin/app/layout.tsx +1 -1
- package/template/apps/admin/app/login/page.tsx +13 -145
- package/template/apps/admin/app/plugins/page.tsx +16 -402
- package/template/apps/admin/app/profile/page.tsx +5 -2
- package/template/apps/admin/app/settings/page.tsx +14 -265
- package/template/apps/admin/components/ai-assistant-widget.tsx +3 -6
- package/template/apps/admin/components/app-shell.tsx +25 -373
- package/template/apps/admin/components/auth-guard.tsx +8 -28
- package/template/apps/admin/components/logo.tsx +1 -30
- package/template/apps/admin/components/resource-form.tsx +3 -3
- package/template/apps/admin/components/resource-table.tsx +12 -8
- package/template/apps/admin/lib/api.ts +45 -107
- package/template/apps/admin/lib/resource-table-prefs.ts +1 -57
- package/template/apps/admin/lib/server-api.ts +7 -0
- package/template/apps/admin/lib/tokens.ts +9 -81
- package/template/apps/admin/middleware.ts +9 -50
- package/template/apps/admin/next.config.mjs +4 -0
- package/template/apps/admin/package.json +2 -1
- package/template/apps/admin/public/brand/favicon.svg +4 -1
- package/template/apps/admin/tailwind.config.ts +9 -8
- package/template/apps/api/package.json +13 -6
- package/template/apps/api/src/access/catalog.ts +4 -0
- package/template/apps/api/src/admin/admin-ai.controller.ts +15 -125
- package/template/apps/api/src/admin/admin-analytics.service.ts +16 -148
- package/template/apps/api/src/admin/admin-logs.controller.ts +4 -1
- package/template/apps/api/src/admin/admin-plugins.controller.ts +8 -8
- package/template/apps/api/src/admin/admin-plugins.service.ts +15 -259
- package/template/apps/api/src/admin/admin-resource.service.ts +105 -254
- package/template/apps/api/src/admin/admin.controller.ts +17 -4
- package/template/apps/api/src/admin/admin.module.ts +2 -2
- package/template/apps/api/src/admin/resource-policy.ts +1 -0
- package/template/apps/api/src/admin/resource-query.ts +1 -0
- package/template/apps/api/src/admin/safe-ai.service.ts +43 -0
- package/template/apps/api/src/admin/validate-resource-payload.ts +2 -0
- package/template/apps/api/src/auth/auth.controller.ts +4 -2
- package/template/apps/api/src/auth/auth.service.ts +68 -83
- package/template/apps/api/src/auth/sso-oidc.controller.ts +12 -74
- package/template/apps/api/src/auth/sso-oidc.service.ts +51 -268
- package/template/apps/api/src/common/api-exception.filter.ts +1 -0
- package/template/apps/api/src/common/auth.guard.ts +66 -39
- package/template/apps/api/src/common/json-field-codec.ts +138 -0
- package/template/apps/api/src/common/prisma.service.ts +12 -7
- package/template/apps/api/src/common/request-logging.interceptor.ts +8 -3
- package/template/apps/api/src/graphql/graphql.module.ts +14 -1
- package/template/apps/api/src/health/health.controller.ts +6 -0
- package/template/apps/api/src/main.ts +11 -2
- package/template/apps/api/src/plugins/plugin-loader.ts +5 -3
- package/template/apps/api/src/resources/commerce.resource.ts +3 -34
- package/template/apps/api/src/resources/operations.resource.ts +1 -0
- package/template/apps/api/src/store/payment/payment.controller.ts +15 -92
- package/template/apps/api/src/store/payment/payment.module.ts +2 -3
- package/template/apps/api/src/store/payment/payment.service.ts +121 -227
- package/template/apps/api/webpack.config.cjs +2 -1
- package/template/apps/web/next.config.mjs +4 -0
- package/template/apps/web/public/brand/favicon.svg +4 -1
- package/template/compose.yaml +56 -0
- package/template/examples/crm-admin/README.md +31 -0
- package/template/examples/crm-admin/package.json +17 -0
- package/template/examples/crm-admin/prisma/models.fragment.prisma +50 -0
- package/template/examples/crm-admin/src/index.ts +7 -0
- package/template/examples/crm-admin/src/resources/activities.resource.ts +29 -0
- package/template/examples/crm-admin/src/resources/companies.resource.ts +21 -0
- package/template/examples/crm-admin/src/resources/contacts.resource.ts +24 -0
- package/template/examples/crm-admin/src/resources/deals.resource.ts +30 -0
- package/template/examples/crm-admin/tsconfig.json +7 -0
- package/template/package.json +8 -1
- package/template/packages/admin-client/package.json +18 -0
- package/template/packages/admin-client/src/contracts.ts +29 -0
- package/template/packages/admin-client/src/index.ts +2 -0
- package/template/packages/admin-client/src/preferences.ts +57 -0
- package/template/packages/admin-client/tsconfig.json +12 -0
- package/template/packages/auth/package.json +1 -1
- package/template/packages/brand/site/assets/brand/favicon.svg +4 -1
- package/template/packages/brand/src/generate-assets.mjs +17 -186
- package/template/packages/core/package.json +1 -1
- package/template/packages/mail/package.json +1 -1
- package/template/packages/nest/package.json +22 -0
- package/template/packages/nest/src/api-exception.filter.ts +23 -0
- package/template/packages/nest/src/index.ts +3 -0
- package/template/packages/nest/src/resource-policy.ts +64 -0
- package/template/packages/nest/src/resource-query.ts +103 -0
- package/template/packages/nest/tsconfig.json +12 -0
- package/template/packages/notifications/package.json +1 -1
- package/template/packages/payments/package.json +1 -1
- package/template/packages/permissions/package.json +1 -1
- package/template/packages/permissions/src/index.ts +2 -2
- package/template/packages/plugin-sdk/package.json +1 -1
- package/template/packages/plugin-sdk/src/index.ts +2 -2
- package/template/packages/prisma/package.json +21 -0
- package/template/packages/prisma/schema/ai.prisma +36 -0
- package/template/packages/prisma/schema/audit.prisma +13 -0
- package/template/packages/prisma/schema/commerce.prisma +79 -0
- package/template/packages/prisma/schema/content.prisma +27 -0
- package/template/packages/prisma/schema/core.prisma +106 -0
- package/template/packages/prisma/schema/header.prisma +8 -0
- package/template/packages/prisma/schema/jobs.prisma +9 -0
- package/template/packages/prisma/schema/media.prisma +9 -0
- package/template/packages/prisma/schema/modules.json +47 -0
- package/template/packages/prisma/schema/notifications.prisma +9 -0
- package/template/packages/prisma/schema/settings.prisma +8 -0
- package/template/packages/prisma/schema/tokens.prisma +10 -0
- package/template/packages/prisma/src/index.d.ts +12 -0
- package/template/packages/prisma/src/index.mjs +138 -0
- package/template/packages/queue/package.json +1 -1
- package/template/packages/resource/package.json +1 -1
- package/template/packages/resource/src/index.ts +1 -0
- package/template/packages/storage/package.json +1 -1
- package/template/packages/storage/src/index.ts +37 -0
- package/template/prisma/migrations/20260713120000_add_user_oidc_key_and_category_order/migration.sql +11 -0
- package/template/prisma/migrations/20261126130000_add_sessions/migration.sql +26 -0
- package/template/prisma/migrations/20261126140000_api_token_hash/migration.sql +3 -0
- package/template/prisma/migrations/20261126150000_payment_idempotency/migration.sql +6 -0
- package/template/prisma/schema.prisma +82 -54
- package/template/prisma/seed.ts +14 -38
- package/template/runtime-versions.json +15 -0
- package/template/scripts/db-init.mjs +33 -0
- package/template/scripts/install-crm.mjs +50 -0
- package/template/scripts/migrate-existing.mjs +65 -0
- package/template/scripts/schema.mjs +48 -0
- package/template/tsconfig.base.json +23 -5
- package/LICENSE +0 -21
- package/dist/create-project.test.d.ts +0 -1
- package/dist/create-project.test.js +0 -99
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -7
- package/dist/resource-slug.test.d.ts +0 -1
- package/dist/resource-slug.test.js +0 -9
- package/template/apps/admin/.storybook/main.ts +0 -12
- package/template/apps/admin/.storybook/preview.ts +0 -10
- package/template/apps/admin/app/login/page.test.tsx +0 -18
- package/template/apps/admin/components/auth-guard.test.tsx +0 -55
- package/template/apps/admin/components/logo.stories.tsx +0 -24
- package/template/apps/admin/lib/api.test.ts +0 -118
- package/template/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
- package/template/apps/admin/vitest.config.ts +0 -7
- package/template/apps/api/src/access/derive-permissions.test.ts +0 -26
- package/template/apps/api/src/admin/admin-resource.service.test.ts +0 -118
- package/template/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
- package/template/apps/api/src/app.module.test.ts +0 -12
- package/template/apps/api/src/auth/auth.service.test.ts +0 -78
- package/template/apps/api/src/auth/sso-oidc.service.test.ts +0 -84
- package/template/apps/api/src/common/auth.guard.test.ts +0 -62
- package/template/apps/api/src/common/casl-ability.factory.test.ts +0 -33
- package/template/apps/api/src/common/request-logging.interceptor.test.ts +0 -39
- package/template/apps/api/src/graphql/admin-resources.resolver.test.ts +0 -45
- package/template/apps/api/src/graphql/ensure-gql-paramtypes.test.ts +0 -44
- package/template/apps/api/src/graphql/graphql-schema.test.ts +0 -26
- package/template/apps/api/src/plugins/manifest.schema.test.ts +0 -36
- package/template/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
- package/template/apps/api/src/queue/queue.service.test.ts +0 -33
- package/template/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
- package/template/apps/api/vitest.config.ts +0 -21
- package/template/apps/web/lib/seo.test.ts +0 -41
- package/template/apps/web/vitest.config.ts +0 -19
- package/template/packages/auth/src/index.test.ts +0 -10
- package/template/packages/brand/src/index.test.ts +0 -9
- package/template/packages/core/src/index.test.ts +0 -27
- package/template/packages/core/vitest.config.ts +0 -9
- package/template/packages/mail/src/index.test.ts +0 -23
- package/template/packages/notifications/src/index.test.ts +0 -9
- package/template/packages/permissions/src/blueprints.test.ts +0 -62
- package/template/packages/permissions/src/index.test.ts +0 -34
- package/template/packages/plugin-sdk/src/sdk.test.ts +0 -13
- package/template/packages/plugin-sdk/vitest.config.ts +0 -5
- package/template/packages/queue/src/index.test.ts +0 -12
- package/template/packages/resource/src/index.test.ts +0 -196
- package/template/packages/storage/src/index.test.ts +0 -10
|
@@ -1,379 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
2
|
import Link from "next/link";
|
|
4
3
|
import { usePathname } from "next/navigation";
|
|
5
4
|
import { useTheme } from "next-themes";
|
|
6
|
-
import { useEffect,
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
ChevronRight,
|
|
10
|
-
FileText,
|
|
11
|
-
Gauge,
|
|
12
|
-
History,
|
|
13
|
-
Image,
|
|
14
|
-
KeyRound,
|
|
15
|
-
Menu,
|
|
16
|
-
Moon,
|
|
17
|
-
Puzzle,
|
|
18
|
-
Search,
|
|
19
|
-
Settings,
|
|
20
|
-
Sparkles,
|
|
21
|
-
Sun,
|
|
22
|
-
Users,
|
|
23
|
-
X
|
|
24
|
-
} from "lucide-react";
|
|
25
|
-
import { AiAssistantWidget } from "./ai-assistant-widget";
|
|
26
|
-
import { api } from "../lib/api";
|
|
5
|
+
import { useEffect,useRef,useState } from "react";
|
|
6
|
+
import { Bot,Bell,ChevronRight,Database,FileText,Gauge,History,Image,Menu,Moon,Puzzle,Search,Settings,Sun,Users,X,Terminal } from "lucide-react";
|
|
7
|
+
import { api,type ResourceMeta } from "../lib/api";
|
|
27
8
|
import { Logo } from "./logo";
|
|
28
|
-
|
|
29
|
-
type
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{ href: "/system-logs", label: "System Logs", icon: FileText },
|
|
51
|
-
{ href: "/plugins", label: "Plugins", icon: Puzzle },
|
|
52
|
-
{ href: "/notifications", label: "Notifications", icon: Bell },
|
|
53
|
-
{ href: "/api-tokens", label: "API Tokens", icon: KeyRound },
|
|
54
|
-
{ href: "/settings", label: "Settings", icon: Settings }
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
function cn(...classes: (string | false | undefined | null)[]) {
|
|
60
|
-
return classes.filter(Boolean).join(" ");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function NavItem({
|
|
64
|
-
href,
|
|
65
|
-
label,
|
|
66
|
-
icon: Icon,
|
|
67
|
-
active,
|
|
68
|
-
onClick
|
|
69
|
-
}: {
|
|
70
|
-
href: string;
|
|
71
|
-
label: string;
|
|
72
|
-
icon: React.ElementType;
|
|
73
|
-
active: boolean;
|
|
74
|
-
onClick?: () => void;
|
|
75
|
-
}) {
|
|
76
|
-
return (
|
|
77
|
-
<Link
|
|
78
|
-
href={href}
|
|
79
|
-
onClick={onClick}
|
|
80
|
-
className={cn(
|
|
81
|
-
"group relative flex items-center gap-3 rounded-xl px-3.5 py-2.5 text-sm font-medium transition-all duration-150",
|
|
82
|
-
active
|
|
83
|
-
? "bg-blue-50 text-[#2454ff]"
|
|
84
|
-
: "text-slate-500 hover:bg-slate-50 hover:text-slate-800"
|
|
85
|
-
)}
|
|
86
|
-
>
|
|
87
|
-
{active && (
|
|
88
|
-
<span className="absolute left-0 top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-[#2454ff]" />
|
|
89
|
-
)}
|
|
90
|
-
<Icon
|
|
91
|
-
className={cn(
|
|
92
|
-
"h-[1.05rem] w-[1.05rem] shrink-0 transition-transform duration-150",
|
|
93
|
-
active
|
|
94
|
-
? "text-[#2454ff]"
|
|
95
|
-
: "text-slate-400 group-hover:scale-110 group-hover:text-slate-600"
|
|
96
|
-
)}
|
|
97
|
-
/>
|
|
98
|
-
<span className="flex-1">{label}</span>
|
|
99
|
-
{active && <ChevronRight className="h-3.5 w-3.5 text-blue-300" />}
|
|
100
|
-
</Link>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function Sidebar({ onClose }: { onClose?: () => void }) {
|
|
105
|
-
const pathname = usePathname();
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<div className="flex h-full flex-col">
|
|
109
|
-
{/* Logo */}
|
|
110
|
-
<div className="flex h-16 shrink-0 items-center border-b border-slate-100 px-5">
|
|
111
|
-
<Link href="/dashboard" onClick={onClose}>
|
|
112
|
-
<Logo />
|
|
113
|
-
</Link>
|
|
114
|
-
</div>
|
|
115
|
-
|
|
116
|
-
{/* Navigation */}
|
|
117
|
-
<nav className="flex-1 overflow-y-auto px-3 py-4">
|
|
118
|
-
<div className="space-y-5">
|
|
119
|
-
{navGroups.map((group) => (
|
|
120
|
-
<div key={group.label}>
|
|
121
|
-
<p className="mb-1.5 px-3.5 text-[10px] font-bold uppercase tracking-widest text-slate-400">
|
|
122
|
-
{group.label}
|
|
123
|
-
</p>
|
|
124
|
-
<div className="space-y-0.5">
|
|
125
|
-
{group.items.map((item) => {
|
|
126
|
-
const active =
|
|
127
|
-
pathname === item.href || pathname.startsWith(`${item.href}/`);
|
|
128
|
-
return (
|
|
129
|
-
<NavItem
|
|
130
|
-
key={item.href}
|
|
131
|
-
{...item}
|
|
132
|
-
active={active}
|
|
133
|
-
onClick={onClose}
|
|
134
|
-
/>
|
|
135
|
-
);
|
|
136
|
-
})}
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
))}
|
|
140
|
-
</div>
|
|
141
|
-
</nav>
|
|
142
|
-
|
|
143
|
-
{/* Promo banner */}
|
|
144
|
-
<div className="mx-3 mb-3 overflow-hidden rounded-2xl bg-gradient-to-br from-[#2454ff] to-[#0ea5a4] p-4 text-white">
|
|
145
|
-
<div className="flex items-center gap-2">
|
|
146
|
-
<Sparkles className="h-4 w-4 opacity-90" />
|
|
147
|
-
<span className="text-[10px] font-bold uppercase tracking-widest opacity-80">
|
|
148
|
-
Resource-driven
|
|
149
|
-
</span>
|
|
150
|
-
</div>
|
|
151
|
-
<p className="mt-2 text-[11px] leading-5 opacity-75">
|
|
152
|
-
API, admin and web are connected through schema metadata.
|
|
153
|
-
</p>
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
{/* User footer */}
|
|
157
|
-
<div className="border-t border-slate-100 p-3">
|
|
158
|
-
<Link
|
|
159
|
-
href="/profile"
|
|
160
|
-
onClick={onClose}
|
|
161
|
-
className="group flex items-center gap-3 rounded-xl px-3 py-2.5 transition-all hover:bg-slate-50"
|
|
162
|
-
>
|
|
163
|
-
<span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-[#2454ff] to-[#0ea5a4] text-[11px] font-bold text-white shadow-[0_2px_8px_rgba(36,84,255,0.3)]">
|
|
164
|
-
A
|
|
165
|
-
</span>
|
|
166
|
-
<div className="min-w-0 flex-1">
|
|
167
|
-
<p className="text-[13px] font-semibold text-slate-800">Admin</p>
|
|
168
|
-
<p className="truncate text-[11px] text-slate-400">Signed in user</p>
|
|
169
|
-
</div>
|
|
170
|
-
<Settings className="h-3.5 w-3.5 shrink-0 text-slate-300 transition-colors group-hover:text-slate-500" />
|
|
171
|
-
</Link>
|
|
172
|
-
</div>
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function ThemeToggle() {
|
|
178
|
-
const { resolvedTheme, setTheme } = useTheme();
|
|
179
|
-
const [mounted, setMounted] = useState(false);
|
|
180
|
-
useEffect(() => setMounted(true), []);
|
|
181
|
-
if (!mounted) return <span className="h-9 w-9" />;
|
|
182
|
-
const isDark = resolvedTheme === "dark";
|
|
183
|
-
return (
|
|
184
|
-
<button
|
|
185
|
-
onClick={() => setTheme(isDark ? "light" : "dark")}
|
|
186
|
-
className="rounded-xl border border-slate-200 p-2.5 text-slate-500 transition hover:bg-slate-50 hover:text-slate-700 dark:border-slate-700 dark:hover:bg-slate-800 dark:hover:text-slate-300"
|
|
187
|
-
aria-label={isDark ? "Switch to light mode" : "Switch to dark mode"}
|
|
188
|
-
>
|
|
189
|
-
{isDark ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
|
|
190
|
-
</button>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function AppShell({ children }: { children: React.ReactNode }) {
|
|
195
|
-
const [mobileOpen, setMobileOpen] = useState(false);
|
|
196
|
-
const [searchOpen, setSearchOpen] = useState(false);
|
|
197
|
-
const [query, setQuery] = useState("");
|
|
198
|
-
const [hits, setHits] = useState<SearchHit[]>([]);
|
|
199
|
-
const [searchLoading, setSearchLoading] = useState(false);
|
|
200
|
-
const pathname = usePathname();
|
|
201
|
-
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
setMobileOpen(false);
|
|
204
|
-
}, [pathname]);
|
|
205
|
-
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
const onKey = (e: KeyboardEvent) => {
|
|
208
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
209
|
-
e.preventDefault();
|
|
210
|
-
setSearchOpen((v) => !v);
|
|
211
|
-
}
|
|
212
|
-
if (e.key === "Escape") setSearchOpen(false);
|
|
213
|
-
};
|
|
214
|
-
window.addEventListener("keydown", onKey);
|
|
215
|
-
return () => window.removeEventListener("keydown", onKey);
|
|
216
|
-
}, []);
|
|
217
|
-
|
|
218
|
-
useEffect(() => {
|
|
219
|
-
if (!searchOpen) return;
|
|
220
|
-
const q = query.trim();
|
|
221
|
-
if (q.length < 2) {
|
|
222
|
-
setHits([]);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const handle = setTimeout(async () => {
|
|
226
|
-
setSearchLoading(true);
|
|
227
|
-
try {
|
|
228
|
-
const result = await api<SearchHit[]>(`/admin/resources/search?q=${encodeURIComponent(q)}&limit=6`);
|
|
229
|
-
setHits(result);
|
|
230
|
-
} catch {
|
|
231
|
-
setHits([]);
|
|
232
|
-
} finally {
|
|
233
|
-
setSearchLoading(false);
|
|
234
|
-
}
|
|
235
|
-
}, 180);
|
|
236
|
-
return () => clearTimeout(handle);
|
|
237
|
-
}, [query, searchOpen]);
|
|
238
|
-
|
|
239
|
-
return (
|
|
240
|
-
<div className="min-h-screen bg-[#f8fafc] text-slate-900 dark:bg-[#0a0f1e] dark:text-slate-100">
|
|
241
|
-
{/* Desktop sidebar */}
|
|
242
|
-
<aside className="fixed inset-y-0 left-0 z-30 hidden w-72 border-r border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-950 md:block">
|
|
243
|
-
<Sidebar />
|
|
244
|
-
</aside>
|
|
245
|
-
|
|
246
|
-
{/* Mobile: overlay */}
|
|
247
|
-
{mobileOpen && (
|
|
248
|
-
<div
|
|
249
|
-
className="fixed inset-0 z-30 bg-slate-900/50 backdrop-blur-sm md:hidden"
|
|
250
|
-
onClick={() => setMobileOpen(false)}
|
|
251
|
-
/>
|
|
252
|
-
)}
|
|
253
|
-
|
|
254
|
-
{/* Mobile: drawer */}
|
|
255
|
-
<aside
|
|
256
|
-
className={cn(
|
|
257
|
-
"fixed inset-y-0 left-0 z-40 w-72 border-r border-slate-200 bg-white transition-transform duration-300 ease-in-out dark:border-slate-800 dark:bg-slate-950 md:hidden",
|
|
258
|
-
mobileOpen ? "translate-x-0" : "-translate-x-full"
|
|
259
|
-
)}
|
|
260
|
-
>
|
|
261
|
-
<Sidebar onClose={() => setMobileOpen(false)} />
|
|
262
|
-
<button
|
|
263
|
-
className="absolute right-3 top-4 rounded-lg p-1.5 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
|
|
264
|
-
onClick={() => setMobileOpen(false)}
|
|
265
|
-
aria-label="Close menu"
|
|
266
|
-
>
|
|
267
|
-
<X className="h-4 w-4" />
|
|
268
|
-
</button>
|
|
269
|
-
</aside>
|
|
270
|
-
|
|
271
|
-
{/* Content area */}
|
|
272
|
-
<div className="md:pl-72">
|
|
273
|
-
{/* Header */}
|
|
274
|
-
<header className="sticky top-0 z-20 flex h-16 items-center gap-3 border-b border-slate-200 bg-white/80 px-4 backdrop-blur-md dark:border-slate-800 dark:bg-slate-950/80 sm:px-6">
|
|
275
|
-
{/* Mobile hamburger */}
|
|
276
|
-
<button
|
|
277
|
-
className="rounded-xl border border-slate-200 p-2 text-slate-500 transition hover:bg-slate-50 hover:text-slate-700 md:hidden"
|
|
278
|
-
onClick={() => setMobileOpen(true)}
|
|
279
|
-
aria-label="Open menu"
|
|
280
|
-
>
|
|
281
|
-
<Menu className="h-4 w-4" />
|
|
282
|
-
</button>
|
|
283
|
-
|
|
284
|
-
{/* Mobile logo */}
|
|
285
|
-
<div className="md:hidden">
|
|
286
|
-
<Logo compact />
|
|
287
|
-
</div>
|
|
288
|
-
|
|
289
|
-
{/* Search */}
|
|
290
|
-
<button
|
|
291
|
-
onClick={() => setSearchOpen(true)}
|
|
292
|
-
className="hidden min-w-0 flex-1 items-center gap-3 rounded-xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm text-slate-400 transition-all hover:border-slate-300 hover:bg-white focus-visible:outline-none md:flex"
|
|
293
|
-
>
|
|
294
|
-
<Search className="h-4 w-4 shrink-0" />
|
|
295
|
-
<span className="flex-1 text-left">Search anything...</span>
|
|
296
|
-
<kbd className="hidden h-5 items-center rounded border border-slate-200 bg-white px-1.5 text-[10px] font-medium text-slate-400 lg:inline-flex">
|
|
297
|
-
⌘K
|
|
298
|
-
</kbd>
|
|
299
|
-
</button>
|
|
300
|
-
|
|
301
|
-
<div className="ml-auto flex items-center gap-2">
|
|
302
|
-
{/* Theme toggle */}
|
|
303
|
-
<ThemeToggle />
|
|
304
|
-
|
|
305
|
-
{/* Notifications */}
|
|
306
|
-
<button
|
|
307
|
-
className="relative rounded-xl border border-slate-200 p-2.5 text-slate-500 transition hover:bg-slate-50 hover:text-slate-700 dark:border-slate-700 dark:hover:bg-slate-800 dark:hover:text-slate-300"
|
|
308
|
-
aria-label="Notifications"
|
|
309
|
-
>
|
|
310
|
-
<Bell className="h-4 w-4" />
|
|
311
|
-
<span className="absolute right-1.5 top-1.5 h-1.5 w-1.5 rounded-full bg-[#2454ff]" />
|
|
312
|
-
</button>
|
|
313
|
-
|
|
314
|
-
{/* User avatar */}
|
|
315
|
-
<Link
|
|
316
|
-
href="/profile"
|
|
317
|
-
className="flex h-9 w-9 items-center justify-center rounded-full bg-gradient-to-br from-[#2454ff] to-[#0ea5a4] text-[11px] font-bold text-white shadow-[0_2px_8px_rgba(36,84,255,0.35)] transition-shadow hover:shadow-[0_4px_14px_rgba(36,84,255,0.45)]"
|
|
318
|
-
aria-label="Profile"
|
|
319
|
-
>
|
|
320
|
-
A
|
|
321
|
-
</Link>
|
|
322
|
-
</div>
|
|
323
|
-
</header>
|
|
324
|
-
|
|
325
|
-
{/* Page content */}
|
|
326
|
-
<main className="mx-auto w-full max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
|
|
327
|
-
{children}
|
|
328
|
-
</main>
|
|
329
|
-
</div>
|
|
330
|
-
<AiAssistantWidget />
|
|
331
|
-
|
|
332
|
-
{searchOpen && (
|
|
333
|
-
<div className="fixed inset-0 z-50 flex items-start justify-center bg-slate-900/45 p-4 pt-20 backdrop-blur-sm">
|
|
334
|
-
<div className="w-full max-w-2xl overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-900">
|
|
335
|
-
<div className="flex items-center gap-3 border-b border-slate-100 px-4 py-3 dark:border-slate-800">
|
|
336
|
-
<Search className="h-4 w-4 text-slate-400" />
|
|
337
|
-
<input
|
|
338
|
-
autoFocus
|
|
339
|
-
value={query}
|
|
340
|
-
onChange={(e) => setQuery(e.target.value)}
|
|
341
|
-
placeholder="Search resources by title…"
|
|
342
|
-
className="w-full bg-transparent text-sm outline-none placeholder:text-slate-400"
|
|
343
|
-
/>
|
|
344
|
-
<button
|
|
345
|
-
onClick={() => setSearchOpen(false)}
|
|
346
|
-
className="rounded-md p-1.5 text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800"
|
|
347
|
-
aria-label="Close search"
|
|
348
|
-
>
|
|
349
|
-
<X className="h-4 w-4" />
|
|
350
|
-
</button>
|
|
351
|
-
</div>
|
|
352
|
-
<div className="max-h-[50vh] overflow-y-auto p-2">
|
|
353
|
-
{searchLoading && <p className="px-3 py-2 text-xs text-slate-400">Searching…</p>}
|
|
354
|
-
{!searchLoading && query.trim().length < 2 && (
|
|
355
|
-
<p className="px-3 py-2 text-xs text-slate-400">Type at least 2 characters.</p>
|
|
356
|
-
)}
|
|
357
|
-
{!searchLoading && query.trim().length >= 2 && hits.length === 0 && (
|
|
358
|
-
<p className="px-3 py-2 text-xs text-slate-400">No matches.</p>
|
|
359
|
-
)}
|
|
360
|
-
{hits.map((hit) => (
|
|
361
|
-
<Link
|
|
362
|
-
key={`${hit.resource}:${hit.id}`}
|
|
363
|
-
href={`/resources/${hit.resource}/${hit.id}`}
|
|
364
|
-
onClick={() => setSearchOpen(false)}
|
|
365
|
-
className="block rounded-lg px-3 py-2.5 hover:bg-slate-50 dark:hover:bg-slate-800"
|
|
366
|
-
>
|
|
367
|
-
<p className="text-sm font-medium text-slate-800 dark:text-slate-100">{hit.title}</p>
|
|
368
|
-
<p className="text-xs text-slate-500">
|
|
369
|
-
{hit.resourceLabel} · {hit.id.slice(-8)}
|
|
370
|
-
</p>
|
|
371
|
-
</Link>
|
|
372
|
-
))}
|
|
373
|
-
</div>
|
|
374
|
-
</div>
|
|
375
|
-
</div>
|
|
376
|
-
)}
|
|
377
|
-
</div>
|
|
378
|
-
);
|
|
9
|
+
type Me={name?:string|null;email:string;permissions:string[]};
|
|
10
|
+
type Hit={resource:string;resourceLabel:string;id:string;title:string};
|
|
11
|
+
const icons={FileText,Users,Image,History,Bell,Settings,Database,Gauge,Puzzle};
|
|
12
|
+
const direct:Record<string,string>={"api-tokens":"/api-tokens",files:"/files","audit-logs":"/audit-logs",notifications:"/notifications"};
|
|
13
|
+
export function AppShell({children}:{children:React.ReactNode}){
|
|
14
|
+
const pathname=usePathname(),{resolvedTheme,setTheme}=useTheme();
|
|
15
|
+
const [me,setMe]=useState<Me|null>(null),[resources,setResources]=useState<ResourceMeta[]>([]),[navError,setNavError]=useState(false),[mobile,setMobile]=useState(false),[search,setSearch]=useState(false),[query,setQuery]=useState(""),[hits,setHits]=useState<Hit[]>([]),[status,setStatus]=useState("Type at least 2 characters."),[mounted,setMounted]=useState(false),[aiEnabled,setAiEnabled]=useState(false);
|
|
16
|
+
const dialog=useRef<HTMLDialogElement>(null),input=useRef<HTMLInputElement>(null);
|
|
17
|
+
useEffect(()=>{setMounted(true);let live=true;Promise.all([api<Me>("/auth/me"),api<ResourceMeta[]>("/admin/resources")]).then(([u,r])=>{if(live){setMe(u);setResources(r);api<{enabled:boolean}>("/admin/ai/status").then(s=>{if(live)setAiEnabled(s.enabled)}).catch(()=>{})}}).catch(()=>{if(live)setNavError(true)});return()=>{live=false}},[]);
|
|
18
|
+
useEffect(()=>{setMobile(false);setSearch(false)},[pathname]);
|
|
19
|
+
useEffect(()=>{const fn=(e:KeyboardEvent)=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="k"){e.preventDefault();setSearch(v=>!v)}if(e.key==="Escape")setMobile(false)};document.addEventListener("keydown",fn);return()=>document.removeEventListener("keydown",fn)},[]);
|
|
20
|
+
useEffect(()=>{if(search&&!dialog.current?.open){dialog.current?.showModal();input.current?.focus()}if(!search&&dialog.current?.open)dialog.current.close()},[search]);
|
|
21
|
+
useEffect(()=>{if(!search)return;let live=true;setHits([]);if(query.trim().length<2){setStatus("Type at least 2 characters.");return}setStatus("Searching…");const timer=setTimeout(()=>{api<Hit[]>("/admin/resources/search?q="+encodeURIComponent(query.trim())+"&limit=6").then(r=>{if(live){setHits(r);setStatus(r.length?"":"No matches.")}}).catch(()=>{if(live)setStatus("Search unavailable. Try again.")})},220);return()=>{live=false;clearTimeout(timer)}},[query,search]);
|
|
22
|
+
const can=(p:string)=>Boolean(me?.permissions.includes("*")||me?.permissions.includes(p));
|
|
23
|
+
const nav=(href:string,title:string,Icon:React.ElementType)=>{const active=pathname===href||pathname.startsWith(href+"/");return <Link key={href} href={href} aria-current={active?"page":undefined} className={"oc-nav-item"+(active?" is-active":"")} onClick={()=>setMobile(false)}><Icon size={17} aria-hidden/><span>{title}</span>{active&&<ChevronRight size={14}/>}</Link>};
|
|
24
|
+
const sidebar=<><div className="oc-workspace"><div className="oc-workspace-icon"><Terminal size={19}/></div><div><strong>Workspace</strong><small>RESOURCE ENGINE</small></div></div><nav aria-label="Workspace navigation" className="oc-sidebar-nav"><p>Overview</p>{nav("/dashboard","Dashboard",Gauge)}<p>Resources</p>{navError?<small>Unable to load resources</small>:!me?<small>Loading…</small>:resources.filter(r=>r.name !== "settings").map(r=>nav(direct[r.name]??"/resources/"+r.name,r.label,icons[r.icon as keyof typeof icons]??Database))}<p>Workspace</p>{can("system-logs.read")&&nav("/system-logs","System logs",FileText)}{can("*")&&nav("/plugins","Plugins",Puzzle)}{aiEnabled&&nav("/assistant","Assistant",Bot)}{nav("/settings","Settings",Settings)}</nav><div className="oc-sidebar-foot"><span className="oc-status-dot"/><span>Open Core<small>Development workspace</small></span></div></>;
|
|
25
|
+
const current=resources.find(r=>pathname=== (direct[r.name]??"/resources/"+r.name)||pathname.startsWith((direct[r.name]??"/resources/"+r.name)+"/"));
|
|
26
|
+
return <div className="oc-shell"><a href="#workspace-main" className="oc-skip-link">Skip to content</a>
|
|
27
|
+
<header className="oc-topbar"><button type="button" className="oc-top-icon oc-mobile-menu" aria-label="Open navigation" aria-expanded={mobile} onClick={()=>setMobile(v=>!v)}><Menu size={20}/></button><Link href="/dashboard"><Logo compact/></Link><span className="oc-top-caption">ADMIN / WORKSPACE</span><button className="oc-top-search" type="button" onClick={()=>setSearch(true)}><Search size={16}/><span>Search resources</span><kbd>Ctrl K</kbd></button><div className="oc-top-actions"><button className="oc-top-icon oc-mobile-search" type="button" aria-label="Search resources" onClick={()=>setSearch(true)}><Search size={18}/></button><button type="button" className="oc-top-icon" aria-label={mounted&&resolvedTheme==="dark"?"Switch to light mode":"Switch to dark mode"} onClick={()=>setTheme(resolvedTheme==="dark"?"light":"dark")}>{mounted&&resolvedTheme==="dark"?<Sun size={18}/>:<Moon size={18}/>}</button>{resources.some(r=>r.name==="notifications")&&<Link href="/notifications" className="oc-top-icon" aria-label="Notifications"><Bell size={18}/></Link>}<Link className="oc-account" href="/profile" aria-label="Account" title={me?.email}>{me?.name?.[0]?.toUpperCase()??me?.email?.[0]?.toUpperCase()??"A"}</Link></div></header>
|
|
28
|
+
<aside className="oc-sidebar">{sidebar}</aside>{mobile&&<div className="oc-mobile-overlay"><button className="oc-mobile-backdrop" aria-label="Close navigation" onClick={()=>setMobile(false)}/><aside className="oc-mobile-sidebar"><button className="oc-mobile-close" aria-label="Close navigation" onClick={()=>setMobile(false)}><X size={20}/></button>{sidebar}</aside></div>}
|
|
29
|
+
<main id="workspace-main" tabIndex={-1} className="oc-main-area"><div className="oc-breadcrumb"><Link href="/dashboard">Workspace</Link><ChevronRight size={12}/><span>{current?.label??(pathname.split("/")[1]||"overview").replaceAll("-"," ")}</span></div><div className="oc-content">{children}</div></main>
|
|
30
|
+
<dialog ref={dialog} aria-label="Search workspace" className="oc-command-dialog" onClose={()=>setSearch(false)} onCancel={()=>setSearch(false)} onClick={e=>{if(e.target===e.currentTarget)setSearch(false)}}><div className="oc-command-head"><Search size={20}/><input ref={input} aria-label="Search resources" placeholder="Search by name or title…" value={query} onChange={e=>setQuery(e.target.value)}/><button type="button" aria-label="Close search" onClick={()=>setSearch(false)}><X size={18}/></button></div><div className="oc-command-results" aria-live="polite">{status&&<p>{status}</p>}{hits.map(h=><Link key={h.resource+h.id} href={"/resources/"+h.resource+"/"+h.id} onClick={()=>setSearch(false)}><Database size={16}/><span><strong>{h.title}</strong><small>{h.resourceLabel}</small></span><ChevronRight size={16}/></Link>)}</div></dialog></div>;
|
|
379
31
|
}
|
|
@@ -1,39 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Client-side auth guard — secondary fallback after the Next.js middleware SSR check.
|
|
5
|
-
* The middleware handles the primary redirect before any page renders.
|
|
6
|
-
* This component catches edge cases where the client navigates directly (e.g. browser back/forward
|
|
7
|
-
* cache) and the cookie has expired between page loads without the middleware re-running.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
2
|
import React from "react";
|
|
11
3
|
import { usePathname, useRouter } from "next/navigation";
|
|
12
|
-
import { useEffect
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
function isPublicPath(pathname: string | null): boolean {
|
|
16
|
-
if (!pathname) return false;
|
|
17
|
-
return pathname === "/login" || pathname.startsWith("/login/");
|
|
18
|
-
}
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { api } from "../lib/api";
|
|
19
6
|
|
|
20
7
|
export function AuthGuard({ children }: { children: React.ReactNode }) {
|
|
21
8
|
const pathname = usePathname();
|
|
22
9
|
const router = useRouter();
|
|
23
|
-
const checked = useRef(false);
|
|
24
|
-
|
|
25
10
|
useEffect(() => {
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
11
|
+
if (!pathname || pathname === "/login" || pathname.startsWith("/login/")) return;
|
|
12
|
+
let cancelled = false;
|
|
13
|
+
api("/auth/me").catch(error => {
|
|
14
|
+
if (!cancelled && error?.status === 401) router.replace(`/login?next=${encodeURIComponent(pathname)}`);
|
|
15
|
+
});
|
|
16
|
+
return () => { cancelled = true; };
|
|
33
17
|
}, [pathname, router]);
|
|
34
|
-
|
|
35
|
-
// Render children immediately — no loading flash.
|
|
36
|
-
// The middleware already protected this route server-side; if somehow we reach here
|
|
37
|
-
// without a valid token, the router.replace above will kick in on the next tick.
|
|
38
18
|
return <>{children}</>;
|
|
39
19
|
}
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
import { useTheme } from "next-themes";
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import { BRAND } from "../lib/brand";
|
|
6
|
-
|
|
7
|
-
export function Logo({ compact = false }: { compact?: boolean }) {
|
|
8
|
-
const { resolvedTheme } = useTheme();
|
|
9
|
-
const [mounted, setMounted] = useState(false);
|
|
10
|
-
useEffect(() => setMounted(true), []);
|
|
11
|
-
|
|
12
|
-
const sizeClass = compact
|
|
13
|
-
? "h-7 w-auto max-w-[min(11rem,42vw)] shrink-0 object-contain object-left"
|
|
14
|
-
: "h-8 w-auto max-w-[min(16rem,85vw)] object-contain object-left";
|
|
15
|
-
|
|
16
|
-
// Before hydration, render a placeholder so there's no layout shift
|
|
17
|
-
if (!mounted) {
|
|
18
|
-
return <span className={compact ? "inline-block h-7 w-32" : "inline-block h-8 w-40"} />;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const isDark = resolvedTheme === "dark";
|
|
22
|
-
return (
|
|
23
|
-
<img
|
|
24
|
-
src={isDark ? BRAND.logoMonochromePng : BRAND.logoNew}
|
|
25
|
-
alt="OpenAdminJS"
|
|
26
|
-
className={sizeClass}
|
|
27
|
-
draggable={false}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
1
|
+
export function Logo({compact=false}:{compact?:boolean}){return <span className={"oc-brand-mark"+(compact?" oc-brand-compact":"")} aria-label="OpenAdminJS"><svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M29 13a19 19 0 1 0 0 38h9l11-23 7 15H45l-4 8h18L42 13h-8L21 42a11 11 0 1 1 8-21l3-7z"/></svg><span>OpenAdmin<span className="oc-brand-accent">JS</span></span></span>}
|
|
@@ -140,8 +140,8 @@ function RelationPicker({ field, value, onChange, disabled }: RelationPickerProp
|
|
|
140
140
|
<button
|
|
141
141
|
type="button"
|
|
142
142
|
onClick={() => { onChange(opt.id); setSelectedLabel(opt.label); setOpen(false); setSearch(""); }}
|
|
143
|
-
className={`w-full px-4 py-2.5 text-left text-sm transition-colors hover:bg-
|
|
144
|
-
opt.id === value ? "bg-[#
|
|
143
|
+
className={`w-full px-4 py-2.5 text-left text-sm transition-colors hover:bg-lime-50 hover:text-[#426b1d] dark:hover:bg-slate-800 ${
|
|
144
|
+
opt.id === value ? "bg-[#e6f6d4] font-semibold text-[#426b1d] dark:bg-slate-800" : "text-slate-700 dark:text-slate-300"
|
|
145
145
|
}`}
|
|
146
146
|
>
|
|
147
147
|
{opt.label}
|
|
@@ -265,7 +265,7 @@ export function ResourceForm({ resource, mode, recordId, initialData }: Props) {
|
|
|
265
265
|
<ArrowLeft className="h-4 w-4" />
|
|
266
266
|
</Link>
|
|
267
267
|
<div>
|
|
268
|
-
<p className="text-[11px] font-bold uppercase tracking-widest text-[#
|
|
268
|
+
<p className="text-[11px] font-bold uppercase tracking-widest text-[#426b1d]">
|
|
269
269
|
{mode === "create" ? "New record" : "Edit record"}
|
|
270
270
|
</p>
|
|
271
271
|
<h1 className="text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-100">
|
|
@@ -77,8 +77,8 @@ function SkeletonRow({ cols }: { cols: number }) {
|
|
|
77
77
|
function SortIcon({ field, sort }: { field: string; sort?: SortState }) {
|
|
78
78
|
if (!sort || sort.field !== field) return <ArrowUpDown className="h-3 w-3 text-slate-300 group-hover:text-slate-400" />;
|
|
79
79
|
return sort.dir === "asc"
|
|
80
|
-
? <ArrowUp className="h-3 w-3 text-[#
|
|
81
|
-
: <ArrowDown className="h-3 w-3 text-[#
|
|
80
|
+
? <ArrowUp className="h-3 w-3 text-[#426b1d]" />
|
|
81
|
+
: <ArrowDown className="h-3 w-3 text-[#426b1d]" />;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function canInlineEdit(field: ResourceMeta["fields"][string], canUpdate: boolean): boolean {
|
|
@@ -291,7 +291,7 @@ export function ResourceTable({
|
|
|
291
291
|
<div className="space-y-5">
|
|
292
292
|
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between animate-in stagger-1">
|
|
293
293
|
<div>
|
|
294
|
-
<p className="text-[11px] font-bold uppercase tracking-widest text-[#
|
|
294
|
+
<p className="text-[11px] font-bold uppercase tracking-widest text-[#426b1d]">Resource</p>
|
|
295
295
|
<h1 className="mt-1 text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-100">
|
|
296
296
|
{resource.label}
|
|
297
297
|
</h1>
|
|
@@ -311,7 +311,7 @@ export function ResourceTable({
|
|
|
311
311
|
</div>
|
|
312
312
|
|
|
313
313
|
<div className="flex flex-wrap items-center gap-2 animate-in stagger-2">
|
|
314
|
-
<div className="flex min-w-[200px] flex-1 items-center gap-2.5 rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 shadow-[0_1px_3px_rgba(0,0,0,0.04)] transition-all focus-within:border-[#
|
|
314
|
+
<div className="flex min-w-[200px] flex-1 items-center gap-2.5 rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 shadow-[0_1px_3px_rgba(0,0,0,0.04)] transition-all focus-within:border-[#426b1d] focus-within:shadow-[0_0_0_3px_rgba(66,107,29,0.1)] dark:border-slate-700 dark:bg-slate-900">
|
|
315
315
|
<Search className="h-4 w-4 shrink-0 text-slate-400" />
|
|
316
316
|
<input
|
|
317
317
|
value={search}
|
|
@@ -337,7 +337,7 @@ export function ResourceTable({
|
|
|
337
337
|
</div>
|
|
338
338
|
|
|
339
339
|
{selected.size > 0 && bulkEnabled && (
|
|
340
|
-
<div className="flex flex-wrap items-center gap-2 rounded-xl border border-[#
|
|
340
|
+
<div className="flex flex-wrap items-center gap-2 rounded-xl border border-[#426b1d]/30 bg-[#e6f6d4] px-4 py-3 text-sm dark:border-lime-500/30 dark:bg-slate-800/80">
|
|
341
341
|
<span className="font-semibold text-slate-800 dark:text-slate-200">{selected.size} selected</span>
|
|
342
342
|
{resource.permissions.delete && (
|
|
343
343
|
<button
|
|
@@ -416,6 +416,10 @@ export function ResourceTable({
|
|
|
416
416
|
onDragOver={(e) => e.preventDefault()}
|
|
417
417
|
onDrop={() => onColDrop(name)}
|
|
418
418
|
className={`${padClass} ${sortable ? "cursor-pointer select-none" : "cursor-grab active:cursor-grabbing"}`}
|
|
419
|
+
scope="col"
|
|
420
|
+
aria-sort={sortable ? sort?.field === name ? sort.dir === "asc" ? "ascending" : "descending" : "none" : undefined}
|
|
421
|
+
tabIndex={sortable ? 0 : undefined}
|
|
422
|
+
onKeyDown={(e) => {if(sortable && (e.key==="Enter"||e.key===" ")){e.preventDefault();handleSort(name);}}}
|
|
419
423
|
onClick={() => sortable && handleSort(name)}
|
|
420
424
|
>
|
|
421
425
|
<div className="group flex items-center gap-1 text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400">
|
|
@@ -444,7 +448,7 @@ export function ResourceTable({
|
|
|
444
448
|
return (
|
|
445
449
|
<tr
|
|
446
450
|
key={rowId}
|
|
447
|
-
className={`group transition-colors hover:bg-
|
|
451
|
+
className={`group transition-colors hover:bg-lime-50/30 dark:hover:bg-slate-800/50 ${dragRowId === rowId ? "opacity-70" : ""}`}
|
|
448
452
|
onDragOver={(e) => listReorderEnabled && e.preventDefault()}
|
|
449
453
|
onDrop={() => onRowDrop(rowId)}
|
|
450
454
|
>
|
|
@@ -563,7 +567,7 @@ export function ResourceTable({
|
|
|
563
567
|
<td className={`${padClass} text-right`}>
|
|
564
568
|
<Link
|
|
565
569
|
href={`/resources/${resource.name}/${rowId}`}
|
|
566
|
-
className="inline-flex items-center gap-1 rounded-lg bg-slate-100 px-2.5 py-1 text-xs font-semibold text-slate-600 transition-all hover:bg-[#
|
|
570
|
+
className="inline-flex items-center gap-1 rounded-lg bg-slate-100 px-2.5 py-1 text-xs font-semibold text-slate-600 transition-all hover:bg-[#e6f6d4] hover:text-[#426b1d] dark:bg-slate-800 dark:text-slate-400 dark:hover:bg-slate-700"
|
|
567
571
|
>
|
|
568
572
|
Open
|
|
569
573
|
</Link>
|
|
@@ -616,7 +620,7 @@ export function ResourceTable({
|
|
|
616
620
|
onClick={() => onPageChange?.(p)}
|
|
617
621
|
className={`flex h-7 w-7 items-center justify-center rounded-lg text-xs font-semibold transition ${
|
|
618
622
|
p === pagination.page
|
|
619
|
-
? "bg-[#
|
|
623
|
+
? "bg-[#426b1d] text-white shadow-[0_2px_6px_rgba(66,107,29,0.35)]"
|
|
620
624
|
: "border border-slate-200 text-slate-500 hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
|
|
621
625
|
}`}
|
|
622
626
|
>
|