Skip to content

Commit cc879c1

Browse files
committed
fix: don't ask role when user joins by themself
ref issue #4101
1 parent 74222c6 commit cc879c1

File tree

4 files changed

+60
-115
lines changed

4 files changed

+60
-115
lines changed

src/components/TeamManagement/Dialog.js

Lines changed: 36 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,47 @@
11
import React from 'react'
22
import Modal from 'react-modal'
33
import PT from 'prop-types'
4-
import SelectDropdown from '../SelectDropdown/SelectDropdown'
54
import LoadingIndicator from '../../components/LoadingIndicator/LoadingIndicator'
65

7-
class Dialog extends React.Component {
8-
9-
constructor(props) {
10-
super(props)
11-
this.state = {
12-
role: 'manager'
13-
}
14-
15-
this.roles = [{
16-
title: 'Manager',
17-
value: 'manager',
18-
}, {
19-
title: 'Observer',
20-
value: 'observer',
21-
}, {
22-
title: 'Account Manager',
23-
value: 'account_manager',
24-
}, {
25-
title: 'Account Executive',
26-
value: 'account_executive',
27-
}, {
28-
title: 'Program Manager',
29-
value: 'program_manager',
30-
}, {
31-
title: 'Solution Architect',
32-
value: 'solution_architect',
33-
}, {
34-
title: 'Project Manager',
35-
value: 'project_manager',
36-
}]
37-
38-
this.handleRoles = this.handleRoles.bind(this)
39-
this.onConfirm = this.onConfirm.bind(this)
40-
}
41-
42-
handleRoles(option) {
43-
this.setState({
44-
role: option.value
45-
})
46-
}
47-
48-
onConfirm() {
49-
if(this.props.showRoleSelector) {
50-
this.props.onConfirm(this.state.role)
51-
} else {
52-
this.props.onConfirm()
53-
}
54-
55-
}
56-
57-
render()
58-
{
59-
const {onCancel, title, content, buttonColor, buttonText, isLoading, showRoleSelector, loadingTitle} = this.props
60-
61-
return (
62-
<Modal
63-
isOpen
64-
className="management-dialog"
65-
overlayClassName="management-dialog-overlay"
66-
shouldCloseOnOverlayClick={false}
67-
shouldCloseOnEsc={false}
68-
contentLabel=""
69-
>
70-
<div className="management-dialog-container">
71-
<div className="dialog-title">{isLoading ? loadingTitle : title}</div>
72-
{isLoading ? (
73-
<LoadingIndicator />
74-
) : (
75-
<div>
76-
<div className="dialog-content" dangerouslySetInnerHTML={{__html: content}}/>
77-
{showRoleSelector && <Formsy.Form className="input-container">
78-
<SelectDropdown
79-
name="role"
80-
value={this.state.role}
81-
theme="role-drop-down default"
82-
options={this.roles}
83-
onSelect={this.handleRoles}
84-
/>
85-
</Formsy.Form>}
86-
</div>
87-
)}
88-
<div className="dialog-actions">
89-
<button
90-
onClick={onCancel}
91-
className="tc-btn tc-btn-default"
92-
disabled={isLoading}
93-
>
94-
Cancel
95-
</button>
96-
<button
97-
onClick={this.onConfirm}
98-
className={'tc-btn tc-btn-primary tc-btn-md ' + (buttonColor !== 'blue' ? 'btn-red' : '')}
99-
disabled={isLoading}
100-
>
101-
{buttonText}
102-
</button>
103-
</div>
6+
const Dialog = ({onCancel, title, content, buttonColor, buttonText, isLoading, loadingTitle, onConfirm}) => (
7+
<Modal
8+
isOpen
9+
className="management-dialog"
10+
overlayClassName="management-dialog-overlay"
11+
shouldCloseOnOverlayClick={false}
12+
shouldCloseOnEsc={false}
13+
contentLabel=""
14+
>
15+
<div className="management-dialog-container">
16+
<div className="dialog-title">{isLoading ? loadingTitle : title}</div>
17+
{isLoading ? (
18+
<LoadingIndicator />
19+
) : (
20+
<div>
21+
<div className="dialog-content" dangerouslySetInnerHTML={{__html: content}}/>
10422
</div>
105-
</Modal>
106-
)
107-
}
108-
}
23+
)}
24+
<div className="dialog-actions">
25+
<button
26+
onClick={onCancel}
27+
className="tc-btn tc-btn-default"
28+
disabled={isLoading}
29+
>
30+
Cancel
31+
</button>
32+
<button
33+
onClick={onConfirm}
34+
className={'tc-btn tc-btn-primary tc-btn-md ' + (buttonColor !== 'blue' ? 'btn-red' : '')}
35+
disabled={isLoading}
36+
>
37+
{buttonText}
38+
</button>
39+
</div>
40+
</div>
41+
</Modal>
42+
)
10943

11044
Dialog.defaultProps = {
111-
showRoleSelector: false,
11245
isLoading: false,
11346
}
11447

@@ -119,7 +52,6 @@ Dialog.propTypes = {
11952
content: PT.string,
12053
buttonColor: PT.string,
12154
buttonText: PT.string,
122-
showRoleSelector: PT.bool,
12355
isLoading: PT.bool,
12456
}
12557

src/components/TeamManagement/TeamManagement.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TeamManagement extends React.Component {
5252
this.projectTeamInviteButtonClick = this.projectTeamInviteButtonClick.bind(this)
5353
this.topcoderTeamInviteButtonClick = this.topcoderTeamInviteButtonClick.bind(this)
5454
this.copilotTeamInviteButtonClick = this.copilotTeamInviteButtonClick.bind(this)
55+
this.onJoinConfirm = this.onJoinConfirm.bind(this)
5556
}
5657

5758
topcoderTeamInviteButtonClick() {
@@ -85,10 +86,16 @@ class TeamManagement extends React.Component {
8586
}
8687
}
8788

89+
onJoinConfirm() {
90+
const { onJoinConfirm } = this.props
91+
// call without argument, so the role would be detected automatically
92+
onJoinConfirm()
93+
}
94+
8895
render() {
8996
const {
9097
currentUser, members, deletingMember, isAddingTeamMember, onMemberDeleteConfirm, onMemberDelete, isShowJoin,
91-
showNewMemberConfirmation, onJoin, onJoinConfirm, onShowProjectDialog, isShowProjectDialog,
98+
showNewMemberConfirmation, onJoin, onShowProjectDialog, isShowProjectDialog,
9299
projectTeamInvites, onProjectInviteDeleteConfirm, onProjectInviteSend, deletingInvite, changeRole,
93100
onDeleteInvite, isShowTopcoderDialog, onShowTopcoderDialog, processingInvites, processingMembers,
94101
onTopcoderInviteSend, onTopcoderInviteDeleteConfirm, topcoderTeamInvites, onAcceptOrRefuse, error,
@@ -109,7 +116,7 @@ class TeamManagement extends React.Component {
109116
const copilotTeamManageAction = hasPermission(PERMISSIONS.MANAGE_COPILOTS)
110117
const canRequestCopilot = hasPermission(PERMISSIONS.REQUEST_COPILOTS)
111118
const canJoinAsCopilot = !currentMember && currentUser.isCopilot
112-
const canJoinAsManager = !currentMember && (currentUser.isManager || currentUser.isAccountManager)
119+
const canJoinTopcoderTeam = !currentMember && hasPermission(PERMISSIONS.JOIN_TOPCODER_TEAM)
113120
const canShowInvite = currentMember && (currentMember.isCustomer || currentMember.isCopilot || currentMember.isManager)
114121

115122
const sortedMembers = members
@@ -124,7 +131,7 @@ class TeamManagement extends React.Component {
124131
<span styleName="title-text">Team</span>
125132
{(customerTeamManageAction) &&
126133
<span className="title-action" onClick={() => onShowProjectDialog(true)}>
127-
Manage
134+
{currentUser.isAdmin ? 'Manage' : 'View'}
128135
</span>
129136
}
130137
</div>
@@ -292,7 +299,7 @@ class TeamManagement extends React.Component {
292299
</div>
293300
</div>
294301
}
295-
{ (canJoinAsCopilot || canJoinAsManager) &&
302+
{ (canJoinAsCopilot || canJoinTopcoderTeam) &&
296303
<div styleName="button-container">
297304
<div className="join-btn" onClick={() => onJoin(true)}>
298305
<AddIcon />
@@ -306,23 +313,18 @@ class TeamManagement extends React.Component {
306313
</div>
307314
{isShowJoin && ((() => {
308315
const onClickCancel = () => onJoin(false)
309-
const onClickJoinConfirm = (role) => {
310-
onJoinConfirm(role)
311-
}
312316
let role = 'Manager'
313317
if (currentUser.isCopilot) role = 'Copilot'
314-
if (currentUser.isAccountManager) role = 'Account Manager'
315318
return (
316319
<Dialog
317320
isLoading={processingMembers}
318321
onCancel={onClickCancel}
319-
onConfirm={onClickJoinConfirm}
322+
onConfirm={this.onJoinConfirm}
320323
title={`Join project as ${role}`}
321324
loadingTitle="Adding you to the project...."
322325
content={JOIN_MESSAGE}
323326
buttonText="Join project"
324327
buttonColor="blue"
325-
showRoleSelector={currentUser.isManager}
326328
/>
327329
)
328330
})())}

src/config/permissions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ export default {
196196
]
197197
},
198198

199+
JOIN_TOPCODER_TEAM: {
200+
_meta: {
201+
group: 'Project Members',
202+
title: 'Join topcoder team',
203+
description: 'Join Topcoder Team without invitation',
204+
},
205+
topcoderRoles: [
206+
...TOPCODER_ADMINS,
207+
ROLE_CONNECT_MANAGER,
208+
]
209+
},
210+
199211
MANAGE_COPILOTS: {
200212
_meta: {
201213
group: 'Project Members',

src/projects/detail/containers/TeamManagementContainer.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class TeamManagementContainer extends Component {
9191
const { currentUser, projectId, addProjectMember } = this.props
9292
let defaultRole = PROJECT_ROLE_MANAGER
9393
if (currentUser.isCopilot) defaultRole = PROJECT_ROLE_COPILOT
94-
if (currentUser.isAccountManager) defaultRole = PROJECT_ROLE_ACCOUNT_MANAGER
9594
role = role || defaultRole
9695
addProjectMember(
9796
projectId,

0 commit comments

Comments
 (0)