Skip to content

Add dedicated Tags management page and hide restricted tags from riders - #466

Merged
mveytsman merged 7 commits into
mainfrom
mv/tags
Feb 3, 2026
Merged

Add dedicated Tags management page and hide restricted tags from riders#466
mveytsman merged 7 commits into
mainfrom
mv/tags

Conversation

@mveytsman

@mveytsman mveytsman commented Jan 26, 2026

Copy link
Copy Markdown
Member

Describe your changes

  • Add /tags admin page for dispatchers to manage rider tags
  • Tags can be marked as restricted, hiding them from riders on their profile
  • Restricted tags are shown with a lock icon in the dispatcher view
  • Riders can only see and modify non-restricted tags on their profile
  • Remove inline tag creation from rider edit form (use Tags page instead)
  • Add Tags link to sidebar navigation
CleanShot 2026-01-26 at 00 22 55@2x

Editing a riders' tags
CleanShot 2026-01-26 at 00 23 05@2x

When not a dispatcher you don't see restricted tags
CleanShot 2026-01-26 at 00 23 31@2x

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added tests.
  • Are there other PRs or Issues that I should link to here?
  • Will this be part of a product update? If yes, please write one phrase
    about this update in the description above.

- Add /tags admin page for dispatchers to manage rider tags
- Tags can be marked as restricted, hiding them from riders on their
  profile
- Restricted tags are shown with a lock icon in the dispatcher view
- Riders can only see and modify non-restricted tags on their profile
- Remove inline tag creation from rider edit form (use Tags page
  instead)
- Add Tags link to sidebar navigation
- Add tag fixture in test/support/fixtures.ex for creating test tags
- Add context tests in riders_test.exs for tag CRUD operations:
  - create_tag, update_tag, delete_tag
  - list_tags, list_tags_with_rider_count
  - toggle_tag_restricted, change_tag, get_tag!, search_tags
- Create tag_live_test.exs for Tags admin page:
  - List tags with name, restricted status, and rider count
  - Create, edit, delete tags via modals
  - Toggle restricted status inline
  - Access control for non-dispatchers
- Add tag visibility tests in rider_live_test.exs:
  - Dispatcher can see all tags including restricted
  - Rider cannot see restricted tags on profile
  - Rider cannot see restricted tags in edit form

@teesloane teesloane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few optional nits and comments but can be merged without.

Comment thread lib/bike_brigade_web/live/rider_live/tags_component.ex Outdated
Comment on lines +118 to +127
<span
class={[
"my-0.5 inline-flex items-center px-2.5 py-1.5 rounded-md text-md font-medium cursor-pointer hover:bg-gray-200",
if(tag.restricted, do: "bg-gray-200 text-gray-500", else: "bg-gray-100 text-gray-500")
]}
phx-click={JS.push("select", value: %{name: tag.name}, target: @myself)}
>
<Heroicons.plus mini class="w-4 h-4 mr-1" />
{tag.name}
<Heroicons.lock_closed :if={tag.restricted} mini class="w-4 h-4 ml-1 text-amber-600" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required but we could make this a "dumb component" to tidy up a bit.

<.header>
Tags
<:subtitle>
Manage rider tags. Restricted tags are hidden from riders on their profile.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth saying why one might want to add rider tags / how they are used?

<% visible_tags =
if @current_user.is_dispatcher,
do: @rider.tags,
else: Enum.reject(@rider.tags, & &1.restricted) %>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: normally I think it's fine to assign variables in template code, but since we're dealing with content that may be restricted, it might be worth pulling this out into a function and putting it in rider_live/show.ex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this is still executed in the server (e.g. the security consideration doesn't apply here afaik, based on the liveview design) but I think it's correct for code quality

@mveytsman
mveytsman merged commit b65a8d9 into main Feb 3, 2026
1 check passed
@mveytsman
mveytsman deleted the mv/tags branch February 3, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants