Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-13271 Fix for Leave team making 403 calls #2187

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
MM-13271 Fix for Leave team making 403 calls
  * Leave team should not call for stat calls
  * removeUserFromTeam be used for remvoving user and to get stats
  • Loading branch information
sudheerDev committed Dec 12, 2018
commit 998c6d9c7a9db5fcae745269c15cbf9e1fc0a5ce
2 changes: 1 addition & 1 deletion components/admin_console/manage_teams_modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {updateTeamMemberSchemeRoles, getTeamMembersForUser, getTeamsForUser} from 'mattermost-redux/actions/teams';
import {removeUserFromTeam} from 'mattermost-redux/actions/teams';

import {removeUserFromTeam} from 'actions/team_actions.jsx';
import {getCurrentLocale} from 'selectors/i18n';

import ManageTeamsModal from './manage_teams_modal';
Expand Down
4 changes: 2 additions & 2 deletions components/leave_team_modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {removeUserFromTeam as leaveTeam} from 'mattermost-redux/actions/teams';

import {toggleSideBarRightMenuAction} from 'actions/global_actions.jsx';
import {removeUserFromTeam} from 'actions/team_actions';
import {ModalIdentifiers} from 'utils/constants';

import {isModalOpen} from 'selectors/views/modals';
Expand All @@ -29,7 +29,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
removeUserFromTeam,
leaveTeam,
toggleSideBarRightMenu: toggleSideBarRightMenuAction,
}, dispatch),
};
Expand Down
4 changes: 2 additions & 2 deletions components/leave_team_modal/leave_team_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LeaveTeamModal extends React.PureComponent {
* An action to remove user from team
*/

removeUserFromTeam: PropTypes.func.isRequired,
leaveTeam: PropTypes.func.isRequired,

/**
* An action to toggle the right menu
Expand Down Expand Up @@ -70,7 +70,7 @@ class LeaveTeamModal extends React.PureComponent {

handleSubmit = () => {
this.props.onHide();
this.props.actions.removeUserFromTeam(this.props.currentTeamId, this.props.currentUserId);
this.props.actions.leaveTeam(this.props.currentTeamId, this.props.currentUserId);
this.props.actions.toggleSideBarRightMenu();
};

Expand Down
8 changes: 4 additions & 4 deletions components/leave_team_modal/leave_team_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('components/LeaveTeamModal', () => {
show: false,
isBusy: false,
actions: {
removeUserFromTeam: jest.fn(),
leaveTeam: jest.fn(),
toggleSideBarRightMenu: jest.fn(),
},

Expand All @@ -35,16 +35,16 @@ describe('components/LeaveTeamModal', () => {
expect(requiredProps.onHide).toHaveBeenCalledTimes(1);
});

it('should call removeUserFromTeam and toggleSideBarRightMenu when ok is clicked', () => {
it('should call leaveTeam and toggleSideBarRightMenu when ok is clicked', () => {
const wrapper = shallowWithIntl(<LeaveTeamModal {...requiredProps}/>).
dive({disableLifecycleMethods: true});
const ok = wrapper.find('.btn-danger').first();

ok.simulate('click');
expect(requiredProps.actions.removeUserFromTeam).toHaveBeenCalledTimes(1);
expect(requiredProps.actions.leaveTeam).toHaveBeenCalledTimes(1);
expect(requiredProps.actions.toggleSideBarRightMenu).toHaveBeenCalledTimes(1);
expect(requiredProps.onHide).toHaveBeenCalledTimes(1);
expect(requiredProps.actions.removeUserFromTeam).
expect(requiredProps.actions.leaveTeam).
toHaveBeenCalledWith(requiredProps.currentTeamId, requiredProps.currentUserId);
});

Expand Down
4 changes: 1 addition & 3 deletions components/team_members_dropdown/team_members_dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export default class TeamMembersDropdown extends React.Component {

handleRemoveFromTeam = async () => {
const {data, error} = await this.props.actions.removeUserFromTeam(this.props.teamMember.team_id, this.props.user.id);
if (data) {
this.props.actions.getTeamStats(this.props.teamMember.team_id);
sudheerDev marked this conversation as resolved.
Show resolved Hide resolved
} else if (error) {
if (error) {
this.setState({serverError: error.message});
}
}
Expand Down