From 6b70d8e82bbc2b29c7773c9e838c81a29ebd61ea Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Wed, 19 Jun 2024 11:43:34 -0700 Subject: [PATCH] Hide more guess queue functionality when queue is disabled. - Disable guess notifications - Hide extraneous columns from the guess queue page - Rename "Guess queue" to "Answer log" and "Guesses" to "Answers" Fixes #2168 --- imports/client/components/GuessQueuePage.tsx | 99 ++++++++++++------- imports/client/components/HuntNav.tsx | 6 +- .../client/components/NotificationCenter.tsx | 1 + 3 files changed, 66 insertions(+), 40 deletions(-) diff --git a/imports/client/components/GuessQueuePage.tsx b/imports/client/components/GuessQueuePage.tsx index 074df3166..01a575014 100644 --- a/imports/client/components/GuessQueuePage.tsx +++ b/imports/client/components/GuessQueuePage.tsx @@ -52,17 +52,17 @@ import { mediaBreakpointDown } from "./styling/responsive"; const compactViewBreakpoint: Breakpoint = "md"; -const StyledTable = styled.div` +const StyledTable = styled.div<{ $hasGuessQueue: boolean }>` display: grid; grid-template-columns: [timestamp] auto [submitter] minmax(auto, 8em) [puzzle] minmax(10em, auto) [answer] minmax(10em, auto) - [direction] minmax(6em, auto) - [confidence] minmax(6em, auto) + ${(props) => props.$hasGuessQueue && "[direction] minmax(6em, auto)"} + ${(props) => props.$hasGuessQueue && "[confidence] minmax(6em, auto)"} [status] auto - [actions] auto; + ${(props) => props.$hasGuessQueue && "[actions] auto"}; border-bottom: 1px solid #ddd; ${mediaBreakpointDown( compactViewBreakpoint, @@ -316,32 +316,40 @@ const GuessBlock = React.memo( {" "} - - - Solve direction - - - - Confidence - - - + {hunt.hasGuessQueue && ( + + + Solve direction + + + + Confidence + + + + )} - - {canEdit && guess.state !== "pending" && ( - - )} - + {hunt.hasGuessQueue && ( + + {canEdit && guess.state !== "pending" && ( + + )} + + )} {guess.additionalNotes && ( )} @@ -355,12 +363,23 @@ const GuessQueuePage = () => { const [searchParams, setSearchParams] = useSearchParams(); const searchString = searchParams.get("q") ?? ""; - useBreadcrumb({ title: "Guess queue", path: `/hunts/${huntId}/guesses` }); - const guessesLoading = useTypedSubscribe(guessesForGuessQueue, { huntId }); const loading = guessesLoading(); const hunt = useTracker(() => Hunts.findOne({ _id: huntId }), [huntId]); + + const pageTitle = useTracker(() => { + if (loading || !hunt) { + return "Loading..."; + } else if (hunt.hasGuessQueue) { + return "Guess queue"; + } else { + return "Answer log"; + } + }, [hunt, loading]); + + useBreadcrumb({ title: pageTitle, path: `/hunts/${huntId}/guesses` }); + const guesses = useTracker( () => loading @@ -499,7 +518,7 @@ const GuessQueuePage = () => { return (
-

Guess queue

+

{pageTitle}

{ - + Time Submitter Puzzle Answer - - Direction - - - Confidence - + {hunt.hasGuessQueue && ( + <> + + Direction + + + Confidence + + + )} Status -   + {hunt.hasGuessQueue &&  } {filteredGuesses(guesses, puzzles).map((guess) => { return ( diff --git a/imports/client/components/HuntNav.tsx b/imports/client/components/HuntNav.tsx index 0e25001d7..32457183e 100644 --- a/imports/client/components/HuntNav.tsx +++ b/imports/client/components/HuntNav.tsx @@ -167,10 +167,12 @@ const HuntNav = () => { - Guesses + + {hunt.hasGuessQueue ? "Guesses" : "Answers"} + { const hunt = hunts.get(g.hunt); const puzzle = puzzles.get(g.puzzle); if (!hunt || !puzzle) return; + if (!hunt.hasGuessQueue) return; messages.push(