mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 19:15:06 +08:00
Improve admin permissions page with icons, visual tweaks
This commit is contained in:
parent
3ac9efde3e
commit
8a5a3a0624
|
@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [Unreleased][unreleased]
|
## [Unreleased][unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Allow discussions to be hidden and restored.
|
- Ability to hide and restore discussions.
|
||||||
- External authentication (social login) API.
|
- External authentication (social login) API.
|
||||||
- API to set asset compiler filename.
|
- API to set asset compiler filename.
|
||||||
- Migration generator, available via generate:migration console command.
|
- Migration generator, available via generate:migration console command.
|
||||||
|
@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
- Abstract SettingsModal component for quickly building admin config modals.
|
- Abstract SettingsModal component for quickly building admin config modals.
|
||||||
- "Debug" button to inspect the response of a failed AJAX request.
|
- "Debug" button to inspect the response of a failed AJAX request.
|
||||||
- `Model::afterSave()` API to run callback after a model instance is saved.
|
- `Model::afterSave()` API to run callback after a model instance is saved.
|
||||||
|
- Improved admin Permissions page with icons and other tweaks.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Migrations must be namespaced under `Flarum\Migrations\{Core|ExtensionName}`. ([#422](https://github.com/flarum/core/issues/422))
|
- Migrations must be namespaced under `Flarum\Migrations\{Core|ExtensionName}`. ([#422](https://github.com/flarum/core/issues/422))
|
||||||
|
|
|
@ -61,7 +61,7 @@ export default class PermissionDropdown extends Dropdown {
|
||||||
icon: !everyone && !members ? 'check' : true,
|
icon: !everyone && !members ? 'check' : true,
|
||||||
disabled: !everyone && !members,
|
disabled: !everyone && !members,
|
||||||
onclick: e => {
|
onclick: e => {
|
||||||
e.stopPropagation();
|
if (e.shiftKey) e.stopPropagation();
|
||||||
this.save([]);
|
this.save([]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -75,7 +75,7 @@ export default class PermissionDropdown extends Dropdown {
|
||||||
children: [GroupBadge.component({group, label: null}), ' ', group.namePlural()],
|
children: [GroupBadge.component({group, label: null}), ' ', group.namePlural()],
|
||||||
icon: groupIds.indexOf(group.id()) !== -1 ? 'check' : true,
|
icon: groupIds.indexOf(group.id()) !== -1 ? 'check' : true,
|
||||||
onclick: (e) => {
|
onclick: (e) => {
|
||||||
e.stopPropagation();
|
if (e.shiftKey) e.stopPropagation();
|
||||||
this.toggle(group.id());
|
this.toggle(group.id());
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -3,6 +3,7 @@ import PermissionDropdown from 'flarum/components/PermissionDropdown';
|
||||||
import ConfigDropdown from 'flarum/components/ConfigDropdown';
|
import ConfigDropdown from 'flarum/components/ConfigDropdown';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import ItemList from 'flarum/utils/ItemList';
|
import ItemList from 'flarum/utils/ItemList';
|
||||||
|
import icon from 'flarum/helpers/icon';
|
||||||
|
|
||||||
export default class PermissionGrid extends Component {
|
export default class PermissionGrid extends Component {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
|
@ -45,7 +46,7 @@ export default class PermissionGrid extends Component {
|
||||||
</tr>
|
</tr>
|
||||||
{section.children.map(child => (
|
{section.children.map(child => (
|
||||||
<tr className="PermissionGrid-child">
|
<tr className="PermissionGrid-child">
|
||||||
<th>{child.label}</th>
|
<th>{child.icon ? icon(child.icon) : ''}{child.label}</th>
|
||||||
{permissionCells(child)}
|
{permissionCells(child)}
|
||||||
<td/>
|
<td/>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -60,24 +61,24 @@ export default class PermissionGrid extends Component {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
items.add('view', {
|
items.add('view', {
|
||||||
label: 'View the forum',
|
label: 'Read',
|
||||||
children: this.viewItems().toArray()
|
children: this.viewItems().toArray()
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
items.add('start', {
|
items.add('start', {
|
||||||
label: 'Start discussions',
|
label: 'Create',
|
||||||
children: this.startItems().toArray()
|
children: this.startItems().toArray()
|
||||||
});
|
}, 90);
|
||||||
|
|
||||||
items.add('reply', {
|
items.add('reply', {
|
||||||
label: 'Reply to discussions',
|
label: 'Participate',
|
||||||
children: this.replyItems().toArray()
|
children: this.replyItems().toArray()
|
||||||
});
|
}, 80);
|
||||||
|
|
||||||
items.add('moderate', {
|
items.add('moderate', {
|
||||||
label: 'Moderate',
|
label: 'Moderate',
|
||||||
children: this.moderateItems().toArray()
|
children: this.moderateItems().toArray()
|
||||||
});
|
}, 70);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -86,12 +87,14 @@ export default class PermissionGrid extends Component {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
items.add('view', {
|
items.add('view', {
|
||||||
|
icon: 'eye',
|
||||||
label: 'View discussions',
|
label: 'View discussions',
|
||||||
permission: 'forum.view',
|
permission: 'forum.view',
|
||||||
allowGuest: true
|
allowGuest: true
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
items.add('signUp', {
|
items.add('signUp', {
|
||||||
|
icon: 'user-plus',
|
||||||
label: 'Sign up',
|
label: 'Sign up',
|
||||||
setting: () => ConfigDropdown.component({
|
setting: () => ConfigDropdown.component({
|
||||||
key: 'allow_sign_up',
|
key: 'allow_sign_up',
|
||||||
|
@ -100,7 +103,7 @@ export default class PermissionGrid extends Component {
|
||||||
{value: '0', label: 'Closed'}
|
{value: '0', label: 'Closed'}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
}, 90);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -109,11 +112,13 @@ export default class PermissionGrid extends Component {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
items.add('start', {
|
items.add('start', {
|
||||||
|
icon: 'edit',
|
||||||
label: 'Start discussions',
|
label: 'Start discussions',
|
||||||
permission: 'forum.startDiscussion'
|
permission: 'forum.startDiscussion'
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
items.add('allowRenaming', {
|
items.add('allowRenaming', {
|
||||||
|
icon: 'i-cursor',
|
||||||
label: 'Allow renaming',
|
label: 'Allow renaming',
|
||||||
setting: () => {
|
setting: () => {
|
||||||
const minutes = parseInt(app.config.allow_renaming, 10);
|
const minutes = parseInt(app.config.allow_renaming, 10);
|
||||||
|
@ -128,7 +133,7 @@ export default class PermissionGrid extends Component {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}, 90);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -137,11 +142,13 @@ export default class PermissionGrid extends Component {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
items.add('reply', {
|
items.add('reply', {
|
||||||
|
icon: 'reply',
|
||||||
label: 'Reply to discussions',
|
label: 'Reply to discussions',
|
||||||
permission: 'discussion.reply'
|
permission: 'discussion.reply'
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
items.add('allowPostEditing', {
|
items.add('allowPostEditing', {
|
||||||
|
icon: 'pencil',
|
||||||
label: 'Allow post editing',
|
label: 'Allow post editing',
|
||||||
setting: () => {
|
setting: () => {
|
||||||
const minutes = parseInt(app.config.allow_post_editing, 10);
|
const minutes = parseInt(app.config.allow_post_editing, 10);
|
||||||
|
@ -156,7 +163,7 @@ export default class PermissionGrid extends Component {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}, 90);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -164,25 +171,35 @@ export default class PermissionGrid extends Component {
|
||||||
moderateItems() {
|
moderateItems() {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
|
|
||||||
items.add('editPosts', {
|
|
||||||
label: 'Edit posts',
|
|
||||||
permission: 'discussion.editPosts'
|
|
||||||
});
|
|
||||||
|
|
||||||
items.add('deletePosts', {
|
|
||||||
label: 'Delete posts',
|
|
||||||
permission: 'discussion.deletePosts'
|
|
||||||
});
|
|
||||||
|
|
||||||
items.add('renameDiscussions', {
|
items.add('renameDiscussions', {
|
||||||
|
icon: 'i-cursor',
|
||||||
label: 'Rename discussions',
|
label: 'Rename discussions',
|
||||||
permission: 'discussion.rename'
|
permission: 'discussion.rename'
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
|
items.add('hideDiscussions', {
|
||||||
|
icon: 'trash-o',
|
||||||
|
label: 'Delete discussions',
|
||||||
|
permission: 'discussion.hide'
|
||||||
|
}, 90);
|
||||||
|
|
||||||
items.add('deleteDiscussions', {
|
items.add('deleteDiscussions', {
|
||||||
label: 'Delete discussions',
|
icon: 'times',
|
||||||
|
label: 'Delete discussions forever',
|
||||||
permission: 'discussion.delete'
|
permission: 'discussion.delete'
|
||||||
});
|
}, 80);
|
||||||
|
|
||||||
|
items.add('editPosts', {
|
||||||
|
icon: 'pencil',
|
||||||
|
label: 'Edit and delete posts',
|
||||||
|
permission: 'discussion.editPosts'
|
||||||
|
}, 70);
|
||||||
|
|
||||||
|
items.add('deletePosts', {
|
||||||
|
icon: 'times',
|
||||||
|
label: 'Delete posts forever',
|
||||||
|
permission: 'discussion.deletePosts'
|
||||||
|
}, 60);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -196,12 +213,15 @@ export default class PermissionGrid extends Component {
|
||||||
if (item.setting) {
|
if (item.setting) {
|
||||||
return item.setting();
|
return item.setting();
|
||||||
} else if (item.permission) {
|
} else if (item.permission) {
|
||||||
return PermissionDropdown.component(Object.assign({}, item));
|
return PermissionDropdown.component({
|
||||||
|
permission: item.permission,
|
||||||
|
allowGuest: item.allowGuest
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,18 +59,26 @@
|
||||||
tbody {
|
tbody {
|
||||||
th {
|
th {
|
||||||
padding-right: 50px;
|
padding-right: 50px;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-right: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tr:last-child {
|
tr:last-child {
|
||||||
td, th {
|
td, th {
|
||||||
padding-bottom: 15px !important;
|
padding-bottom: 15px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
select {
|
.Dropdown {
|
||||||
background: transparent;
|
display: block;
|
||||||
padding: 0 30px 0 0;
|
|
||||||
height: auto;
|
.Dropdown-toggle {
|
||||||
border: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
text-align: left;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.Button {
|
.Button {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -93,9 +101,14 @@
|
||||||
margin: -1px 0;
|
margin: -1px 0;
|
||||||
}
|
}
|
||||||
.PermissionDropdown {
|
.PermissionDropdown {
|
||||||
|
.Dropdown-toggle {
|
||||||
|
padding: 5px 0;
|
||||||
|
margin: -5px 0;
|
||||||
|
}
|
||||||
.Badge {
|
.Badge {
|
||||||
margin: -3px 3px -3px 0;
|
margin: -3px 3px -3px 0;
|
||||||
vertical-align: 1px;
|
vertical-align: 1px;
|
||||||
|
.box-shadow(none);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.PermissionGrid-section {
|
.PermissionGrid-section {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user