Merge pull request #484 from mattermost/mm-1994

MM-1994 Improvements to import UI
Этот коммит содержится в:
Corey Hulen
2015-08-27 08:32:09 -07:00
родитель e1c09605dc 1ed6718dd9
Коммит d3093028cf
3 изменённых файлов: 31 добавлений и 31 удалений

Просмотреть файл

@@ -82,8 +82,8 @@ func SlackParsePosts(data io.Reader) []SlackPost {
func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map[string]*model.User { func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map[string]*model.User {
// Log header // Log header
log.WriteString("\n Users Created\n") log.WriteString("\r\n Users Created\r\n")
log.WriteString("===============\n\n") log.WriteString("===============\r\n\r\n")
addedUsers := make(map[string]*model.User) addedUsers := make(map[string]*model.User)
for _, sUser := range slackusers { for _, sUser := range slackusers {
@@ -109,9 +109,9 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
if mUser := ImportUser(&newUser); mUser != nil { if mUser := ImportUser(&newUser); mUser != nil {
addedUsers[sUser.Id] = mUser addedUsers[sUser.Id] = mUser
log.WriteString("Email, Password: " + newUser.Email + ", " + password + "\n") log.WriteString("Email, Password: " + newUser.Email + ", " + password + "\r\n")
} else { } else {
log.WriteString("Unable to import user: " + sUser.Username) log.WriteString("Unable to import user: " + sUser.Username + "\r\n")
} }
} }
@@ -163,8 +163,8 @@ func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]*
func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel { func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel {
// Write Header // Write Header
log.WriteString("\n Channels Added \n") log.WriteString("\r\n Channels Added \r\n")
log.WriteString("=================\n\n") log.WriteString("=================\r\n\r\n")
addedChannels := make(map[string]*model.Channel) addedChannels := make(map[string]*model.Channel)
for _, sChannel := range slackchannels { for _, sChannel := range slackchannels {
@@ -180,14 +180,14 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
// Maybe it already exists? // Maybe it already exists?
if result := <-Srv.Store.Channel().GetByName(teamId, sChannel.Name); result.Err != nil { if result := <-Srv.Store.Channel().GetByName(teamId, sChannel.Name); result.Err != nil {
l4g.Debug("Failed to import: %s", newChannel.DisplayName) l4g.Debug("Failed to import: %s", newChannel.DisplayName)
log.WriteString("Failed to import: " + newChannel.DisplayName + "\n") log.WriteString("Failed to import: " + newChannel.DisplayName + "\r\n")
continue continue
} else { } else {
mChannel = result.Data.(*model.Channel) mChannel = result.Data.(*model.Channel)
log.WriteString("Merged with existing channel: " + newChannel.DisplayName + "\n") log.WriteString("Merged with existing channel: " + newChannel.DisplayName + "\r\n")
} }
} }
log.WriteString(newChannel.DisplayName + "\n") log.WriteString(newChannel.DisplayName + "\r\n")
addedChannels[sChannel.Id] = mChannel addedChannels[sChannel.Id] = mChannel
SlackAddPosts(mChannel, posts[sChannel.Name], users) SlackAddPosts(mChannel, posts[sChannel.Name], users)
} }
@@ -202,7 +202,7 @@ func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model
} }
// Create log file // Create log file
log := bytes.NewBufferString("Mattermost Slack Import Log\n") log := bytes.NewBufferString("Mattermost Slack Import Log\r\n")
var channels []SlackChannel var channels []SlackChannel
var users []SlackUser var users []SlackUser
@@ -234,11 +234,11 @@ func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model
addedUsers := SlackAddUsers(teamID, users, log) addedUsers := SlackAddUsers(teamID, users, log)
SlackAddChannels(teamID, channels, posts, addedUsers, log) SlackAddChannels(teamID, channels, posts, addedUsers, log)
log.WriteString("\n Notes \n") log.WriteString("\r\n Notes \r\n")
log.WriteString("=======\n\n") log.WriteString("=======\r\n\r\n")
log.WriteString("- Some posts may not have been imported because they where not supported by this importer.\n") log.WriteString("- Some posts may not have been imported because they where not supported by this importer.\r\n")
log.WriteString("- Slack bot posts are currently not supported.\n") log.WriteString("- Slack bot posts are currently not supported.\r\n")
return nil, log return nil, log
} }

Просмотреть файл

@@ -8,7 +8,8 @@ module.exports = React.createClass({
submit: React.PropTypes.func.isRequired, submit: React.PropTypes.func.isRequired,
fileTypesAccepted: React.PropTypes.string.isRequired, fileTypesAccepted: React.PropTypes.string.isRequired,
clientError: React.PropTypes.string, clientError: React.PropTypes.string,
serverError: React.PropTypes.string serverError: React.PropTypes.string,
helpText: React.PropTypes.string
}, },
getInitialState: function() { getInitialState: function() {
return { return {
@@ -38,14 +39,6 @@ module.exports = React.createClass({
this.setState({clientError: 'No file selected.'}); this.setState({clientError: 'No file selected.'});
} }
}, },
doCancel: function(e) {
e.preventDefault();
this.refs.uploadinput.getDOMNode().value = '';
this.setState({
clientError: '',
serverError: ''
});
},
onFileSelect: function(e) { onFileSelect: function(e) {
var filename = $(e.target).val(); var filename = $(e.target).val();
if (filename.substring(3, 11) === 'fakepath') { if (filename.substring(3, 11) === 'fakepath') {
@@ -70,6 +63,7 @@ module.exports = React.createClass({
return ( return (
<ul className='section-max'> <ul className='section-max'>
<li className='col-xs-12 section-title'>{this.props.title}</li> <li className='col-xs-12 section-title'>{this.props.title}</li>
<li className='col-xs-offset-3'>{this.props.helpText}</li>
<li className='col-xs-offset-3 col-xs-8'> <li className='col-xs-offset-3 col-xs-8'>
<ul className='setting-list'> <ul className='setting-list'>
<li className='setting-list-item'> <li className='setting-list-item'>
@@ -79,12 +73,6 @@ module.exports = React.createClass({
onClick={this.doSubmit}> onClick={this.doSubmit}>
Import Import
</a> </a>
<a
className='btn btn-sm btn-link theme'
href='#'
onClick={this.doCancel}>
Cancel
</a>
<div className='file-status file-name hide'></div> <div className='file-status file-name hide'></div>
{serverError} {serverError}
{clientError} {clientError}

Просмотреть файл

@@ -20,10 +20,22 @@ module.exports = React.createClass({
utils.importSlack(file, this.onImportSuccess, this.onImportFailure); utils.importSlack(file, this.onImportSuccess, this.onImportFailure);
}, },
render: function() { render: function() {
var uploadHelpText = (
<div>
<br/>
Slack does now allow you to export any of your files or images stored in slack. Private channels and direct message channels are also not exported. Therefore, no files, images, or private channels will be imported.
<br/>
Slack bot posts are not imported.
<br/>
Unable to import Slack channels that are not valid Mattermost channels. (ex underscores)
<br/>
</div>
);
var uploadSection = ( var uploadSection = (
<SettingUpload <SettingUpload
title='Import from Slack' title='Import from Slack'
submit={this.doImportSlack} submit={this.doImportSlack}
helpText={uploadHelpText}
fileTypesAccepted='.zip'/> fileTypesAccepted='.zip'/>
); );
@@ -39,12 +51,12 @@ module.exports = React.createClass({
break; break;
case 'done': case 'done':
messageSection = ( messageSection = (
<p className="confirm-import alert alert-success"><i className="fa fa-check"></i> Import sucessfull: <a href={this.state.link} download='MattermostImportSummery.txt'>View Summery</a></p> <p className="confirm-import alert alert-success"><i className="fa fa-check"></i> Import successful: <a href={this.state.link} download='MattermostImportSummary.txt'>View Summary</a></p>
); );
break; break;
case 'fail': case 'fail':
messageSection = ( messageSection = (
<p className="confirm-import alert alert-warning"><i className="fa fa-warning"></i> Import failure: <a href={this.state.link} download='MattermostImportSummery.txt'>View Summery</a></p> <p className="confirm-import alert alert-warning"><i className="fa fa-warning"></i> Import failure: <a href={this.state.link} download='MattermostImportSummary.txt'>View Summary</a></p>
); );
break; break;
} }