// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import Client from 'client/web_client.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; export default class RecycleDbButton extends React.Component { constructor(props) { super(props); this.handleRecycle = this.handleRecycle.bind(this); this.state = { loading: false, fail: null }; } handleRecycle(e) { e.preventDefault(); this.setState({ loading: true, fail: null }); Client.recycleDatabaseConnection( () => { 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 = (
); } let helpText = ( ); let contents = null; if (this.state.loading) { contents = ( {Utils.localizeMessage('admin.recycle.loading', ' Recycling...')} ); } else { contents = ( ); } return (
{testMessage}
{helpText}
); } }