create-nextjs-cms 0.6.1 → 0.6.3
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/package.json +1 -1
- package/templates/default/app/(auth)/auth/login/LoginPage.tsx +5 -1
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/page.tsx +8 -4
- package/templates/default/app/(rootLayout)/dashboard/page.tsx +20 -1
- package/templates/default/app/globals.css +5 -0
- package/templates/default/components/AdminCard.tsx +2 -3
- package/templates/default/components/AdminPrivilegeCard.tsx +1 -1
- package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
- package/templates/default/components/login-locale-dropdown.tsx +2 -1
- package/templates/default/components/ui/badge.tsx +1 -0
- package/templates/default/package.json +3 -3
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { Button } from '@/components/ui/button'
|
|
|
11
11
|
import { MoonIcon, SunIcon } from '@radix-ui/react-icons'
|
|
12
12
|
import { useTheme } from 'next-themes'
|
|
13
13
|
import { login, useSession } from 'nextjs-cms/auth/react'
|
|
14
|
+
import { wasLocaleChangedOnLogin } from 'nextjs-cms/translations'
|
|
14
15
|
import LoginLocaleDropdown from '@/components/login-locale-dropdown'
|
|
15
16
|
import { useAuthLocale } from '../../auth-locale-provider'
|
|
16
17
|
|
|
@@ -38,10 +39,13 @@ export default function LoginPage() {
|
|
|
38
39
|
loginButtonRef.current.innerHTML = t('loading')
|
|
39
40
|
}
|
|
40
41
|
try {
|
|
42
|
+
// Only send locale if user explicitly changed it on login page
|
|
43
|
+
// Otherwise, server will use admin's stored DB preference
|
|
44
|
+
const localeChanged = wasLocaleChangedOnLogin()
|
|
41
45
|
await login({
|
|
42
46
|
username: formRef.current?.username.value,
|
|
43
47
|
password: formRef.current?.password.value,
|
|
44
|
-
locale: initialLocale,
|
|
48
|
+
locale: localeChanged ? initialLocale : undefined,
|
|
45
49
|
})
|
|
46
50
|
} catch (error: any) {
|
|
47
51
|
if (loginButtonRef.current) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { notFound } from 'next/navigation'
|
|
2
2
|
import auth from 'nextjs-cms/auth'
|
|
3
3
|
import { getAdminPrivileges } from 'nextjs-cms/api/helpers'
|
|
4
|
-
import { findPluginRouteByPath } from 'nextjs-cms/plugins/server'
|
|
4
|
+
import { findPluginRouteByPath, isDashboardOverridePlugin } from 'nextjs-cms/plugins/server'
|
|
5
5
|
import { getPluginServerComponent } from './plugin-server-registry'
|
|
6
6
|
|
|
7
7
|
export const dynamic = 'force-dynamic'
|
|
@@ -22,9 +22,13 @@ export default async function Page(props: { params: Params }) {
|
|
|
22
22
|
notFound()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Bypass privilege check for dashboard override plugin
|
|
26
|
+
const isDashboardPlugin = await isDashboardOverridePlugin(plugin.pluginName)
|
|
27
|
+
if (!isDashboardPlugin) {
|
|
28
|
+
const privilegeSet = await getAdminPrivileges(session.user.id)
|
|
29
|
+
if (!privilegeSet.has(plugin.pluginName)) {
|
|
30
|
+
notFound()
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
const PluginComponent = await getPluginServerComponent(plugin.pluginRegistryName, plugin.component)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { getDashboardOverride } from 'nextjs-cms/plugins/server'
|
|
2
|
+
import { getPluginServerComponent } from '../(plugins)/[...slug]/plugin-server-registry'
|
|
3
|
+
|
|
1
4
|
export const dynamic = 'force-dynamic'
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
function DefaultDashboard() {
|
|
4
7
|
return (
|
|
5
8
|
<div className='w-full'>
|
|
6
9
|
<div className='bg-linear-to-r from-amber-200 via-orange-200 to-rose-200 p-8 text-foreground dark:from-amber-900 dark:via-orange-900 dark:to-rose-900'>
|
|
@@ -42,3 +45,19 @@ export default function DashboardPage() {
|
|
|
42
45
|
</div>
|
|
43
46
|
)
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
export default async function DashboardPage() {
|
|
50
|
+
// Check for dashboard override configuration
|
|
51
|
+
const override = await getDashboardOverride()
|
|
52
|
+
if (!override) {
|
|
53
|
+
return <DefaultDashboard />
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Render the override plugin component (no privilege check for dashboard override)
|
|
57
|
+
const PluginComponent = await getPluginServerComponent(override.pluginRegistryName, override.component)
|
|
58
|
+
if (!PluginComponent) {
|
|
59
|
+
return <DefaultDashboard />
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return <PluginComponent />
|
|
63
|
+
}
|
|
@@ -11,13 +11,12 @@ import { Button } from '@/components/ui/button'
|
|
|
11
11
|
import { trpc } from '@/app/_trpc/client'
|
|
12
12
|
import Image from 'next/image'
|
|
13
13
|
import type { RouterOutputs } from 'nextjs-cms/api'
|
|
14
|
-
|
|
15
14
|
export default function AdminCard({
|
|
16
15
|
admin,
|
|
17
16
|
action,
|
|
18
17
|
}: {
|
|
19
|
-
admin: RouterOutputs['admins']['list']['admins'][
|
|
20
|
-
action:
|
|
18
|
+
admin: NonNullable<RouterOutputs['admins']['list']['admins']>[number]
|
|
19
|
+
action: () => void
|
|
21
20
|
}) {
|
|
22
21
|
const t = useI18n()
|
|
23
22
|
const { setModal, modal, modalResponse, setModalResponse } = useModal()
|
|
@@ -16,7 +16,7 @@ export default function AdminRoleCard({
|
|
|
16
16
|
publisher: false,
|
|
17
17
|
}
|
|
18
18
|
}: {
|
|
19
|
-
privilege: RouterOutputs['admins']['list']['privileges'][
|
|
19
|
+
privilege: NonNullable<RouterOutputs['admins']['list']['privileges']>[number]
|
|
20
20
|
allChecked: boolean | 'edited' | null
|
|
21
21
|
setAllChecked: React.Dispatch<React.SetStateAction<boolean | 'edited' | null>>
|
|
22
22
|
defaultValue?: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useCallback } from 'react'
|
|
4
4
|
import { useRouter } from 'next/navigation'
|
|
5
5
|
import { useI18n } from 'nextjs-cms/translations/client'
|
|
6
|
-
import { setLoginPageLocaleCookie } from 'nextjs-cms/translations'
|
|
6
|
+
import { setLoginPageLocaleCookie, markLocaleChangedOnLogin } from 'nextjs-cms/translations'
|
|
7
7
|
import LocalePicker from './locale-picker'
|
|
8
8
|
|
|
9
9
|
export interface LoginLocaleDropdownProps {
|
|
@@ -29,6 +29,7 @@ export default function LoginLocaleDropdown({
|
|
|
29
29
|
(locale: string) => {
|
|
30
30
|
if (locale === currentLocale) return
|
|
31
31
|
setLoginPageLocaleCookie(locale)
|
|
32
|
+
markLocaleChangedOnLogin()
|
|
32
33
|
router.refresh()
|
|
33
34
|
},
|
|
34
35
|
[currentLocale, router],
|
|
@@ -12,6 +12,7 @@ const badgeVariants = cva(
|
|
|
12
12
|
default: 'border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
|
13
13
|
primary: 'border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
|
14
14
|
secondary: 'border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90',
|
|
15
|
+
success: 'border-transparent bg-green-500 text-white [a&]:hover:bg-green-600',
|
|
15
16
|
destructive:
|
|
16
17
|
'border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
17
18
|
outline: 'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"file-type": "^20.1.0",
|
|
62
62
|
"isomorphic-dompurify": "^2.21.0",
|
|
63
63
|
"lodash-es": "^4.17.21",
|
|
64
|
-
"lucide-react": "^0.
|
|
64
|
+
"lucide-react": "^0.563.0",
|
|
65
65
|
"nanoid": "^5.1.2",
|
|
66
66
|
"next": "16.1.1",
|
|
67
67
|
"next-themes": "^0.4.6",
|
|
68
|
-
"nextjs-cms": "0.6.
|
|
68
|
+
"nextjs-cms": "0.6.3",
|
|
69
69
|
"plaiceholder": "^3.0.0",
|
|
70
70
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
71
71
|
"qrcode": "^1.5.4",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"eslint-config-prettier": "^10.0.1",
|
|
99
99
|
"eslint-plugin-prettier": "^5.2.3",
|
|
100
100
|
"fs-extra": "^11.3.3",
|
|
101
|
-
"nextjs-cms-kit": "0.6.
|
|
101
|
+
"nextjs-cms-kit": "0.6.3",
|
|
102
102
|
"postcss": "^8.5.1",
|
|
103
103
|
"prettier": "3.5.0",
|
|
104
104
|
"raw-loader": "^4.0.2",
|