Org access limiting: Add feature-flagged radio UI for access-limiting organisations [WHIT-3543]#11546
Open
GDSNewt wants to merge 6 commits into
Open
Org access limiting: Add feature-flagged radio UI for access-limiting organisations [WHIT-3543]#11546GDSNewt wants to merge 6 commits into
GDSNewt wants to merge 6 commits into
Conversation
92afbb4 to
bff1f86
Compare
Contributor
There was a problem hiding this comment.
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
…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.
bff1f86 to
2923338
Compare
727b094 to
737e53e
Compare
When :access_limiting_organisations_ui is enabled and an edition is access_limited, at least one access_limiting_organisation must be present.
d6bf045 to
10973e0
Compare
513fa22 to
fa654a7
Compare
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.
fa654a7 to
b7c28e2
Compare
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.
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
Flag on — main edit form (/edit)
Flag on — edit_access_limited form
Flag on — default-access-limited types
Revert