// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Client from '../utils/client.jsx'; export default class TeamExportTab extends React.Component { constructor(props) { super(props); this.state = {status: 'request', link: '', err: ''}; this.onExportSuccess = this.onExportSuccess.bind(this); this.onExportFailure = this.onExportFailure.bind(this); this.doExport = this.doExport.bind(this); } onExportSuccess(data) { this.setState({status: 'ready', link: data.link, err: ''}); } onExportFailure(e) { this.setState({status: 'failure', link: '', err: e.message}); } doExport() { if (this.state.status === 'in-progress') { return; } this.setState({status: 'in-progress'}); Client.exportTeam(this.onExportSuccess, this.onExportFailure); } render() { var messageSection = ''; switch (this.state.status) { case 'request': messageSection = ''; break; case 'in-progress': messageSection = (
{' Exporting...'}
); break; case 'ready': messageSection = ({' Ready for '} {'download'}
); break; case 'failure': messageSection = ({' Unable to export: ' + this.state.err}
); break; } return (