diff --git a/src/components/Tab/index.js b/src/components/Tab/index.js
index 21f821b8..f5c94cd2 100644
--- a/src/components/Tab/index.js
+++ b/src/components/Tab/index.js
@@ -8,7 +8,8 @@ const Tab = ({
selectTab,
projectId,
canViewAssets,
- canViewEngagements,
+ canViewEngagements, // Admin or TM
+ isAdmin, // Only admin
onBack
}) => {
const projectTabs = [
@@ -21,7 +22,7 @@ const Tab = ({
: [
{ id: 1, label: 'All Work' },
{ id: 2, label: 'Projects' },
- ...(canViewEngagements ? [{ id: 3, label: 'Engagements' }] : []),
+ ...(isAdmin ? [{ id: 3, label: 'Engagements' }] : []),
{ id: 4, label: 'Users' },
{ id: 5, label: 'Self-Service' },
{ id: 6, label: 'TaaS' },
@@ -88,6 +89,7 @@ Tab.defaultProps = {
projectId: null,
canViewAssets: true,
canViewEngagements: false,
+ isAdmin: false,
onBack: () => {}
}
@@ -97,6 +99,7 @@ Tab.propTypes = {
projectId: PT.oneOfType([PT.string, PT.number]),
canViewAssets: PT.bool,
canViewEngagements: PT.bool,
+ isAdmin: PT.bool,
onBack: PT.func
}
diff --git a/src/containers/Tab/index.js b/src/containers/Tab/index.js
index 0a056f7f..e00bf5b2 100644
--- a/src/containers/Tab/index.js
+++ b/src/containers/Tab/index.js
@@ -38,6 +38,13 @@ class TabContainer extends Component {
return !!resolvedToken && checkAdminOrTalentManager(resolvedToken)
}
+ getIsAdmin (props = this.props) {
+ const { token: currentToken } = this.props
+ const { token } = props
+ const resolvedToken = token || currentToken
+ return !!resolvedToken && checkAdmin(resolvedToken)
+ }
+
componentDidMount () {
const {
projectId,
@@ -63,8 +70,9 @@ class TabContainer extends Component {
const canViewAssets = this.getCanViewAssets()
const canViewEngagements = this.getCanViewEngagements()
+ const isAdmin = this.getIsAdmin()
this.setState({
- currentTab: this.getTabFromPath(history.location.pathname, projectId, canViewAssets, canViewEngagements)
+ currentTab: this.getTabFromPath(history.location.pathname, projectId, canViewAssets, canViewEngagements, isAdmin)
})
}
@@ -77,8 +85,9 @@ class TabContainer extends Component {
const canViewAssets = this.getCanViewAssets(nextProps)
const canViewEngagements = this.getCanViewEngagements(nextProps)
+ const isAdmin = this.getIsAdmin(nextProps)
this.setState({
- currentTab: this.getTabFromPath(nextProps.history.location.pathname, projectId, canViewAssets, canViewEngagements)
+ currentTab: this.getTabFromPath(nextProps.history.location.pathname, projectId, canViewAssets, canViewEngagements, isAdmin)
})
if (
isLoading ||
@@ -130,7 +139,7 @@ class TabContainer extends Component {
return 0
}
- getTabFromPath (pathname, projectId, canViewAssets = true, canViewEngagements = false) {
+ getTabFromPath (pathname, projectId, canViewAssets = true, canViewEngagements = false, isAdmin = false) {
if (projectId) {
return this.getProjectTabFromPath(pathname, projectId, canViewAssets, canViewEngagements)
}
@@ -141,7 +150,7 @@ class TabContainer extends Component {
return 2
}
if (pathname === '/engagements') {
- return canViewEngagements ? 3 : 0
+ return isAdmin ? 3 : 0
}
if (pathname === '/users') {
return 4
@@ -178,7 +187,8 @@ class TabContainer extends Component {
onTabChange (tab) {
const { history, resetSidebarActiveParams, projectId } = this.props
const canViewAssets = this.getCanViewAssets()
- const canViewEngagements = this.getCanViewEngagements()
+ const canViewEngagements = this.getCanViewEngagements() // admin OR TM
+ const isAdmin = this.getIsAdmin() // admin
if (projectId) {
if ((tab === 2 && !canViewEngagements) || (tab === 3 && !canViewAssets)) {
return
@@ -200,7 +210,7 @@ class TabContainer extends Component {
history.push('/projects')
this.props.unloadProjects()
this.setState({ currentTab: 2 })
- } else if (tab === 3 && canViewEngagements) {
+ } else if (tab === 3 && isAdmin) {
history.push('/engagements')
this.setState({ currentTab: 3 })
} else if (tab === 4) {
@@ -225,6 +235,7 @@ class TabContainer extends Component {
const { currentTab } = this.state
const canViewAssets = this.getCanViewAssets()
const canViewEngagements = this.getCanViewEngagements()
+ const isAdmin = this.getIsAdmin()
return (
)
diff --git a/src/routes.js b/src/routes.js
index c485bb53..f4b66bb1 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -156,7 +156,7 @@ class Routes extends React.Component {
)()}
/>
- {canAccessEngagements && (
+ {isAdmin && (
renderApp(
,
@@ -166,12 +166,12 @@ class Routes extends React.Component {
)()}
/>
)}
- {!canAccessEngagements && (
+ {!isAdmin && (
renderApp(
,
,
,