Change the panels for access mode fields#16481
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/access_mode.test.jsdecidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.jsdecidim-assemblies/app/views/decidim/assemblies/admin/assemblies/_form.html.erbdecidim-assemblies/config/locales/en.ymldecidim-participatory_processes/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erbdecidim-participatory_processes/config/locales/en.yml
decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
🧹 Nitpick comments (3)
decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb (1)
96-98: Samenilhandling consideration as inAssemblyForm.For consistency, if
has_membersbeingnilshould also result inaccess_modebeing set to:open, consider usingunless has_membersinstead 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_modeis reset to"open"whenhas_membersisfalse. For completeness, consider adding a similar test case for whenaccess_modeis"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 handlingnilcase forhas_members.The condition
has_members == falsewill not trigger whenhas_membersisnil. Ifnilshould be treated the same asfalse(i.e., no members), consider using!has_membersor explicitly handling thenilcase 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
📒 Files selected for processing (11)
decidim-admin/app/packs/src/decidim/admin/controllers/access_mode/controller.jsdecidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rbdecidim-assemblies/app/packs/src/decidim/assemblies/controllers/assembly_admin/controller.jsdecidim-assemblies/config/locales/en.ymldecidim-assemblies/lib/decidim/assemblies/test/factories.rbdecidim-assemblies/spec/forms/assembly_form_spec.rbdecidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rbdecidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rbdecidim-participatory_processes/lib/decidim/participatory_processes/test/factories.rbdecidim-participatory_processes/spec/forms/participatory_process_form_spec.rbdecidim-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
27aca0e
greenwoodt
left a comment
There was a problem hiding this comment.
Works as expected! Good job!
🎩 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
📷 Screenshots
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Tests