Update admin info links in menu

This commit is contained in:
Sam Becker 2025-02-28 19:57:39 -06:00
parent 3e368d9aa4
commit f4ecda7548
3 changed files with 17 additions and 6 deletions

View File

@ -2,6 +2,7 @@
import MoreMenu from '@/components/more/MoreMenu';
import {
PATH_ADMIN_CONFIGURATION,
PATH_ADMIN_INSIGHTS,
PATH_ADMIN_PHOTOS,
PATH_ADMIN_TAGS,
@ -30,8 +31,7 @@ export default function AdminAppMenu({
className?: string
}) {
const {
photosCount = 0,
photosCountHidden = 0,
photosCountTotal = 0,
uploadsCount = 0,
tagsCount = 0,
selectedPhotoIds,
@ -41,8 +41,6 @@ export default function AdminAppMenu({
clearAuthStateAndRedirect,
} = useAppState();
const photosCountTotal = photosCount + photosCountHidden;
const isSelecting = selectedPhotoIds !== undefined;
const items: ComponentProps<typeof MoreMenu>['items'] = [{
@ -95,12 +93,16 @@ export default function AdminAppMenu({
}
items.push({
label: 'App Info',
label: photosCountTotal > 0
? 'App Insights'
: 'App Configuration',
icon: <AdminAppInfoIcon
size="small"
className="translate-x-[-0.5px] translate-y-[-0.5px]"
/>,
href: PATH_ADMIN_INSIGHTS,
href: photosCountTotal > 0
? PATH_ADMIN_INSIGHTS
: PATH_ADMIN_CONFIGURATION,
}, {
label: isSelecting
? 'Exit Select'

View File

@ -45,6 +45,7 @@ export interface AppStateContext {
refreshAdminData?: () => void
photosCount?: number
photosCountHidden?: number
photosCountTotal?: number
uploadsCount?: number
tagsCount?: number
selectedPhotoIds?: string[]

View File

@ -90,6 +90,13 @@ export default function AppStateProvider({
const [shouldDebugRecipeOverlays, setShouldDebugRecipeOverlays] =
useState(false);
const photosCountTotal = (
photosCount !== undefined &&
photosCountHidden !== undefined
)
? photosCount + photosCountHidden
: undefined;
const startUpload = useCallback((onStart?: () => void) => {
if (uploadInputRef.current) {
uploadInputRef.current.value = '';
@ -200,6 +207,7 @@ export default function AppStateProvider({
refreshAdminData,
photosCount,
photosCountHidden,
photosCountTotal,
uploadsCount,
tagsCount,
selectedPhotoIds,