Created dedicated Admin cmd-k section
This commit is contained in:
parent
ebbdff4a5a
commit
68775381d1
@ -209,8 +209,8 @@ export default function CommandKClient({
|
||||
action,
|
||||
}) =>
|
||||
<Command.Item
|
||||
key={`${heading}-${label}`}
|
||||
value={`${heading}-${label}`}
|
||||
key={`${heading} ${label}`}
|
||||
value={`${heading} ${label}`}
|
||||
className={clsx(
|
||||
'px-2',
|
||||
accessory ? 'py-2' : 'py-1',
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
PATH_ADMIN_PHOTOS,
|
||||
PATH_ADMIN_TAGS,
|
||||
PATH_ADMIN_UPLOADS,
|
||||
PATH_SIGN_IN,
|
||||
pathForCamera,
|
||||
pathForFilmSimulation,
|
||||
pathForPhoto,
|
||||
@ -22,13 +23,14 @@ import { photoQuantityText, titleForPhoto } from '@/photo';
|
||||
import PhotoTiny from '@/photo/PhotoTiny';
|
||||
import { formatDate } from '@/utility/date';
|
||||
import { formatCount, formatCountDescriptive } from '@/utility/string';
|
||||
import { BiLockAlt } from 'react-icons/bi';
|
||||
import { BiLockAlt, BiSolidUser } from 'react-icons/bi';
|
||||
import { sortTagsObject } from '@/tag';
|
||||
import PhotoFilmSimulationIcon from '@/simulation/PhotoFilmSimulationIcon';
|
||||
import { FaTag } from 'react-icons/fa';
|
||||
import { TbPhoto } from 'react-icons/tb';
|
||||
import { IoMdCamera } from 'react-icons/io';
|
||||
import { HiDocumentText } from 'react-icons/hi';
|
||||
import { signOutAction } from '@/auth/actions';
|
||||
|
||||
export default async function CommandK() {
|
||||
const [
|
||||
@ -45,7 +47,7 @@ export default async function CommandK() {
|
||||
|
||||
const session = await authCached().catch(() => null);
|
||||
|
||||
const showAdminPages = Boolean(session?.user?.email);
|
||||
const isAdminLoggedIn = Boolean(session?.user?.email);
|
||||
|
||||
const SECTION_TAGS: CommandKSection = {
|
||||
heading: 'Tags',
|
||||
@ -75,7 +77,7 @@ export default async function CommandK() {
|
||||
const SECTION_FILM: CommandKSection = {
|
||||
heading: 'Film Simulations',
|
||||
accessory: <span className="w-3">
|
||||
<PhotoFilmSimulationIcon />
|
||||
<PhotoFilmSimulationIcon className="translate-y-[0.5px]" />
|
||||
</span>,
|
||||
items: filmSimulations.map(({ simulation, count }) => ({
|
||||
label: simulation,
|
||||
@ -94,23 +96,37 @@ export default async function CommandK() {
|
||||
}, {
|
||||
label: 'Grid',
|
||||
path:'/grid',
|
||||
}] as CommandKSection['items']).concat(showAdminPages ? [{
|
||||
label: 'Admin / Photos',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_PHOTOS,
|
||||
}, {
|
||||
label: 'Admin / Uploads',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_UPLOADS,
|
||||
}, {
|
||||
label: 'Admin / Tags',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_TAGS,
|
||||
}, {
|
||||
label: 'Admin / Config',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_CONFIGURATION,
|
||||
}] : []),
|
||||
}]),
|
||||
};
|
||||
|
||||
const SECTION_ADMIN: CommandKSection = {
|
||||
heading: 'Admin',
|
||||
accessory: <BiSolidUser size={15} className="translate-x-[-1px]" />,
|
||||
items: isAdminLoggedIn
|
||||
? [{
|
||||
label: 'Manage Photos',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_PHOTOS,
|
||||
}, {
|
||||
label: 'Manage Uploads',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_UPLOADS,
|
||||
}, {
|
||||
label: 'Manage Tags',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_TAGS,
|
||||
}, {
|
||||
label: 'App Config',
|
||||
annotation: <BiLockAlt />,
|
||||
path: PATH_ADMIN_CONFIGURATION,
|
||||
}, {
|
||||
label: 'Sign Out',
|
||||
action: signOutAction,
|
||||
}]
|
||||
: [{
|
||||
label: 'Sign In',
|
||||
path: PATH_SIGN_IN,
|
||||
}],
|
||||
};
|
||||
|
||||
return <CommandKClient
|
||||
@ -119,6 +135,7 @@ export default async function CommandK() {
|
||||
SECTION_CAMERAS,
|
||||
SECTION_FILM,
|
||||
SECTION_PAGES,
|
||||
SECTION_ADMIN,
|
||||
]}
|
||||
onQueryChange={async (query) => {
|
||||
'use server';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user