Skip to content

Commit 2e5bbd8

Browse files
committed
Merge branch 'dev' of https://github.com/appirio-tech/connect-app into dev
* 'dev' of https://github.com/appirio-tech/connect-app: Github issue#2736, [Team Management 2.0] Admin/Managers are not able to add existing users to the customer team — Added the capability of inviting members by handle even in customers section.
2 parents fbcf2b4 + 01b8993 commit 2e5bbd8

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/components/TeamManagement/ProjectManagementDialog.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ class Dialog extends React.Component {
3232

3333
onInviteChange(evt) {
3434
const text = evt.target.value
35-
const emails = text.split(/[,;]/g)
36-
const isInvalid = emails.some(email => {
37-
email = email.trim()
38-
if (email === '') {
39-
return false
40-
}
41-
return !/(.+)@(.+){2,}\.(.+){2,}/.test(email)
35+
const invites = text.split(/[,;]/g)
36+
const isValid = invites.every(invite => {
37+
invite = invite.trim()
38+
return invite.length > 1 && (/(.+)@(.+){2,}\.(.+){2,}/.test(invite) || invite.startsWith('@'))
4239
})
4340
this.setState({
44-
validInviteText: !isInvalid && text.length > 0,
41+
validInviteText: isValid && text.trim().length > 0,
4542
inviteText: evt.target.value
4643
})
4744
}
4845

4946
// SEND INVITES
5047
sendInvites() {
51-
let emails = this.state.inviteText.split(/[,;]/g)
52-
emails = emails.map(email => email.trim())
48+
let invites = this.state.inviteText.split(/[,;]/g)
49+
invites = invites.map(invite => invite.trim())
5350
//emails = emails.filter((email) => /(.+)@(.+){2,}\.(.+){2,}/.test(email))
51+
let handles = invites.filter((invite) => (invite.startsWith('@') && invite.length > 1))
52+
handles = handles.map(handle => handle.replace(/^@/, ''))
53+
const emails = invites.filter((invite) => (!invite.startsWith('@') && invite.length > 1))
5454

55-
this.props.sendInvite(emails)
55+
this.props.sendInvite(emails, handles)
5656
this.setState({clearText: true})
5757
}
5858

@@ -119,6 +119,7 @@ class Dialog extends React.Component {
119119
removeInvite(invite)
120120
}
121121
i++
122+
const username = invite.member ? invite.member.handle : invite.userId
122123
return (
123124
<div
124125
key={i}
@@ -130,7 +131,7 @@ class Dialog extends React.Component {
130131
/>
131132
<div className="member-name member-email">
132133
<span>
133-
{invite.email}
134+
{invite.email || username}
134135
</span>
135136
<span className="email-date">
136137
Invited {moment(invite.createdAt).format('MMM D, YY')}

src/projects/actions/projectMember.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ function inviteMembersWithData(dispatch, projectId, emailIds, handles, role) {
7878
const req = {}
7979
if(value && value.length > 0) {
8080
req.userIds = value.map(member => member.userId)
81-
} else if(emailIds && emailIds.length > 0) {
81+
}
82+
if(emailIds && emailIds.length > 0) {
8283
req.emails = emailIds
8384
}
8485
req.role = role
@@ -131,11 +132,11 @@ export function deleteProjectInvite(projectId, invite) {
131132
}
132133
}
133134

134-
export function inviteProjectMembers(projectId, emailIds) {
135+
export function inviteProjectMembers(projectId, emailIds, handles) {
135136
return (dispatch) => {
136137
return dispatch({
137138
type: INVITE_CUSTOMER,
138-
payload: inviteMembersWithData(dispatch, projectId, emailIds, null, PROJECT_ROLE_CUSTOMER)
139+
payload: inviteMembersWithData(dispatch, projectId, emailIds, handles, PROJECT_ROLE_CUSTOMER)
139140
})
140141
}
141142
}

0 commit comments

Comments
 (0)