Skip to content

Add dispatcher UI for managing community fridges - #526

Closed
neal-bpm wants to merge 30 commits into
mainfrom
vn/community-fridge-ui-v1
Closed

neal-bpm wants to merge 30 commits into
mainfrom
vn/community-fridge-ui-v1

Conversation

@neal-bpm

@neal-bpm neal-bpm commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Adds the Community Fridges dispatcher UI, building on the data model and CRUD context added in #508.

Changes:

  • Add CommunityFridgeLive.Index and CommunityFridgeLive.FormComponent with routes for /community_fridges, /community_fridges/new, and /community_fridges/:id/edit
  • Add "Community Fridges" entry to the sidebar navigation (archive_box icon)
  • Relax CommunityFridge changeset to not require location_id at the UI level — name is the only required field;
  • Register :community_fridges as a valid page in the layout's current_page attribute
  • Fix a redundant DB query in the index mount
  • Add LiveView tests covering list, create, validate, edit, direct navigation, and access control (non-dispatchers are redirected to /login)

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? — depends on Add community fridges data model #508
  • Will this be part of a product update? If yes, please write one phrase about this update in the description above.

Summary by CodeRabbit

  • New Features
    • Dispatchers can view, create, and edit community fridges from a new Community Fridges page. Listings show each fridge’s name, description, pair preference, and active status.
    • Community fridge forms include name, description, photo URL, active, and pair-preferred fields. Only a name is required.
  • Access Control
    • Riders are redirected to the login page when they try to open the Community Fridges page.

  Introduces the CommunityFridge schema, migration, and test fixtures as the first step of the community fridges feature.
  The cubic-dev review suggested supporting a `location:` key in
  fixture(:community_fridge, ...) so callers can pass a location struct
  directly, matching the pattern used by rider and campaign fixtures.

  Implementing this requires fixture(:location) to persist a Location
  record and return a struct with an id, rather than returning a plain
  map as it does today. That change affects every fixture and test that
  currently calls fixture(:location), so the blast radius is wider than
  this PR's scope.

  The improvement will be handled in a follow-up PR dedicated to
  normalising the location fixture across the test suite.
  Add unique_constraint(:location_id) to CommunityFridge.changeset/2 so a
  location cannot be associated with more than one community fridge. The
  has_one relationship does not enforce cardinality at the database level,
  so this constraint surfaces duplicate-location errors as changeset errors.

  Also trim the minimal-attributes changeset test to focus on required
  fields rather than default values.
  - Add `persisted_location` fixture that inserts a Location into the
  database
    (complements existing in-memory `location` fixture)
  - Add `community_fridge` fixture that lazily creates a persisted location
  and
    handles required location_id association
  - Add LocationsTest with full coverage of community_fridge operations
  - Use setup block to eliminate fixture repetition across tests
  - Use pin operator (^) in pattern matches to validate update attrs without
    assertion repetition
  - Enable async: true for parallel test execution
  Changes:
  - Add CommunityFridgeLive.Index and FormComponent with routes for /community_fridges, /community_fridges/new, and /community_fridges/:id/edit
  - Add "Community Fridges" entry to the sidebar navigation (archive_box icon)
  - Relax CommunityFridge changeset to not require location_id at the UI level (name is the only required field; location association remains constrained at the DB level via assoc_constraint)
  - Add LiveView tests covering list, create, validate, edit, direct navigation, and access control (non-dispatchers redirected to /login)
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: bikebrigade/dispatch/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b258db1-7a8e-4664-a181-b833ce4f1266
📥 Commits

Reviewing files that changed from the base of the PR and between 0c8390d and c4e8ee5.

📒 Files selected for processing (1)
  • test/bike_brigade_web/live/community_fridge_live_test.exs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: bikebrigade/dispatch/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: abdcfcdd-744b-4fac-9f6a-0b5c0574af2f
📥 Commits

Reviewing files that changed from the base of the PR and between d3749bc and 0c8390d.

📒 Files selected for processing (8)
  • lib/bike_brigade/locations/community_fridge.ex
  • lib/bike_brigade_web/components/layouts.ex
  • lib/bike_brigade_web/live/community_fridge_live/form_component.ex
  • lib/bike_brigade_web/live/community_fridge_live/form_component.html.heex
  • lib/bike_brigade_web/live/community_fridge_live/index.ex
  • lib/bike_brigade_web/live/community_fridge_live/index.html.heex
  • lib/bike_brigade_web/router.ex
  • test/bike_brigade_web/live/community_fridge_live_test.exs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The changes add dispatcher routes and a LiveView interface to list, create, and edit community fridges. The form validates required names, and the changeset no longer requires a location ID.

Changes

Community fridge management

Layer / File(s) Summary
Dispatcher routes and page state
lib/bike_brigade_web/router.ex, lib/bike_brigade_web/live/community_fridge_live/index.ex, lib/bike_brigade_web/components/layouts.ex
Adds dispatcher routes and sidebar navigation. The LiveView loads the fridge list and selects the record for the current action.
Fridge listing and modal navigation
lib/bike_brigade_web/live/community_fridge_live/index.html.heex, test/bike_brigade_web/live/community_fridge_live_test.exs
Displays fridge details and provides create and edit navigation through a modal. Tests cover the index, direct editing, existing values, and rider access control.
Form validation and save flow
lib/bike_brigade/locations/community_fridge.ex, lib/bike_brigade_web/live/community_fridge_live/form_component.ex, lib/bike_brigade_web/live/community_fridge_live/form_component.html.heex, test/bike_brigade_web/live/community_fridge_live_test.exs
Requires a fridge name but not a location ID. The form validates changes and creates or updates fridges. Tests cover validation and successful saves.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 0c839

No actionable merge-blocking issue is established for the community-fridge pages. They are mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main change: adding dispatcher UI for managing community fridges.
Description check Passed The description follows the required template, explains the changes, references related work, and confirms test coverage. The product-update checklist item is unchecked, but this is non-critical and d…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

  Introduces the CommunityFridge schema, migration, and test fixtures as the first step of the community fridges feature.
  The cubic-dev review suggested supporting a `location:` key in
  fixture(:community_fridge, ...) so callers can pass a location struct
  directly, matching the pattern used by rider and campaign fixtures.

  Implementing this requires fixture(:location) to persist a Location
  record and return a struct with an id, rather than returning a plain
  map as it does today. That change affects every fixture and test that
  currently calls fixture(:location), so the blast radius is wider than
  this PR's scope.

  The improvement will be handled in a follow-up PR dedicated to
  normalising the location fixture across the test suite.
  Add unique_constraint(:location_id) to CommunityFridge.changeset/2 so a
  location cannot be associated with more than one community fridge. The
  has_one relationship does not enforce cardinality at the database level,
  so this constraint surfaces duplicate-location errors as changeset errors.

  Also trim the minimal-attributes changeset test to focus on required
  fields rather than default values.
  - Add `persisted_location` fixture that inserts a Location into the
  database
    (complements existing in-memory `location` fixture)
  - Add `community_fridge` fixture that lazily creates a persisted location
  and
    handles required location_id association
  - Add LocationsTest with full coverage of community_fridge operations
  - Use setup block to eliminate fixture repetition across tests
  - Use pin operator (^) in pattern matches to validate update attrs without
    assertion repetition
  - Enable async: true for parallel test execution
@neal-bpm
neal-bpm force-pushed the vn/community-fridge-crud-v1 branch from 144a202 to 8849b2b Compare September 25, 2026 18:55
@neal-bpm
neal-bpm changed the base branch from vn/community-fridge-crud-v1 to main September 30, 2026 19:15
@neal-bpm
neal-bpm changed the base branch from main to vn/community-fridge-crud-v1 September 30, 2026 19:15
@neal-bpm
neal-bpm changed the base branch from vn/community-fridge-crud-v1 to main September 30, 2026 19:16
@neal-bpm
neal-bpm changed the base branch from main to vn/community-fridge-crud-v1 September 30, 2026 19:19
… attr

  - Remove duplicate list_community_fridges/0 call from apply_action(:index) since mount/3 already loads the list on every mount
  - Add :community_fridges to the current_page attr values list in layouts.ex
@neal-bpm
neal-bpm marked this pull request as ready for review October 8, 2026 01:34
@neal-bpm
neal-bpm requested a review from mveytsman October 8, 2026 03:57
Base automatically changed from vn/community-fridge-crud-v1 to main October 8, 2026 15:13
@neal-bpm neal-bpm changed the title Vn/community fridge UI v1 Add dispatcher UI for managing community fridges Oct 9, 2026
@neal-bpm

neal-bpm commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #540. Work consolidated into vn/community-fridge-feature for unified review.

@neal-bpm neal-bpm closed this Oct 9, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Bike Brigade all things tech Oct 9, 2026
@neal-bpm
neal-bpm removed the request for review from mveytsman October 9, 2026 15:44
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