Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84cb534

Browse files
committedJun 19, 2019
check eligible roles to enable switch to business option.
1 parent 47a5600 commit 84cb534

File tree

3 files changed

+60
-37
lines changed

3 files changed

+60
-37
lines changed
 

‎dist/dev/index.js

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/prod/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/components/AccountMenu/index.js

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import IconSwitchBusiness from '../../assets/images/icon-switch-business.svg'
99
import styles from './styles.module.scss'
1010
import moment from 'moment'
1111

12+
// The roles of managers/copilots/admins.
13+
const MANAGE_ROLES = [
14+
'administrator',
15+
'admin',
16+
'copilot',
17+
'connect copilot',
18+
'manager',
19+
'global manager',
20+
'client manager',
21+
'connect manager'
22+
]
23+
24+
const hasAccess = roles => {
25+
if (!roles) {
26+
return false
27+
}
28+
return roles.some(v => MANAGE_ROLES.indexOf(v.toLowerCase()) !== -1)
29+
}
30+
1231
class AccountMenu extends React.Component {
1332
renderLink (menu, i) {
1433
const { onClose } = this.props
@@ -66,22 +85,26 @@ class AccountMenu extends React.Component {
6685
</span>
6786
</div>
6887

69-
<div
70-
role='button'
71-
className={styles['switch-to-business-container']}
72-
onClick={onSwitch}
73-
>
74-
<IconSwitchBusiness className={styles['switch-icon']} />
75-
{
76-
_.isEmpty(switchText.href) ? (
77-
<Link to={switchText.link} onClick={onClose}>
78-
<span className={styles['switch-to-busniness']}>{switchText.title}</span>
79-
</Link>
80-
) : (
81-
<a href={switchText.href} className={styles['switch-to-busniness']} onClick={onClose}>{switchText.title}</a>
82-
)
83-
}
84-
</div>
88+
{
89+
!_.isEmpty(profile) && hasAccess(profile.roles) && (
90+
<div
91+
role='button'
92+
className={styles['switch-to-business-container']}
93+
onClick={onSwitch}
94+
>
95+
<IconSwitchBusiness className={styles['switch-icon']} />
96+
{
97+
_.isEmpty(switchText.href) ? (
98+
<Link to={switchText.link} onClick={onClose}>
99+
<span className={styles['switch-to-busniness']}>{switchText.title}</span>
100+
</Link>
101+
) : (
102+
<a href={switchText.href} className={styles['switch-to-busniness']} onClick={onClose}>{switchText.title}</a>
103+
)
104+
}
105+
</div>
106+
)
107+
}
85108

86109
<div className={styles.menu}>
87110

0 commit comments

Comments
 (0)
Please sign in to comment.