mirror of
https://github.com/flarum/core.git
synced 2025-10-12 23:44:27 +02:00
Since Mithril doesn't really offer granular redraw control, typing in a text input on a modal would trigger a redraw for the whole page (including the page content behind the modal) on every keystroke. This commit allows components to be "paused" so that their vdom subtree will be retained instead of reconstructed on subsequent redraws. When a modal is opened, we pause the main page component, and when it's closed, we unpause it. This means that while a modal is visible, only the content inside of the modal will be redrawn, dramatically improving performance.
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import Page from 'flarum/components/Page';
|
|
import GroupBadge from 'flarum/components/GroupBadge';
|
|
import EditGroupModal from 'flarum/components/EditGroupModal';
|
|
import Group from 'flarum/models/Group';
|
|
import icon from 'flarum/helpers/icon';
|
|
import PermissionGrid from 'flarum/components/PermissionGrid';
|
|
|
|
export default class PermissionsPage extends Page {
|
|
view() {
|
|
return (
|
|
<div className="PermissionsPage">
|
|
<div className="PermissionsPage-groups">
|
|
<div className="container">
|
|
{app.store.all('groups')
|
|
.filter(group => [Group.GUEST_ID, Group.MEMBER_ID].indexOf(group.id()) === -1)
|
|
.map(group => (
|
|
<button className="Button Group" onclick={() => app.modal.show(new EditGroupModal({group}))}>
|
|
{GroupBadge.component({
|
|
group,
|
|
className: 'Group-icon',
|
|
label: null
|
|
})}
|
|
<span className="Group-name">{group.namePlural()}</span>
|
|
</button>
|
|
))}
|
|
<button className="Button Group Group--add" onclick={() => app.modal.show(new EditGroupModal())}>
|
|
{icon('plus', {className: 'Group-icon'})}
|
|
<span className="Group-name">{app.translator.trans('core.admin.permissions.new_group_button')}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="PermissionsPage-permissions">
|
|
<div className="container">
|
|
{PermissionGrid.component()}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|