New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent user without permissions from seeing service as a clickable in context selector #304
Changes from all commits
be60594
6a775b1
e9f34e3
f670253
445e8e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,18 +44,33 @@ class ContextSelector extends React.Component { | |
) | ||
} | ||
|
||
getClassNamesFor ({ menu, api }) { | ||
const { activeMenu, currentApi } = this.props | ||
getClassNamesForMenu (menu) { | ||
const { activeMenu } = this.props | ||
|
||
if (menu === 'dashboard' && activeMenu === 'dashboard' || | ||
menu === 'audience' && (['buyers', 'finance', 'cms', 'site'].indexOf(activeMenu) !== -1) || | ||
api && (['serviceadmin', 'monitoring'].indexOf(activeMenu) !== -1) && api === currentApi.service.id) { | ||
menu === 'audience' && (['buyers', 'finance', 'cms', 'site'].indexOf(activeMenu) !== -1)) { | ||
return 'PopNavigation-link current-context' | ||
} | ||
|
||
return 'PopNavigation-link' | ||
} | ||
|
||
getClassNamesForService (service) { | ||
const { activeMenu, currentApi } = this.props | ||
let classNames = 'PopNavigation-link' | ||
|
||
if (['serviceadmin', 'monitoring'].indexOf(activeMenu) !== -1 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Read comment above. |
||
service.id === currentApi.service.id) { | ||
classNames += ' current-context' | ||
} | ||
|
||
if (!service.link) { | ||
classNames += ' unauthorized' | ||
} | ||
|
||
return classNames | ||
} | ||
|
||
renderOptions () { | ||
const { apis } = this.props | ||
const { filterQuery } = this.state | ||
|
@@ -67,7 +82,7 @@ class ContextSelector extends React.Component { | |
|
||
const displayedApis = filteredApis.map(({ service }) => ( | ||
<li key={service.id} className="PopNavigation-listItem"> | ||
<a className={this.getClassNamesFor({ api: service.id })} href={service.link}> | ||
<a className={this.getClassNamesForService(service)} href={service.link}> | ||
<i className="fa fa-puzzle-piece" />{service.name} | ||
</a> | ||
</li> | ||
|
@@ -92,13 +107,13 @@ class ContextSelector extends React.Component { | |
</a> | ||
<ul id="context-menu" className="PopNavigation-list u-toggleable"> | ||
<li className="PopNavigation-listItem"> | ||
<a className={this.getClassNamesFor({ menu: 'dashboard' })} href={DASHBOARD_PATH}> | ||
<a className={this.getClassNamesForMenu('dashboard')} href={DASHBOARD_PATH}> | ||
<i className='fa fa-home' />Dashboard | ||
</a> | ||
</li> | ||
{audienceLink ? ( | ||
<li className="PopNavigation-listItem"> | ||
<a className={this.getClassNamesFor({ menu: 'audience' })} href={audienceLink}> | ||
<a className={this.getClassNamesForMenu('audience')} href={audienceLink}> | ||
<i className='fa fa-bullseye' />Audience | ||
</a> | ||
</li> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
// Copied from colors.scss | ||
$lochMaraBlue: #0088ce; //pf-blue-400 | ||
$font-color: #393f44; // pf-black-800 | ||
|
||
.current-context { | ||
color: $lochMaraBlue; | ||
} | ||
|
||
.PopNavigation-link > i { | ||
padding-right: 0.5rem; | ||
} | ||
|
||
.unauthorized { | ||
cursor: not-allowed; | ||
|
||
&:hover { | ||
color: $font-color; | ||
} | ||
} |
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extract to an array
const menuNames = ['buyers', 'finance', 'cms', 'site'];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! This actually gives me some ideas for a better refactoring, I will address it in a different PR.