PLT-6213 Move team store and actions over to use redux (#6222)

* Move team store and actions over to user redux

* Fix JS error when inviting by email
Этот коммит содержится в:
Joram Wilander
2017-04-26 15:49:15 -04:00
коммит произвёл GitHub
родитель 1fef5bf5fe
Коммит 7307156c49
27 изменённых файлов: 387 добавлений и 390 удалений

Просмотреть файл

@@ -0,0 +1,27 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeams, getTeamStats} from 'mattermost-redux/actions/teams';
import {getUser} from 'mattermost-redux/actions/users';
import SystemUsers from './system_users.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeams,
getTeamStats,
getUser
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(SystemUsers);

Просмотреть файл

@@ -16,7 +16,7 @@ import AnalyticsStore from 'stores/analytics_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {getAllTeams, getStandardAnalytics, getTeamStats, getUser} from 'utils/async_client.jsx';
import {getStandardAnalytics} from 'utils/async_client.jsx';
import {Constants, StatTypes, UserSearchOptions} from 'utils/constants.jsx';
import {convertTeamMapToList} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';
@@ -33,6 +33,14 @@ const USER_ID_LENGTH = 26;
const USERS_PER_PAGE = 50;
export default class SystemUsers extends React.Component {
static propTypes = {
actions: React.PropTypes.shape({
getTeams: React.PropTypes.func.isRequired,
getTeamStats: React.PropTypes.func.isRequired,
getUser: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
@@ -76,7 +84,7 @@ export default class SystemUsers extends React.Component {
UserStore.addWithoutTeamChangeListener(this.updateUsersFromStore);
this.loadDataForTeam(this.state.teamId);
getAllTeams();
this.props.actions.getTeams(0, 1000);
}
componentWillUpdate(nextProps, nextState) {
@@ -155,7 +163,7 @@ export default class SystemUsers extends React.Component {
loadProfilesWithoutTeam(0, Constants.PROFILE_CHUNK_SIZE, this.loadComplete);
} else {
loadProfilesAndTeamMembers(0, Constants.PROFILE_CHUNK_SIZE, teamId, this.loadComplete);
getTeamStats(teamId);
this.props.actions.getTeamStats(teamId);
}
}
@@ -240,7 +248,7 @@ export default class SystemUsers extends React.Component {
return;
}
getUser(
this.props.actions.getUser(
id,
() => {
this.setState({

Просмотреть файл

@@ -0,0 +1,24 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeams} from 'mattermost-redux/actions/teams';
import TeamAnalytics from './team_analytics.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeams
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(TeamAnalytics);

Просмотреть файл

@@ -15,14 +15,20 @@ import * as AsyncClient from 'utils/async_client.jsx';
import {StatTypes} from 'utils/constants.jsx';
import {convertTeamMapToList} from 'utils/team_utils.jsx';
import LineChart from './line_chart.jsx';
import StatisticCount from './statistic_count.jsx';
import TableChart from './table_chart.jsx';
import {formatPostsPerDayData, formatUsersWithPostsPerDayData} from './system_analytics.jsx';
import LineChart from 'components/analytics/line_chart.jsx';
import StatisticCount from 'components/analytics/statistic_count.jsx';
import TableChart from 'components/analytics/table_chart.jsx';
import {formatPostsPerDayData, formatUsersWithPostsPerDayData} from 'components/analytics/system_analytics.jsx';
const LAST_ANALYTICS_TEAM = 'last_analytics_team';
export default class TeamAnalytics extends React.Component {
static propTypes = {
actions: React.PropTypes.shape({
getTeams: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
@@ -50,7 +56,7 @@ export default class TeamAnalytics extends React.Component {
}
if (this.state.teams.length === 0) {
AsyncClient.getAllTeams();
this.props.actions.getTeams(0, 1000);
}
}

Просмотреть файл

@@ -11,7 +11,6 @@ import TeamStore from 'stores/team_store.jsx';
import {searchUsers} from 'actions/user_actions.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
import Constants from 'utils/constants.jsx';
@@ -29,7 +28,8 @@ export default class ChannelInviteModal extends React.Component {
onHide: React.PropTypes.func.isRequired,
channel: React.PropTypes.object.isRequired,
actions: React.PropTypes.shape({
getProfilesNotInChannel: React.PropTypes.func.isRequired
getProfilesNotInChannel: React.PropTypes.func.isRequired,
getTeamStats: React.PropTypes.func.isRequired
}).isRequired
}
@@ -64,7 +64,7 @@ export default class ChannelInviteModal extends React.Component {
UserStore.addStatusesChangeListener(this.onStatusChange);
this.props.actions.getProfilesNotInChannel(TeamStore.getCurrentId(), this.props.channel.id, 0);
AsyncClient.getTeamStats(TeamStore.getCurrentId());
this.props.actions.getTeamStats(TeamStore.getCurrentId());
}
componentWillUnmount() {

Просмотреть файл

@@ -4,6 +4,7 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getProfilesNotInChannel} from 'mattermost-redux/actions/users';
import {getTeamStats} from 'mattermost-redux/actions/teams';
import ChannelInviteModal from './channel_invite_modal.jsx';
@@ -16,7 +17,8 @@ function mapStateToProps(state, ownProps) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getProfilesNotInChannel
getProfilesNotInChannel,
getTeamStats
}, dispatch)
};
}

24
webapp/components/member_list_team/index.js Обычный файл
Просмотреть файл

@@ -0,0 +1,24 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeamStats} from 'mattermost-redux/actions/teams';
import MemberListTeam from './member_list_team.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeamStats
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(MemberListTeam);

Просмотреть файл

@@ -8,7 +8,6 @@ import UserStore from 'stores/user_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import {searchUsers, loadProfilesAndTeamMembers, loadTeamMembersForProfilesList} from 'actions/user_actions.jsx';
import {getTeamStats} from 'utils/async_client.jsx';
import Constants from 'utils/constants.jsx';
@@ -22,11 +21,17 @@ import {searchProfilesInCurrentTeam} from 'mattermost-redux/selectors/entities/u
const USERS_PER_PAGE = 50;
export default class MemberListTeam extends React.Component {
static propTypes = {
isAdmin: React.PropTypes.bool,
actions: React.PropTypes.shape({
getTeamStats: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
this.onChange = this.onChange.bind(this);
this.onTeamChange = this.onTeamChange.bind(this);
this.onStatsChange = this.onStatsChange.bind(this);
this.search = this.search.bind(this);
this.loadComplete = this.loadComplete.bind(this);
@@ -45,19 +50,19 @@ export default class MemberListTeam extends React.Component {
}
componentDidMount() {
UserStore.addInTeamChangeListener(this.onTeamChange);
UserStore.addInTeamChangeListener(this.onChange);
UserStore.addStatusesChangeListener(this.onChange);
TeamStore.addChangeListener(this.onTeamChange);
TeamStore.addChangeListener(this.onChange);
TeamStore.addStatsChangeListener(this.onStatsChange);
loadProfilesAndTeamMembers(0, Constants.PROFILE_CHUNK_SIZE, TeamStore.getCurrentId(), this.loadComplete);
getTeamStats(TeamStore.getCurrentId());
this.props.actions.getTeamStats(TeamStore.getCurrentId());
}
componentWillUnmount() {
UserStore.removeInTeamChangeListener(this.onTeamChange);
UserStore.removeInTeamChangeListener(this.onChange);
UserStore.removeStatusesChangeListener(this.onChange);
TeamStore.removeChangeListener(this.onTeamChange);
TeamStore.removeChangeListener(this.onChange);
TeamStore.removeStatsChangeListener(this.onStatsChange);
}
@@ -65,10 +70,6 @@ export default class MemberListTeam extends React.Component {
this.setState({loading: false});
}
onTeamChange() {
this.onChange(true);
}
onChange() {
let users;
if (this.term) {
@@ -163,7 +164,3 @@ export default class MemberListTeam extends React.Component {
);
}
}
MemberListTeam.propTypes = {
isAdmin: React.PropTypes.bool
};

24
webapp/components/select_team/index.js Обычный файл
Просмотреть файл

@@ -0,0 +1,24 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeams} from 'mattermost-redux/actions/teams';
import SelectTeam from './select_team.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeams
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(SelectTeam);

Просмотреть файл

@@ -7,7 +7,6 @@ import * as UserAgent from 'utils/user_agent.jsx';
import * as Utils from 'utils/utils.jsx';
import ErrorBar from 'components/error_bar.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import SelectTeamItem from './components/select_team_item.jsx';
@@ -19,6 +18,11 @@ import React from 'react';
import logoImage from 'images/logo.png';
export default class SelectTeam extends React.Component {
static propTypes = {
actions: React.PropTypes.shape({
getTeams: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
@@ -33,7 +37,7 @@ export default class SelectTeam extends React.Component {
componentDidMount() {
TeamStore.addChangeListener(this.onTeamChange);
AsyncClient.getAllTeamListings();
this.props.actions.getTeams(0, 200);
}
componentWillUnmount() {

Просмотреть файл

@@ -86,7 +86,7 @@ class GeneralTab extends React.Component {
var state = {serverError: '', clientError: ''};
var data = this.props.team;
var data = {...this.props.team};
data.allow_open_invite = this.state.allow_open_invite;
updateTeam(data,
() => {
@@ -119,7 +119,7 @@ class GeneralTab extends React.Component {
return;
}
var data = this.props.team;
var data = {...this.props.team};
data.display_name = this.state.name;
updateTeam(data,
() => {
@@ -152,7 +152,7 @@ class GeneralTab extends React.Component {
return;
}
var data = this.props.team;
var data = {...this.props.team};
data.invite_id = this.state.invite_id;
updateTeam(data,
() => {
@@ -189,7 +189,7 @@ class GeneralTab extends React.Component {
return;
}
var data = this.props.team;
var data = {...this.props.team};
data.description = this.state.description;
updateTeam(data,
() => {

Просмотреть файл

@@ -4,6 +4,7 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getUser} from 'mattermost-redux/actions/users';
import {getTeamStats} from 'mattermost-redux/actions/teams';
import TeamMembersDropdown from './team_members_dropdown.jsx';
@@ -16,7 +17,8 @@ function mapStateToProps(state, ownProps) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getUser
getUser,
getTeamStats
}, dispatch)
};
}

Просмотреть файл

@@ -22,7 +22,8 @@ export default class TeamMembersDropdown extends React.Component {
user: React.PropTypes.object.isRequired,
teamMember: React.PropTypes.object.isRequired,
actions: React.PropTypes.shape({
getUser: React.PropTypes.func.isRequired
getUser: React.PropTypes.func.isRequired,
getTeamStats: React.PropTypes.func.isRequired
}).isRequired
}
@@ -76,7 +77,7 @@ export default class TeamMembersDropdown extends React.Component {
() => {
UserStore.removeProfileFromTeam(this.props.teamMember.team_id, this.props.user.id);
UserStore.emitInTeamChange();
AsyncClient.getTeamStats(this.props.teamMember.team_id);
this.props.actions.getTeamStats(this.props.teamMember.team_id);
},
(err) => {
this.setState({serverError: err.message});
@@ -88,7 +89,7 @@ export default class TeamMembersDropdown extends React.Component {
updateActive(this.props.user.id, true,
() => {
AsyncClient.getChannelStats(ChannelStore.getCurrentId());
AsyncClient.getTeamStats(this.props.teamMember.team_id);
this.props.actions.getTeamStats(this.props.teamMember.team_id);
},
(err) => {
this.setState({serverError: err.message});
@@ -100,7 +101,7 @@ export default class TeamMembersDropdown extends React.Component {
updateActive(this.props.user.id, false,
() => {
AsyncClient.getChannelStats(ChannelStore.getCurrentId());
AsyncClient.getTeamStats(this.props.teamMember.team_id);
this.props.actions.getTeamStats(this.props.teamMember.team_id);
},
(err) => {
this.setState({serverError: err.message});

Просмотреть файл

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import MemberListTeam from './member_list_team.jsx';
import MemberListTeam from 'components/member_list_team';
import TeamStore from 'stores/team_store.jsx';
import {FormattedMessage} from 'react-intl';

24
webapp/components/team_sidebar/index.js Обычный файл
Просмотреть файл

@@ -0,0 +1,24 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeams} from 'mattermost-redux/actions/teams';
import TeamSidebar from './team_sidebar_controller.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getTeams
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(TeamSidebar);

Просмотреть файл

@@ -6,7 +6,6 @@ import TeamButton from './components/team_button.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {sortTeamsByDisplayName} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';
@@ -15,6 +14,12 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
export default class TeamSidebar extends React.Component {
static propTypes = {
actions: React.PropTypes.shape({
getTeams: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
@@ -44,7 +49,7 @@ export default class TeamSidebar extends React.Component {
window.addEventListener('resize', this.handleResize);
TeamStore.addChangeListener(this.onChange);
TeamStore.addUnreadChangeListener(this.onChange);
AsyncClient.getAllTeamListings();
this.props.actions.getTeams(0, 200);
this.setStyles();
}