feat: admin players is_public toggle (#122) #125
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/westside-landing!125
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "122-admin-visibility-toggle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Changes
src/routes/(app)/admin/players/+page.svelte: Replaced full-row<a>link with<div>card-row so toggle click does not navigate. Player name remains a clickable link. Added toggle switch per row with async PATCH call, optimistic local state update, and scoped CSS for track/thumb/label using existing design tokens (no Tailwind).Test Plan
Review Checklist
Related Notes
project-westside-- westside-app admin toolingEach player row now has a toggle switch that PATCHes /admin/players/{id}/visibility to flip is_public on/off. Visual feedback shows saving/saved/failed states. Closes #122 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>QA Review -- PR #125
Diff Analysis (1 file, +130/-3)
src/routes/(app)/admin/players/+page.sveltetoggleVisibility()-- async PATCH with proper state machine (saving/saved/error/null). Local state only updates on success, not optimistic. Timeout clears feedback after 1.5s (success) / 2.5s (error). Correct pattern.<a>wrapper correctly replaced with<div>. Player name becomes the link instead, preventing toggle clicks from navigating.aria-label,aria-pressed,focus-visibleoutline,disabledduring save. All present.<style>block. Uses existing design tokens (--color-green,--color-gray-*,--color-blue,--color-white). No Tailwind. Toggle dimensions (40x22px track, 14px thumb) are appropriately sized for mobile touch targets.Nits
None.
VERDICT: APPROVED
PR #125 Review
DOMAIN REVIEW
Tech stack: SvelteKit 5 (Svelte 5 runes), vanilla CSS with design tokens, Keycloak auth via
apiFetch.API integration -- Correct. The
toggleVisibilityfunction callsPATCH /admin/players/{id}/visibilitywith{ is_public: boolean }payload viaapiFetch, which automatically attaches the Bearer token from Keycloak. This matches the auth pattern used by every other admin page in the repo (/admin/dashboard,/admin/playersGET, etc.). TheContent-Type: application/jsonheader is set byapiFetchby default.State management -- Sound. This is NOT an optimistic update (despite the PR description saying "optimistic"). Local state (
allPlayers) is only mutated AFTER the API call succeeds (line 73-74 is insidetry, afterawait). On failure, the toggle stays in its original position and shows "Failed" for 2.5s. This is the safer pattern -- good choice.CSS -- All variables (
--color-green,--color-gray-800,--color-gray-600,--color-gray-200,--color-gray-400,--color-white,--color-blue) are confirmed defined insrc/app.css. No Tailwind. No magic numbers -- toggle dimensions (40x22px, 14px thumb, 18px translateX) are internally consistent. Scoped<style>block keeps styles local.Layout change -- The
<a class="card-row">wrapper was correctly replaced with a<div class="card-row">, moving the link to just the player name. This prevents the toggle click from triggering navigation. The.card-rowclass inapp.cssusesdisplay: flexwithalign-items: flex-start, and the toggle cell usesmargin-left: autoto push right -- this is the correct flexbox pattern.Accessibility -- Good foundation:
aria-label="Toggle public visibility for {player.name}"-- descriptive, per-playeraria-pressedcorrectly reflectsis_publicstatedisabledduring saving prevents double-clicks:focus-visibleoutline for keyboard usersBLOCKERS
None.
Test coverage note: This repo has zero test infrastructure (no vitest, no playwright, no test files). The "new functionality with zero test coverage" blocker criterion does not apply here -- there is no testing framework to write tests against. This is a pre-existing repo-level gap, not a PR-level omission. The Test Plan in the PR body is manual and appropriate given the current state.
NITS
Missing
role="switch": The toggle button semantically acts as a switch. Addingrole="switch"alongside the existingaria-pressedwould give screen readers the correct widget type announcement. Currently it announces as a button with pressed state, which is functional but not ideal.cursor: pointeron.card-row: The global.card-rowclass inapp.css(line 1467) setscursor: pointer. Now that the row is a<div>instead of an<a>, the entire row shows a pointer cursor but is not itself clickable. Consider adding a scoped override:.card-row { cursor: default; }in the component's<style>block so the pointer only appears on the name link and toggle button.Inline styles on the name link:
style="text-decoration:none;color:inherit;"on the<a>tag could be a scoped CSS class (e.g.,.player-link) for consistency with the rest of the file's approach.PR body says "optimistic local state update": The implementation is actually a success-first update (state mutates after API confirmation). The PR description is slightly misleading -- minor, but worth correcting for documentation accuracy.
SOP COMPLIANCE
122-admin-visibility-togglereferences #122)project-westsideand closes #122feat: admin players is_public toggle (#122))PROCESS OBSERVATIONS
VERDICT: APPROVED