All files / src/app/layout/sidebar SidebarNavList.tsx

100% Statements 88/88
100% Branches 2/2
100% Functions 1/1
100% Lines 88/88

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 891x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x  
/**
 * @file SidebarNavList.tsx
 * @module app/layout/sidebar/SidebarNavList
 *
 * @summary
 * Navigation items list extracted from sidebar footer.
 * Renders all navigation items from centralized navConfig with route matching.
 *
 * @enterprise
 * - Centralized navigation from navConfig module
 * - i18n translation with type casting for dynamic keys
 * - Route matching for active state highlighting
 * - Support for disabled navigation items via feature flags
 * - Full TypeDoc coverage for navigation rendering logic
 */
 
import {
  List,
  Box,
  Divider,
  ListItemButton,
  ListItemIcon,
  ListItemText,
} from '@mui/material';
import LogoutIcon from '@mui/icons-material/Logout';
import { useTranslation } from 'react-i18next';
import { NAV_ITEMS } from '../navConfig';
import NavItem from './NavItem';
 
interface SidebarNavListProps {
  /** Callback for logout action */
  onLogout: () => void;
}
 
/**
 * Sidebar navigation list component.
 *
 * Renders all navigation items from navConfig and logout button.
 * Navigation items support disabled state with tooltips.
 *
 * @param props - Component props
 * @returns JSX element rendering navigation list with logout button
 *
 * @example
 * ```tsx
 * <SidebarNavList onLogout={handleLogout} />
 * ```
 */
export default function SidebarNavList({ onLogout }: SidebarNavListProps) {
  const { t } = useTranslation(['common']);
 
  return (
    <>
      {/* Navigation Items */}
      <Box sx={{ py: 0.25 }}>
        <List>
          {NAV_ITEMS.map((item) => {
            // Cast label key to bypass strict type checking for dynamic i18n keys
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            const translatedLabel = t(item.label as any);
            return (
              <NavItem
                key={item.route}
                to={item.route}
                icon={item.icon}
                label={translatedLabel}
                disabled={item.disabled}
                tooltip={item.tooltip}
              />
            );
          })}
        </List>
      </Box>
 
      <Divider />
 
      {/* Logout Button */}
      <Box sx={{ p: 1 }}>
        <ListItemButton onClick={onLogout} sx={{ borderRadius: 1 }}>
          <ListItemIcon sx={{ minWidth: 36 }}>
            <LogoutIcon />
          </ListItemIcon>
          <ListItemText primary={t('nav.logout')} />
        </ListItemButton>
      </Box>
    </>
  );
}