// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import * as Utils from 'utils/utils.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); this.handleReloadConfig = this.handleReloadConfig.bind(this); this.state = { loading: false, fail: null }; } handleReloadConfig(e) { e.preventDefault(); this.setState({ loading: true, fail: null }); reloadConfig( () => { this.setState({ loading: false }); }, (err) => { this.setState({ loading: false, fail: err.message + ' - ' + err.detailed_error }); } ); } render() { if (global.window.mm_license.IsLicensed !== 'true') { return
; } let testMessage = null; if (this.state.fail) { testMessage = (
); } const helpText = ( ); let contents = null; if (this.state.loading) { contents = ( {Utils.localizeMessage('admin.reload.loading', ' Loading...')} ); } else { contents = ( ); } return (
{testMessage}
{helpText}
); } }