mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: Groups navigation to a component
This commit is contained in:
parent
7f33f7850a
commit
f57d3c2315
@ -0,0 +1,15 @@
|
|||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
tagName: '',
|
||||||
|
|
||||||
|
@computed('group')
|
||||||
|
availableTabs(group) {
|
||||||
|
return this.get('tabs').filter(t => {
|
||||||
|
if (t.admin) {
|
||||||
|
return this.currentUser ? this.currentUser.canManageGroup(group) : false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -1,14 +1,11 @@
|
|||||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
var Tab = Em.Object.extend({
|
const Tab = Ember.Object.extend({
|
||||||
@computed('name')
|
init() {
|
||||||
location(name) {
|
this._super();
|
||||||
return 'group.' + name;
|
let name = this.get('name');
|
||||||
},
|
this.set('route', this.get('route') || `group.` + name);
|
||||||
|
this.set('message', I18n.t(`groups.${this.get('i18nKey') || name}`));
|
||||||
@computed('name', 'i18nKey')
|
|
||||||
message(name, i18nKey) {
|
|
||||||
return I18n.t(`groups.${i18nKey || name}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -18,13 +15,13 @@ export default Ember.Controller.extend({
|
|||||||
showing: 'members',
|
showing: 'members',
|
||||||
|
|
||||||
tabs: [
|
tabs: [
|
||||||
Tab.create({ name: 'members', 'location': 'group.index', icon: 'users' }),
|
Tab.create({ name: 'members', route: 'group.index', icon: 'users' }),
|
||||||
Tab.create({ name: 'activity' }),
|
Tab.create({ name: 'activity' }),
|
||||||
Tab.create({
|
Tab.create({
|
||||||
name: 'edit', i18nKey: 'edit.title', icon: 'pencil', requiresGroupAdmin: true
|
name: 'edit', i18nKey: 'edit.title', icon: 'pencil', admin: true
|
||||||
}),
|
}),
|
||||||
Tab.create({
|
Tab.create({
|
||||||
name: 'logs', i18nKey: 'logs.title', icon: 'list-alt', requiresGroupAdmin: true
|
name: 'logs', i18nKey: 'logs.title', icon: 'list-alt', admin: true
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -58,21 +55,6 @@ export default Ember.Controller.extend({
|
|||||||
this.get('tabs')[0].set('count', this.get('model.user_count'));
|
this.get('tabs')[0].set('count', this.get('model.user_count'));
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed('model.is_group_owner', 'model.automatic')
|
|
||||||
getTabs() {
|
|
||||||
return this.get('tabs').filter(t => {
|
|
||||||
let canSee = true;
|
|
||||||
|
|
||||||
if (this.currentUser && t.requiresGroupAdmin) {
|
|
||||||
canSee = this.currentUser.canManageGroup(this.get('model'));
|
|
||||||
} else if (t.requiresGroupAdmin) {
|
|
||||||
canSee = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return canSee;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
messageGroup() {
|
messageGroup() {
|
||||||
this.send('createNewMessageViaParams', this.get('model.name'));
|
this.send('createNewMessageViaParams', this.get('model.name'));
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
{{#mobile-nav class='group-nav' desktopClass="nav nav-pills" currentPath=currentPath}}
|
||||||
|
{{#each availableTabs as |tab|}}
|
||||||
|
<li>
|
||||||
|
{{#link-to tab.route group title=tab.message class=tab.name}}
|
||||||
|
{{#if tab.icon}}{{d-icon tab.icon}}{{/if}}
|
||||||
|
{{tab.message}}
|
||||||
|
{{#if tab.count}}<span class='count'>({{tab.count}})</span>{{/if}}
|
||||||
|
{{/link-to}}
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
{{/mobile-nav}}
|
@ -21,7 +21,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if model.bio_cooked}}
|
{{#if model.bio_cooked}}
|
||||||
<hr/>
|
<hr>
|
||||||
|
|
||||||
<div class='group-bio'>
|
<div class='group-bio'>
|
||||||
<p>{{{model.bio_cooked}}}</p>
|
<p>{{{model.bio_cooked}}}</p>
|
||||||
@ -31,17 +31,7 @@
|
|||||||
|
|
||||||
<div class="list-controls">
|
<div class="list-controls">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{#mobile-nav class='group-nav' desktopClass="nav nav-pills" currentPath=application.currentPath}}
|
{{group-navigation group=model currentPath=application.currentPath tabs=tabs}}
|
||||||
{{#each getTabs as |tab|}}
|
|
||||||
<li>
|
|
||||||
{{#link-to tab.location model title=tab.message class=tab.name}}
|
|
||||||
{{#if tab.icon}}{{d-icon tab.icon}}{{/if}}
|
|
||||||
{{tab.message}}
|
|
||||||
{{#if tab.count}}<span class='count'>({{tab.count}})</span>{{/if}}
|
|
||||||
{{/link-to}}
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
{{/mobile-nav}}
|
|
||||||
|
|
||||||
{{#if displayGroupMessageButton}}
|
{{#if displayGroupMessageButton}}
|
||||||
{{d-button
|
{{d-button
|
||||||
|
Loading…
Reference in New Issue
Block a user