Move checklist to admin settings

This commit is contained in:
Sam Becker 2023-10-11 11:00:34 -05:00
parent bb94f75270
commit 8e18eb7766
4 changed files with 34 additions and 13 deletions

View File

@ -1,9 +1,15 @@
'use client'; 'use client';
import SiteGrid from '@/components/SiteGrid'; import SiteGrid from '@/components/SiteGrid';
import {
PATH_ADMIN_SETTINGS,
checkPathPrefix,
isPathAdminSettings,
} from '@/site/paths';
import { cc } from '@/utility/css'; import { cc } from '@/utility/css';
import Link from 'next/link'; import Link from 'next/link';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
import { BiCog } from 'react-icons/bi';
export default function AdminNav({ export default function AdminNav({
items, items,
@ -20,10 +26,12 @@ export default function AdminNav({
<SiteGrid <SiteGrid
contentMain={ contentMain={
<div className={cc( <div className={cc(
'flex gap-2 md:gap-4',
'border-b border-gray-200 dark:border-gray-800 pb-3', 'border-b border-gray-200 dark:border-gray-800 pb-3',
)}> )}>
<div className={cc( <div className={cc(
'flex gap-2 md:gap-4', 'flex gap-2 md:gap-4',
'flex-grow',
)}> )}>
{items.map(({ label, href, count }) => {items.map(({ label, href, count }) =>
<Link <Link
@ -31,13 +39,21 @@ export default function AdminNav({
href={href} href={href}
className={cc( className={cc(
'flex gap-0.5', 'flex gap-0.5',
pathname.startsWith(href) ? 'font-bold' : 'text-dim', checkPathPrefix(pathname, href) ? 'font-bold' : 'text-dim',
)} )}
> >
<span>{label}</span> <span>{label}</span>
<span>({count})</span> <span>({count})</span>
</Link>)} </Link>)}
</div> </div>
<Link
href={PATH_ADMIN_SETTINGS}
className={isPathAdminSettings(pathname)
? 'font-bold'
: 'text-dim'}
>
<BiCog />
</Link>
</div> </div>
} }
/> />

View File

@ -4,7 +4,7 @@ import SiteChecklist from '@/site/SiteChecklist';
export const runtime = 'edge'; export const runtime = 'edge';
export default async function ChecklistPage() { export default async function AdminSettingsPage() {
return ( return (
<SiteGrid <SiteGrid
contentMain={<InfoBlock> contentMain={<InfoBlock>

View File

@ -207,7 +207,7 @@ export default function SiteChecklistClient({
</ChecklistRow> </ChecklistRow>
</Checklist> </Checklist>
<Checklist <Checklist
title="Settings" title="Configuration"
icon={<BiCog size={16} />} icon={<BiCog size={16} />}
> >
<ChecklistRow <ChecklistRow

View File

@ -17,7 +17,6 @@ export const PATH_GRID = '/grid';
export const PATH_ADMIN = '/admin'; export const PATH_ADMIN = '/admin';
export const PATH_SIGN_IN = '/sign-in'; export const PATH_SIGN_IN = '/sign-in';
export const PATH_OG = '/og'; export const PATH_OG = '/og';
export const PATH_CHECKLIST = '/checklist';
// Admin paths // Admin paths
export const PATH_ADMIN_PHOTOS = `${PATH_ADMIN}/photos`; export const PATH_ADMIN_PHOTOS = `${PATH_ADMIN}/photos`;
@ -25,6 +24,7 @@ export const PATH_ADMIN_UPLOADS = `${PATH_ADMIN}/uploads`;
export const PATH_ADMIN_TAGS = `${PATH_ADMIN}/tags`; export const PATH_ADMIN_TAGS = `${PATH_ADMIN}/tags`;
export const PATH_ADMIN_UPLOAD = `${PATH_ADMIN}/uploads`; export const PATH_ADMIN_UPLOAD = `${PATH_ADMIN}/uploads`;
export const PATH_ADMIN_UPLOAD_BLOB = `${PATH_ADMIN_UPLOAD}/blob`; export const PATH_ADMIN_UPLOAD_BLOB = `${PATH_ADMIN_UPLOAD}/blob`;
export const PATH_ADMIN_SETTINGS = `${PATH_ADMIN}/settings`;
// Modifiers // Modifiers
const SHARE = 'share'; const SHARE = 'share';
@ -158,18 +158,23 @@ export const isPathCameraPhoto = (pathname = '') =>
export const isPathCameraPhotoShare = (pathname = '') => export const isPathCameraPhotoShare = (pathname = '') =>
new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/${SHARE}/?$`).test(pathname); new RegExp(`^${PREFIX_CAMERA}/[^/]+/[^/]+/${SHARE}/?$`).test(pathname);
export const isPathGrid = (pathname = '') => export const checkPathPrefix = (pathname = '', prefix: string) =>
pathname.startsWith(PATH_GRID); pathname.toLowerCase().startsWith(prefix);
export const isPathSignIn = (pathname = '') => export const isPathGrid = (pathname?: string) =>
pathname.startsWith(PATH_SIGN_IN); checkPathPrefix(pathname, PATH_GRID);
export const isPathAdmin = (pathname = '') => export const isPathSignIn = (pathname?: string) =>
pathname.startsWith(PATH_ADMIN); checkPathPrefix(pathname, PATH_SIGN_IN);
export const isPathProtected = (pathname = '') => export const isPathAdmin = (pathname?: string) =>
pathname.startsWith(PATH_ADMIN) || checkPathPrefix(pathname, PATH_ADMIN);
pathname === PATH_CHECKLIST;
export const isPathAdminSettings = (pathname?: string) =>
checkPathPrefix(pathname, PATH_ADMIN_SETTINGS);
export const isPathProtected = (pathname?: string) =>
checkPathPrefix(pathname, PATH_ADMIN);
export const getPathComponents = (pathname = ''): { export const getPathComponents = (pathname = ''): {
photoId?: string photoId?: string