// 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 SyncNowButton extends React.Component { static get propTypes() { return { disabled: React.PropTypes.bool }; } constructor(props) { super(props); this.handleSyncNow = this.handleSyncNow.bind(this); this.state = { buisy: false, fail: null }; } handleSyncNow(e) { e.preventDefault(); this.setState({ buisy: true, fail: null }); Client.ldapSyncNow( () => { this.setState({ buisy: false }); }, (err) => { this.setState({ buisy: false, fail: err.message + ' - ' + err.detailed_error }); } ); } render() { let failMessage = null; if (this.state.fail) { failMessage = (
); } const helpText = ( ); let contents = null; if (this.state.loading) { contents = ( {Utils.localizeMessage('admin.reload.loading', ' Loading...')} ); } else { contents = ( ); } return (
{failMessage}
{helpText}
); } }