UX: Allow admins to manage automatic groups on group page.
This commit is contained in:
parent
4f7f733ab0
commit
e6d07fa6d8
|
@ -1,9 +1,24 @@
|
|||
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
application: Ember.inject.controller(),
|
||||
|
||||
tabs: [
|
||||
@computed("model.automatic")
|
||||
tabs(automatic) {
|
||||
const defaultTabs = [
|
||||
{ route: 'group.manage.profile', title: 'groups.manage.profile.title' },
|
||||
{ route: 'group.manage.members', title: 'groups.manage.members.title' },
|
||||
];
|
||||
|
||||
if (!automatic) {
|
||||
defaultTabs.push(
|
||||
{ route: 'group.manage.members', title: 'groups.manage.members.title' }
|
||||
);
|
||||
|
||||
defaultTabs.push(
|
||||
{ route: 'group.manage.logs', title: 'groups.manage.logs.title' },
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return defaultTabs;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -14,8 +14,8 @@ export default Ember.Controller.extend({
|
|||
counts: null,
|
||||
showing: 'members',
|
||||
|
||||
@computed('showMessages', 'model.user_count')
|
||||
tabs(showMessages, userCount) {
|
||||
@computed('showMessages', 'model.user_count', 'canManageGroup')
|
||||
tabs(showMessages, userCount, canManageGroup) {
|
||||
const membersTab = Tab.create({
|
||||
name: 'members',
|
||||
route: 'group.index',
|
||||
|
@ -36,7 +36,7 @@ export default Ember.Controller.extend({
|
|||
}));
|
||||
}
|
||||
|
||||
if (this.currentUser && this.currentUser.canManageGroup(this.model)) {
|
||||
if (canManageGroup) {
|
||||
defaultTabs.push(
|
||||
Tab.create({
|
||||
name: 'manage', i18nKey: 'manage.title', icon: 'wrench'
|
||||
|
@ -81,9 +81,12 @@ export default Ember.Controller.extend({
|
|||
return this.currentUser && messageable;
|
||||
},
|
||||
|
||||
@computed('model')
|
||||
canManageGroup(model) {
|
||||
return this.currentUser && this.currentUser.canManageGroup(model);
|
||||
@computed('model', 'model.automatic')
|
||||
canManageGroup(model, automatic) {
|
||||
return this.currentUser && (
|
||||
this.currentUser.canManageGroup(model) ||
|
||||
(this.currentUser.admin && automatic)
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -8,7 +8,10 @@ export default Discourse.Route.extend({
|
|||
},
|
||||
|
||||
afterModel(group) {
|
||||
if (!this.currentUser || !this.currentUser.canManageGroup(group)) {
|
||||
if (!this.currentUser ||
|
||||
!(this.currentUser.admin && group.get('automatic')) &&
|
||||
!this.currentUser.canManageGroup(group)) {
|
||||
|
||||
this.transitionTo("group.members", group);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,4 +1,40 @@
|
|||
<form class="groups-new-form form-horizontal">
|
||||
{{#if model.automatic}}
|
||||
<div class="control-group">
|
||||
<label for="visiblity">{{i18n 'groups.visibility_levels.title'}}</label>
|
||||
|
||||
{{combo-box name="alias"
|
||||
valueAttribute="value"
|
||||
value=model.visibility_level
|
||||
content=visibilityLevelOptions
|
||||
castInteger=true}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="alias">{{i18n 'groups.alias_levels.mentionable'}}</label>
|
||||
|
||||
{{combo-box name="alias"
|
||||
valueAttribute="value"
|
||||
value=model.mentionable_level
|
||||
content=aliasLevelOptions}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="alias">{{i18n 'groups.alias_levels.messageable'}}</label>
|
||||
|
||||
{{combo-box name="alias"
|
||||
valueAttribute="value"
|
||||
value=model.messageable_level
|
||||
content=aliasLevelOptions}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label>{{i18n 'groups.notification_level'}}</label>
|
||||
|
||||
{{notifications-button i18nPrefix='groups.notifications'
|
||||
value=model.default_notification_level}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{#if this.currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="name">{{i18n 'groups.name'}}</label>
|
||||
|
@ -186,4 +222,5 @@
|
|||
|
||||
{{yield}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue