Project picker: precompute the label and drop the silent fallback#4770
Merged
midigofrank merged 1 commit intoMay 19, 2026
Merged
Conversation
…component Fixes #4769. The breadcrumb project picker accepted any of project / current_user / access_root and silently fell back to using the project itself as its own access root when neither user nor access_root was passed. The project settings page hit that fallback, which is why the picker label there collapsed to the sandbox's own name instead of the full ancestor path. Move the label computation upstream so the component is a pure render: - :project_scope on_mount now computes project_label once per request via display_name_within_access_root/2 alongside the existing access_root assign. - breadcrumb_project_picker/1 now declares :label as a required attr and renders it directly. The case statement and the embedded access_root_for_user/2 DB query are gone. - Every call site passes label={@project_label} (and the settings page now passes it at all, fixing the original bug). Tests: the two component tests now pass an explicit label; the access_root- and current_user-dispatch tests are removed (those semantics are tested directly on display_name_within_access_root/2 in projects_test.exs).
Security Review ✅
|
midigofrank
approved these changes
May 19, 2026
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.
Description
The breadcrumb project picker on the settings page collapsed to the sandbox's own name instead of the full ancestor path, because the page didn't pass the user's access root and the component fell back silently. This PR moves the label computation into the
:project_scopehook (precomputed asproject_label) and makes the picker a pure render with a requiredlabelattr, removing the silent fallback and theaccess_root_for_user/2query that the component used to run inside its render path. Every call site now passeslabel={@project_label}.Two tests in
layout_components_test.exsthat exercised the old in-component dispatch (theaccess_rootandcurrent_userresolution paths) are removed — those semantics now live in the hook and indisplay_name_within_access_root/2, which is already covered inprojects_test.exs. The two remaining picker tests pass a precomputedlabel.Closes #4769.
Validation steps
demo@openfn.orgworks afterLightning.SetupUtils.setup_demo(create_super: true)).dhis2-project/feature-x.dhis2-project/feature-x(before this PR it showedfeature-x).AI Usage
Pre-submission checklist