[PR #3760] [MERGED] Refactor of item-level permission to be more intuitive #6260

Closed
opened 2026-02-05 10:27:56 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/3760
Author: @ssddanbrown
Created: 10/2/2022
Status: Merged
Merged: 10/14/2022
Merged by: @ssddanbrown

Base: developmentHead: item_permission_revamp


📝 Commits (10+)

  • f19bad8 Started item permission design revamp
  • b8b0afa Cleaned up old permission JS code
  • a03245e Added user-interface for "Everyone Else" entity permission item
  • 1df9ec9 Added proper entity permission removal on role deletion
  • 1d3dbd6 Migrated entity_permissions table to new flat format
  • aee0e16 Started code update for new entity permission format
  • 3839bf6 Updated joint perms. gen. to use new entity permission format
  • 06a7f1b Added migration to drop entity restricted field
  • bf59176 Reorgranised permission routes into their own controller
  • ffd6a10 Centralised handling of permission form data to own class

📊 Changes

65 files changed (+1084 additions, -468 deletions)

View changed files

📝 app/Auth/Permissions/EntityPermission.php (+26 -5)
📝 app/Auth/Permissions/JointPermissionBuilder.php (+25 -23)
📝 app/Auth/Permissions/PermissionApplicator.php (+36 -12)
app/Auth/Permissions/PermissionFormData.php (+68 -0)
📝 app/Auth/Permissions/PermissionsRepo.php (+1 -0)
📝 app/Auth/Permissions/SimpleEntityData.php (+0 -1)
📝 app/Auth/Role.php (+9 -11)
📝 app/Console/Commands/CopyShelfPermissions.php (+7 -10)
📝 app/Entities/Models/Book.php (+10 -1)
📝 app/Entities/Models/Bookshelf.php (+10 -1)
📝 app/Entities/Models/Chapter.php (+10 -1)
📝 app/Entities/Models/Entity.php (+3 -5)
📝 app/Entities/Models/Page.php (+10 -1)
📝 app/Entities/Models/PageRevision.php (+1 -1)
📝 app/Entities/Repos/BookshelfRepo.php (+0 -25)
📝 app/Entities/Tools/Cloner.php (+1 -2)
📝 app/Entities/Tools/HierarchyTransformer.php (+1 -1)
📝 app/Entities/Tools/PermissionsUpdater.php (+40 -14)
📝 app/Http/Controllers/BookController.php (+0 -31)
📝 app/Http/Controllers/BookshelfController.php (+0 -43)

...and 45 more files

📄 Description

Related to #410

Also makes the item permissions view much more mobile responsive.

Todo

  • Fix existing use of permission page JavaScript (Row toggle)
  • Add interface support for selecting/adding additional roles.
  • Add new "Other Roles" option.
  • Migrate & drop existing entity permissions where restricted=0. DOCUMENT.
  • Migrate existing restricted=1 item entries with new "Other Roles" option with no permissions.
  • Drop restricted entity field.
  • Translations for strings.
  • Update "Restricted" search filter.
  • Update restricted indicator in entity details view partial.
  • Fix shelf-copy-permissions functionality.
  • Handle/warn/document removal of restricted field in API data (If exists). Not part of API data AFAICT.
  • Dark mode support check
  • Update item-permission page with new intro text.
    • Mention cascade behaviour for chapters and books?
  • Scenario test manually - Scenario Testing
  • Re-test migration from old DB content
  • Test dropping of entity-permissions on non-restricted entities upon upgrade.
  • Test migration of restricted=1 entries to new "Other Role" active entries.
  • Test PermissionApplicator@hasEntityPermission logic.
  • Test migration on MySQL container (upon dev mariadb setup)
  • Test migration on demo instance db copy.

Docs Updates

  • Update note: General advisory of significant change of entity permission application.
    • Update note: Advise that previous rows in custom permissions, with nothing selected, will not be visible since the "Everyone Else" fallback handles this instead now.
  • Update note: Inactive Entity permissions will be deleted upon upgrade.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/3760 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 10/2/2022 **Status:** ✅ Merged **Merged:** 10/14/2022 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `item_permission_revamp` --- ### 📝 Commits (10+) - [`f19bad8`](https://github.com/BookStackApp/BookStack/commit/f19bad89033ee31e9157341214ae3a7e3b0fbb40) Started item permission design revamp - [`b8b0afa`](https://github.com/BookStackApp/BookStack/commit/b8b0afa0df6f9a63438c214fc08664e6b4cd3455) Cleaned up old permission JS code - [`a03245e`](https://github.com/BookStackApp/BookStack/commit/a03245e427d3257eeb2bbf137e8e6ce1388c1e69) Added user-interface for "Everyone Else" entity permission item - [`1df9ec9`](https://github.com/BookStackApp/BookStack/commit/1df9ec96477740360fc6542beed902cc2571c6de) Added proper entity permission removal on role deletion - [`1d3dbd6`](https://github.com/BookStackApp/BookStack/commit/1d3dbd6f6e1925c08237c009e8e65b5a66194ad2) Migrated entity_permissions table to new flat format - [`aee0e16`](https://github.com/BookStackApp/BookStack/commit/aee0e16194cd9d03e4d818220d52421aac8bd15f) Started code update for new entity permission format - [`3839bf6`](https://github.com/BookStackApp/BookStack/commit/3839bf6bf11ac6b4d19c2ae8f62a314a2c164251) Updated joint perms. gen. to use new entity permission format - [`06a7f1b`](https://github.com/BookStackApp/BookStack/commit/06a7f1b54ad02a9597509275f80407d667014e9f) Added migration to drop entity restricted field - [`bf59176`](https://github.com/BookStackApp/BookStack/commit/bf591765c1e642f144675afaa031ecd283a8673b) Reorgranised permission routes into their own controller - [`ffd6a10`](https://github.com/BookStackApp/BookStack/commit/ffd6a1002e8ed40ba7b651391ee39c9ff6b2ea1f) Centralised handling of permission form data to own class ### 📊 Changes **65 files changed** (+1084 additions, -468 deletions) <details> <summary>View changed files</summary> 📝 `app/Auth/Permissions/EntityPermission.php` (+26 -5) 📝 `app/Auth/Permissions/JointPermissionBuilder.php` (+25 -23) 📝 `app/Auth/Permissions/PermissionApplicator.php` (+36 -12) ➕ `app/Auth/Permissions/PermissionFormData.php` (+68 -0) 📝 `app/Auth/Permissions/PermissionsRepo.php` (+1 -0) 📝 `app/Auth/Permissions/SimpleEntityData.php` (+0 -1) 📝 `app/Auth/Role.php` (+9 -11) 📝 `app/Console/Commands/CopyShelfPermissions.php` (+7 -10) 📝 `app/Entities/Models/Book.php` (+10 -1) 📝 `app/Entities/Models/Bookshelf.php` (+10 -1) 📝 `app/Entities/Models/Chapter.php` (+10 -1) 📝 `app/Entities/Models/Entity.php` (+3 -5) 📝 `app/Entities/Models/Page.php` (+10 -1) 📝 `app/Entities/Models/PageRevision.php` (+1 -1) 📝 `app/Entities/Repos/BookshelfRepo.php` (+0 -25) 📝 `app/Entities/Tools/Cloner.php` (+1 -2) 📝 `app/Entities/Tools/HierarchyTransformer.php` (+1 -1) 📝 `app/Entities/Tools/PermissionsUpdater.php` (+40 -14) 📝 `app/Http/Controllers/BookController.php` (+0 -31) 📝 `app/Http/Controllers/BookshelfController.php` (+0 -43) _...and 45 more files_ </details> ### 📄 Description Related to #410 Also makes the item permissions view much more mobile responsive. ### Todo - [x] Fix existing use of permission page JavaScript (Row toggle) - [x] Add interface support for selecting/adding additional roles. - [x] Add new "Other Roles" option. - [x] Migrate & drop existing entity permissions where `restricted=0`. DOCUMENT. - [x] Migrate existing `restricted=1` item entries with new "Other Roles" option with no permissions. - [x] Drop `restricted` entity field. - [x] Translations for strings. - [x] Update "Restricted" search filter. - [x] Update restricted indicator in entity details view partial. - [x] Fix shelf-copy-permissions functionality. - [x] ~~Handle/warn/document removal of `restricted` field in API data (If exists).~~ Not part of API data AFAICT. - [x] Dark mode support check - [x] Update item-permission page with new intro text. - [x] Mention cascade behaviour for chapters and books? - [x] Scenario test manually - [Scenario Testing](https://user-images.githubusercontent.com/8343178/195886376-77ea46d8-8ff1-418a-9beb-017f8b2d61b2.jpg) - [x] Re-test migration from old DB content - [x] Test dropping of entity-permissions on non-restricted entities upon upgrade. - [x] Test migration of restricted=1 entries to new "Other Role" active entries. - [x] Test PermissionApplicator@hasEntityPermission logic. - [x] Test migration on MySQL container (upon dev mariadb setup) - [x] Test migration on demo instance db copy. ### Docs Updates - [ ] Update note: General advisory of significant change of entity permission application. - [ ] Update note: Advise that previous rows in custom permissions, with nothing selected, will not be visible since the "Everyone Else" fallback handles this instead now. - [ ] Update note: Inactive Entity permissions will be deleted upon upgrade. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:27:56 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6260