Skip to content

Commit cc78293

Browse files
committed
copilot workflow changes
1 parent 7cf6bd3 commit cc78293

File tree

9 files changed

+118
-33
lines changed

9 files changed

+118
-33
lines changed

src/components/TeamManagement/TeamManagement.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TeamManagement extends React.Component {
5656
showNewMemberConfirmation, onJoin, onJoinConfirm, onShowProjectDialog, isShowProjectDialog,
5757
projectTeamInvites, onProjectInviteDeleteConfirm, onProjectInviteSend, deletingInvite, changeRole,
5858
onDeleteInvite, isShowTopcoderDialog, onShowTopcoderDialog, processingInvites, processingMembers,
59-
onTopcoderInviteSend, onTopcoderInviteDeleteConfirm, topcoderTeamInvites, error
59+
onTopcoderInviteSend, onTopcoderInviteDeleteConfirm, topcoderTeamInvites, onAcceptOrRefuse, error
6060
} = this.props
6161
const currentMember = members.filter((member) => member.userId === currentUser.userId)[0]
6262
const modalActive = isAddingTeamMember || deletingMember || isShowJoin || showNewMemberConfirmation || deletingInvite
@@ -196,8 +196,11 @@ class TeamManagement extends React.Component {
196196
/>
197197
)
198198
})())}
199-
{(!modalActive && isShowTopcoderDialog) && ((() => {
200-
const onClickCancel = () => onShowTopcoderDialog(false)
199+
{(!modalActive && (isShowTopcoderDialog || this.props.history.location.hash === '#manageTopcoderTeam')) && ((() => {
200+
const onClickCancel = () => {
201+
this.props.history.push(this.props.history.location.pathname)
202+
onShowTopcoderDialog(false)
203+
}
201204
const removeMember = (member) => {
202205
onMemberDelete(member)
203206
}
@@ -214,6 +217,7 @@ class TeamManagement extends React.Component {
214217
onCancel={onClickCancel}
215218
removeMember={removeMember}
216219
addUsers={onTopcoderInviteSend}
220+
approveOrDecline={onAcceptOrRefuse}
217221
invites={topcoderTeamInvites}
218222
removeInvite={removeInvite}
219223
changeRole={changeRole}
@@ -370,6 +374,11 @@ TeamManagement.propTypes = {
370374
*/
371375
onTopcoderInviteSend: PropTypes.func,
372376

377+
/**
378+
* Callback to accept or refuse invite
379+
*/
380+
onAcceptOrRefuse: PropTypes.func,
381+
373382
/**
374383
* Callback to send member role
375384
*/

src/components/TeamManagement/TeamManagement.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@
212212
font-size: $tc-label-sm;
213213
cursor: pointer;
214214

215+
span {
216+
margin-left: $base-unit*3;
217+
}
218+
215219
.email-date {
216220
cursor: default;
217221
color: $tc-gray-40;
218-
margin-left: $base-unit*3;
219222

220223
@media screen and (max-width: $screen-md - 1px) {
221224
display: none;

src/components/TeamManagement/TopcoderManagementDialog.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ class Dialog extends React.Component {
112112
}
113113

114114
render() {
115-
const {members, currentUser, isMember, removeMember, onCancel, removeInvite, invites = []} = this.props
115+
const {members, currentUser, isMember, removeMember, onCancel, removeInvite, approveOrDecline, invites = []} = this.props
116116
const showRemove = currentUser.isAdmin || (isMember && currentUser.isManager)
117+
const showApproveDecline = currentUser.isCopilotManager
117118
let i = 0
118119
return (
119120
<Modal
@@ -226,6 +227,18 @@ class Dialog extends React.Component {
226227
const remove = () => {
227228
removeInvite(invite)
228229
}
230+
const approve = () => {
231+
approveOrDecline({
232+
userId: invite.userId,
233+
status: 'accepted'
234+
})
235+
}
236+
const decline = () => {
237+
approveOrDecline({
238+
userId: invite.userId,
239+
status: 'refused'
240+
})
241+
}
229242
const firstName = _.get(invite.member, 'firstName', '')
230243
const lastName = _.get(invite.member, 'lastName', '')
231244
let userFullName = `${firstName} ${lastName}`
@@ -247,7 +260,14 @@ class Dialog extends React.Component {
247260
@{invite.member.handle || 'ConnectUser'}
248261
</span>
249262
</div>
250-
{showRemove && <div className="member-remove" onClick={remove}>
263+
{showApproveDecline && <div className="member-remove">
264+
<span onClick={approve}>approve</span>
265+
<span onClick={decline}>decline</span>
266+
<span className="email-date">
267+
requested {moment(invite.createdAt).format('MMM D, YY')}
268+
</span>
269+
</div>}
270+
{!showApproveDecline && showRemove && <div className="member-remove" onClick={remove}>
251271
Remove
252272
<span className="email-date">
253273
Invited {moment(invite.createdAt).format('MMM D, YY')}
@@ -269,7 +289,7 @@ class Dialog extends React.Component {
269289
disabled={(!currentUser.isAdmin && !isMember) || this.state.clearText}
270290
/>
271291
{ this.state.showAlreadyMemberError && <div className="error-message">
272-
Project Member(s) can't be invited again. Please remove them from list.
292+
'Project Member(s) can\'t be invited again. Please remove them from list.'
273293
</div> }
274294
<SelectDropdown
275295
name="role"
@@ -305,6 +325,7 @@ Dialog.propTypes = {
305325
changeRole: PT.func.isRequired,
306326
invites: PT.arrayOf(PT.object),
307327
addUsers: PT.func.isRequired,
328+
approveOrDecline: PT.func.isRequired,
308329
removeInvite: PT.func.isRequired,
309330
}
310331

src/config/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ export const EVENT_TYPE = {
780780
MANAGER_JOINED: 'notifications.connect.project.member.managerJoined',
781781
COPILOT_JOINED: 'notifications.connect.project.member.copilotJoined',
782782
ASSIGNED_AS_OWNER: 'notifications.connect.project.member.assignedAsOwner',
783+
INVITE_REQUESTED: 'notifications.connect.project.member.invite.requested',
784+
COPILOT_ADDED: 'notifications.connect.project.member.copilot.added',
785+
COPILOT_REFUSED: 'notifications.connect.project.member.copilot.refused',
783786
},
784787
PROJECT: {
785788
ACTIVE: 'notifications.connect.project.active',

src/projects/detail/containers/TeamManagementContainer.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TeamManagementContainer extends Component {
2323
this.onTopcoderInviteSend = this.onTopcoderInviteSend.bind(this)
2424
this.onMemberDeleteConfirm = this.onMemberDeleteConfirm.bind(this)
2525
this.onJoinConfirm = this.onJoinConfirm.bind(this)
26+
this.onAcceptOrRefuse = this.onAcceptOrRefuse.bind(this)
2627
this.changeRole = this.changeRole.bind(this)
2728
}
2829

@@ -74,6 +75,10 @@ class TeamManagementContainer extends Component {
7475
this.props.inviteProjectMembers(this.props.projectId, emails, handles)
7576
}
7677

78+
onAcceptOrRefuse(invite) {
79+
this.props.acceptOrRefuseInvite(this.props.projectId, invite)
80+
}
81+
7782
changeRole(memberId, item) {
7883
this.props.updateProjectMember(this.props.projectId, memberId, item)
7984
}
@@ -118,6 +123,7 @@ class TeamManagementContainer extends Component {
118123
<div>
119124
<TeamManagement
120125
{...this.state}
126+
history={this.props.history}
121127
onUserInviteAction={this.onUserInviteAction}
122128
processingMembers={this.props.processingMembers}
123129
processingInvites={this.props.processingInvites}
@@ -129,6 +135,7 @@ class TeamManagementContainer extends Component {
129135
onMemberDeleteConfirm={this.onMemberDeleteConfirm}
130136
onJoinConfirm={this.onJoinConfirm}
131137
onProjectInviteDeleteConfirm={this.onProjectInviteDelete}
138+
onAcceptOrRefuse={this.onAcceptOrRefuse}
132139
onProjectInviteSend={this.onProjectInviteSend}
133140
onTopcoderInviteDeleteConfirm={this.onTopcoderInviteDelete}
134141
onTopcoderInviteSend={this.onTopcoderInviteSend}

src/projects/reducers/project.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
INVITE_TOPCODER_MEMBER_SUCCESS, REMOVE_TOPCODER_MEMBER_INVITE_SUCCESS, INVITE_TOPCODER_MEMBER_PENDING, REMOVE_CUSTOMER_INVITE_PENDING,
2020
REMOVE_TOPCODER_MEMBER_INVITE_PENDING, REMOVE_TOPCODER_MEMBER_INVITE_FAILURE, REMOVE_CUSTOMER_INVITE_FAILURE,
2121
INVITE_CUSTOMER_FAILURE, INVITE_TOPCODER_MEMBER_FAILURE, INVITE_CUSTOMER_PENDING,
22-
ACCEPT_OR_REFUSE_INVITE_SUCCESS, ACCEPT_OR_REFUSE_INVITE_FAILURE, ACCEPT_OR_REFUSE_INVITE_PENDING,
22+
ACCEPT_OR_REFUSE_INVITE_SUCCESS, ACCEPT_OR_REFUSE_INVITE_FAILURE, ACCEPT_OR_REFUSE_INVITE_PENDING,
2323
UPLOAD_PROJECT_ATTACHMENT_FILES, DISCARD_PROJECT_ATTACHMENT, CHANGE_ATTACHMENT_PERMISSION
2424
} from '../../config/constants'
2525
import _ from 'lodash'
@@ -165,7 +165,7 @@ export const projectState = function (state=initialState, action) {
165165

166166
case LOAD_PROJECT_MEMBER_INVITES_SUCCESS: {
167167
return Object.assign({}, state, {
168-
showUserInvited: true
168+
showUserInvited: true && action.payload.role !== 'copilot'
169169
})
170170
}
171171

@@ -177,7 +177,7 @@ export const projectState = function (state=initialState, action) {
177177

178178
case ACCEPT_OR_REFUSE_INVITE_PENDING:
179179
return Object.assign({}, state, {
180-
showUserInvited: true
180+
showUserInvited: false
181181
})
182182

183183
case ACCEPT_OR_REFUSE_INVITE_SUCCESS: {
@@ -388,7 +388,7 @@ export const projectState = function (state=initialState, action) {
388388
attachmentsAwaitingPermission: action.payload,
389389
attachmentPermissions: null
390390
}
391-
391+
392392
case DISCARD_PROJECT_ATTACHMENT:
393393
return {
394394
...state,

src/routes/notifications/constants/notifications.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import {
88
NOTIFICATION_TYPE,
9-
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR,
9+
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_COPILOT_MANAGER,
1010
PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_OWNER, PROJECT_ROLE_MEMBER,
1111
EVENT_TYPE,
1212
} from '../../../config/constants'
@@ -18,7 +18,8 @@ export const GOTO = {
1818
TOPIC: '/projects/{{projectId}}/#feed-{{topicId}}',
1919
POST: '/projects/{{projectId}}/#comment-{{postId}}',
2020
FILE_LIST: '/projects/{{projectId}}/specification#appDefinition-files',
21-
PHASE: '/projects/{{projectId}}/plan#phase-{{phaseId}}'
21+
PHASE: '/projects/{{projectId}}/plan#phase-{{phaseId}}',
22+
TOPCODER_TEAM: '/projects/{{projectId}}#manageTopcoderTeam'
2223
}
2324

2425
// each notification can be displayed differently depend on WHO see them
@@ -212,6 +213,40 @@ export const NOTIFICATIONS = [
212213
}]
213214
},
214215

216+
{
217+
eventType: EVENT_TYPE.MEMBER.INVITE_REQUESTED,
218+
type: NOTIFICATION_TYPE.MEMBER_ADDED,
219+
rules: [{
220+
text: 'You are requested to add <strong>{{userFullName}}</strong> as a copilot',
221+
topcoderRoles: [ROLE_CONNECT_COPILOT_MANAGER],
222+
goTo: GOTO.TOPCODER_TEAM
223+
}]
224+
},
225+
226+
{
227+
eventType: EVENT_TYPE.MEMBER.COPILOT_ADDED,
228+
type: NOTIFICATION_TYPE.MEMBER_ADDED,
229+
rules: [{
230+
text: 'You are added as a copilot',
231+
toUserHandle: true,
232+
goTo: GOTO.PROJECT_DASHBOARD
233+
}, {
234+
text: 'Your request to add invite the copilot was approved',
235+
creator: true,
236+
goTo: GOTO.PROJECT_DASHBOARD
237+
}]
238+
},
239+
240+
{
241+
eventType: EVENT_TYPE.MEMBER.COPILOT_REFUSED,
242+
type: NOTIFICATION_TYPE.MEMBER_ADDED,
243+
rules: [{
244+
text: 'Your request to add invite the copilot was refused',
245+
creator: true,
246+
goTo: GOTO.PROJECT_DASHBOARD
247+
}]
248+
},
249+
215250
{
216251
eventType: EVENT_TYPE.MEMBER.COPILOT_JOINED,
217252
type: NOTIFICATION_TYPE.MEMBER_ADDED,
@@ -288,8 +323,8 @@ export const NOTIFICATIONS = [
288323
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
289324
goTo: GOTO.POST
290325
}]
291-
},
292-
326+
},
327+
293328
{
294329
version: 2,
295330
eventType: EVENT_TYPE.POST.UPDATED,
@@ -302,8 +337,8 @@ export const NOTIFICATIONS = [
302337
toTopicStarter: true,
303338
goTo: GOTO.POST
304339
}]
305-
},
306-
340+
},
341+
307342
{
308343
version: 2,
309344
eventType: EVENT_TYPE.POST.MENTION,
@@ -379,7 +414,7 @@ export const NOTIFICATIONS = [
379414
goTo: GOTO.PROJECT_SPECIFICATION
380415
}]
381416
},
382-
417+
383418
{
384419
eventType: EVENT_TYPE.PROJECT_PLAN.READY,
385420
type: NOTIFICATION_TYPE.UPDATES,
@@ -469,7 +504,7 @@ export const NOTIFICATIONS = [
469504
goTo: GOTO.PHASE
470505
}]
471506
},
472-
507+
473508
{
474509
eventType: EVENT_TYPE.PROJECT_PLAN.PHASE_PROGRESS_UPDATED,
475510
type: NOTIFICATION_TYPE.UPDATES,
@@ -524,7 +559,7 @@ export const NOTIFICATIONS = [
524559
goTo: GOTO.PROJECT_PLAN
525560
}]
526561
},
527-
562+
528563
{
529564
eventType: EVENT_TYPE.PROJECT_PLAN.TIMELINE_ADJUSTED,
530565
type: NOTIFICATION_TYPE.UPDATES,

0 commit comments

Comments
 (0)