Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Card, Flex } from "@radix-ui/themes";
import { Disclosure } from "./section";
import { useIsWide } from "./use-is-wide";

type Props = {
summary: React.ReactNode;
children: React.ReactNode;
};

export const CollapsibleCard = ({ summary, children }: Props) => {
const isWide = useIsWide();

if (isWide) {
return (
<Card>
<Flex direction="column" gap="3">
{summary}
{children}
</Flex>
</Card>
);
}

return (
<Card>
<Disclosure summary={summary}>
<Flex direction="column" gap="3" mt="3">
{children}
</Flex>
</Disclosure>
</Card>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
fragment ReviewProposalFragment on ReviewProposal {
id
title {
en
it
}
elevatorPitchHtml {
en
it
}
abstractHtml {
en
it
}
notes
tags {
id
name
}
type
audienceLevel
duration
languages
rankings {
tag
rank
total
}
websiteUrl
adminUrl
isMine
speaker {
id
fullName
gender
country
photoUrl
bio
website
twitterHandle
instagramHandle
mastodonHandle
linkedinUrl
facebookUrl
speakerLevel
previousTalkVideo
participantAdminUrl
grant {
status
adminUrl
}
proposalsCount
maxProposals
otherProposals {
id
title
}
}
votes {
id
reviewerName
isMine
scoreLabel
scoreValue
comment
}
myVote {
scoreOptionId
comment
}
}

query FocusReviewSession($reviewSessionId: ID!) {
reviewSession(reviewSessionId: $reviewSessionId) {
id
scoreOptions {
id
label
numericValue
}
tags {
id
name
}
}
}

query NextProposalToReview(
$reviewSessionId: ID!
$excludeTags: [ID!]!
$seen: [ID!]!
) {
nextProposalToReview(
reviewSessionId: $reviewSessionId
excludeTags: $excludeTags
seen: $seen
)
}

query ReviewProposal($reviewSessionId: ID!, $proposalId: ID!) {
reviewProposal(reviewSessionId: $reviewSessionId, proposalId: $proposalId) {
...ReviewProposalFragment
}
}

mutation VoteProposal($input: VoteProposalInput!) {
voteProposal(input: $input) {
__typename
... on ReviewProposal {
...ReviewProposalFragment
}
... on NotFound {
message
}
}
}
182 changes: 182 additions & 0 deletions backend/custom_admin/src/components/review-beta/focus/focus-mode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import { useApolloClient } from "@apollo/client";
import {
Box,
Button,
Callout,
Flex,
Link,
Spinner,
Text,
} from "@radix-ui/themes";
import { Suspense, useEffect, useState } from "react";
import { createPortal } from "react-dom";
import { useArgs } from "../../shared/args";
import { useNavActionsSlot } from "../nav";
import type { Screen } from "../types";
import {
NextProposalToReviewDocument,
type NextProposalToReviewQuery,
type NextProposalToReviewQueryVariables,
useFocusReviewSessionSuspenseQuery,
} from "./focus-mode.generated";
import { ProposalReview } from "./proposal-review";
import { TagFilter } from "./tag-filter";
import { readUrlState, writeUrlState } from "./url-state";

export const FocusMode = () => (
<Suspense fallback={<Loading />}>
<FocusModeContent />
</Suspense>
);

const FocusModeContent = () => {
const { reviewSessionId, screens } = useArgs() as {
reviewSessionId: number;
screens: Screen[];
};
const client = useApolloClient();
const {
data: { reviewSession },
} = useFocusReviewSessionSuspenseQuery({
variables: { reviewSessionId: String(reviewSessionId) },
});

const navActions = useNavActionsSlot();
const [initialState] = useState(readUrlState);
const [excludeTags, setExcludeTags] = useState(initialState.excludeTags);
const [history, setHistory] = useState<string[]>(
initialState.proposalId ? [initialState.proposalId] : [],
);
const [position, setPosition] = useState(0);
const [loadingNext, setLoadingNext] = useState(!initialState.proposalId);

const currentId = history[position] ?? null;
const shortlistUrl = screens.find((screen) => screen.id === "shortlist")?.url;

const fetchNext = async (seen: string[]) => {
setLoadingNext(true);
const { data } = await client.query<
NextProposalToReviewQuery,
NextProposalToReviewQueryVariables
>({
query: NextProposalToReviewDocument,
variables: {
reviewSessionId: String(reviewSessionId),
excludeTags,
seen,
},
fetchPolicy: "network-only",
});
const nextId = data.nextProposalToReview;
const newHistory = nextId ? [...seen, nextId] : seen;
setHistory(newHistory);
setPosition(nextId ? newHistory.length - 1 : newHistory.length);
setLoadingNext(false);
};

useEffect(() => {
if (!initialState.proposalId) {
fetchNext([]);
}
}, []);

useEffect(() => {
writeUrlState({ proposalId: currentId, excludeTags });
}, [currentId, excludeTags]);

const goForward = () => {
if (position < history.length - 1) {
setPosition(position + 1);
return;
}
fetchNext(history);
};

const goBack = () => setPosition(Math.max(position - 1, 0));

const [toast, setToast] = useState<string | null>(null);
useEffect(() => {
if (!toast) {
return;
}
const timeout = setTimeout(() => setToast(null), 3000);
return () => clearTimeout(timeout);
}, [toast]);

const onVoted = (message: string) => {
setToast(message);
goForward();
};

if (reviewSession.scoreOptions.length === 0) {
return (
<Callout.Root color="amber">
<Callout.Text>
This review session has no score options yet. An admin must add them
in the review session page before anyone can vote.
</Callout.Text>
</Callout.Root>
);
}

return (
<Flex direction="column" gap="4">
{toast && (
<Box
role="status"
className="fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-[var(--radius-3)] bg-[var(--color-panel-solid)] shadow-lg"
>
<Callout.Root color="green" variant="surface">
<Callout.Text>✓ {toast}</Callout.Text>
</Callout.Root>
</Box>
)}
{navActions &&
createPortal(
<TagFilter
tags={reviewSession.tags}
excluded={excludeTags}
onChange={setExcludeTags}
/>,
navActions,
)}
{loadingNext && <Loading />}
{!loadingNext && currentId && (
<Suspense key={currentId} fallback={<Loading />}>
<ProposalReview
key={currentId}
proposalId={currentId}
scoreOptions={reviewSession.scoreOptions}
canGoBack={position > 0}
onVoted={onVoted}
onSkip={goForward}
onBack={goBack}
/>
</Suspense>
)}
{!loadingNext && !currentId && (
<Flex direction="column" gap="3" align="start">
<Text size="4" weight="bold">
You've reviewed everything
</Text>
<Flex gap="4">
{history.length > 0 && (
<Button variant="soft" color="gray" onClick={goBack}>
← Previous
</Button>
)}
{shortlistUrl && (
<Link href={shortlistUrl}>Go to the Shortlist</Link>
)}
</Flex>
</Flex>
)}
</Flex>
);
};

const Loading = () => (
<Flex justify="center" py="9">
<Spinner size="3" />
</Flex>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Badge, Flex } from "@radix-ui/themes";
import type { ReviewProposalFragmentFragment } from "./focus-mode.generated";

const LANGUAGES: Record<string, { flag: string; name: string }> = {
en: { flag: "🇬🇧", name: "English" },
it: { flag: "🇮🇹", name: "Italiano" },
};

const TYPE_ICONS: Record<string, string> = {
talk: "🎤",
tutorial: "🛠️",
workshop: "🛠️",
keynote: "⭐",
};

type Props = { proposal: ReviewProposalFragmentFragment };

export const ProposalFacts = ({ proposal }: Props) => (
<Flex gap="4" justify="between" align="start" wrap="wrap">
<Flex gap="2" wrap="wrap" align="center">
<Badge size="2" color="gray" variant="surface" className="capitalize">
{TYPE_ICONS[proposal.type.toLowerCase()] ?? "📄"} {proposal.type}
</Badge>
<Badge size="2" color="gray" variant="surface">
📶 {proposal.audienceLevel}
</Badge>
<Badge size="2" color="gray" variant="surface">
⏱ {proposal.duration} min
</Badge>
{proposal.languages.map((code) => (
<Badge key={code} size="2" color="gray" variant="surface">
{LANGUAGES[code]?.flag} {LANGUAGES[code]?.name ?? code}
</Badge>
))}
</Flex>
<Flex gap="2" wrap="wrap" justify="end">
{proposal.tags.map((tag) => (
<Badge key={tag.id} size="2">
{tag.name}
</Badge>
))}
</Flex>
</Flex>
);
Loading
Loading