Skip to content

Project picker: precompute the label and drop the silent fallback#4770

Merged
midigofrank merged 1 commit into
release/2.16.4from
fix/breadcrumb-picker-precompute-label
May 19, 2026
Merged

Project picker: precompute the label and drop the silent fallback#4770
midigofrank merged 1 commit into
release/2.16.4from
fix/breadcrumb-picker-precompute-label

Conversation

@elias-ba
Copy link
Copy Markdown
Contributor

@elias-ba elias-ba commented May 19, 2026

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_scope hook (precomputed as project_label) and makes the picker a pure render with a required label attr, removing the silent fallback and the access_root_for_user/2 query that the component used to run inside its render path. Every call site now passes label={@project_label}.

Two tests in layout_components_test.exs that exercised the old in-component dispatch (the access_root and current_user resolution paths) are removed — those semantics now live in the hook and in display_name_within_access_root/2, which is already covered in projects_test.exs. The two remaining picker tests pass a precomputed label.

Closes #4769.

Validation steps

  1. Sign in as a user with access to both a parent project and one of its sandboxes (the demo user demo@openfn.org works after Lightning.SetupUtils.setup_demo(create_super: true)).
  2. Open the sandbox (DHIS2 > Sandboxes > pick one).
  3. Visit any page inside the sandbox other than Settings (Workflows, Runs, Channels, Dataclips). The picker shows the full path, e.g. dhis2-project/feature-x.
  4. Click Settings. The picker should still show dhis2-project/feature-x (before this PR it showed feature-x).
  5. Switch back to the parent project. The picker shows just the parent project's name on every page, including Settings.

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code
  • I have implemented and tested all related authorization policies
  • I have updated the changelog
  • I have ticked a box in "AI usage" in this PR

…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).
@github-project-automation github-project-automation Bot moved this to New Issues in Core May 19, 2026
@github-actions
Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): N/A — pure UI refactor that moves an already-computed label (from authorized access_root) up into :project_scope on_mount; no new queries or entry points.
  • S1 (authorization): N/A — no new actions, events, or endpoints; :project_scope still gates with Permissions.can?(ProjectUsers, :access_project, ...) (lib/lightning_web/hooks.ex:51).
  • S2 (audit trail): N/A — no writes to project/instance configuration; the change only assigns a display string to the socket.

@elias-ba elias-ba changed the title Precompute the breadcrumb project picker label in :project_scope; fix settings page Project picker: show the full ancestor path on the settings page May 19, 2026
@elias-ba elias-ba changed the title Project picker: show the full ancestor path on the settings page Project picker: precompute the label in :project_scope and drop the silent fallback May 19, 2026
@elias-ba elias-ba changed the title Project picker: precompute the label in :project_scope and drop the silent fallback Project picker: precompute the label and drop the silent fallback May 19, 2026
@elias-ba elias-ba requested a review from midigofrank May 19, 2026 12:48
@midigofrank midigofrank merged commit 2e29289 into release/2.16.4 May 19, 2026
6 of 8 checks passed
@midigofrank midigofrank deleted the fix/breadcrumb-picker-precompute-label branch May 19, 2026 13:38
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core May 19, 2026
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