Commit ed5cbc05 authored by Jesús Espino's avatar Jesús Espino Committed by Carlos Tadeu Panato Junior

Remove number of members on teams to avoid a lot of requests (#1334)

parent 1fa5bfec
......@@ -3,29 +3,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import {imageURLForTeam} from 'utils/utils.jsx';
export default class TeamInList extends React.Component {
static propTypes = {
team: PropTypes.object.isRequired,
stats: PropTypes.object,
actions: PropTypes.shape({
loadTeamStats: PropTypes.func.isRequired,
}).isRequired,
}
componentDidMount() {
this.props.actions.loadTeamStats(this.props.team.id);
}
render() {
const {team, stats} = this.props;
let totalMembers = 0;
if (stats && stats[team.id]) {
totalMembers = stats[team.id].total_member_count;
}
const {team} = this.props;
const teamIconUrl = imageURLForTeam(team);
let icon = null;
if (teamIconUrl) {
......@@ -47,13 +34,6 @@ export default class TeamInList extends React.Component {
<span className='icon'>{icon}</span>
<div className='team-data'>
<div className='title'>{team.display_name}</div>
<div className='members'>
<FormattedMessage
id='admin.team_info.numMembers'
defaultMessage='{count} {count, plural, one {Member} other {Members}}'
values={{count: totalMembers}}
/>
</div>
</div>
</div>
);
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeamStats as loadTeamStats} from 'mattermost-redux/actions/teams';
import {getTeamStats} from 'mattermost-redux/selectors/entities/teams';
import TeamInfo from './team_info.jsx';
function mapStateToProps(state) {
return {
stats: getTeamStats(state),
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
loadTeamStats,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(TeamInfo);
......@@ -10,7 +10,7 @@ import Constants from 'utils/constants.jsx';
import {localizeMessage} from 'utils/utils.jsx';
import MultiSelect from 'components/multiselect/multiselect.jsx';
import TeamInfo from 'components/team_info';
import TeamInfo from 'components/team_info.jsx';
import ConfirmModal from 'components/confirm_modal.jsx';
const TEAMS_PER_PAGE = 50;
......
......@@ -24,19 +24,6 @@ exports[`components/TeamInfo should match snapshot, with icon 1`] = `
>
Test team
</div>
<div
className="members"
>
<FormattedMessage
defaultMessage="{count} {count, plural, one {Member} other {Members}}"
id="admin.team_info.numMembers"
values={
Object {
"count": 5,
}
}
/>
</div>
</div>
</div>
`;
......@@ -62,19 +49,6 @@ exports[`components/TeamInfo should match snapshot, without icon 1`] = `
>
Test team
</div>
<div
className="members"
>
<FormattedMessage
defaultMessage="{count} {count, plural, one {Member} other {Members}}"
id="admin.team_info.numMembers"
values={
Object {
"count": 5,
}
}
/>
</div>
</div>
</div>
`;
......@@ -4,7 +4,7 @@
import React from 'react';
import {shallow} from 'enzyme';
import TeamInfo from 'components/team_info/team_info.jsx';
import TeamInfo from 'components/team_info.jsx';
jest.mock('utils/utils.jsx');
......@@ -15,14 +15,6 @@ describe('components/TeamInfo', () => {
name: 'test-team',
display_name: 'Test team',
},
stats: {
xxxx: {
total_member_count: 5,
},
},
actions: {
loadTeamStats: jest.fn(),
},
};
test('should match snapshot, without icon', () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment