From aa0ac57db627fc46d2b017fcabe33ebf87c0dde1 Mon Sep 17 00:00:00 2001 From: Sabine Maennel <5292683+sabinem@users.noreply.github.com> Date: Tue, 1 Dec 2026 06:33:30 +0100 Subject: [PATCH] fix(frontend): show owners the participant nav a participant sees The participant section counted teams with whatever the viewer may list. A participant may list teams only while View teams is on, but an owner always may, so an owner saw Teams (and Our submission, if on a team) before assignments were published. Count teams only while CAPABILITY_VIEW_TEAMS is on. Off, both entries are hidden for every viewer and the layout skips the TeamService.List call. --- CHANGELOG.md | 4 ++ .../frontend/src/lib/navigation/items.ts | 7 ++- .../(app)/my/hackathon/[id]/+layout.server.ts | 56 +++++++++++-------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9694d71..3d52e671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ written while it was being built. See [RELEASING.md](RELEASING.md). ### Fixed +- Owners no longer see `Teams` or `Our submission` in a hackathon's participant + section while `See team assignments` is off. That section now shows them + exactly what a participant sees. + - A hackathon's start and end are now a date and a time in Zurich time, and the hackathon closes exactly then. Before, only a date could be picked, and the hackathon closed at 01:00 on its last day: nobody could join, invite links diff --git a/components/frontend/src/lib/navigation/items.ts b/components/frontend/src/lib/navigation/items.ts index a9aa8569..f06459b7 100644 --- a/components/frontend/src/lib/navigation/items.ts +++ b/components/frontend/src/lib/navigation/items.ts @@ -120,9 +120,10 @@ export interface HackathonPageRef { * `teamCount` gates the third, and now carries both meanings at once. It used to * be purely "has the page anything on it yet", because `TeamService.List` asked * only for `hackathon:read`; it now asks for `team:read`, which a member holds - * only while `CAPABILITY_VIEW_TEAMS` is on. So the caller counts what it is - * *allowed* to see (`listVisibleTeams`), and zero covers both "no teams yet" and - * "assignments not published" — two states that want the same nav either way. + * only while `CAPABILITY_VIEW_TEAMS` is on. An owner holds it regardless, so + * the caller counts only while the capability is on: what a participant would + * be allowed to see. Zero covers both "no teams yet" and "assignments not + * published", two states that want the same nav for every viewer. * Zero is the honest default, the same way `manageNav` treats `trackCount`. * * `myProjectCount` and `proposalsOpen` gate My projects, either one enough. diff --git a/components/frontend/src/routes/(app)/my/hackathon/[id]/+layout.server.ts b/components/frontend/src/routes/(app)/my/hackathon/[id]/+layout.server.ts index cc3866c0..31d97a9c 100644 --- a/components/frontend/src/routes/(app)/my/hackathon/[id]/+layout.server.ts +++ b/components/frontend/src/routes/(app)/my/hackathon/[id]/+layout.server.ts @@ -88,36 +88,44 @@ export const load: LayoutServerLoad = async (event) => { // count, and there is no cheaper existence check. Drop this call and read the // count off `hackathon.get` once it is there. // - // Two ways to end up with no entry, and only one of them is a problem. - // `listVisibleTeams` answers `undefined` when the viewer may not see team - // assignments — a member with `CAPABILITY_VIEW_TEAMS` off, which is every - // hackathon until an organiser publishes — and that is the entry being - // correctly withheld rather than a failure to log about on every request in - // the subtree. A genuine failure still degrades to no entry rather than no - // hackathon, and still says so: the alternative offers a link whose page would - // fail the same way. + // Gated on `CAPABILITY_VIEW_TEAMS` before asking at all, because the member + // nav shows everyone — owner included — what a participant sees. The + // permission alone cannot say that: a participant holds `team:read` only while + // the capability is on, but an owner holds it unconditionally, so an owner's + // list came back full and offered Teams before assignments were published. + // Off, both counts stay zero for every viewer, and no call is made. + // + // With the capability on, `listVisibleTeams` can still answer `undefined` — + // a participant whose grant has not caught up — and that is the entry being + // withheld, not a failure to log about on every request in the subtree. A + // genuine failure still degrades to no entry rather than no hackathon, and + // still says so: the alternative offers a link whose page would fail the same + // way. // // The viewer's own teams come off the same list, for the Our submission - // entry, so that entry costs no call of its own. + // entry, so that entry costs no call of its own — and follows the same gate. + // + // Resolved here rather than in the sidebar because `enabledCapabilities` reads + // generated types and is server-only. Besides Teams, it decides whether the + // participant Voting entry is in the nav at all — see `memberNav`. + const caps = enabledCapabilities(result.hackathon.state) let teamCount = 0 let myTeamCount = 0 - try { - const teams = (await listVisibleTeams(team, event.params.id)) ?? [] - teamCount = teams.length - myTeamCount = teams.filter((t) => - t.members.some((m) => m.id === platformUserId), - ).length - } catch (err) { - event.locals.logger.warn( - { err }, - "LAYOUT: team list failed, rendering the hackathon nav without the Teams entry", - ) + if (caps.includes(Capability.CAPABILITY_VIEW_TEAMS)) { + try { + const teams = (await listVisibleTeams(team, event.params.id)) ?? [] + teamCount = teams.length + myTeamCount = teams.filter((t) => + t.members.some((m) => m.id === platformUserId), + ).length + } catch (err) { + event.locals.logger.warn( + { err }, + "LAYOUT: team list failed, rendering the hackathon nav without the Teams entry", + ) + } } - // Resolved here rather than in the sidebar because `enabledCapabilities` reads - // generated types and is server-only. It decides whether the participant - // Voting entry is in the nav at all — see `memberNav`. - const caps = enabledCapabilities(result.hackathon.state) const votingEnabled = caps.includes(Capability.CAPABILITY_VOTE) // Its own switch, not implied by voting — an organiser closes voting, checks // the tally, then publishes.