Skip to content

Org access limiting: Add feature-flagged radio UI for access-limiting organisations [WHIT-3543]#11546

Open
GDSNewt wants to merge 6 commits into
mainfrom
add-featured-flag-ui-for-limiting-orgs-clean
Open

Org access limiting: Add feature-flagged radio UI for access-limiting organisations [WHIT-3543]#11546
GDSNewt wants to merge 6 commits into
mainfrom
add-featured-flag-ui-for-limiting-orgs-clean

Conversation

@GDSNewt

@GDSNewt GDSNewt commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

JIRA

What

Introduces a new radio-based access limiting UI for organisations, behind an :access_limiting_organisations_ui Flipflop feature flag, replacing the existing checkbox when the flag is enabled.

When the flag is off (default), existing behaviour is fully preserved — the checkbox renders and access limiting continues to use lead/supporting organisations.

When the flag is on:

  • The checkbox is replaced with two radio options: "No access limiting" and "Organisation access limiting"

  • Selecting "Organisation access limiting" reveals an organisation select with search

  • For edition types that are access-limited by default (e.g. StatisticalDataSet, PlanForChangeLandingPage, official/national statistics Publication), the form pre-selects "Organisation access limiting" and pre-fills the org select with lead organisations

  • Saving with "Organisation access limiting" and no org selected raises a validation error

  • Switching to "No access limiting" clears any previously set access_limiting_organisations

Why

To prepare for a new workflow that prevents users getting locked out of documents. The feature flag allows safe rollout with the ability to revert instantly by flipping the flag back off.

Testing

To test, toggle it at /flipflop on integration or locally.

Flag off

  • Open any edition's main edit form — confirm checkbox renders, not radio buttons
  • Open any edition's edit_access_limited form — confirm checkbox renders
  • Save with access_limited checked and no access_limiting_organisations — confirm it saves successfully
  • Confirm existing behaviour is unchanged

Flag on — main edit form (/edit)

  • Confirm radio buttons replace the checkbox
  • Select "Organisation access limiting", pick an org, save — confirm access_limiting_organisations persists
  • Try saving with "Organisation access limiting" and no org — confirm validation error

Flag on — edit_access_limited form

  • Confirm radio buttons replace the checkbox
  • Select "Organisation access limiting", pick an org, add editorial remark, save — confirm redirect and data persists
  • Try saving with "Organisation access limiting" and no org — confirm validation error
  • Try saving with a change and no editorial remark — confirm blank remark error
  • Select "No access limiting", add remark, save — confirm access_limited is false and access_limiting_organisations is empty

Flag on — default-access-limited types

  • Open a StatisticalDataSet edit_access_limited form
  • Confirm "Organisation access limiting" is pre-selected automatically
  • Confirm org select is pre-filled with lead organisations

Revert

  • Disable access_limiting_organisations_ui at /flipflop
  • Confirm checkbox reappears immediately on both forms
  • Confirm existing access_limiting_organisations data is unaffected

@GDSNewt GDSNewt force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch from 92afbb4 to bff1f86 Compare June 9, 2026 20:12

@ChrisBAshton ChrisBAshton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking really good, Alex. 👏 It does feel like it's missing a set of Cucumber scenarios, but we can tackle that separately and there are enough controller tests to give confidence in the meantime.

I also think we're going to want to replicate the existing validation rules around "You can't choose that access-limiting setting as you'll lock yourself out!" - but that is out of scope for this PR and likely warrants its own ticket. I'll write one up and link it from this ticket.
EDIT: raised https://gov-uk.atlassian.net/browse/WHIT-3583

Comment thread app/models/edition.rb
Comment thread app/models/concerns/edition/limited_access.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb
Comment thread app/controllers/admin/edition_access_limited_controller.rb
Comment thread app/controllers/admin/editions_controller.rb Outdated
Comment thread app/controllers/admin/editions_controller.rb Outdated
GDSNewt added 2 commits June 10, 2026 08:26
…ition

The existing has_many :access_limiting_organisations in Edition::Organisations
pointed directly at the join table model, meaning access_limiting_organisation_ids=
accepted join table row IDs rather than Organisation IDs.

This is significant; for example

To get the actual organisation you had to do:
edition.access_limiting_organisations.map(&:organisation).map(&:name)

After the refactor

edition.access_limiting_organisations.map(&:name)

TLDR: You pass Organisation IDs and get Organisation records back.
Defaults to false. Gates the new radio-based access limiting UI,
preserving the existing checkbox flow until the flag is enabled.
@jamiestamp jamiestamp force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch from bff1f86 to 2923338 Compare June 11, 2026 13:41
@GDSNewt GDSNewt marked this pull request as ready for review June 11, 2026 13:41
@jamiestamp jamiestamp force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch 2 times, most recently from 727b094 to 737e53e Compare June 11, 2026 14:15
ChrisBAshton

This comment was marked as outdated.

When :access_limiting_organisations_ui is enabled and an edition is
access_limited, at least one access_limiting_organisation must be present.
@GDSNewt GDSNewt force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch 3 times, most recently from d6bf045 to 10973e0 Compare June 12, 2026 12:24
Comment thread test/unit/app/services/edition_publisher_test.rb
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/edition_access_limited_controller.rb Outdated
Comment thread app/controllers/admin/editions_controller.rb
Comment thread test/functional/admin/edition_access_limited_controller_test.rb Outdated
Comment thread test/functional/admin/edition_access_limited_controller_test.rb
Comment thread lib/whitehall/authority/rules/edition_rules.rb
@jamiestamp jamiestamp force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch 6 times, most recently from 513fa22 to fa654a7 Compare June 15, 2026 11:27
GDSNewt and others added 3 commits June 15, 2026 15:08
Behind the access_limiting_organisations_ui flag, replace the access limiting checkbox with a radio ("No access limiting" / "Organisation access limiting") that reveals an organisation select, rendering a validation error when organisation limiting is selected with no organisations.

The radio lives in the shared _access_limiting_fields partial, so it renders on both the access-limited form and the main edition form. Both controllers are wired to translate the access_limiting value and persist access_limiting_organisation_ids, so a publisher's selection on either form is saved rather than silently ignored.
When access limiting is removed VIA the UI, the organisations sassociated with that option will now also be removed
For edition types that are access-limited by default (e.g. StatisticalDataSet, official/national statistics Publications), pre-select organisation access limiting and pre-fill the organisation select with the edition's lead organisations.

A shared Edition#prefill_default_access_limiting_organisations is called from the access-limited form's edit action and the main edition form's new and edit actions, so the behaviour is consistent when creating or editing.
@jamiestamp jamiestamp force-pushed the add-featured-flag-ui-for-limiting-orgs-clean branch from fa654a7 to b7c28e2 Compare June 15, 2026 14:08
@GDSNewt GDSNewt requested a review from ChrisBAshton June 15, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants