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: [
|
||||
{ route: 'group.manage.profile', title: 'groups.manage.profile.title' },
|
||||
{ route: 'group.manage.members', title: 'groups.manage.members.title' },
|
||||
{ route: 'group.manage.logs', title: 'groups.manage.logs.title' },
|
||||
],
|
||||
@computed("model.automatic")
|
||||
tabs(automatic) {
|
||||
const defaultTabs = [
|
||||
{ route: 'group.manage.profile', title: 'groups.manage.profile.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,57 +1,5 @@
|
|||
<form class="groups-new-form form-horizontal">
|
||||
{{#if this.currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="name">{{i18n 'groups.name'}}</label>
|
||||
|
||||
{{text-field name="name"
|
||||
class="input-xxlarge group-form-name"
|
||||
value=model.name
|
||||
placeholderKey="groups.name_placeholder"}}
|
||||
|
||||
{{input-tip validation=nameValidation}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<label for='full_name'>{{i18n 'groups.manage.full_name'}}</label>
|
||||
|
||||
{{text-field name='full_name'
|
||||
class="input-xxlarge group-form-full-name"
|
||||
value=model.full_name}}
|
||||
</div>
|
||||
|
||||
{{#if this.currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="title">
|
||||
{{i18n 'admin.groups.default_title'}}
|
||||
</label>
|
||||
|
||||
{{input value=model.title name="title" class="input-xxlarge"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<label for="bio">{{i18n 'groups.bio'}}</label>
|
||||
{{d-editor value=model.bio_raw class="group-form-bio"}}
|
||||
</div>
|
||||
|
||||
{{#if manageMembership}}
|
||||
<div class="control-group">
|
||||
<label for="owner-selector">{{i18n 'admin.groups.add_owners'}}</label>
|
||||
|
||||
{{user-selector usernames=model.ownerUsernames
|
||||
placeholderKey="groups.selector_placeholder"
|
||||
id="owner-selector"}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="member-selector">{{i18n 'groups.members.title'}}</label>
|
||||
|
||||
{{user-selector usernames=model.usernames
|
||||
placeholderKey="groups.selector_placeholder"
|
||||
id="member-selector"}}
|
||||
</div>
|
||||
|
||||
{{#if model.automatic}}
|
||||
<div class="control-group">
|
||||
<label for="visiblity">{{i18n 'groups.visibility_levels.title'}}</label>
|
||||
|
||||
|
@ -61,56 +9,7 @@
|
|||
content=visibilityLevelOptions
|
||||
castInteger=true}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{#if currentUser.admin}}
|
||||
<label>
|
||||
{{input type="checkbox" checked=model.primary_group}}
|
||||
{{i18n 'admin.groups.primary_group'}}
|
||||
</label>
|
||||
{{/if}}
|
||||
|
||||
<label>
|
||||
{{input type="checkbox"
|
||||
class="group-form-public-admission"
|
||||
checked=model.public_admission
|
||||
disabled=disablePublicSetting}}
|
||||
|
||||
{{i18n 'groups.public_admission'}}
|
||||
</label>
|
||||
|
||||
<label>
|
||||
{{input type='checkbox'
|
||||
class='group-form-public-exit'
|
||||
checked=model.public_exit}}
|
||||
|
||||
{{i18n 'groups.public_exit'}}
|
||||
</label>
|
||||
|
||||
<label>
|
||||
{{input type="checkbox"
|
||||
class="group-form-allow-membership-requests"
|
||||
checked=model.allow_membership_requests
|
||||
disabled=disableMembershipRequestSetting}}
|
||||
|
||||
{{i18n 'groups.allow_membership_requests'}}
|
||||
</label>
|
||||
|
||||
{{#if model.allow_membership_requests}}
|
||||
<div>
|
||||
<label for="membership-request-template">
|
||||
{{i18n 'groups.membership_request_template'}}
|
||||
</label>
|
||||
|
||||
{{expanding-text-area name="membership-request-template"
|
||||
class='group-form-membership-request-template'
|
||||
value=model.membership_request_template}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{#if currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="alias">{{i18n 'groups.alias_levels.mentionable'}}</label>
|
||||
|
||||
|
@ -135,55 +34,193 @@
|
|||
{{notifications-button i18nPrefix='groups.notifications'
|
||||
value=model.default_notification_level}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="automatic_membership">
|
||||
{{i18n 'admin.groups.automatic_membership_email_domains'}}
|
||||
</label>
|
||||
|
||||
{{list-setting name="automatic_membership" settingValue=model.emailDomains}}
|
||||
|
||||
<label>
|
||||
{{input type="checkbox" checked=model.automatic_membership_retroactive}}
|
||||
{{i18n 'admin.groups.automatic_membership_retroactive'}}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="grant_trust_level">{{i18n 'groups.trust_levels.title'}}</label>
|
||||
|
||||
{{combo-box name="grant_trust_level"
|
||||
valueAttribute="value"
|
||||
value=model.grant_trust_level
|
||||
content=trustLevelOptions}}
|
||||
</div>
|
||||
|
||||
{{#if siteSettings.email_in}}
|
||||
{{else}}
|
||||
{{#if this.currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="incoming_email">{{i18n 'admin.groups.incoming_email'}}</label>
|
||||
<label for="name">{{i18n 'groups.name'}}</label>
|
||||
|
||||
{{text-field name="incoming_email"
|
||||
class="input-xxlarge"
|
||||
value=model.incoming_email
|
||||
placeholderKey="admin.groups.incoming_email_placeholder"}}
|
||||
{{text-field name="name"
|
||||
class="input-xxlarge group-form-name"
|
||||
value=model.name
|
||||
placeholderKey="groups.name_placeholder"}}
|
||||
|
||||
{{plugin-outlet name="group-email-in" args=(hash model=model)}}
|
||||
{{input-tip validation=nameValidation}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<label for='full_name'>{{i18n 'groups.manage.full_name'}}</label>
|
||||
|
||||
{{text-field name='full_name'
|
||||
class="input-xxlarge group-form-full-name"
|
||||
value=model.full_name}}
|
||||
</div>
|
||||
|
||||
{{#if this.currentUser.admin}}
|
||||
<div class="control-group">
|
||||
<label for="title">
|
||||
{{i18n 'admin.groups.default_title'}}
|
||||
</label>
|
||||
|
||||
{{input value=model.title name="title" class="input-xxlarge"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<label for="bio">{{i18n 'groups.bio'}}</label>
|
||||
{{d-editor value=model.bio_raw class="group-form-bio"}}
|
||||
</div>
|
||||
|
||||
{{#if manageMembership}}
|
||||
<div class="control-group">
|
||||
<label for="owner-selector">{{i18n 'admin.groups.add_owners'}}</label>
|
||||
|
||||
{{user-selector usernames=model.ownerUsernames
|
||||
placeholderKey="groups.selector_placeholder"
|
||||
id="owner-selector"}}
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="member-selector">{{i18n 'groups.members.title'}}</label>
|
||||
|
||||
{{user-selector usernames=model.usernames
|
||||
placeholderKey="groups.selector_placeholder"
|
||||
id="member-selector"}}
|
||||
</div>
|
||||
|
||||
<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>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{#if currentUser.admin}}
|
||||
<label>
|
||||
{{input type="checkbox" checked=model.primary_group}}
|
||||
{{i18n 'admin.groups.primary_group'}}
|
||||
</label>
|
||||
{{/if}}
|
||||
|
||||
<label>
|
||||
{{input type="checkbox"
|
||||
class="group-form-public-admission"
|
||||
checked=model.public_admission
|
||||
disabled=disablePublicSetting}}
|
||||
|
||||
{{i18n 'groups.public_admission'}}
|
||||
</label>
|
||||
|
||||
<label>
|
||||
{{input type='checkbox'
|
||||
class='group-form-public-exit'
|
||||
checked=model.public_exit}}
|
||||
|
||||
{{i18n 'groups.public_exit'}}
|
||||
</label>
|
||||
|
||||
<label>
|
||||
{{input type="checkbox"
|
||||
class="group-form-allow-membership-requests"
|
||||
checked=model.allow_membership_requests
|
||||
disabled=disableMembershipRequestSetting}}
|
||||
|
||||
{{i18n 'groups.allow_membership_requests'}}
|
||||
</label>
|
||||
|
||||
{{#if model.allow_membership_requests}}
|
||||
<div>
|
||||
<label for="membership-request-template">
|
||||
{{i18n 'groups.membership_request_template'}}
|
||||
</label>
|
||||
|
||||
{{expanding-text-area name="membership-request-template"
|
||||
class='group-form-membership-request-template'
|
||||
value=model.membership_request_template}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{#if currentUser.admin}}
|
||||
<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>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="automatic_membership">
|
||||
{{i18n 'admin.groups.automatic_membership_email_domains'}}
|
||||
</label>
|
||||
|
||||
{{list-setting name="automatic_membership" settingValue=model.emailDomains}}
|
||||
|
||||
<label>
|
||||
{{input type="checkbox" checked=model.automatic_membership_retroactive}}
|
||||
{{i18n 'admin.groups.automatic_membership_retroactive'}}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="grant_trust_level">{{i18n 'groups.trust_levels.title'}}</label>
|
||||
|
||||
{{combo-box name="grant_trust_level"
|
||||
valueAttribute="value"
|
||||
value=model.grant_trust_level
|
||||
content=trustLevelOptions}}
|
||||
</div>
|
||||
|
||||
{{#if siteSettings.email_in}}
|
||||
<div class="control-group">
|
||||
<label for="incoming_email">{{i18n 'admin.groups.incoming_email'}}</label>
|
||||
|
||||
{{text-field name="incoming_email"
|
||||
class="input-xxlarge"
|
||||
value=model.incoming_email
|
||||
placeholderKey="admin.groups.incoming_email_placeholder"}}
|
||||
|
||||
{{plugin-outlet name="group-email-in" args=(hash model=model)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{group-flair-inputs model=model}}
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="group-edit" args=(hash group=model)}}
|
||||
|
||||
<div class='control-group buttons'>
|
||||
{{d-button action="save"
|
||||
disabled=disableSave
|
||||
class='btn btn-primary group-form-save'
|
||||
label=saveLabel}}
|
||||
|
||||
{{yield}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{group-flair-inputs model=model}}
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="group-edit" args=(hash group=model)}}
|
||||
|
||||
<div class='control-group buttons'>
|
||||
{{d-button action="save"
|
||||
disabled=disableSave
|
||||
class='btn btn-primary group-form-save'
|
||||
label=saveLabel}}
|
||||
|
||||
{{yield}}
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue