mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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({
|
export default Ember.Controller.extend({
|
||||||
application: Ember.inject.controller(),
|
application: Ember.inject.controller(),
|
||||||
|
|
||||||
tabs: [
|
@computed("model.automatic")
|
||||||
|
tabs(automatic) {
|
||||||
|
const defaultTabs = [
|
||||||
{ route: 'group.manage.profile', title: 'groups.manage.profile.title' },
|
{ 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' },
|
{ route: 'group.manage.logs', title: 'groups.manage.logs.title' },
|
||||||
],
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultTabs;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -14,8 +14,8 @@ export default Ember.Controller.extend({
|
|||||||
counts: null,
|
counts: null,
|
||||||
showing: 'members',
|
showing: 'members',
|
||||||
|
|
||||||
@computed('showMessages', 'model.user_count')
|
@computed('showMessages', 'model.user_count', 'canManageGroup')
|
||||||
tabs(showMessages, userCount) {
|
tabs(showMessages, userCount, canManageGroup) {
|
||||||
const membersTab = Tab.create({
|
const membersTab = Tab.create({
|
||||||
name: 'members',
|
name: 'members',
|
||||||
route: 'group.index',
|
route: 'group.index',
|
||||||
@ -36,7 +36,7 @@ export default Ember.Controller.extend({
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentUser && this.currentUser.canManageGroup(this.model)) {
|
if (canManageGroup) {
|
||||||
defaultTabs.push(
|
defaultTabs.push(
|
||||||
Tab.create({
|
Tab.create({
|
||||||
name: 'manage', i18nKey: 'manage.title', icon: 'wrench'
|
name: 'manage', i18nKey: 'manage.title', icon: 'wrench'
|
||||||
@ -81,9 +81,12 @@ export default Ember.Controller.extend({
|
|||||||
return this.currentUser && messageable;
|
return this.currentUser && messageable;
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed('model')
|
@computed('model', 'model.automatic')
|
||||||
canManageGroup(model) {
|
canManageGroup(model, automatic) {
|
||||||
return this.currentUser && this.currentUser.canManageGroup(model);
|
return this.currentUser && (
|
||||||
|
this.currentUser.canManageGroup(model) ||
|
||||||
|
(this.currentUser.admin && automatic)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -8,7 +8,10 @@ export default Discourse.Route.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
afterModel(group) {
|
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);
|
this.transitionTo("group.members", group);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,40 @@
|
|||||||
<form class="groups-new-form form-horizontal">
|
<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}}
|
{{#if this.currentUser.admin}}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="name">{{i18n 'groups.name'}}</label>
|
<label for="name">{{i18n 'groups.name'}}</label>
|
||||||
@ -186,4 +222,5 @@
|
|||||||
|
|
||||||
{{yield}}
|
{{yield}}
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user