feat: remove Account page and add PassthroughLanding page
- Deleted the Account page and its associated logic. - Introduced a new PassthroughLanding page for users without management access. - Updated Settings page to conditionally display the Users link for admin users. - Enhanced UsersPage to support passthrough user role, including invite functionality and user detail modal. - Updated tests to reflect changes in user roles and navigation.
This commit is contained in:
@@ -85,8 +85,7 @@ export default function Layout({ children }: LayoutProps) {
|
||||
{ name: t('navigation.system'), path: '/settings/system', icon: '⚙️' },
|
||||
{ name: t('navigation.notifications'), path: '/settings/notifications', icon: '🔔' },
|
||||
{ name: t('navigation.email'), path: '/settings/smtp', icon: '📧' },
|
||||
{ name: t('navigation.adminAccount'), path: '/settings/account', icon: '🛡️' },
|
||||
{ name: t('navigation.accountManagement'), path: '/settings/account-management', icon: '👥' },
|
||||
...(user?.role === 'admin' ? [{ name: t('navigation.users'), path: '/settings/users', icon: '👥' }] : []),
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -109,6 +108,8 @@ export default function Layout({ children }: LayoutProps) {
|
||||
]
|
||||
},
|
||||
].filter(item => {
|
||||
// Passthrough users see no navigation — they're redirected to /passthrough
|
||||
if (user?.role === 'passthrough') return false
|
||||
// Optional Features Logic
|
||||
// Default to visible (true) if flags are loading or undefined
|
||||
if (item.name === t('navigation.uptime')) return featureFlags?.['feature.uptime.enabled'] !== false
|
||||
@@ -362,7 +363,7 @@ export default function Layout({ children }: LayoutProps) {
|
||||
</div>
|
||||
<div className="w-1/3 flex justify-end items-center gap-4">
|
||||
{user && (
|
||||
<Link to="/settings/account" className="text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors">
|
||||
<Link to="/settings/users" className="text-sm font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors">
|
||||
{user.name}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
25
frontend/src/components/RequireRole.tsx
Normal file
25
frontend/src/components/RequireRole.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react'
|
||||
import { Navigate } from 'react-router-dom'
|
||||
import { useAuth } from '../hooks/useAuth'
|
||||
|
||||
interface RequireRoleProps {
|
||||
allowed: Array<'admin' | 'user' | 'passthrough'>
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const RequireRole: React.FC<RequireRoleProps> = ({ allowed, children }) => {
|
||||
const { user } = useAuth()
|
||||
|
||||
if (!user) {
|
||||
return <Navigate to="/login" replace />
|
||||
}
|
||||
|
||||
if (!allowed.includes(user.role)) {
|
||||
const redirectTarget = user.role === 'passthrough' ? '/passthrough' : '/'
|
||||
return <Navigate to={redirectTarget} replace />
|
||||
}
|
||||
|
||||
return children
|
||||
}
|
||||
|
||||
export default RequireRole
|
||||
Reference in New Issue
Block a user