Move instances of Client.updateTeam() in components to an action (#4574)
* Move instances of Client.updateTeam() in components to an action * remove client from missing ones * update code per review * update per code review
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
7d68434e8c
Коммит
34c3e9e50d
@@ -36,6 +36,24 @@ export function createTeam(team, onSuccess, onError) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateTeam(team, onSuccess, onError) {
|
||||||
|
Client.updateTeam(team,
|
||||||
|
(rteam) => {
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.UPDATE_TEAM,
|
||||||
|
team: rteam
|
||||||
|
});
|
||||||
|
|
||||||
|
browserHistory.push('/' + rteam.name + '/channels/town-square');
|
||||||
|
|
||||||
|
if (onSuccess) {
|
||||||
|
onSuccess(rteam);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function removeUserFromTeam(teamId, userId, success, error) {
|
export function removeUserFromTeam(teamId, userId, success, error) {
|
||||||
Client.removeUserFromTeam(
|
Client.removeUserFromTeam(
|
||||||
teamId,
|
teamId,
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import $ from 'jquery';
|
|||||||
import SettingItemMin from './setting_item_min.jsx';
|
import SettingItemMin from './setting_item_min.jsx';
|
||||||
import SettingItemMax from './setting_item_max.jsx';
|
import SettingItemMax from './setting_item_max.jsx';
|
||||||
|
|
||||||
import Client from 'client/web_client.jsx';
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
|
||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
|
|
||||||
import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||||
|
import {updateTeam} from 'actions/team_actions.jsx';
|
||||||
|
|
||||||
const holders = defineMessages({
|
const holders = defineMessages({
|
||||||
dirDisabled: {
|
dirDisabled: {
|
||||||
@@ -131,10 +130,8 @@ class GeneralTab extends React.Component {
|
|||||||
|
|
||||||
var data = this.props.team;
|
var data = this.props.team;
|
||||||
data.allow_open_invite = this.state.allow_open_invite;
|
data.allow_open_invite = this.state.allow_open_invite;
|
||||||
Client.updateTeam(data,
|
updateTeam(data,
|
||||||
(team) => {
|
() => {
|
||||||
TeamStore.saveTeam(team);
|
|
||||||
TeamStore.emitChange();
|
|
||||||
this.updateSection('');
|
this.updateSection('');
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -170,10 +167,8 @@ class GeneralTab extends React.Component {
|
|||||||
|
|
||||||
var data = this.props.team;
|
var data = this.props.team;
|
||||||
data.display_name = this.state.name;
|
data.display_name = this.state.name;
|
||||||
Client.updateTeam(data,
|
updateTeam(data,
|
||||||
(team) => {
|
() => {
|
||||||
TeamStore.saveTeam(team);
|
|
||||||
TeamStore.emitChange();
|
|
||||||
this.updateSection('');
|
this.updateSection('');
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -205,10 +200,8 @@ class GeneralTab extends React.Component {
|
|||||||
|
|
||||||
var data = this.props.team;
|
var data = this.props.team;
|
||||||
data.invite_id = this.state.invite_id;
|
data.invite_id = this.state.invite_id;
|
||||||
Client.updateTeam(data,
|
updateTeam(data,
|
||||||
(team) => {
|
() => {
|
||||||
TeamStore.saveTeam(team);
|
|
||||||
TeamStore.emitChange();
|
|
||||||
this.updateSection('');
|
this.updateSection('');
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|||||||
@@ -265,6 +265,10 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
TeamStore.appendMyTeamMember(action.member);
|
TeamStore.appendMyTeamMember(action.member);
|
||||||
TeamStore.emitChange();
|
TeamStore.emitChange();
|
||||||
break;
|
break;
|
||||||
|
case ActionTypes.UPDATE_TEAM:
|
||||||
|
TeamStore.saveTeam(action.team);
|
||||||
|
TeamStore.emitChange();
|
||||||
|
break;
|
||||||
case ActionTypes.RECEIVED_ALL_TEAMS:
|
case ActionTypes.RECEIVED_ALL_TEAMS:
|
||||||
TeamStore.saveTeams(action.teams);
|
TeamStore.saveTeams(action.teams);
|
||||||
TeamStore.emitChange();
|
TeamStore.emitChange();
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export const ActionTypes = keyMirror({
|
|||||||
|
|
||||||
RECEIVED_MY_TEAM: null,
|
RECEIVED_MY_TEAM: null,
|
||||||
CREATED_TEAM: null,
|
CREATED_TEAM: null,
|
||||||
|
UPDATE_TEAM: null,
|
||||||
|
|
||||||
RECEIVED_CONFIG: null,
|
RECEIVED_CONFIG: null,
|
||||||
RECEIVED_LOGS: null,
|
RECEIVED_LOGS: null,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user