feat: quick visibility toggle on activity cards - #147
Merged
Conversation
Private-by-default shipped in v0.4.2 left the edit form as the only way to change an activity's visibility. Each card in the logged activities list now carries a Public/Private pill that flips the flag over Turbo without leaving the page; the same control sits in the activity page actions row. The card's full-card link_to now wraps only the content, with the toggle as a sibling — a button nested in an anchor is invalid HTML and Turbo would follow the link instead of submitting the form.
toggle! expresses the intent of a boolean flip and skips the photo/gpx attachment validations, which have nothing to say about visibility and would 500 the toggle on a legacy record carrying an attachment that no longer validates. It still bumps updated_at. The button's text is its current state, so a screen reader announced "Private" with no hint that clicking changes anything — title never becomes the accessible name when the button has content. aria-label now carries the action.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
v0.4.2 made activities private by default and gave public ones tokenized URLs. The only way to change an activity's visibility since then is the checkbox buried in the edit form — you have to open the activity, click edit, scroll, tick, save. Managing what is shared became clunky enough that dogfooding turned up the obvious ask: a selector per activity.
What it does
toggle_visibilityand Turbo replaces just that pill. No page reload, no navigation away from the list.link_towas narrowed to wrap only the content, with the toggle as a sibling. A<button>nested in an<a>is invalid HTML and Turbo would follow the card link instead of submitting.Consent
Flipping an activity to public stays an explicit owner action — the action is scoped to
current_profile.activities, someone else's activity 404s, and nothing here changes the private-by-default write path or the Strava importer, which keeps importing private. Public athlete pages are untouched.Tests
524 runs, 1675 assertions, 0 failures, 0 errors. New coverage: toggle flips both directions and answers turbo_stream, HTML falls back to a redirect, another profile's activity 404s, signed-out is bounced, and the index renders the right state per activity.rubocopclean; the four new keys are in all 15 locales.