Skip to content

Change the panels for access mode fields#16481

Merged
greenwoodt merged 9 commits intodevelopfrom
feature/access-mode-ux
Mar 26, 2026
Merged

Change the panels for access mode fields#16481
greenwoodt merged 9 commits intodevelopfrom
feature/access-mode-ux

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Mar 25, 2026

🎩 What? Why?

These are the final touches for the Access Mode feature: moves the fields to its own panel, and makes the Members toggle the Access Mode radio buttons.

📌 Related Issues

Testing

  1. Sign in as admin
  2. Edit a process or an assembly or create a new one
  3. See that you have an "Access" panel
  4. See that if you click in "This space has members", then the checkboxes are shown or not

📷 Screenshots

image image

♥️ Thank you!

Summary by CodeRabbit

  • New Features

    • Access settings now dynamically show or hide based on whether a space has members.
  • Bug Fixes

    • Access mode is coerced to "open" when a space has no members to prevent invalid states.
  • Chores

    • Admin form sections reorganized (new "Access" section) and new English i18n labels added.
  • Tests

    • Added frontend and form specs for access-mode behavior and teardown; adjusted related test coverage.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1bc164e5-cff5-4861-97fb-08fbe7a6a2d6

📥 Commits

Reviewing files that changed from the base of the PR and between 47a080c and 27aca0e.

📒 Files selected for processing (1)
  • decidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/assembly_admin.test.js
💤 Files with no reviewable changes (1)
  • decidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/assembly_admin.test.js

📝 Walkthrough

Walkthrough

Adds a Stimulus access-mode controller and tests; restructures admin forms to introduce a new "access" accordion (members checkbox + access_mode radios) for assemblies and participatory processes; enforces access_mode -> open when has_members is false via form validations; updates factories and specs accordingly.

Changes

Cohort / File(s) Summary
Access Mode controller & tests
decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js, decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/access_mode.test.js
New Stimulus controller that toggles #access_mode fieldset visibility based on #has_members checkbox; binds/unbinds change listener. Jest tests verify initial hidden state, interaction, and listener cleanup.
Admin form templates (assemblies + processes)
decidim-assemblies/app/views/.../_form.html.erb, decidim-participatory_processes/app/views/.../_form.html.erb
Introduced an access accordion (wired to data-controller="access-mode") containing the members checkbox and access_mode radios; reintroduced the original visibility accordion below with prior visibility fields.
Form validations & specs
decidim-assemblies/app/forms/.../assembly_form.rb, decidim-participatory_processes/app/forms/.../participatory_process_form.rb, decidim-assemblies/spec/forms/assembly_form_spec.rb, decidim-participatory_processes/spec/forms/participatory_process_form_spec.rb
Added ensure_access_mode_for_has_members validation to force access_mode to :open when has_members is false; added specs asserting the reset behavior.
Assembly admin controller change
decidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/controller.js
Removed legacy connect() wiring and toggleDisabledHiddenFields() method that synchronized #is_transparent and #special_features with #private_space.
Factory trait adjustments
decidim-assemblies/lib/.../test/factories.rb, decidim-participatory_processes/lib/.../test/factories.rb
Updated :transparent and :restricted traits to explicitly set has_members { true } alongside access_mode.
System/spec updates
decidim-assemblies/spec/system/..._admin_manages_assemblies_spec.rb, decidim-participatory_processes/spec/system/..._admin_manages_participatory_processes_spec.rb
Removed explicit Capybara choose(..._access_mode_open) steps from creation flows.
Locales
decidim-assemblies/config/locales/en.yml, decidim-participatory_processes/config/locales/en.yml
Added access.set_this_space_as / set_this_space_as English translation keys for the new access accordion label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alecslupu

Poem

🐰 I hopped into code with a checkbox so bright,
I nudged radios in place and hid fields from sight,
I bind and unbind with a tidy little paw,
Forms whisper "members" now — organized with awe,
Hooray — access made clear, and everything's right!

🚥 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Change the panels for access mode fields' directly describes the main structural change in the PR—reorganizing form panels to separate access-related fields.
Linked Issues check ✅ Passed The PR implements all key requirements from #15720: unified access model with three modes (Open/Transparent/Restricted), Members checkbox toggle for radio buttons, proper defaults (Open when members enabled), consistent Members terminology, and integrated into both processes and assemblies.
Out of Scope Changes check ✅ Passed All changes are directly scoped to #15720 objectives: new AccessModeController, form reorganization, validation logic, factories, and test updates align with implementing the access mode feature and Members UI toggle.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/access-mode-ux

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 and usage tips.

github-actions[bot]
github-actions bot previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js`:
- Around line 39-43: In toggleAccessMode(), when you hide or show the
accessModeFieldset based on hasMembersCheckbox, also disable or enable the
contained radio inputs so a hidden/disabled access_mode isn't submitted; locate
the toggleAccessMode method and update it to query the radios inside
accessModeFieldset (e.g., input[type="radio"] or by name 'access_mode'), set
.disabled = true when hiding and .disabled = false when showing, and optionally
clear checked state when hiding if you want to avoid preserving selection state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aa3001aa-a8c7-4256-bece-5c4070b32e12

📥 Commits

Reviewing files that changed from the base of the PR and between fbc04fc and cc61c35.

📒 Files selected for processing (6)
  • decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/access_mode.test.js
  • decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js
  • decidim-assemblies/app/views/decidim/assemblies/admin/assemblies/_form.html.erb
  • decidim-assemblies/config/locales/en.yml
  • decidim-participatory_processes/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb
  • decidim-participatory_processes/config/locales/en.yml

github-actions[bot]
github-actions bot previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb (1)

96-98: Same nil handling consideration as in AssemblyForm.

For consistency, if has_members being nil should also result in access_mode being set to :open, consider using unless has_members instead of == false.

♻️ Proposed fix to handle nil
 def ensure_access_mode_for_has_members
-  self.access_mode = :open if has_members == false
+  self.access_mode = :open unless has_members
 end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb`
around lines 96 - 98, The method ensure_access_mode_for_has_members currently
does strict comparison (has_members == false) which ignores nil; change the
condition to treat nil as falsy (e.g., use unless has_members) so that when
has_members is nil or false you set self.access_mode = :open; update the logic
inside ensure_access_mode_for_has_members to use the falsy check and keep
references to access_mode and has_members unchanged.
decidim-participatory_processes/spec/forms/participatory_process_form_spec.rb (1)

130-138: Test coverage looks good, but consider adding a test for "restricted" access mode.

The test correctly validates that access_mode is reset to "open" when has_members is false. For completeness, consider adding a similar test case for when access_mode is "restricted" to ensure both non-open modes are properly reset.

🧪 Optional: Add test for restricted access mode
describe "access_mode reset when has_members is false" do
  context "when access_mode is transparent" do
    let(:access_mode) { "transparent" }
    let(:has_members) { false }

    it "resets access_mode to open" do
      subject.valid?
      expect(subject.access_mode).to eq("open")
    end
  end

  context "when access_mode is restricted" do
    let(:access_mode) { "restricted" }
    let(:has_members) { false }

    it "resets access_mode to open" do
      subject.valid?
      expect(subject.access_mode).to eq("open")
    end
  end
end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@decidim-participatory_processes/spec/forms/participatory_process_form_spec.rb`
around lines 130 - 138, Add a parallel test for the "restricted" access_mode
inside the same describe block so both non-open modes are covered: ensure you
add a context or it-block that sets let(:access_mode) { "restricted" } and
let(:has_members) { false }, then call subject.valid? and
expect(subject.access_mode).to eq("open"); reference the existing describe
"access_mode reset when has_members is false", subject, access_mode, and
has_members to mirror the "transparent" case.
decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb (1)

128-130: Consider handling nil case for has_members.

The condition has_members == false will not trigger when has_members is nil. If nil should be treated the same as false (i.e., no members), consider using !has_members or explicitly handling the nil case to ensure consistent behavior.

♻️ Proposed fix to handle nil
 def ensure_access_mode_for_has_members
-  self.access_mode = :open if has_members == false
+  self.access_mode = :open unless has_members
 end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb`
around lines 128 - 130, The method ensure_access_mode_for_has_members currently
sets access_mode only when has_members == false, which ignores nil; update the
condition in ensure_access_mode_for_has_members to treat nil as false (e.g., use
!has_members or has_members != true) so that when has_members is nil or false
the method sets self.access_mode = :open; reference
ensure_access_mode_for_has_members, has_members, and access_mode when making the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb`:
- Around line 128-130: The method ensure_access_mode_for_has_members currently
sets access_mode only when has_members == false, which ignores nil; update the
condition in ensure_access_mode_for_has_members to treat nil as false (e.g., use
!has_members or has_members != true) so that when has_members is nil or false
the method sets self.access_mode = :open; reference
ensure_access_mode_for_has_members, has_members, and access_mode when making the
change.

In
`@decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb`:
- Around line 96-98: The method ensure_access_mode_for_has_members currently
does strict comparison (has_members == false) which ignores nil; change the
condition to treat nil as falsy (e.g., use unless has_members) so that when
has_members is nil or false you set self.access_mode = :open; update the logic
inside ensure_access_mode_for_has_members to use the falsy check and keep
references to access_mode and has_members unchanged.

In
`@decidim-participatory_processes/spec/forms/participatory_process_form_spec.rb`:
- Around line 130-138: Add a parallel test for the "restricted" access_mode
inside the same describe block so both non-open modes are covered: ensure you
add a context or it-block that sets let(:access_mode) { "restricted" } and
let(:has_members) { false }, then call subject.valid? and
expect(subject.access_mode).to eq("open"); reference the existing describe
"access_mode reset when has_members is false", subject, access_mode, and
has_members to mirror the "transparent" case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6865059d-a9ef-43ff-8693-c247da2624f0

📥 Commits

Reviewing files that changed from the base of the PR and between cc61c35 and 47a080c.

📒 Files selected for processing (11)
  • decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js
  • decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb
  • decidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/controller.js
  • decidim-assemblies/config/locales/en.yml
  • decidim-assemblies/lib/decidim/assemblies/test/factories.rb
  • decidim-assemblies/spec/forms/assembly_form_spec.rb
  • decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb
  • decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb
  • decidim-participatory_processes/lib/decidim/participatory_processes/test/factories.rb
  • decidim-participatory_processes/spec/forms/participatory_process_form_spec.rb
  • decidim-participatory_processes/spec/system/admin/admin_manages_participatory_processes_spec.rb
💤 Files with no reviewable changes (3)
  • decidim-participatory_processes/spec/system/admin/admin_manages_participatory_processes_spec.rb
  • decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb
  • decidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/controller.js
✅ Files skipped from review due to trivial changes (2)
  • decidim-assemblies/lib/decidim/assemblies/test/factories.rb
  • decidim-assemblies/config/locales/en.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Member

@greenwoodt greenwoodt left a comment

Choose a reason for hiding this comment

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

Works as expected! Good job!

@greenwoodt greenwoodt merged commit f44bd6e into develop Mar 26, 2026
66 of 73 checks passed
@greenwoodt greenwoodt deleted the feature/access-mode-ux branch March 26, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce access modes for processes and assemblies

2 participants