Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide more guess queue functionality when queue is disabled. #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 61 additions & 38 deletions imports/client/components/GuessQueuePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -316,32 +316,40 @@ const GuessBlock = React.memo(
</OverlayTrigger>{" "}
<PuzzleAnswer answer={guess.guess} breakable indented />
</StyledGuessCell>
<StyledGuessDetails>
<StyledGuessDetailWithLabel>
<StyledGuessDetailLabel>Solve direction</StyledGuessDetailLabel>
<StyledGuessDirection
id={`guess-${guess._id}-direction`}
value={guess.direction}
/>
</StyledGuessDetailWithLabel>
<StyledGuessDetailWithLabel>
<StyledGuessDetailLabel>Confidence</StyledGuessDetailLabel>
<StyledGuessConfidence
id={`guess-${guess._id}-confidence`}
value={guess.confidence}
/>
</StyledGuessDetailWithLabel>
</StyledGuessDetails>
{hunt.hasGuessQueue && (
<StyledGuessDetails>
<StyledGuessDetailWithLabel>
<StyledGuessDetailLabel>Solve direction</StyledGuessDetailLabel>
<StyledGuessDirection
id={`guess-${guess._id}-direction`}
value={guess.direction}
/>
</StyledGuessDetailWithLabel>
<StyledGuessDetailWithLabel>
<StyledGuessDetailLabel>Confidence</StyledGuessDetailLabel>
<StyledGuessConfidence
id={`guess-${guess._id}-confidence`}
value={guess.confidence}
/>
</StyledGuessDetailWithLabel>
</StyledGuessDetails>
)}
<StyledCell>
<GuessState id={`guess-${guess._id}-state`} state={guess.state} />
</StyledCell>
<StyledCell>
{canEdit && guess.state !== "pending" && (
<Button variant="outline-secondary" size="sm" onClick={markPending}>
Return to queue
</Button>
)}
</StyledCell>
{hunt.hasGuessQueue && (
<StyledCell>
{canEdit && guess.state !== "pending" && (
<Button
variant="outline-secondary"
size="sm"
onClick={markPending}
>
Return to queue
</Button>
)}
</StyledCell>
)}
{guess.additionalNotes && (
<Markdown as={StyledAdditionalNotes} text={guess.additionalNotes} />
)}
Expand All @@ -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
Expand Down Expand Up @@ -499,7 +518,7 @@ const GuessQueuePage = () => {

return (
<div>
<h1>Guess queue</h1>
<h1>{pageTitle}</h1>
<FormGroup className="mb-3">
<InputGroup>
<FormControl
Expand All @@ -516,20 +535,24 @@ const GuessQueuePage = () => {
</Button>
</InputGroup>
</FormGroup>
<StyledTable>
<StyledTable $hasGuessQueue={hunt.hasGuessQueue}>
<StyledHeaderRow>
<StyledHeader>Time</StyledHeader>
<StyledHeader>Submitter</StyledHeader>
<StyledHeader>Puzzle</StyledHeader>
<StyledHeader>Answer</StyledHeader>
<OverlayTrigger placement="top" overlay={directionTooltip}>
<StyledHeader>Direction</StyledHeader>
</OverlayTrigger>
<OverlayTrigger placement="top" overlay={confidenceTooltip}>
<StyledHeader>Confidence</StyledHeader>
</OverlayTrigger>
{hunt.hasGuessQueue && (
<>
<OverlayTrigger placement="top" overlay={directionTooltip}>
<StyledHeader>Direction</StyledHeader>
</OverlayTrigger>
<OverlayTrigger placement="top" overlay={confidenceTooltip}>
<StyledHeader>Confidence</StyledHeader>
</OverlayTrigger>
</>
)}
<StyledHeader>Status</StyledHeader>
<StyledHeader>&nbsp;</StyledHeader>
{hunt.hasGuessQueue && <StyledHeader>&nbsp;</StyledHeader>}
</StyledHeaderRow>
{filteredGuesses(guesses, puzzles).map((guess) => {
return (
Expand Down
6 changes: 4 additions & 2 deletions imports/client/components/HuntNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ const HuntNav = () => {

<StyledPuzzleListLinkAnchor
to={`/hunts/${huntId}/guesses`}
title="Guess queue"
title={hunt.hasGuessQueue ? "Guess queue" : "Answer log"}
>
<MenuIcon icon={faReceipt} />
<StyledPuzzleListLinkLabel>Guesses</StyledPuzzleListLinkLabel>
<StyledPuzzleListLinkLabel>
{hunt.hasGuessQueue ? "Guesses" : "Answers"}
</StyledPuzzleListLinkLabel>
</StyledPuzzleListLinkAnchor>

<StyledPuzzleListLinkAnchor
Expand Down
1 change: 1 addition & 0 deletions imports/client/components/NotificationCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ const NotificationCenter = () => {
const hunt = hunts.get(g.hunt);
const puzzle = puzzles.get(g.puzzle);
if (!hunt || !puzzle) return;
if (!hunt.hasGuessQueue) return;
messages.push(
<GuessMessage
key={g._id}
Expand Down