// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import Client from 'utils/web_client.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; export default class ReloadConfigButton extends React.Component { constructor(props) { super(props); this.handleReloadConfig = this.handleReloadConfig.bind(this); this.state = { loading: false, fail: null }; } handleReloadConfig(e) { e.preventDefault(); this.setState({ loading: true, fail: null }); Client.reloadConfig( () => { this.setState({ loading: false }); }, (err) => { this.setState({ loading: false, fail: err.message + ' - ' + err.detailed_error }); } ); } render() { let testMessage = null; if (this.state.fail) { testMessage = (
); } let contents = null; if (this.state.loading) { contents = ( {Utils.localizeMessage('admin.reload.loading', ' Loading...')} ); } else { contents = ( ); } return (
{testMessage}
); } }