Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ compile:

deployment:
development:
branch: [dev, 'feature/performance-testing']
branch: dev
owner: appirio-tech
commands:
- ./deploy.sh DEV
Expand Down
13 changes: 12 additions & 1 deletion src/actions/loadUser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import _ from 'lodash'
import { ACCOUNTS_APP_CONNECTOR_URL, LOAD_USER_SUCCESS, LOAD_USER_FAILURE, ROLE_ADMINISTRATOR, ROLE_CONNECT_COPILOT, ROLE_TOPCODER_USER, ROLE_CONNECT_MANAGER } from '../config/constants'
import {
ACCOUNTS_APP_CONNECTOR_URL,
LOAD_USER_SUCCESS,
LOAD_USER_FAILURE,
ROLE_ADMINISTRATOR,
ROLE_CONNECT_COPILOT,
ROLE_TOPCODER_USER,
ROLE_CONNECT_MANAGER,
ROLE_CONNECT_ADMIN
} from '../config/constants'
import { getFreshToken, configureConnector, decodeToken } from 'tc-accounts'
import { getUserProfile } from '../api/users'
import { EventTypes } from 'redux-segment'
Expand Down Expand Up @@ -46,6 +55,8 @@ export function loadUserSuccess(dispatch, token) {
let userRole
if (_.indexOf(currentUser.roles, ROLE_ADMINISTRATOR) > -1) {
userRole = ROLE_ADMINISTRATOR
} else if (_.indexOf(currentUser.roles, ROLE_CONNECT_ADMIN) > -1) {
userRole = ROLE_CONNECT_ADMIN
} else if (_.indexOf(currentUser.roles, ROLE_CONNECT_MANAGER) > -1) {
userRole = ROLE_CONNECT_MANAGER
} else if (_.indexOf(currentUser.roles, ROLE_CONNECT_COPILOT) > -1) {
Expand Down
9 changes: 6 additions & 3 deletions src/components/TeamManagement/MemberRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ActionBtn = (props) => {
)
}

const MemberRow = ({ member, currentMember, onMemberDelete, onChangeOwner }) => {
const MemberRow = ({ member, currentMember, currentUser, onMemberDelete, onChangeOwner }) => {
let title
// rendered member
const isOwner = member.isPrimary && member.isCustomer
Expand All @@ -44,21 +44,24 @@ const MemberRow = ({ member, currentMember, onMemberDelete, onChangeOwner }) =>
if (!isCurrentOwner && !member.isCopilot) {
buttons.push(<ActionBtn key={0} type="leave" title="Leave Project" onClick={onDelete} />)
}
} else if (currentMember) {
} else if (currentMember || currentUser.isAdmin) {
// owner can remove only customers
if (isCurrentOwner && member.isCustomer) {
buttons.push(<ActionBtn key={1} type="user-remove" title="Remove team member from project" onClick={onDelete} />)
}

// manager can remove all except owner
if (currentMember.isManager && !isOwner) {
if ((currentMember && currentMember.isManager) || currentUser.isAdmin) {
let tooltip = 'Remove team member from project'
if (member.isCopilot) {
tooltip = 'Remove copilot from project'
}
if (member.isManager) {
tooltip = 'Remove manager from project'
}
if (member.isCustomer && isOwner) {
tooltip = 'Remove owner from project'
}
buttons.push(<ActionBtn key={2} type="user-remove" title={tooltip} onClick={onDelete} />)
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/TeamManagement/TeamManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const TeamManagement = (props) => {
return (
<div className="team-management">
<Panel className={cn({'modal-active': modalActive})}>
{currentMember && <Panel.AddBtn onClick={() => onToggleAddTeamMember(true)}>Add Team Member</Panel.AddBtn>}
{(currentMember || currentUser.isAdmin) && <Panel.AddBtn onClick={() => onToggleAddTeamMember(true)}>Add Team Member</Panel.AddBtn>}

{modalActive && <div className="modal-overlay" />}
<Panel.Title>
Expand Down Expand Up @@ -114,7 +114,7 @@ const TeamManagement = (props) => {
})}

{canJoin && <Join {...props} isCopilot={currentUser.isCopilot} owner={owner} />}
{currentMember && <AddTeamMember {...props} owner={owner} />}
{(currentMember || currentUser.isAdmin) && <AddTeamMember {...props} owner={owner} />}

{ showNewMemberConfirmation && <NewMemberConfirmModal onConfirm={ _onAddNewMember } onCancel={ _onAddMemberCancel } />}
</Panel>
Expand Down
3 changes: 2 additions & 1 deletion src/components/TopBar/TopBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ROLE_CONNECT_COPILOT,
ROLE_CONNECT_MANAGER,
ROLE_ADMINISTRATOR,
ROLE_CONNECT_ADMIN,
DOMAIN
} from '../../config/constants'
require('./TopBarContainer.scss')
Expand Down Expand Up @@ -122,7 +123,7 @@ class TopBarContainer extends React.Component {

const mapStateToProps = ({ loadUser }) => {
let isPowerUser = false
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR]
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
if (loadUser.user) {
isPowerUser = loadUser.user.roles.some((role) => roles.indexOf(role) !== -1)
}
Expand Down
1 change: 1 addition & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const EVENT_ROUTE_CHANGE = 'event.route_change'
export const ROLE_TOPCODER_USER = 'Topcoder User'
export const ROLE_CONNECT_COPILOT = 'Connect Copilot'
export const ROLE_CONNECT_MANAGER = 'Connect Manager'
export const ROLE_CONNECT_ADMIN = 'Connect Admin'
export const ROLE_ADMINISTRATOR = 'administrator'

// FIXME .. remove defaults
Expand Down
4 changes: 2 additions & 2 deletions src/projects/actions/loadProjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PROJECT_SEARCH, GET_PROJECTS, PROJECT_STATUS, PROJECT_STATUS_CANCELLED,
SET_SEARCH_TERM, GET_PROJECTS_SEARCH_CRITERIA,
CLEAR_PROJECT_SUGGESTIONS_SEARCH, PROJECT_SUGGESTIONS_SEARCH_SUCCESS,
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN
} from '../../config/constants'
import { getProjects } from '../../api/projects'
import { loadMembers } from '../../actions/members'
Expand All @@ -23,7 +23,7 @@ const getProjectsWithMembers = (dispatch, getState, criteria, pageNum) => {
let isPowerUser = false
const loadUser = getState().loadUser
// power user roles
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR]
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
if (loadUser.user) {
// determine if user is a power user
isPowerUser = loadUser.user.roles.some((role) => roles.indexOf(role) !== -1)
Expand Down
4 changes: 2 additions & 2 deletions src/projects/detail/ProjectDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { renderComponent, branch, compose, withProps } from 'recompose'
import { loadProjectDashboard } from '../actions/projectDashboard'
import {
LOAD_PROJECT_FAILURE, PROJECT_ROLE_CUSTOMER, PROJECT_ROLE_OWNER,
ROLE_ADMINISTRATOR
ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN
} from '../../config/constants'
import spinnerWhileLoading from '../../components/LoadingSpinner'
import CoderBot from '../../components/CoderBot/CoderBot'
Expand Down Expand Up @@ -71,7 +71,7 @@ class ProjectDetail extends Component {

render() {
const currentMemberRole = this.getProjectRoleForCurrentUser(this.props)
const powerRoles = [ROLE_ADMINISTRATOR]
const powerRoles = [ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
const isSuperUser = this.props.currentUserRoles.some((role) => powerRoles.indexOf(role) !== -1)
return (
<EnhancedProjectDetailView
Expand Down
11 changes: 7 additions & 4 deletions src/projects/detail/containers/TeamManagementContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import _ from 'lodash'
import {
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR,
PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_CUSTOMER, AUTOCOMPLETE_TRIGGER_LENGTH
ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN,
PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_CUSTOMER,
AUTOCOMPLETE_TRIGGER_LENGTH
} from '../../../config/constants'
import TeamManagement from '../../../components/TeamManagement/TeamManagement'
import { addProjectMember, updateProjectMember, removeProjectMember,
Expand Down Expand Up @@ -221,12 +222,14 @@ class TeamManagementContainer extends Component {
}

const mapStateToProps = ({ loadUser, members }) => {
const powerUserRoles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR]
const managerRoles = [ ROLE_ADMINISTRATOR, ROLE_CONNECT_MANAGER ]
const adminRoles = [ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
const powerUserRoles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
const managerRoles = [ ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN, ROLE_CONNECT_MANAGER ]
return {
currentUser: {
userId: parseInt(loadUser.user.id),
isCopilot: _.indexOf(loadUser.user.roles, ROLE_CONNECT_COPILOT) > -1,
isAdmin: _.intersection(loadUser.user.roles, adminRoles).length > 0,
isManager: loadUser.user.roles.some((role) => managerRoles.indexOf(role) !== -1),
isCustomer: !loadUser.user.roles.some((role) => powerUserRoles.indexOf(role) !== -1)
},
Expand Down
9 changes: 7 additions & 2 deletions src/projects/list/components/Projects/Projects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import ProjectsCardView from './ProjectsCardView'
import { loadProjects } from '../../../actions/loadProjects'
import _ from 'lodash'
import querystring from 'query-string'
import { ROLE_CONNECT_MANAGER, ROLE_CONNECT_COPILOT, ROLE_ADMINISTRATOR } from '../../../../config/constants'
import {
ROLE_CONNECT_MANAGER,
ROLE_CONNECT_COPILOT,
ROLE_ADMINISTRATOR,
ROLE_CONNECT_ADMIN
} from '../../../../config/constants'

// This handles showing a spinner while the state is being loaded async
import spinnerWhileLoading from '../../../../components/LoadingSpinner'
Expand Down Expand Up @@ -172,7 +177,7 @@ class Projects extends Component {

const mapStateToProps = ({ projectSearch, members, loadUser }) => {
let isPowerUser = false
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR]
const roles = [ROLE_CONNECT_COPILOT, ROLE_CONNECT_MANAGER, ROLE_ADMINISTRATOR, ROLE_CONNECT_ADMIN]
if (loadUser.user) {
isPowerUser = loadUser.user.roles.some((role) => roles.indexOf(role) !== -1)
}
Expand Down