11import _ from 'lodash'
22import React from 'react'
33import PT from 'prop-types'
4- import cn from 'classnames'
54import moment from 'moment'
65import Modal from 'react-modal'
76import XMarkIcon from '../../assets/icons/icon-x-mark.svg'
87import Avatar from 'appirio-tech-react-components/components/Avatar/Avatar'
98import { getAvatarResized , getFullNameWithFallback } from '../../helpers/tcHelpers'
10- import SelectDropdown from '../SelectDropdown/SelectDropdown'
11- import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
129import AutocompleteInputContainer from './AutocompleteInputContainer'
1310import {
1411 PROJECT_MEMBER_INVITE_STATUS_REQUESTED , PROJECT_MEMBER_INVITE_STATUS_PENDING ,
@@ -23,58 +20,14 @@ class TopcoderManagementDialog extends React.Component {
2320 constructor ( props ) {
2421 super ( props )
2522 this . state = {
26- userRole : 'manager' ,
2723 managerType : { } ,
2824 showAlreadyMemberError : false ,
2925 errorMessage : null ,
3026 processingInviteRequestIds : [ ] , // ids of invites for which request is being processed
3127 }
3228
33- this . onUserRoleChange = this . onUserRoleChange . bind ( this )
34- this . handleRoles = this . handleRoles . bind ( this )
35- this . addUsers = this . addUsers . bind ( this )
3629 this . onChange = this . onChange . bind ( this )
3730 this . showIndividualErrors = this . showIndividualErrors . bind ( this )
38-
39- this . roles = [ {
40- title : 'Manager' ,
41- value : 'manager' ,
42- } , {
43- title : 'Observer' ,
44- value : 'observer' ,
45- } , {
46- title : 'Account Manager' ,
47- value : 'account_manager' ,
48- } , {
49- title : 'Account Executive' ,
50- value : 'account_executive' ,
51- } , {
52- title : 'Program Manager' ,
53- value : 'program_manager' ,
54- } , {
55- title : 'Solution Architect' ,
56- value : 'solution_architect' ,
57- } , {
58- title : 'Project Manager' ,
59- value : 'project_manager' ,
60- } ]
61- }
62-
63- onUserRoleChange ( memberId , id , type ) {
64- const managerType = Object . assign ( { } , this . state . managerType )
65- managerType [ memberId ] = type
66- this . props . changeRole ( id , { role : this . roles . find ( ( role ) => role . title === type ) . value } )
67- this . setState ( { managerType} )
68- }
69-
70- handleRoles ( option ) {
71- this . setState ( {
72- userRole : option . value
73- } )
74- }
75-
76- addUsers ( ) {
77- this . props . addUsers ( this . state . userRole )
7831 }
7932
8033 onChange ( selectedMembers ) {
@@ -142,7 +95,7 @@ class TopcoderManagementDialog extends React.Component {
14295 render ( ) {
14396 const {
14497 members, currentUser, isMember, removeMember, onCancel, removeInvite, approveOrDecline, topcoderTeamInvites = [ ] ,
145- selectedMembers, processingInvites, updatingMemberIds
98+ selectedMembers, processingInvites,
14699 } = this . props
147100 const { processingInviteRequestIds } = this . state
148101 const showRemove = hasPermission ( PERMISSIONS . MANAGE_TOPCODER_TEAM )
@@ -159,7 +112,7 @@ class TopcoderManagementDialog extends React.Component {
159112 contentLabel = ""
160113 >
161114
162- < div className = "project-dialog topcoder-dialog " >
115+ < div className = "project-dialog" >
163116 < div className = "dialog-title" >
164117 Topcoder team
165118 < span onClick = { onCancel } > < XMarkIcon /> </ span >
@@ -175,8 +128,6 @@ class TopcoderManagementDialog extends React.Component {
175128 removeMember ( member )
176129 }
177130 const userFullName = getFullNameWithFallback ( member )
178- const role = _ . get ( _ . find ( this . roles , r => r . value === member . role ) , 'title' )
179- const isMemberProcessing = _ . includes ( updatingMemberIds , member . id )
180131 return (
181132 < div
182133 key = { i }
@@ -203,59 +154,6 @@ class TopcoderManagementDialog extends React.Component {
203154 Leave
204155 </ div >
205156 }
206- { ( ( ) => {
207- if ( ! isMember || ( ! currentUser . isAdmin && ! currentUser . isManager ) ) {
208- return (
209- < div className = "member-type-wrapper" >
210- < div className = "member-type" >
211- { role }
212- </ div >
213- </ div >
214- )
215- }
216- let types = [ 'Manager' , 'Account Manager' , 'Account Executive' , 'Program Manager' , 'Solution Architect' , 'Project Manager' ]
217- const currentType = role
218- types = currentType === 'Observer' ? [ 'Observer' , ...types ] : [ ...types ]
219- const onClick = ( type ) => {
220- this . onUserRoleChange ( member . userId , member . id , type )
221- }
222- return (
223- < div className = { `member-role-container ${ isMemberProcessing ? 'is-processing' : '' } ` } >
224- {
225- isMemberProcessing ? < LoadingIndicator isSmall /> :
226- types . map ( ( type ) => {
227- const isCopilotDisabled =
228- type === 'Copilot' &&
229- type !== currentType &&
230- ! ( currentUser . isCopilotManager || currentUser . isAdmin )
231-
232- return (
233- isCopilotDisabled ? (
234- < Tooltip theme = "light" key = { type } >
235- < div className = "tooltip-target" >
236- < div className = "member-role disabled" >
237- { type }
238- </ div >
239- </ div >
240- < div className = "tooltip-body" >
241- { 'Only Connect Copilot Managers can change member role to copilots.' }
242- </ div >
243- </ Tooltip >
244- ) : (
245- < div
246- key = { type }
247- onClick = { ( ) => onClick ( type ) }
248- className = { cn ( 'member-role' , { active : type === currentType } ) }
249- >
250- { type }
251- </ div >
252- )
253- )
254- } )
255- }
256- </ div >
257- )
258- } ) ( ) }
259157 </ div >
260158 )
261159 } ) ) }
@@ -358,23 +256,14 @@ class TopcoderManagementDialog extends React.Component {
358256 { this . state . showAlreadyMemberError && < div className = "error-message" >
359257 Project Member(s) can\'t be invited again. Please remove them from list.
360258 </ div > }
361- < Formsy . Form >
362- < SelectDropdown
363- name = "role"
364- value = { this . state . userRole }
365- theme = "role-drop-down default"
366- options = { this . roles . filter ( role => role . title !== 'Observer' ) }
367- onSelect = { this . handleRoles }
368- />
369- </ Formsy . Form >
370259 { this . state . errorMessage && < div className = "error-message" >
371260 { this . state . errorMessage }
372261 </ div > }
373262 < button
374263 className = "tc-btn tc-btn-primary tc-btn-md"
375264 type = "submit"
376265 disabled = { processingInvites || this . state . showAlreadyMemberError || selectedMembers . length === 0 }
377- onClick = { this . addUsers }
266+ onClick = { this . props . sendInvite }
378267 >
379268 Invite users
380269 </ button >
@@ -404,7 +293,7 @@ TopcoderManagementDialog.propTypes = {
404293 changeRole : PT . func . isRequired ,
405294 projectTeamInvites : PT . arrayOf ( PT . object ) ,
406295 topcoderTeamInvites : PT . arrayOf ( PT . object ) ,
407- addUsers : PT . func . isRequired ,
296+ sendInvite : PT . func . isRequired ,
408297 approveOrDecline : PT . func . isRequired ,
409298 removeInvite : PT . func . isRequired ,
410299 onSelectedMembersUpdate : PT . func . isRequired ,
0 commit comments