Skip to content

feat: advanced admin registry extenders #4209

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented Apr 11, 2025

Addresses #4200 (comment)

Changes proposed in this pull request:

  • Allows changing an existing admin setting/permission.
  • Allows changing the priority of an existing admin setting/permission.
  • Allows removing an existing admin setting/priority.

The current caveat is that when extension A wants to do any of this to a setting/permission from extension B, it has to specify the extension ID in the constructor of the Admin extender, and it also has to be booted after extension B.

Examples

// current extension: nicknames

new Extend.Admin('flarum-sticky').replaceSetting('flarum-sticky.only_sticky_unread_discussions', (original) => ({
  ...original,
  label: 'test',
 })),

new Extend.Admin('flarum-sticky').setSettingPriority('flarum-sticky.only_sticky_unread_discussions', 500),

new Extend.Admin('flarum-sticky').removeSetting('flarum-sticky.only_sticky_unread_discussions'),

new Extend.Admin('flarum-sticky').replacePermission(
  'discussion.sticky',
  (original) => ({
    ...original,
    icon: 'fas fa-at',
  }),
  'moderate'
),

new Extend.Admin('flarum-sticky').setPermissionPriority('discussion.sticky', 'moderate', 500),

new Extend.Admin('flarum-sticky').removePermission('discussion.sticky', 'moderate'),
new Extend.Admin('core-basics').removeSetting('welcome_title'),

@SychO9 SychO9 added this to the 2.0.0-beta.3 milestone Apr 11, 2025
@SychO9 SychO9 requested a review from a team as a code owner April 11, 2025 13:04
@SychO9 SychO9 marked this pull request as draft April 11, 2025 13:07
@SychO9 SychO9 marked this pull request as ready for review April 11, 2025 14:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants