From e03c31a1a4028b273538a00b3c3bc549fdb93b7f Mon Sep 17 00:00:00 2001 From: Mark Saroufim Date: Thu, 12 Feb 2026 08:24:00 -0800 Subject: [PATCH] Allow admins to view submission code on active leaderboards Non-admin users still see plain text file names on active leaderboards. Admins get clickable buttons that open the code dialog. The backend already authorizes admin access to codes for active leaderboards, so this is a frontend-only change. Also removes the LOC column entirely. --- .../leaderboard/components/RankingLists.tsx | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/frontend/src/pages/leaderboard/components/RankingLists.tsx b/frontend/src/pages/leaderboard/components/RankingLists.tsx index 27f42de..e9fe3b3 100644 --- a/frontend/src/pages/leaderboard/components/RankingLists.tsx +++ b/frontend/src/pages/leaderboard/components/RankingLists.tsx @@ -70,11 +70,6 @@ const styles: Record> = { color: "text.secondary", minWidth: "90px", }, - loc: { - fontFamily: "monospace", - color: "text.secondary", - textAlign: "right", - }, submissionId: { fontFamily: "monospace", color: "text.secondary", @@ -86,7 +81,7 @@ export default function RankingsList({ leaderboardId, deadline, }: RankingsListProps) { - const showLoc = !!deadline && isExpired(deadline); + const expired = !!deadline && isExpired(deadline); const me = useAuthStore((s) => s.me); const isAdmin = !!me?.user?.is_admin; const [expanded, setExpanded] = useState>({}); @@ -112,7 +107,7 @@ export default function RankingsList({ }, [rankings]); useEffect(() => { - if (!showLoc) return; + if (!expired && !isAdmin) return; if (!submissionIds || submissionIds.length === 0 || !leaderboardId) return; fetchCodes(leaderboardId, submissionIds) .then((data) => { @@ -126,7 +121,7 @@ export default function RankingsList({ // soft error handle it since it's not critical console.warn("[RankingsList] Failed to fetch codes:", err); }); - }, [leaderboardId, submissionIds, showLoc]); + }, [leaderboardId, submissionIds, expired, isAdmin]); const toggleExpanded = (field: string) => { setExpanded((prev) => ({ @@ -181,35 +176,23 @@ export default function RankingsList({ {item.user_name} {getMedalIcon(item.rank)} - + {formatMicroseconds(item.score)} - + {item.prev_score > 0 && `+${formatMicroseconds(item.prev_score)}`} - {showLoc && ( - - - {(() => { - const code = codes.get(item?.submission_id); - if (!code) return ""; - const lines = code.split("\n").length; - return `${lines} LOC`; - })()} - - - )} - + {isAdmin && ( - + ID: {item.submission_id}