hyrax
hyrax copied to clipboard
Fix visibility prompt bug
Fixes
Fixes #6537
Summary
When saving a work in Sirenia, users consistently receive a prompt to verify changes to visibility, even when they did not make any edits to visibility. This is due to an underlying bug in comparing saved permissions with new permissions.
Guidance for testing, such as acceptance criteria or new user interface behaviors:
- Login as an Admin user
- Go to Dashboard > Works > All Works
- Edit a work deposited by a different user OR a work you deposited
- Make a minor metadata-only edit somewhere in the Description tab (do not adjust Visibility)
- Save the changes
- Verify that you cannot see the prompt to "Apply changes to contents? You have changed the access level..."
Type of change (for release notes)
-
notes-bugfix
Bug Fixes
Detailed Description
the underlying problem is in this method in app/controllers/concerns/hyrax/works_controller_behavior.rb
:
def permissions_changed?
@saved_permissions !=
case curation_concern
when ActiveFedora::Base
curation_concern.permissions.map(&:to_hash)
else
Hyrax::AccessControl.for(resource: curation_concern).permissions
end
end
when using Valkyrie, the array comparison between @saved_permissions
and Hyrax::AccessControl.for(resource: curation_concern).permissions
is always returning false even when permissions are exactly the same, because order in the two arrays is not always the same.
Changes proposed in this pull request:
- Replace comparing arrays with comparing array sizes and checking that each permission in the new permissions array exists in the saved permissions set
@samvera/hyrax-code-reviewers