Move remaining client functions in components to actions (#5171)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
49c677f6b4
Коммит
d72547433a
@@ -4,11 +4,12 @@
|
||||
import React from 'react';
|
||||
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
import Client from 'client/web_client.jsx';
|
||||
|
||||
import FormError from 'components/form_error.jsx';
|
||||
import SaveButton from 'components/admin_console/save_button.jsx';
|
||||
|
||||
import {saveConfig} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class AdminSettings extends React.Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
@@ -53,7 +54,7 @@ export default class AdminSettings extends React.Component {
|
||||
let config = JSON.parse(JSON.stringify(this.props.config));
|
||||
config = this.getConfigFromState(config);
|
||||
|
||||
Client.saveConfig(
|
||||
saveConfig(
|
||||
config,
|
||||
() => {
|
||||
AsyncClient.getConfig((savedConfig) => {
|
||||
|
||||
@@ -6,12 +6,10 @@ import ConfirmModal from '../confirm_modal.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
import {updateUserRoles, updateActive} from 'actions/user_actions.jsx';
|
||||
import {updateTeamMemberRoles} from 'actions/team_actions.jsx';
|
||||
import {updateTeamMemberRoles, removeUserFromTeam, adminResetMfa} from 'actions/team_actions.jsx';
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
@@ -75,14 +73,10 @@ export default class AdminTeamMembersDropdown extends React.Component {
|
||||
}
|
||||
|
||||
handleRemoveFromTeam() {
|
||||
Client.removeUserFromTeam(
|
||||
removeUserFromTeam(
|
||||
this.props.teamMember.team_id,
|
||||
this.props.user.id,
|
||||
() => {
|
||||
AsyncClient.getTeamStats(this.props.teamMember.team_id);
|
||||
UserStore.removeProfileFromTeam(this.props.teamMember.team_id, this.props.user.id);
|
||||
UserStore.emitInTeamChange();
|
||||
},
|
||||
null,
|
||||
(err) => {
|
||||
this.setState({serverError: err.message});
|
||||
}
|
||||
@@ -150,10 +144,8 @@ export default class AdminTeamMembersDropdown extends React.Component {
|
||||
handleResetMfa(e) {
|
||||
e.preventDefault();
|
||||
|
||||
Client.adminResetMfa(this.props.user.id,
|
||||
() => {
|
||||
AsyncClient.getUser(this.props.user.id);
|
||||
},
|
||||
adminResetMfa(this.props.user.id,
|
||||
null,
|
||||
(err) => {
|
||||
this.setState({serverError: err.message});
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import ReactDOM from 'react-dom';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import {uploadBrandImage} from 'actions/admin_actions.jsx';
|
||||
|
||||
import FormError from 'components/form_error.jsx';
|
||||
import {FormattedHTMLMessage, FormattedMessage} from 'react-intl';
|
||||
@@ -81,7 +82,7 @@ export default class BrandImageSetting extends React.Component {
|
||||
error: ''
|
||||
});
|
||||
|
||||
Client.uploadBrandImage(
|
||||
uploadBrandImage(
|
||||
this.state.brandImage,
|
||||
() => {
|
||||
$(ReactDOM.findDOMNode(this.refs.upload)).button('complete');
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
import React from 'react';
|
||||
import ClusterTable from './cluster_table.jsx';
|
||||
import LoadingScreen from '../loading_screen.jsx';
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
|
||||
import {getClusterStatus} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class ClusterTableContainer extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -19,15 +19,13 @@ export default class ClusterTableContainer extends React.Component {
|
||||
}
|
||||
|
||||
load() {
|
||||
Client.getClusterStatus(
|
||||
getClusterStatus(
|
||||
(data) => {
|
||||
this.setState({
|
||||
clusterInfos: data
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'getClusterStatus');
|
||||
}
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import UserStore from '../../stores/user_store.jsx';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as AsyncClient from '../../utils/async_client.jsx';
|
||||
import {saveComplianceReports} from 'actions/admin_actions.jsx';
|
||||
|
||||
import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl';
|
||||
|
||||
@@ -72,7 +73,7 @@ export default class ComplianceReports extends React.Component {
|
||||
job.start_at = Date.parse(ReactDOM.findDOMNode(this.refs.from).value);
|
||||
job.end_at = Date.parse(ReactDOM.findDOMNode(this.refs.to).value);
|
||||
|
||||
Client.saveComplianceReports(
|
||||
saveComplianceReports(
|
||||
job,
|
||||
() => {
|
||||
ReactDOM.findDOMNode(this.refs.emails).value = '';
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import {testEmail} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class EmailConnectionTestButton extends React.Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
@@ -41,7 +42,7 @@ export default class EmailConnectionTestButton extends React.Component {
|
||||
const config = JSON.parse(JSON.stringify(this.props.config));
|
||||
this.props.getConfigFromState(config);
|
||||
|
||||
Client.testEmail(
|
||||
testEmail(
|
||||
config,
|
||||
() => {
|
||||
this.setState({
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
import {ldapTest} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class LdapTestButton extends React.Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
@@ -38,7 +39,7 @@ export default class LdapTestButton extends React.Component {
|
||||
});
|
||||
|
||||
const doRequest = () => { //eslint-disable-line func-style
|
||||
Client.ldapTest(
|
||||
ldapTest(
|
||||
() => {
|
||||
this.setState({
|
||||
buisy: false,
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import $ from 'jquery';
|
||||
import ReactDOM from 'react-dom';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import Client from 'client/web_client.jsx';
|
||||
|
||||
import {uploadLicenseFile, removeLicenseFile} from 'actions/admin_actions.jsx';
|
||||
|
||||
import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
@@ -54,7 +55,8 @@ class LicenseSettings extends React.Component {
|
||||
|
||||
$('#upload-button').button('loading');
|
||||
|
||||
Client.uploadLicenseFile(file,
|
||||
uploadLicenseFile(
|
||||
file,
|
||||
() => {
|
||||
Utils.clearFileInput(element[0]);
|
||||
$('#upload-button').button('reset');
|
||||
@@ -74,7 +76,7 @@ class LicenseSettings extends React.Component {
|
||||
|
||||
$('#remove-button').button('loading');
|
||||
|
||||
Client.removeLicenseFile(
|
||||
removeLicenseFile(
|
||||
() => {
|
||||
$('#remove-button').button('reset');
|
||||
this.setState({fileSelected: false, fileName: null, serverError: null});
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import {invalidateAllCaches} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class PurgeCachesButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -27,7 +27,7 @@ export default class PurgeCachesButton extends React.Component {
|
||||
fail: null
|
||||
});
|
||||
|
||||
Client.invalidateAllCaches(
|
||||
invalidateAllCaches(
|
||||
() => {
|
||||
this.setState({
|
||||
loading: false
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
import {recycleDatabaseConnection} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class RecycleDbButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -28,7 +29,7 @@ export default class RecycleDbButton extends React.Component {
|
||||
fail: null
|
||||
});
|
||||
|
||||
Client.recycleDatabaseConnection(
|
||||
recycleDatabaseConnection(
|
||||
() => {
|
||||
this.setState({
|
||||
loading: false
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {getConfig} from 'utils/async_client.jsx';
|
||||
|
||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
import {reloadConfig} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class ReloadConfigButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -30,9 +29,8 @@ export default class ReloadConfigButton extends React.Component {
|
||||
fail: null
|
||||
});
|
||||
|
||||
Client.reloadConfig(
|
||||
reloadConfig(
|
||||
() => {
|
||||
getConfig();
|
||||
this.setState({
|
||||
loading: false
|
||||
});
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import {Modal} from 'react-bootstrap';
|
||||
|
||||
import {injectIntl, intlShape, FormattedMessage} from 'react-intl';
|
||||
|
||||
import {adminResetPassword} from 'actions/admin_actions.jsx';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
class ResetPasswordModal extends React.Component {
|
||||
@@ -32,7 +33,7 @@ class ResetPasswordModal extends React.Component {
|
||||
}
|
||||
this.setState({serverError: null});
|
||||
|
||||
Client.adminResetPassword(
|
||||
adminResetPassword(
|
||||
this.props.user.id,
|
||||
password,
|
||||
() => {
|
||||
|
||||
@@ -12,9 +12,10 @@ import RemoveFileSetting from './remove_file_setting.jsx';
|
||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
import SettingsGroup from './settings_group.jsx';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {samlCertificateStatus, uploadCertificateFile, removeCertificateFile} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class SamlSettings extends AdminSettings {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -73,7 +74,7 @@ export default class SamlSettings extends AdminSettings {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
Client.samlCertificateStatus(
|
||||
samlCertificateStatus(
|
||||
(data) => {
|
||||
const files = {};
|
||||
if (!data.IdpCertificateFile) {
|
||||
@@ -93,7 +94,7 @@ export default class SamlSettings extends AdminSettings {
|
||||
}
|
||||
|
||||
uploadCertificate(id, file, callback) {
|
||||
Client.uploadCertificateFile(
|
||||
uploadCertificateFile(
|
||||
file,
|
||||
() => {
|
||||
const fileName = file.name;
|
||||
@@ -112,7 +113,7 @@ export default class SamlSettings extends AdminSettings {
|
||||
}
|
||||
|
||||
removeCertificate(id, callback) {
|
||||
Client.removeCertificateFile(
|
||||
removeCertificateFile(
|
||||
this.state[id],
|
||||
() => {
|
||||
this.handleChange(id, '');
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||
|
||||
import {ldapSyncNow} from 'actions/admin_actions.jsx';
|
||||
|
||||
export default class SyncNowButton extends React.Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
@@ -33,7 +34,7 @@ export default class SyncNowButton extends React.Component {
|
||||
fail: null
|
||||
});
|
||||
|
||||
Client.ldapSyncNow(
|
||||
ldapSyncNow(
|
||||
() => {
|
||||
this.setState({
|
||||
buisy: false
|
||||
|
||||
Ссылка в новой задаче
Block a user