From 3525edab37f638b24667cdbb4fcd35684d74c5f5 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 14 Feb 2025 20:54:18 -0600 Subject: [PATCH] Finalize insights behavior/language --- src/admin/insights/AdminAppInsightsClient.tsx | 71 +++++++++---------- src/components/EnvVar.tsx | 4 +- src/components/ScoreCardRow.tsx | 31 ++++++-- 3 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/admin/insights/AdminAppInsightsClient.tsx b/src/admin/insights/AdminAppInsightsClient.tsx index 47e35a93..6b78f7bb 100644 --- a/src/admin/insights/AdminAppInsightsClient.tsx +++ b/src/admin/insights/AdminAppInsightsClient.tsx @@ -30,21 +30,28 @@ import { PATH_ADMIN_OUTDATED } from '@/app-core/paths'; import { LiaBroomSolid } from 'react-icons/lia'; import { IoMdGrid } from 'react-icons/io'; import { RiSpeedMiniLine } from 'react-icons/ri'; -import LinkWithStatus from '@/components/LinkWithStatus'; + +const DEBUG_COMMIT_SHA = '4cd29ed'; +const DEBUG_COMMIT_MESSAGE = 'Long commit message for debugging purposes'; +const DEBUG_BEHIND_BY = 9; +const DEBUG_PHOTOS_COUNT_OUTDATED = 7; const readmeAnchor = (anchor: string, text: string) => {text} ; -const DEBUG_COMMIT_SHA = '4cd29ed'; -const DEBUG_COMMIT_MESSAGE = 'Long commit message for debugging purposes'; -const DEBUG_BEHIND_BY = 9; -const DEBUG_PHOTOS_COUNT_OUTDATED = 7; +const renderLabeledEnvVar = (label: string, envVar: string, value = '1') => +
+ + {label} + + +
; export default function AdminAppInsightsClient({ codeMeta, @@ -201,7 +208,7 @@ export default function AdminAppInsightsClient({ />} content="AI enabled without rate limiting" // eslint-disable-next-line max-len - expandContent="Create Vercel KV store and link o this project in order to enable rate limiting." + expandContent="Create Vercel KV store and link to this project in order prevent abuse by to enabling rate limiting." />} {(noAi || debug) && } @@ -235,7 +242,9 @@ export default function AdminAppInsightsClient({ icon={} content="Grid homepage" expandContent={<> - Enable grid homepage by setting environment variable + Now that you have a sufficient amount of photos, you can + {' '} + enable grid homepage by setting environment variable {' '} } @@ -249,24 +258,23 @@ export default function AdminAppInsightsClient({ expandContent={<> {/* eslint-disable-next-line max-len */} Enable static optimization by setting any of the following environment variables: -
- - - - +
+ {renderLabeledEnvVar( + 'Pre-render photo pages', + 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTOS', + )} + {renderLabeledEnvVar( + 'Pre-render OG image for each photo', + 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTO_OG_IMAGES', + )} + {renderLabeledEnvVar( + 'Pre-render category pages (tags, cameras, etc.)', + 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTO_CATEGORIES', + )} + {renderLabeledEnvVar( + 'Pre-render OG image for each category page', + 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTO_CATEGORY_OG_IMAGES', + )}
} />} @@ -279,16 +287,7 @@ export default function AdminAppInsightsClient({ />} // eslint-disable-next-line max-len content={`You have ${photosCountOutdated || DEBUG_PHOTOS_COUNT_OUTDATED} outdated ${(photosCountOutdated || DEBUG_PHOTOS_COUNT_OUTDATED) === 1 ? 'photo' : 'photos'}`} - expandContent={<> - - View outdated photos - - {' '} - to update them in batches. - } + expandPath={PATH_ADMIN_OUTDATED} />} diff --git a/src/components/ScoreCardRow.tsx b/src/components/ScoreCardRow.tsx index 21f0a31a..e8765157 100644 --- a/src/components/ScoreCardRow.tsx +++ b/src/components/ScoreCardRow.tsx @@ -1,16 +1,30 @@ import { clsx } from 'clsx/lite'; import { ReactNode, useState } from 'react'; -import { LuChevronsDownUp, LuChevronsUpDown } from 'react-icons/lu'; +import { + LuChevronRight, + LuChevronsDownUp, + LuChevronsUpDown, +} from 'react-icons/lu'; +import LinkWithStatus from './LinkWithStatus'; +import Spinner from './Spinner'; + +const expandAccessoryClasses = clsx( + 'flex items-center justify-center', + 'w-9 h-8', + '*:shrink-0', +); export default function ScoreCardRow({ icon, content, expandContent, + expandPath, className, }: { icon: ReactNode content: ReactNode expandContent?: ReactNode + expandPath?: string className?: string }) { const [isExpanded, setIsExpanded] = useState(false); @@ -39,16 +53,21 @@ export default function ScoreCardRow({ {expandContent && } + {expandPath && + {({ isLoading }) => <> {isLoading + ? + : } + } + }
); }