mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
Compatibility with new "required permissions" concept
This commit is contained in:
parent
c809f329bb
commit
822e823936
19
extensions/tags/js/admin/dist/extension.js
vendored
19
extensions/tags/js/admin/dist/extension.js
vendored
|
@ -531,9 +531,25 @@ System.register('flarum/tags/addTagsPane', ['flarum/extend', 'flarum/components/
|
|||
'use strict';
|
||||
|
||||
System.register('flarum/tags/addTagsPermissionScope', ['flarum/extend', 'flarum/components/PermissionGrid', 'flarum/components/PermissionDropdown', 'flarum/components/Dropdown', 'flarum/components/Button', 'flarum/tags/helpers/tagLabel', 'flarum/tags/helpers/tagIcon', 'flarum/tags/utils/sortTags'], function (_export, _context) {
|
||||
var extend, PermissionGrid, PermissionDropdown, Dropdown, Button, tagLabel, tagIcon, sortTags;
|
||||
var extend, override, PermissionGrid, PermissionDropdown, Dropdown, Button, tagLabel, tagIcon, sortTags;
|
||||
|
||||
_export('default', function () {
|
||||
override(app, 'getRequiredPermissions', function (original, permission) {
|
||||
var tagPrefix = permission.match(/^tag\d+\./);
|
||||
|
||||
if (tagPrefix) {
|
||||
var globalPermission = permission.substr(tagPrefix[0].length);
|
||||
|
||||
var required = original(globalPermission);
|
||||
|
||||
return required.map(function (required) {
|
||||
return tagPrefix[0] + required;
|
||||
});
|
||||
}
|
||||
|
||||
return original(permission);
|
||||
});
|
||||
|
||||
extend(PermissionGrid.prototype, 'scopeItems', function (items) {
|
||||
sortTags(app.store.all('tags')).filter(function (tag) {
|
||||
return tag.isRestricted();
|
||||
|
@ -586,6 +602,7 @@ System.register('flarum/tags/addTagsPermissionScope', ['flarum/extend', 'flarum/
|
|||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
override = _flarumExtend.override;
|
||||
}, function (_flarumComponentsPermissionGrid) {
|
||||
PermissionGrid = _flarumComponentsPermissionGrid.default;
|
||||
}, function (_flarumComponentsPermissionDropdown) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { extend } from 'flarum/extend';
|
||||
import { extend, override } from 'flarum/extend';
|
||||
import PermissionGrid from 'flarum/components/PermissionGrid';
|
||||
import PermissionDropdown from 'flarum/components/PermissionDropdown';
|
||||
import Dropdown from 'flarum/components/Dropdown';
|
||||
|
@ -9,6 +9,20 @@ import tagIcon from 'flarum/tags/helpers/tagIcon';
|
|||
import sortTags from 'flarum/tags/utils/sortTags';
|
||||
|
||||
export default function() {
|
||||
override(app, 'getRequiredPermissions', (original, permission) => {
|
||||
const tagPrefix = permission.match(/^tag\d+\./);
|
||||
|
||||
if (tagPrefix) {
|
||||
const globalPermission = permission.substr(tagPrefix[0].length);
|
||||
|
||||
const required = original(globalPermission);
|
||||
|
||||
return required.map(required => tagPrefix[0] + required);
|
||||
}
|
||||
|
||||
return original(permission);
|
||||
});
|
||||
|
||||
extend(PermissionGrid.prototype, 'scopeItems', items => {
|
||||
sortTags(app.store.all('tags'))
|
||||
.filter(tag => tag.isRestricted())
|
||||
|
|
Loading…
Reference in New Issue
Block a user