// 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 {recycleDatabaseConnection} from 'actions/admin_actions.jsx'; 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 }); 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 = (
); } const helpText = ( ); let contents = null; if (this.state.loading) { contents = ( {Utils.localizeMessage('admin.recycle.loading', ' Recycling...')} ); } else { contents = ( ); } return (
{testMessage}
{helpText}
); } }