Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions components/frontend/src/lib/navigation/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading