group sidebar panel improvements
This commit is contained in:
parent
61134fb645
commit
06e1c47ff4
|
@ -14,7 +14,7 @@ class Api::V1::GroupsController < Api::BaseController
|
|||
when 'featured'
|
||||
@groups = Group.where(is_featured: true).limit(25).all
|
||||
when 'member'
|
||||
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).all
|
||||
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).order('group_accounts.unread_count DESC, group_accounts.id DESC').all
|
||||
when 'admin'
|
||||
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account, role: :admin }).all
|
||||
end
|
||||
|
|
|
@ -5,9 +5,11 @@ import { defineMessages, injectIntl } from 'react-intl';
|
|||
import { connect } from 'react-redux';
|
||||
import Item from './item';
|
||||
import Icon from 'gabsocial/components/icon';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'groups.sidebar-panel.title', defaultMessage: 'Groups you\'re in' },
|
||||
show_all: { id: 'groups.sidebar-panel.show_all', defaultMessage: 'Show all' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, { id }) => ({
|
||||
|
@ -23,9 +25,10 @@ class GroupSidebarPanel extends ImmutablePureComponent {
|
|||
|
||||
render() {
|
||||
const { intl, groupIds } = this.props;
|
||||
const count = groupIds.count();
|
||||
|
||||
// Only when there are groups to show
|
||||
if (groupIds.count() === 0) return null;
|
||||
if (count === 0) return null;
|
||||
|
||||
return (
|
||||
<div className='wtf-panel group-sidebar-panel'>
|
||||
|
@ -36,7 +39,8 @@ class GroupSidebarPanel extends ImmutablePureComponent {
|
|||
|
||||
<div className='wtf-panel__content'>
|
||||
<div className="group-sidebar-panel__items">
|
||||
{groupIds.map(groupId => <Item key={groupId} id={groupId} />)}
|
||||
{groupIds.slice(0, 10).map(groupId => <Item key={groupId} id={groupId} />)}
|
||||
{count > 10 && <Link className="group-sidebar-panel__items__show-all" to='/groups/browse/member'>{intl.formatMessage(messages.show_all)}</Link>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,6 @@ import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel';
|
|||
import LinkFooter from '../features/ui/components/link_footer';
|
||||
import PromoPanel from '../features/ui/components/promo_panel';
|
||||
import UserPanel from '../features/ui/components/user_panel';
|
||||
import GroupSidebarPanel from '../features/groups/sidebar_panel';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
account: state.getIn(['accounts', me]),
|
||||
|
@ -43,7 +42,6 @@ class GroupsPage extends ImmutablePureComponent {
|
|||
|
||||
<div className='columns-area__panels__pane columns-area__panels__pane--right'>
|
||||
<div className='columns-area__panels__pane__inner'>
|
||||
<GroupSidebarPanel />
|
||||
<WhoToFollowPanel />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
.group-sidebar-panel {
|
||||
&__items {
|
||||
padding: 0 15px 15px;
|
||||
|
||||
&__show-all {
|
||||
color: $primary-text-color;
|
||||
}
|
||||
}
|
||||
|
||||
&__item {
|
||||
|
|
Loading…
Reference in New Issue