Этот коммит содержится в:
=Corey Hulen
2016-04-28 17:03:59 -07:00
родитель ad9dfc9c42 f3fa435a1b
Коммит 62901defae
18 изменённых файлов: 138 добавлений и 53 удалений

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

@@ -143,7 +143,7 @@ check-style:
test: start-docker test: start-docker
@echo Running tests @echo Running tests
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=240s ./api || exit 1 $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s ./api || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1 $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./store || exit 1 $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./store || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1 $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1

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

@@ -513,9 +513,18 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "") return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "")
} }
if result := <-Srv.Store.Channel().GetMember(channel.Id, user.Id); result.Err != nil {
if result.Err.Id != store.MISSING_MEMBER_ERROR {
return nil, result.Err
}
} else {
channelMember := result.Data.(model.ChannelMember)
return &channelMember, nil
}
newMember := &model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, NotifyProps: model.GetDefaultChannelNotifyProps()} newMember := &model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
if cmresult := <-Srv.Store.Channel().SaveMember(newMember); cmresult.Err != nil { if result := <-Srv.Store.Channel().SaveMember(newMember); result.Err != nil {
l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, cmresult.Err) l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, result.Err)
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.app_error", nil, "") return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.app_error", nil, "")
} }

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

@@ -691,8 +691,8 @@ func TestAddChannelMember(t *testing.T) {
t.Fatal("Should have errored, bad user id") t.Fatal("Should have errored, bad user id")
} }
if _, err := Client.AddChannelMember(channel1.Id, user2.Id); err == nil { if _, err := Client.AddChannelMember(channel1.Id, user2.Id); err != nil {
t.Fatal("Should have errored, user already a member") t.Fatal(err)
} }
if _, err := Client.AddChannelMember("sgdsgsdg", user2.Id); err == nil { if _, err := Client.AddChannelMember("sgdsgsdg", user2.Id); err == nil {

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

@@ -22,7 +22,7 @@ func ImportPost(post *model.Post) {
} }
} }
func ImportUser(teamId string, user *model.User) *model.User { func ImportUser(team *model.Team, user *model.User) *model.User {
user.MakeNonNil() user.MakeNonNil()
if result := <-Srv.Store.User().Save(user); result.Err != nil { if result := <-Srv.Store.User().Save(user); result.Err != nil {
@@ -31,14 +31,14 @@ func ImportUser(teamId string, user *model.User) *model.User {
} else { } else {
ruser := result.Data.(*model.User) ruser := result.Data.(*model.User)
if err := JoinDefaultChannels(teamId, ruser, ""); err != nil {
l4g.Error(utils.T("api.import.import_user.joining_default.error"), ruser.Id, teamId, err)
}
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil { if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
l4g.Error(utils.T("api.import.import_user.set_email.error"), cresult.Err) l4g.Error(utils.T("api.import.import_user.set_email.error"), cresult.Err)
} }
if err := JoinUserToTeam(team, user); err != nil {
l4g.Error(utils.T("api.import.import_user.join_team.error"), err)
}
return ruser return ruser
} }
} }

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

@@ -99,6 +99,16 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
log.WriteString("===============\r\n\r\n") log.WriteString("===============\r\n\r\n")
addedUsers := make(map[string]*model.User) addedUsers := make(map[string]*model.User)
// Need the team
var team *model.Team
if result := <-Srv.Store.Team().Get(teamId); result.Err != nil {
log.WriteString(utils.T("api.slackimport.slack_import.team_fail"))
return addedUsers
} else {
team = result.Data.(*model.Team)
}
for _, sUser := range slackusers { for _, sUser := range slackusers {
firstName := "" firstName := ""
lastName := "" lastName := ""
@@ -119,7 +129,7 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
Password: password, Password: password,
} }
if mUser := ImportUser(teamId, &newUser); mUser != nil { if mUser := ImportUser(team, &newUser); mUser != nil {
addedUsers[sUser.Id] = mUser addedUsers[sUser.Id] = mUser
log.WriteString(utils.T("api.slackimport.slack_add_users.email_pwd", map[string]interface{}{"Email": newUser.Email, "Password": password})) log.WriteString(utils.T("api.slackimport.slack_add_users.email_pwd", map[string]interface{}{"Email": newUser.Email, "Password": password}))
} else { } else {
@@ -173,6 +183,18 @@ func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]*
} }
} }
func addSlackUsersToChannel(members []string, users map[string]*model.User, channel *model.Channel, log *bytes.Buffer) {
for _, member := range members {
if user, ok := users[member]; !ok {
log.WriteString(utils.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": "?"}))
} else {
if _, err := AddUserToChannel(user, channel); err != nil {
log.WriteString(utils.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": user.Username}))
}
}
}
}
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(utils.T("api.slackimport.slack_add_channels.added")) log.WriteString(utils.T("api.slackimport.slack_add_channels.added"))
@@ -199,6 +221,7 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
log.WriteString(utils.T("api.slackimport.slack_add_channels.merge", map[string]interface{}{"DisplayName": newChannel.DisplayName})) log.WriteString(utils.T("api.slackimport.slack_add_channels.merge", map[string]interface{}{"DisplayName": newChannel.DisplayName}))
} }
} }
addSlackUsersToChannel(sChannel.Members, users, mChannel, log)
log.WriteString(newChannel.DisplayName + "\r\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)

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

@@ -40,8 +40,8 @@ func InitTeam() {
BaseRoutes.NeedTeam.Handle("/add_user_to_team", ApiUserRequired(addUserToTeam)).Methods("POST") BaseRoutes.NeedTeam.Handle("/add_user_to_team", ApiUserRequired(addUserToTeam)).Methods("POST")
// These should be moved to the global admain console // These should be moved to the global admain console
BaseRoutes.Teams.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST") BaseRoutes.NeedTeam.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
BaseRoutes.Teams.Handle("/export_team", ApiUserRequired(exportTeam)).Methods("GET") BaseRoutes.NeedTeam.Handle("/export_team", ApiUserRequired(exportTeam)).Methods("GET")
BaseRoutes.Teams.Handle("/add_user_to_team_from_invite", ApiUserRequired(addUserToTeamFromInvite)).Methods("POST") BaseRoutes.Teams.Handle("/add_user_to_team_from_invite", ApiUserRequired(addUserToTeamFromInvite)).Methods("POST")
} }

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

@@ -667,6 +667,10 @@
"id": "api.import.import_user.set_email.error", "id": "api.import.import_user.set_email.error",
"translation": "Failed to set email verified err=%v" "translation": "Failed to set email verified err=%v"
}, },
{
"id": "api.import.import_user.join_team.error",
"translation": "Failed to join team when importing err=%v"
},
{ {
"id": "api.license.add_license.array.app_error", "id": "api.license.add_license.array.app_error",
"translation": "Empty array under 'license' in request" "translation": "Empty array under 'license' in request"
@@ -995,6 +999,10 @@
"id": "api.slackimport.slack_add_channels.merge", "id": "api.slackimport.slack_add_channels.merge",
"translation": "Merged with existing channel: {{.DisplayName}}\r\n" "translation": "Merged with existing channel: {{.DisplayName}}\r\n"
}, },
{
"id": "api.slackimport.slack_add_channels.failed_to_add_user",
"translation": "Failed to add user to channel: {{.Username}}\r\n"
},
{ {
"id": "api.slackimport.slack_add_posts.bot.warn", "id": "api.slackimport.slack_add_posts.bot.warn",
"translation": "Slack bot posts are not imported yet" "translation": "Slack bot posts are not imported yet"
@@ -1035,6 +1043,10 @@
"id": "api.slackimport.slack_import.log", "id": "api.slackimport.slack_import.log",
"translation": "Mattermost Slack Import Log\r\n" "translation": "Mattermost Slack Import Log\r\n"
}, },
{
"id": "api.slackimport.slack_import.team_fail",
"translation": "Failed to get team to import into.\r\n"
},
{ {
"id": "api.slackimport.slack_import.note1", "id": "api.slackimport.slack_import.note1",
"translation": "- Some posts may not have been imported because they where not supported by this importer.\r\n" "translation": "- Some posts may not have been imported because they where not supported by this importer.\r\n"
@@ -2851,6 +2863,10 @@
"id": "store.sql_channel.get_for_export.app_error", "id": "store.sql_channel.get_for_export.app_error",
"translation": "We couldn't get all the channels" "translation": "We couldn't get all the channels"
}, },
{
"id": "store.sql_channel.get_member.missing.app_error",
"translation": "No channel member found for that user id and channel id"
},
{ {
"id": "store.sql_channel.get_member.app_error", "id": "store.sql_channel.get_member.app_error",
"translation": "We couldn't get the channel member" "translation": "We couldn't get the channel member"

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

@@ -12,6 +12,7 @@ import (
const ( const (
MISSING_CHANNEL_ERROR = "store.sql_channel.get_by_name.missing.app_error" MISSING_CHANNEL_ERROR = "store.sql_channel.get_by_name.missing.app_error"
MISSING_MEMBER_ERROR = "store.sql_channel.get_member.missing.app_error"
) )
type SqlChannelStore struct { type SqlChannelStore struct {
@@ -572,9 +573,13 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel
result := StoreResult{} result := StoreResult{}
var member model.ChannelMember var member model.ChannelMember
err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId})
if err != nil { if err := s.GetReplica().SelectOne(&member, "SELECT * FROM ChannelMembers WHERE ChannelId = :ChannelId AND UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}); err != nil {
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error()) if err == sql.ErrNoRows {
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", MISSING_MEMBER_ERROR, nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
} else {
result.Err = model.NewLocAppError("SqlChannelStore.GetMember", "store.sql_channel.get_member.app_error", nil, "channel_id="+channelId+"user_id="+userId+","+err.Error())
}
} else { } else {
result.Data = member result.Data = member
} }

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

@@ -348,10 +348,9 @@ export default class Client {
importSlack = (fileData, success, error) => { importSlack = (fileData, success, error) => {
request. request.
post(`${this.getTeamsRoute()}/import_team`). post(`${this.getTeamNeededRoute()}/import_team`).
set(this.defaultHeaders). set(this.defaultHeaders).
type('application/json'). accept('application/octet-stream').
accept('application/json').
send(fileData). send(fileData).
end(this.handleResponse.bind(this, 'importSlack', success, error)); end(this.handleResponse.bind(this, 'importSlack', success, error));
} }

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

@@ -5,7 +5,6 @@ import $ from 'jquery';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import React from 'react'; import React from 'react';
import {Link} from 'react-router';
export default class NotLoggedIn extends React.Component { export default class NotLoggedIn extends React.Component {
componentDidMount() { componentDidMount() {
@@ -30,34 +29,38 @@ export default class NotLoggedIn extends React.Component {
</div> </div>
<div className='col-xs-12'> <div className='col-xs-12'>
<span className='pull-right footer-link copyright'>{'© 2015 Mattermost, Inc.'}</span> <span className='pull-right footer-link copyright'>{'© 2015 Mattermost, Inc.'}</span>
<Link <a
id='help_link' id='help_link'
className='pull-right footer-link' className='pull-right footer-link'
to={global.window.mm_config.HelpLink} target='_blank'
href={global.window.mm_config.HelpLink}
> >
<FormattedMessage id='web.footer.help'/> <FormattedMessage id='web.footer.help'/>
</Link> </a>
<Link <a
id='terms_link' id='terms_link'
className='pull-right footer-link' className='pull-right footer-link'
to={global.window.mm_config.TermsOfServiceLink} target='_blank'
href={global.window.mm_config.TermsOfServiceLink}
> >
<FormattedMessage id='web.footer.terms'/> <FormattedMessage id='web.footer.terms'/>
</Link> </a>
<Link <a
id='privacy_link' id='privacy_link'
className='pull-right footer-link' className='pull-right footer-link'
to={global.window.mm_config.PrivacyPolicyLink} target='_blank'
href={global.window.mm_config.PrivacyPolicyLink}
> >
<FormattedMessage id='web.footer.privacy'/> <FormattedMessage id='web.footer.privacy'/>
</Link> </a>
<Link <a
id='about_link' id='about_link'
className='pull-right footer-link' className='pull-right footer-link'
to={global.window.mm_config.AboutLink} target='_blank'
href={global.window.mm_config.AboutLink}
> >
<FormattedMessage id='web.footer.about'/> <FormattedMessage id='web.footer.about'/>
</Link> </a>
</div> </div>
</div> </div>
</div> </div>

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

@@ -9,8 +9,12 @@ function getCountsStateFromStores() {
var channels = ChannelStore.getAll(); var channels = ChannelStore.getAll();
var members = ChannelStore.getAllMembers(); var members = ChannelStore.getAllMembers();
channels.forEach(function setChannelInfo(channel) { channels.forEach((channel) => {
var channelMember = members[channel.id]; var channelMember = members[channel.id];
if (channelMember == null) {
return;
}
if (channel.type === 'D') { if (channel.type === 'D') {
count += channel.total_msg_count - channelMember.msg_count; count += channel.total_msg_count - channelMember.msg_count;
} else if (channelMember.mention_count > 0) { } else if (channelMember.mention_count > 0) {
@@ -20,7 +24,7 @@ function getCountsStateFromStores() {
} }
}); });
return {count: count}; return {count};
} }
import React from 'react'; import React from 'react';

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

@@ -16,6 +16,8 @@ import {createChannelIntroMessage} from 'utils/channel_intro_messages.jsx';
import React from 'react'; import React from 'react';
const MAXIMUM_CACHED_VIEWS = 3;
export default class PostsViewContainer extends React.Component { export default class PostsViewContainer extends React.Component {
constructor() { constructor() {
super(); super();
@@ -105,6 +107,12 @@ export default class PostsViewContainer extends React.Component {
let newIndex = channels.indexOf(channelId); let newIndex = channels.indexOf(channelId);
if (newIndex === -1) { if (newIndex === -1) {
if (channels.length >= MAXIMUM_CACHED_VIEWS) {
channels.shift();
atTop.shift();
postLists.shift();
}
newIndex = channels.length; newIndex = channels.length;
channels.push(channelId); channels.push(channelId);
atTop[newIndex] = PostStore.getVisibilityAtTop(channelId); atTop[newIndex] = PostStore.getVisibilityAtTop(channelId);
@@ -172,7 +180,7 @@ export default class PostsViewContainer extends React.Component {
const isActive = (channels[i] === currentChannelId); const isActive = (channels[i] === currentChannelId);
postListCtls.push( postListCtls.push(
<PostsView <PostsView
key={'postsviewkey' + i} key={'postsviewkey' + channels[i]}
isActive={isActive} isActive={isActive}
postList={postLists[i]} postList={postLists[i]}
scrollType={this.state.scrollType} scrollType={this.state.scrollType}

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

@@ -33,8 +33,8 @@ class TeamImportTab extends React.Component {
this.setState({status: 'fail', link: ''}); this.setState({status: 'fail', link: ''});
} }
onImportSuccess(data) { onImportSuccess(data, res) {
this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(data)}); this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(res.text)});
} }
doImportSlack(file) { doImportSlack(file) {

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

@@ -18,7 +18,10 @@
.popover-title { .popover-title {
background: alpha-color($black, .05); background: alpha-color($black, .05);
max-width: 100%;
overflow: hidden;
padding: 8px 10px; padding: 8px 10px;
text-overflow: ellipsis;
} }
.popover-content { .popover-content {

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

@@ -82,6 +82,12 @@
.channel-intro-profile { .channel-intro-profile {
margin-left: 63px; margin-left: 63px;
margin-top: 5px; margin-top: 5px;
.user-popover {
max-width: calc(100% - 100px);
overflow: hidden;
text-overflow: ellipsis;
}
} }
.channel-intro-img { .channel-intro-img {
@@ -106,6 +112,7 @@
.channel-intro-text { .channel-intro-text {
margin-top: 35px; margin-top: 35px;
word-break: break-all;
} }
} }
@@ -308,7 +315,7 @@
font-size: 1.3em; font-size: 1.3em;
font-weight: 600; font-weight: 600;
margin: 0 4px 0 0; margin: 0 4px 0 0;
max-width: 100%; max-width: calc(100% - 50px);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
vertical-align: middle; vertical-align: middle;

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

@@ -70,8 +70,12 @@
.heading { .heading {
color: $white; color: $white;
display: inline-block;
font-weight: 600; font-weight: 600;
margin-right: 3px; margin-right: 3px;
overflow: hidden;
vertical-align: top;
width: calc(100% - 200px);
} }
.header-dropdown__icon { .header-dropdown__icon {

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

@@ -11,6 +11,10 @@
} }
} }
.user-popover {
pointer-events: none;
}
.signup-team__container { .signup-team__container {
font-size: 1em; font-size: 1em;
} }

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

@@ -33,16 +33,16 @@ class UserTypingStoreClass extends EventEmitter {
this.removeListener(CHANGE_EVENT, callback); this.removeListener(CHANGE_EVENT, callback);
} }
usernameFromId(userId) { nameFromId(userId) {
let username = Utils.localizeMessage('msg_typing.someone', 'Someone'); let name = Utils.localizeMessage('msg_typing.someone', 'Someone');
if (UserStore.hasProfile(userId)) { if (UserStore.hasProfile(userId)) {
username = UserStore.getProfile(userId).username; name = Utils.displayUsername(userId);
} }
return username; return name;
} }
userTyping(channelId, userId, postParentId) { userTyping(channelId, userId, postParentId) {
const username = this.usernameFromId(userId); const name = this.nameFromId(userId);
// Key representing a location where users can type // Key representing a location where users can type
const loc = channelId + postParentId; const loc = channelId + postParentId;
@@ -53,15 +53,15 @@ class UserTypingStoreClass extends EventEmitter {
} }
// If we already have this user, clear it's timeout to be deleted // If we already have this user, clear it's timeout to be deleted
if (this.typingUsers[loc][username]) { if (this.typingUsers[loc][name]) {
clearTimeout(this.typingUsers[loc][username].timeout); clearTimeout(this.typingUsers[loc][name].timeout);
} }
// Set the user and a timeout to remove it // Set the user and a timeout to remove it
this.typingUsers[loc][username] = setTimeout(() => { this.typingUsers[loc][name] = setTimeout(() => {
delete this.typingUsers[loc][username]; Reflect.deleteProperty(this.typingUsers[loc], name);
if (this.typingUsers[loc] === {}) { if (this.typingUsers[loc] === {}) {
delete this.typingUsers[loc]; Reflect.deleteProperty(this.typingUsers, loc);
} }
this.emitChange(); this.emitChange();
}, Constants.UPDATE_TYPING_MS); }, Constants.UPDATE_TYPING_MS);
@@ -76,14 +76,14 @@ class UserTypingStoreClass extends EventEmitter {
} }
userPosted(userId, channelId, postParentId) { userPosted(userId, channelId, postParentId) {
const username = this.usernameFromId(userId); const name = this.nameFromId(userId);
const loc = channelId + postParentId; const loc = channelId + postParentId;
if (this.typingUsers[loc]) { if (this.typingUsers[loc]) {
clearTimeout(this.typingUsers[loc][username]); clearTimeout(this.typingUsers[loc][name]);
delete this.typingUsers[loc][username]; Reflect.deleteProperty(this.typingUsers[loc], name);
if (this.typingUsers[loc] === {}) { if (this.typingUsers[loc] === {}) {
delete this.typingUsers[loc]; Reflect.deleteProperty(this.typingUsers, loc);
} }
this.emitChange(); this.emitChange();
} }