// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as utils from '../utils/utils.jsx'; import SettingUpload from './setting_upload.jsx'; import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; const holders = defineMessages({ importSlack: { id: 'team_import_tab.importSlack', defaultMessage: 'Import from Slack (Beta)' } }); class TeamImportTab extends React.Component { constructor(props) { super(props); this.onImportFailure = this.onImportFailure.bind(this); this.onImportSuccess = this.onImportSuccess.bind(this); this.doImportSlack = this.doImportSlack.bind(this); this.state = { status: 'ready', link: '' }; } onImportFailure() { this.setState({status: 'fail', link: ''}); } onImportSuccess(data) { this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(data)}); } doImportSlack(file) { this.setState({status: 'in-progress', link: ''}); utils.importSlack(file, this.onImportSuccess, this.onImportFailure); } render() { const {formatMessage} = this.props.intl; var uploadHelpText = (
); var uploadSection = ( ); var messageSection; switch (this.state.status) { case 'ready': messageSection = ''; break; case 'in-progress': messageSection = (

); break; case 'done': messageSection = (

); break; case 'fail': messageSection = (

); break; } return (

{uploadSection}
{messageSection}
); } } TeamImportTab.propTypes = { intl: intlShape.isRequired }; export default injectIntl(TeamImportTab);