diff --git a/app/assets/javascripts/admin/templates/group.hbs b/app/assets/javascripts/admin/templates/group.hbs index c10ca20bb34..53ae2b748eb 100644 --- a/app/assets/javascripts/admin/templates/group.hbs +++ b/app/assets/javascripts/admin/templates/group.hbs @@ -11,8 +11,8 @@ {{#unless model.automatic}}
- - {{input type='text' name='full_name' value=model.full_name class='group-edit-full-name'}} + + {{input type='text' name='full_name' value=model.full_name class='group-manage-full-name'}}
diff --git a/app/assets/javascripts/discourse/components/group-logs-filter.js.es6 b/app/assets/javascripts/discourse/components/group-manage-logs-filter.js.es6 similarity index 89% rename from app/assets/javascripts/discourse/components/group-logs-filter.js.es6 rename to app/assets/javascripts/discourse/components/group-manage-logs-filter.js.es6 index ba4ccc3f742..d598bc568fe 100644 --- a/app/assets/javascripts/discourse/components/group-logs-filter.js.es6 +++ b/app/assets/javascripts/discourse/components/group-manage-logs-filter.js.es6 @@ -5,7 +5,7 @@ export default Ember.Component.extend({ @computed('type') label(type) { - return I18n.t(`groups.logs.${type}`); + return I18n.t(`groups.manage.logs.${type}`); }, @computed('value', 'type') diff --git a/app/assets/javascripts/discourse/components/group-logs-row.js.es6 b/app/assets/javascripts/discourse/components/group-manage-logs-row.js.es6 similarity index 100% rename from app/assets/javascripts/discourse/components/group-logs-row.js.es6 rename to app/assets/javascripts/discourse/components/group-manage-logs-row.js.es6 diff --git a/app/assets/javascripts/discourse/components/group-members-input.js.es6 b/app/assets/javascripts/discourse/components/group-members-input.js.es6 index 691eb051bbc..1bb3ca048d7 100644 --- a/app/assets/javascripts/discourse/components/group-members-input.js.es6 +++ b/app/assets/javascripts/discourse/components/group-members-input.js.es6 @@ -55,7 +55,7 @@ export default Ember.Component.extend({ }, removeMember(member) { - const message = I18n.t("groups.edit.delete_member_confirm",{ + const message = I18n.t("groups.manage.delete_member_confirm",{ username: member.get("username"), group: this.get("model.name") }); diff --git a/app/assets/javascripts/discourse/components/group-navigation-dropdown.js.es6 b/app/assets/javascripts/discourse/components/group-navigation-dropdown.js.es6 deleted file mode 100644 index 263fc426e42..00000000000 --- a/app/assets/javascripts/discourse/components/group-navigation-dropdown.js.es6 +++ /dev/null @@ -1,25 +0,0 @@ -import DropdownSelectBox from "select-kit/components/dropdown-select-box"; - -export default DropdownSelectBox.extend({ - classNames: ["group-navigation-dropdown", "pull-right"], - nameProperty: "label", - headerIcon: ["bars"], - showFullTitle: false, - - computeContent() { - const content = []; - - content.push({ - id: "manageMembership", - icon: "user-plus", - label: I18n.t("groups.add_members.title"), - description: I18n.t("groups.add_members.description"), - }); - - return content; - }, - - mutateValue(value) { - this.get(value)(this.get('model')); - } -}); diff --git a/app/assets/javascripts/discourse/controllers/group-logs.js.es6 b/app/assets/javascripts/discourse/controllers/group-manage-logs.js.es6 similarity index 100% rename from app/assets/javascripts/discourse/controllers/group-logs.js.es6 rename to app/assets/javascripts/discourse/controllers/group-manage-logs.js.es6 diff --git a/app/assets/javascripts/discourse/controllers/group-membership.js.es6 b/app/assets/javascripts/discourse/controllers/group-manage-members.js.es6 similarity index 66% rename from app/assets/javascripts/discourse/controllers/group-membership.js.es6 rename to app/assets/javascripts/discourse/controllers/group-manage-members.js.es6 index 8c22d2765e2..71ee3f8a8f0 100644 --- a/app/assets/javascripts/discourse/controllers/group-membership.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group-manage-members.js.es6 @@ -1,18 +1,19 @@ -import ModalFunctionality from 'discourse/mixins/modal-functionality'; import computed from 'ember-addons/ember-computed-decorators'; -import { extractError } from 'discourse/lib/ajax-error'; +import { popupAjaxError } from 'discourse/lib/ajax-error'; -export default Ember.Controller.extend(ModalFunctionality, { +export default Ember.Controller.extend({ loading: false, setAsOwner: false, - @computed('model.usernames') - disableAddButton(usernames) { - return !usernames || !(usernames.length > 0); + @computed('model.usernames', 'loading') + disableAddButton(usernames, loading) { + return loading || !usernames || !(usernames.length > 0); }, actions: { addMembers() { + this.set('loading', true); + const model = this.get('model'); const usernames = model.get('usernames'); if (Em.isEmpty(usernames)) { return; } @@ -33,7 +34,8 @@ export default Ember.Controller.extend(ModalFunctionality, { model.set("usernames", null); this.send('closeModal'); }) - .catch(error => this.flash(extractError(error), 'error')); + .catch(popupAjaxError) + .finally(() => this.set('loading', false)); }, }, }); diff --git a/app/assets/javascripts/discourse/controllers/group-edit.js.es6 b/app/assets/javascripts/discourse/controllers/group-manage-profile.js.es6 similarity index 72% rename from app/assets/javascripts/discourse/controllers/group-edit.js.es6 rename to app/assets/javascripts/discourse/controllers/group-manage-profile.js.es6 index 32277430af5..0c8bec50be7 100644 --- a/app/assets/javascripts/discourse/controllers/group-edit.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group-manage-profile.js.es6 @@ -13,11 +13,11 @@ export default Ember.Controller.extend({ save() { this.set('saving', true); - this.get('model').save().catch(error => { - popupAjaxError(error); - }).finally(() => { - this.set('saving', false); - }); + this.get('model').save() + .catch(popupAjaxError) + .finally(() => { + this.set('saving', false); + }); } } }); diff --git a/app/assets/javascripts/discourse/controllers/group-manage.js.es6 b/app/assets/javascripts/discourse/controllers/group-manage.js.es6 new file mode 100644 index 00000000000..3b94a86d024 --- /dev/null +++ b/app/assets/javascripts/discourse/controllers/group-manage.js.es6 @@ -0,0 +1,9 @@ +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' }, + ], +}); diff --git a/app/assets/javascripts/discourse/controllers/group.js.es6 b/app/assets/javascripts/discourse/controllers/group.js.es6 index 46faf5ae8b5..d17de48bec4 100644 --- a/app/assets/javascripts/discourse/controllers/group.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group.js.es6 @@ -37,14 +37,11 @@ export default Ember.Controller.extend({ } if (this.currentUser && this.currentUser.canManageGroup(this.model)) { - defaultTabs.push(...[ + defaultTabs.push( Tab.create({ - name: 'edit', i18nKey: 'edit.title', icon: 'pencil' - }), - Tab.create({ - name: 'logs', i18nKey: 'logs.title', icon: 'list-alt' + name: 'manage', i18nKey: 'manage.title', icon: 'wrench' }) - ]); + ); } return defaultTabs; diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 index 4ed43977d72..524e8510017 100644 --- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 +++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 @@ -60,8 +60,11 @@ export default function() { this.route('mentions'); }); - this.route('logs'); - this.route('edit'); + this.route('manage', function() { + this.route('profile'); + this.route('members'); + this.route('logs'); + }); this.route('messages', function() { this.route('inbox'); diff --git a/app/assets/javascripts/discourse/routes/group-manage-index.js.es6 b/app/assets/javascripts/discourse/routes/group-manage-index.js.es6 new file mode 100644 index 00000000000..f5b26ccd0c5 --- /dev/null +++ b/app/assets/javascripts/discourse/routes/group-manage-index.js.es6 @@ -0,0 +1,5 @@ +export default Discourse.Route.extend({ + beforeModel() { + this.transitionTo("group.manage.profile"); + } +}); diff --git a/app/assets/javascripts/discourse/routes/group-logs.js.es6 b/app/assets/javascripts/discourse/routes/group-manage-logs.js.es6 similarity index 51% rename from app/assets/javascripts/discourse/routes/group-logs.js.es6 rename to app/assets/javascripts/discourse/routes/group-manage-logs.js.es6 index 9658160fee3..85ee4dfae98 100644 --- a/app/assets/javascripts/discourse/routes/group-logs.js.es6 +++ b/app/assets/javascripts/discourse/routes/group-manage-logs.js.es6 @@ -1,6 +1,6 @@ export default Discourse.Route.extend({ titleToken() { - return I18n.t('groups.logs.title'); + return I18n.t('groups.manage.logs.title'); }, model() { @@ -8,13 +8,12 @@ export default Discourse.Route.extend({ }, setupController(controller, model) { - this.controllerFor('group-logs').setProperties({ model }); - this.controllerFor("group").set("showing", 'logs'); + this.controllerFor('group-manage-logs').setProperties({ model }); }, actions: { willTransition() { - this.controllerFor('group-logs').reset(); + this.controllerFor('group-manage-logs').reset(); } } }); diff --git a/app/assets/javascripts/discourse/routes/group-manage-members.js.es6 b/app/assets/javascripts/discourse/routes/group-manage-members.js.es6 new file mode 100644 index 00000000000..16bec11a463 --- /dev/null +++ b/app/assets/javascripts/discourse/routes/group-manage-members.js.es6 @@ -0,0 +1,9 @@ +export default Discourse.Route.extend({ + titleToken() { + return I18n.t('groups.manage.members.title'); + }, + + model() { + return this.modelFor('group'); + }, +}); diff --git a/app/assets/javascripts/discourse/routes/group-manage-profile.js.es6 b/app/assets/javascripts/discourse/routes/group-manage-profile.js.es6 new file mode 100644 index 00000000000..8c25f3b54b9 --- /dev/null +++ b/app/assets/javascripts/discourse/routes/group-manage-profile.js.es6 @@ -0,0 +1,9 @@ +export default Discourse.Route.extend({ + titleToken() { + return I18n.t('groups.manage.profile.title'); + }, + + model() { + return this.modelFor('group'); + }, +}); diff --git a/app/assets/javascripts/discourse/routes/group-edit.js.es6 b/app/assets/javascripts/discourse/routes/group-manage.js.es6 similarity index 63% rename from app/assets/javascripts/discourse/routes/group-edit.js.es6 rename to app/assets/javascripts/discourse/routes/group-manage.js.es6 index 7f3dc02cec5..aca7a4bc6ed 100644 --- a/app/assets/javascripts/discourse/routes/group-edit.js.es6 +++ b/app/assets/javascripts/discourse/routes/group-manage.js.es6 @@ -1,6 +1,6 @@ export default Discourse.Route.extend({ titleToken() { - return I18n.t('groups.edit.title'); + return I18n.t('groups.manage.title'); }, model() { @@ -14,8 +14,7 @@ export default Discourse.Route.extend({ }, setupController(controller, model) { - this.controllerFor('group-edit').setProperties({ model }); - this.controllerFor("group").set("showing", 'edit'); - model.findMembers(); + this.controllerFor('group-manage').setProperties({ model }); + this.controllerFor("group").set("showing", 'manage'); } }); diff --git a/app/assets/javascripts/discourse/routes/group.js.es6 b/app/assets/javascripts/discourse/routes/group.js.es6 index 6bb9610aede..3df20f794bf 100644 --- a/app/assets/javascripts/discourse/routes/group.js.es6 +++ b/app/assets/javascripts/discourse/routes/group.js.es6 @@ -1,5 +1,4 @@ import Group from 'discourse/models/group'; -import showModal from 'discourse/lib/show-modal'; export default Discourse.Route.extend({ @@ -17,12 +16,5 @@ export default Discourse.Route.extend({ setupController(controller, model) { controller.setProperties({ model, counts: this.get('counts') }); - }, - - actions: { - showGroupMembershipModal(model) { - showModal('group-membership', { model }); - this.controllerFor('modal').set('modalClass', 'group-membership-modal'); - }, } }); diff --git a/app/assets/javascripts/discourse/templates/components/group-logs-filter.hbs b/app/assets/javascripts/discourse/templates/components/group-manage-logs-filter.hbs similarity index 53% rename from app/assets/javascripts/discourse/templates/components/group-logs-filter.hbs rename to app/assets/javascripts/discourse/templates/components/group-manage-logs-filter.hbs index f9f13474c7f..1625fa5fc92 100644 --- a/app/assets/javascripts/discourse/templates/components/group-logs-filter.hbs +++ b/app/assets/javascripts/discourse/templates/components/group-manage-logs-filter.hbs @@ -1,5 +1,5 @@ {{#if value}} - {{#d-button class="btn-small group-logs-filter" action="clearFilter" actionParam=type}} + {{#d-button class="btn-small group-manage-logs-filter" action="clearFilter" actionParam=type}} {{label}}: {{filterText}} {{d-icon "times-circle"}} {{/d-button}} diff --git a/app/assets/javascripts/discourse/templates/components/group-logs-row.hbs b/app/assets/javascripts/discourse/templates/components/group-manage-logs-row.hbs similarity index 80% rename from app/assets/javascripts/discourse/templates/components/group-logs-row.hbs rename to app/assets/javascripts/discourse/templates/components/group-manage-logs-row.hbs index 6fe9bfd858a..da955686e19 100644 --- a/app/assets/javascripts/discourse/templates/components/group-logs-row.hbs +++ b/app/assets/javascripts/discourse/templates/components/group-manage-logs-row.hbs @@ -1,4 +1,4 @@ - + {{#d-button class="btn-small" action="filter" actionParam=(hash value=log.action key="action")}} {{log.actionTitle}} @@ -33,7 +33,7 @@ {{bound-date log.created_at}} - + {{#if log.prev_value}} {{#if expandDetails}} {{d-icon 'ellipsis-v'}} @@ -48,11 +48,11 @@

- {{i18n 'groups.logs.from'}}: {{log.prev_value}} + {{i18n 'groups.manage.logs.from'}}: {{log.prev_value}}

- {{i18n 'groups.logs.to'}}: {{log.new_value}} + {{i18n 'groups.manage.logs.to'}}: {{log.new_value}}

diff --git a/app/assets/javascripts/discourse/templates/components/group-members-input.hbs b/app/assets/javascripts/discourse/templates/components/group-members-input.hbs index fc0e9667b85..036bf9b1ca9 100644 --- a/app/assets/javascripts/discourse/templates/components/group-members-input.hbs +++ b/app/assets/javascripts/discourse/templates/components/group-members-input.hbs @@ -24,7 +24,7 @@ class="add" icon="plus" disabled=disableAddButton - label="groups.edit.add_members"}} + label="groups.manage.add_members"}} {{/if}}
{{/unless}} diff --git a/app/assets/javascripts/discourse/templates/group-edit.hbs b/app/assets/javascripts/discourse/templates/group-edit.hbs deleted file mode 100644 index 7e56a0ead21..00000000000 --- a/app/assets/javascripts/discourse/templates/group-edit.hbs +++ /dev/null @@ -1,66 +0,0 @@ -
-
-
- - {{input type='text' name='full_name' value=model.full_name class='group-edit-full-name'}} -
- -
- - {{d-editor value=model.bio_raw class="group-edit-bio"}} -
- -
- {{group-flair-inputs model=model}} -
- -
- -
- -
- -
- -
- -
- - {{#if model.allow_membership_requests}} -
- - - {{expanding-text-area name="membership-request-template" - value=model.membership_request_template - class="group-edit-membership-request-template"}} -
- {{/if}} - - {{plugin-outlet name="group-edit" args=(hash group=model)}} - - {{d-button action="save" class="btn-primary" disabled=saving label="save"}} - {{savingText}} -
-
diff --git a/app/assets/javascripts/discourse/templates/group-logs.hbs b/app/assets/javascripts/discourse/templates/group-logs.hbs deleted file mode 100644 index 154b78d678e..00000000000 --- a/app/assets/javascripts/discourse/templates/group-logs.hbs +++ /dev/null @@ -1,33 +0,0 @@ -{{#if model.logs}} -
- {{group-logs-filter clearFilter="clearFilter" value=filters.action type="action"}} - {{group-logs-filter clearFilter="clearFilter" value=filters.acting_user type="acting_user"}} - {{group-logs-filter clearFilter="clearFilter" value=filters.target_user type="target_user"}} - {{group-logs-filter clearFilter="clearFilter" value=filters.subject type="subject"}} -
- - {{#load-more selector=".group-logs .group-logs-row" action="loadMore"}} - - - - - - - - - - - - {{#each model.logs as |log|}} - {{group-logs-row - log=log - filters=filters}} - {{/each}} - -
{{i18n 'groups.logs.action'}}{{i18n 'groups.logs.acting_user'}}{{i18n 'groups.logs.target_user'}}{{i18n 'groups.logs.subject'}}{{i18n 'groups.logs.when'}}
- {{/load-more}} - - {{conditional-loading-spinner condition=loading}} -{{else}} -
{{i18n "groups.empty.logs"}}
-{{/if}} diff --git a/app/assets/javascripts/discourse/templates/group.hbs b/app/assets/javascripts/discourse/templates/group.hbs index 6fc009b8300..dfb900b91ed 100644 --- a/app/assets/javascripts/discourse/templates/group.hbs +++ b/app/assets/javascripts/discourse/templates/group.hbs @@ -42,12 +42,6 @@
{{group-navigation group=model currentPath=application.currentPath tabs=tabs}} - {{#if canManageGroup}} - {{group-navigation-dropdown - model=model - manageMembership=(route-action "showGroupMembershipModal")}} - {{/if}} - {{#if displayGroupMessageButton}} {{d-button action="messageGroup" diff --git a/app/assets/javascripts/discourse/templates/group/manage.hbs b/app/assets/javascripts/discourse/templates/group/manage.hbs new file mode 100644 index 00000000000..ed08fad7aa8 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/group/manage.hbs @@ -0,0 +1,15 @@ +
+ {{#mobile-nav class='group-manage-nav' desktopClass='pull-left nav nav-stacked' currentPath=application.currentPath}} + {{#each tabs as |tab|}} +
  • + {{#link-to tab.route model.name}} + {{i18n tab.title}} + {{/link-to}} +
  • + {{/each}} + {{/mobile-nav}} + +
    + {{outlet}} +
    +
    diff --git a/app/assets/javascripts/discourse/templates/group/manage/logs.hbs b/app/assets/javascripts/discourse/templates/group/manage/logs.hbs new file mode 100644 index 00000000000..d21a3a98ae7 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/group/manage/logs.hbs @@ -0,0 +1,33 @@ +{{#if model.logs}} +
    + {{group-manage-logs-filter clearFilter="clearFilter" value=filters.action type="action"}} + {{group-manage-logs-filter clearFilter="clearFilter" value=filters.acting_user type="acting_user"}} + {{group-manage-logs-filter clearFilter="clearFilter" value=filters.target_user type="target_user"}} + {{group-manage-logs-filter clearFilter="clearFilter" value=filters.subject type="subject"}} +
    + + {{#load-more selector=".group-manage-logs .group-manage-logs-row" action="loadMore"}} + + + + + + + + + + + + {{#each model.logs as |log|}} + {{group-manage-logs-row + log=log + filters=filters}} + {{/each}} + +
    {{i18n 'groups.manage.logs.action'}}{{i18n 'groups.manage.logs.acting_user'}}{{i18n 'groups.manage.logs.target_user'}}{{i18n 'groups.manage.logs.subject'}}{{i18n 'groups.manage.logs.when'}}
    + {{/load-more}} + + {{conditional-loading-spinner condition=loading}} +{{else}} +
    {{i18n "groups.empty.logs"}}
    +{{/if}} diff --git a/app/assets/javascripts/discourse/templates/group/manage/members.hbs b/app/assets/javascripts/discourse/templates/group/manage/members.hbs new file mode 100644 index 00000000000..3d1ea6cdd63 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/group/manage/members.hbs @@ -0,0 +1,25 @@ +
    +
    + + + {{user-selector + usernames=model.usernames + placeholderKey="groups.selector_placeholder" + id="group-manage-members-user-selector"}} +
    + + {{#if this.currentUser.admin}} +
    + +
    + {{/if}} + + {{d-button action="addMembers" + class="add btn-primary" + icon="plus" + disabled=disableAddButton + label="groups.add"}} +
    diff --git a/app/assets/javascripts/discourse/templates/group/manage/profile.hbs b/app/assets/javascripts/discourse/templates/group/manage/profile.hbs new file mode 100644 index 00000000000..d90ae631b64 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/group/manage/profile.hbs @@ -0,0 +1,71 @@ +
    + {{#if this.currentUser.admin}} +
    + + {{input type='text' name='name' value=model.name class='group-manage-name'}} +
    + {{/if}} + +
    + + {{input type='text' name='full_name' value=model.full_name class='group-manage-full-name'}} +
    + +
    + + {{d-editor value=model.bio_raw class="group-manage-bio"}} +
    + +
    + {{group-flair-inputs model=model}} +
    + +
    + +
    + +
    + +
    + +
    + +
    + + {{#if model.allow_membership_requests}} +
    + + + {{expanding-text-area name="membership-request-template" + value=model.membership_request_template + class="group-manage-membership-request-template"}} +
    + {{/if}} + + {{plugin-outlet name="group-manage" args=(hash group=model)}} + + {{d-button action="save" class="btn-primary" disabled=saving label="save"}} + {{savingText}} +
    diff --git a/app/assets/javascripts/discourse/templates/modal/group-membership.hbs b/app/assets/javascripts/discourse/templates/modal/group-membership.hbs deleted file mode 100644 index 92c35ab9f0a..00000000000 --- a/app/assets/javascripts/discourse/templates/modal/group-membership.hbs +++ /dev/null @@ -1,25 +0,0 @@ -{{#d-modal-body class='group-membership' title="groups.add_members.title"}} -
    - - - {{user-selector - usernames=model.usernames - placeholderKey="groups.selector_placeholder" - id="group-membership-user-selector"}} -
    - - {{#if this.currentUser.admin}} -
    - - {{input type="checkbox" class="inline" checked=setAsOwner}} -
    - {{/if}} -{{/d-modal-body}} - - diff --git a/app/assets/stylesheets/common/base/group.scss b/app/assets/stylesheets/common/base/group.scss index 082adb401e3..fbcfd1d4893 100644 --- a/app/assets/stylesheets/common/base/group.scss +++ b/app/assets/stylesheets/common/base/group.scss @@ -78,7 +78,7 @@ } } -.group-logs-filter { +.group-manage-logs-filter { margin-right: 10px; &:hover { @@ -86,7 +86,7 @@ } } -table.group-logs { +table.group-manage-logs { width: 100%; th, tr { @@ -102,7 +102,7 @@ table.group-logs { padding: 10px 0; } - .group-logs-expand-details { + .group-manage-logs-expand-details { cursor: pointer; i { @@ -201,7 +201,7 @@ table.group-members { } } -.group-edit { +.group-manage { .form-horizontal { label { font-weight: bold; @@ -209,16 +209,8 @@ table.group-members { } } -.group-membership { - .ac-wrap { - width: 100% !important; - } - - label { - font-weight: bold; - } - - .group-membership-make-owner { +.group-manage-members { + .group-manage-members-make-owner { label { display: inline; vertical-align: middle; diff --git a/app/assets/stylesheets/common/base/request-group-membership-form.scss b/app/assets/stylesheets/common/base/request-group-membership-form.scss index 63dfd0aec7b..19b2213c822 100644 --- a/app/assets/stylesheets/common/base/request-group-membership-form.scss +++ b/app/assets/stylesheets/common/base/request-group-membership-form.scss @@ -4,6 +4,6 @@ } } -.group-edit-membership-request-template { +.group-manage-membership-request-template { width: 98%; } diff --git a/app/assets/stylesheets/desktop/group.scss b/app/assets/stylesheets/desktop/group.scss index e279256e5c3..d34fb0b0a53 100644 --- a/app/assets/stylesheets/desktop/group.scss +++ b/app/assets/stylesheets/desktop/group.scss @@ -20,7 +20,10 @@ margin-bottom: 20px; } -.group-activity-nav, .group-messages-nav { +.group-activity-nav, +.group-messages-nav, +.group-manage-nav +{ width: 15%; background-color: transparent; @@ -43,14 +46,14 @@ } } -.group-activity-outlet, .group-messages-outlet { +.group-activity-outlet, +.group-messages-outlet, +.group-manage-outlet +{ width: 85%; } -.group-edit { - border: 1px solid $primary-low; - padding: 10px; - +.group-manage { .form-horizontal { button { float: none; diff --git a/app/assets/stylesheets/mobile/group.scss b/app/assets/stylesheets/mobile/group.scss index 0ab1c39142d..226f58d339d 100644 --- a/app/assets/stylesheets/mobile/group.scss +++ b/app/assets/stylesheets/mobile/group.scss @@ -23,11 +23,14 @@ float: left; } -.group-activity { +.group-activity, .group-manage { position: relative; } -.group-activity-nav, .group-messages-nav { +.group-activity-nav, +.group-messages-nav, +.group-manage-nav +{ &.mobile-nav { position: absolute; right: 0; @@ -51,7 +54,7 @@ } } -table.group-logs { +table.group-manage-logs { width: 130%; } diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index b41f170edfd..a30a34b8f15 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -411,7 +411,7 @@ class GroupsController < ApplicationController private def group_params - params.require(:group).permit( + permitted_params = [ :flair_url, :flair_bg_color, :flair_color, @@ -421,7 +421,13 @@ class GroupsController < ApplicationController :public_exit, :allow_membership_requests, :membership_request_template, - ) + ] + + if current_user.admin + permitted_params.push(:name) + end + + params.require(:group).permit(*permitted_params) end def find_group(param_name) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d3144ca4c26..31f073ba17d 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -403,21 +403,29 @@ en: remove_user_as_group_owner: "Revoke owner" groups: - logs: - title: "Logs" - when: "When" - action: "Action" - acting_user: "Acting user" - target_user: "Target user" - subject: "Subject" - details: "Details" - from: "From" - to: "To" - edit: - title: 'Edit Group' + manage: + title: 'Manage' + name: 'Name' full_name: 'Full Name' add_members: "Add Members" delete_member_confirm: "Remove '%{username}' from the '%{group}' group?" + profile: + title: Profile + members: + title: "Members" + description: "Manage the membership of this group" + usernames: "Usernames" + as_owner: "Set user(s) as owner(s) of this group" + logs: + title: "Logs" + when: "When" + action: "Action" + acting_user: "Acting user" + target_user: "Target user" + subject: "Subject" + details: "Details" + from: "From" + to: "To" name_placeholder: "Group name, no spaces, same as username rule" public_admission: "Allow users to join the group freely (Requires publicly visible group)" public_exit: "Allow users to leave the group freely" @@ -464,11 +472,6 @@ en: one: "Group" other: "Groups" activity: "Activity" - add_members: - title: "Add Members" - description: "Manage the membership of this group" - usernames: "Usernames" - as_owner: "Set user(s) as owner(s) of this group" members: title: "Members" filter_placeholder_admin: "username or email" diff --git a/config/routes.rb b/config/routes.rb index a5249b598db..38cf78b4e51 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -472,6 +472,10 @@ Discourse::Application.routes.draw do messages messages/inbox messages/archive + manage + manage/profile + manage/members + manage/logs }.each do |path| get path => 'groups#show' end diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index f859a8058d6..9532b927772 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -279,6 +279,7 @@ describe GroupsController do expect do put "/groups/#{group.id}.json", params: { group: { + name: 'testing', flair_bg_color: 'FFF', flair_color: 'BBB', flair_url: 'fa-adjust', @@ -292,7 +293,7 @@ describe GroupsController do } end.to change { GroupHistory.count }.by(9) - expect(response).to be_success + expect(response.status).to eq(200) group.reload @@ -306,6 +307,7 @@ describe GroupsController do expect(group.allow_membership_requests).to eq(true) expect(group.membership_request_template).to eq('testing') expect(GroupHistory.last.subject).to eq('membership_request_template') + expect(group.name).to eq('test') end end @@ -316,10 +318,18 @@ describe GroupsController do end it 'should be able to update the group' do - put "/groups/#{group.id}.json", params: { group: { flair_color: 'BBB' } } + put "/groups/#{group.id}.json", params: { + group: { + flair_color: 'BBB', + name: 'testing' + } + } - expect(response).to be_success - expect(group.reload.flair_color).to eq('BBB') + expect(response.status).to eq(200) + + group.reload + expect(group.flair_color).to eq('BBB') + expect(group.name).to eq('testing') end end diff --git a/test/javascripts/acceptance/group-edit-test.js.es6 b/test/javascripts/acceptance/group-edit-test.js.es6 deleted file mode 100644 index a03cb176298..00000000000 --- a/test/javascripts/acceptance/group-edit-test.js.es6 +++ /dev/null @@ -1,61 +0,0 @@ -import { acceptance, logIn } from "helpers/qunit-helpers"; - -acceptance("Editing Group"); - -QUnit.test("Editing group", assert => { - logIn(); - Discourse.reset(); - - visit("/groups/discourse/edit"); - - andThen(() => { - assert.ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs'); - assert.ok(find('.group-edit-bio').length === 1, 'it should display group bio input'); - assert.ok(find('.group-edit-full-name').length === 1, 'it should display group full name input'); - - assert.ok( - find('.group-edit-public-admission').length === 1, - 'it should display group public admission input' - ); - - assert.ok( - find('.group-edit-public-exit').length === 1, - 'it should display group public exit input' - ); - - assert.ok(find('.group-edit-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input'); - - assert.ok( - find('.group-edit-allow-membership-requests[disabled]').length === 1, - 'it should disable group allow_membership_request input' - ); - }); - - click('.group-edit-public-admission'); - click('.group-edit-allow-membership-requests'); - - andThen(() => { - assert.ok( - find('.group-edit-public-admission[disabled]').length === 1, - 'it should disable group public admission input' - ); - - assert.ok( - find('.group-edit-public-exit[disabled]').length === 0, - 'it should not disable group public exit input' - ); - - assert.equal( - find('.group-edit-membership-request-template').length, 1, - 'it should display the membership request template field' - ); - }); -}); - -QUnit.test("Editing group as an anonymous user", assert => { - visit("/groups/discourse/edit"); - - andThen(() => { - assert.ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user"); - }); -}); diff --git a/test/javascripts/acceptance/group-index-test.js.es6 b/test/javascripts/acceptance/group-index-test.js.es6 index cfd52691af1..caa0a3b8d9d 100644 --- a/test/javascripts/acceptance/group-index-test.js.es6 +++ b/test/javascripts/acceptance/group-index-test.js.es6 @@ -9,11 +9,6 @@ QUnit.test("Viewing Members as anon user", assert => { assert.ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair"); assert.ok(count('.group-members tr') > 0, "it lists group members"); - assert.ok( - count('.group-navigation-dropdown') === 0, - 'it should not display the group navigation dropdown menu' - ); - assert.ok( count('.group-member-dropdown') === 0, 'it does not allow anon user to manage group members' @@ -34,11 +29,6 @@ QUnit.test("Viewing Members as an admin user", assert => { visit("/groups/discourse"); andThen(() => { - assert.ok( - count('.group-navigation-dropdown') === 1, - 'it should display the group navigation dropdown menu' - ); - assert.ok( count('.group-member-dropdown') > 0, 'it allows admin user to manage group members' @@ -50,23 +40,4 @@ QUnit.test("Viewing Members as an admin user", assert => { 'it should display the right filter placehodler' ); }); - - selectKit('.group-navigation-dropdown').expand().selectRowByValue('manageMembership'); - - andThen(() => { - assert.ok( - count('.group-membership') === 1, - 'it should display the right modal' - ); - - assert.ok( - count('#group-membership-user-selector') === 1, - 'it should display the user selector' - ); - - assert.ok( - count(".group-membership-make-owner input[type='checkbox']") === 1, - 'it should display the input to set users as owners' - ); - }); }); diff --git a/test/javascripts/acceptance/group-logs-test.js.es6 b/test/javascripts/acceptance/group-manage-logs-test.js.es6 similarity index 85% rename from test/javascripts/acceptance/group-logs-test.js.es6 rename to test/javascripts/acceptance/group-manage-logs-test.js.es6 index 86d760cb0c2..285ce77899b 100644 --- a/test/javascripts/acceptance/group-logs-test.js.es6 +++ b/test/javascripts/acceptance/group-manage-logs-test.js.es6 @@ -1,6 +1,6 @@ import { acceptance } from "helpers/qunit-helpers"; -acceptance("Group Logs", { +acceptance("Group logs", { loggedIn: true, beforeEach() { const response = object => { @@ -27,14 +27,14 @@ acceptance("Group Logs", { }); QUnit.test("Browsing group logs", assert => { - visit("/groups/snorlax/logs"); + visit("/groups/snorlax/manage/logs"); andThen(() => { - assert.ok(find('tr.group-logs-row').length === 2, 'it should display the right number of logs'); - click(find(".group-logs-row button")[0]); + assert.ok(find('tr.group-manage-logs-row').length === 2, 'it should display the right number of logs'); + click(find(".group-manage-logs-row button")[0]); }); andThen(() => { - assert.ok(find('tr.group-logs-row').length === 1, 'it should display the right number of logs'); + assert.ok(find('tr.group-manage-logs-row').length === 1, 'it should display the right number of logs'); }); -}); \ No newline at end of file +}); diff --git a/test/javascripts/acceptance/group-manage-profile-test.js.es6 b/test/javascripts/acceptance/group-manage-profile-test.js.es6 new file mode 100644 index 00000000000..fd801b4aed7 --- /dev/null +++ b/test/javascripts/acceptance/group-manage-profile-test.js.es6 @@ -0,0 +1,62 @@ +import { acceptance, logIn } from "helpers/qunit-helpers"; + +acceptance("Managing Group Profile"); + +QUnit.test("Editing group", assert => { + logIn(); + Discourse.reset(); + + visit("/groups/discourse/manage/profile"); + + andThen(() => { + assert.ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs'); + assert.ok(find('.group-manage-bio').length === 1, 'it should display group bio input'); + assert.ok(find('.group-manage-name').length === 1, 'it should display group name input'); + assert.ok(find('.group-manage-full-name').length === 1, 'it should display group full name input'); + + assert.ok( + find('.group-manage-public-admission').length === 1, + 'it should display group public admission input' + ); + + assert.ok( + find('.group-manage-public-exit').length === 1, + 'it should display group public exit input' + ); + + assert.ok(find('.group-manage-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input'); + + assert.ok( + find('.group-manage-allow-membership-requests[disabled]').length === 1, + 'it should disable group allow_membership_request input' + ); + }); + + click('.group-manage-public-admission'); + click('.group-manage-allow-membership-requests'); + + andThen(() => { + assert.ok( + find('.group-manage-public-admission[disabled]').length === 1, + 'it should disable group public admission input' + ); + + assert.ok( + find('.group-manage-public-exit[disabled]').length === 0, + 'it should not disable group public exit input' + ); + + assert.equal( + find('.group-manage-membership-request-template').length, 1, + 'it should display the membership request template field' + ); + }); +}); + +QUnit.test("Editing group as an anonymous user", assert => { + visit("/groups/discourse/manage/profile"); + + andThen(() => { + assert.ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user"); + }); +}); diff --git a/test/javascripts/acceptance/groups-test.js.es6 b/test/javascripts/acceptance/groups-test.js.es6 index 0c3e94ddeda..78f55268412 100644 --- a/test/javascripts/acceptance/groups-test.js.es6 +++ b/test/javascripts/acceptance/groups-test.js.es6 @@ -193,8 +193,11 @@ QUnit.test("Admin Viewing Group", assert => { visit("/groups/discourse"); andThen(() => { - assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin'); - assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin'); + assert.ok( + find(".nav-pills li a[title='Manage']").length === 1, + 'it should show manage group tab if user is admin' + ); + assert.equal(count('.group-message-button'), 1, 'it displays show group message button'); assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name'); });