Skip to content
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

Service Desk link addition to Navigation #5024

Merged
merged 3 commits into from
Mar 29, 2022
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
42 changes: 35 additions & 7 deletions frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Popup from 'reactjs-popup';
import { FormattedMessage } from 'react-intl';

import messages from './messages';
import { ORG_URL, ORG_NAME, ORG_LOGO } from '../../config';
import { ORG_URL, ORG_NAME, ORG_LOGO, SERVICE_DESK } from '../../config';
import logo from '../../assets/img/main-logo.svg';
import { ExternalLinkIcon } from '../svgIcons';
import { Dropdown } from '../dropdown';
Expand Down Expand Up @@ -33,6 +33,7 @@ function getMenuItensForUser(userDetails, organisations) {
{ label: messages.manage, link: 'manage', authenticated: true, manager: true },
{ label: messages.learn, link: 'learn', showAlways: true },
{ label: messages.about, link: 'about', showAlways: true },
{ label: messages.support, link: SERVICE_DESK, showAlways: true, serviceDesk: true },
];
let filteredMenuItems;
if (userDetails.username) {
Expand Down Expand Up @@ -97,9 +98,21 @@ const PopupItems = (props) => {
.filter((item) => item.authenticated === false || item.showAlways)
.map((item, n) => (
<p key={n}>
<Link to={item.link} className={props.linkCombo} onClick={props.close}>
<FormattedMessage {...item.label} />
</Link>
{!item.serviceDesk ? (
<Link to={item.link} className={props.linkCombo} onClick={props.close}>
<FormattedMessage {...item.label} />
</Link>
) : (
<a
href={item.link}
target="_blank"
rel="noreferrer"
className="link mh3 barlow-condensed blue-dark f4 ttu"
>
<FormattedMessage {...item.label} />
<ExternalLinkIcon className="pl2 v-cen" style={{ height: '15px' }} />
</a>
)}
</p>
))}
<p className="bb b--grey-light"></p>
Expand All @@ -114,6 +127,7 @@ const PopupItems = (props) => {
</Link>
</p>
))}

{/* user links */}
{props.userDetails.username && (
<>
Expand Down Expand Up @@ -163,9 +177,23 @@ class Header extends React.Component {
return (
<div className="v-mid">
{filteredMenuItems.map((item, n) => (
<TopNavLink to={item.link} key={n} isActive={this.isActive}>
<FormattedMessage {...item.label} />
</TopNavLink>
<>
{!item.serviceDesk ? (
<TopNavLink to={item.link} key={n} isActive={this.isActive}>
<FormattedMessage {...item.label} />
</TopNavLink>
) : (
<a
href={item.link}
target="_blank"
rel="noreferrer"
className="link mh3 barlow-condensed blue-dark f4 ttu"
>
<FormattedMessage {...item.label} />
<ExternalLinkIcon className="pl2 v-cen" style={{ height: '15px' }} />
</a>
)}
</>
))}
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/header/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default defineMessages({
id: 'header.nav.aboutLink',
defaultMessage: 'About',
},
support: {
id: 'header.nav.support',
defaultMessage: 'Support',
},
myContributions: {
id: 'header.nav.my_contributions',
defaultMessage: 'My contributions',
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/header/tests/menuItens.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { getMenuItensForUser } from '../index';
import { SERVICE_DESK } from '../../../config';

it('test menuItems for unlogged user', () => {
const userDetails = {};
const menuItems = getMenuItensForUser(userDetails, []).map((i) => i.link);
expect(menuItems).toEqual(['explore', 'learn', 'about']);
expect(menuItems).toEqual(['explore', 'learn', 'about', SERVICE_DESK]);
});

it('test menuItems for logged non admin user', () => {
const userDetails = { username: 'test', role: 'MAPPER' };
const menuItems = getMenuItensForUser(userDetails, []).map((i) => i.link);
expect(menuItems).toEqual(['explore', 'contributions', 'learn', 'about']);
expect(menuItems).toEqual(['explore', 'contributions', 'learn', 'about', SERVICE_DESK]);
});

it('test menuItems for logged non admin user, but org manager', () => {
const userDetails = { username: 'test', role: 'MAPPER' };
const menuItems = getMenuItensForUser(userDetails, [1, 3, 4]).map((i) => i.link);
expect(menuItems).toEqual(['explore', 'contributions', 'manage', 'learn', 'about']);
expect(menuItems).toEqual(['explore', 'contributions', 'manage', 'learn', 'about', SERVICE_DESK]);
});

it('test menuItems for logged admin user', () => {
const userDetails = { username: 'test', role: 'ADMIN' };
const menuItems = getMenuItensForUser(userDetails, []).map((i) => i.link);
expect(menuItems).toEqual(['explore', 'contributions', 'manage', 'learn', 'about']);
expect(menuItems).toEqual(['explore', 'contributions', 'manage', 'learn', 'about', SERVICE_DESK]);
});
8 changes: 8 additions & 0 deletions frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"banner.button.agree": "I agree",
"banner.privacyPolicy": "privacy policy",
"banner.text": "We use cookies and similar technologies to recognize and analyze your visits, and measure traffic usage and activity. You can learn about how we use the data about your visit or information you provide reading our {link}. By clicking \"I Agree\", you consent to the use of cookies.",
"banner.button.close": "Close",
"banner.button.learnmore": "Learn More",
"banner.title.notification": "Important notification for users",
"banner.text.archivalNotification": "Attention: as part of the ongoing maintenance of the Tasking Manager, projects created before 2020 will be archived.",
"comment.input.imageUpload.error": "The image upload failed.",
"comment.input.imageUpload.progress": "Uploading file...",
"comment.input.sending.progress": "Sending message...",
Expand Down Expand Up @@ -55,6 +59,7 @@
"header.nav.projects": "Explore projects",
"header.nav.learn": "Learn",
"header.nav.aboutLink": "About",
"header.nav.support": "Support",
"header.nav.my_contributions": "My contributions",
"header.nav.manage": "Manage",
"header.buttons.logIn": "Log in",
Expand Down Expand Up @@ -406,6 +411,8 @@
"projects.formInputs.random_task_selection": "Enforce random task selection",
"projects.formInputs.random_task_selection.mapping": "Enforce random task selection on mapping",
"projects.formInputs.random_task_selection.description": "If checked, users must edit tasks at random for the initial editing stage (managers and admins are exempt).",
"projects.formInputs.rapid_power_user": "Enable RapiD Power User Features",
"projects.formInputs.rapid_power_user.description": "If checked, RapiD will load with the power user dialog enabled.",
"projects.formInputs.imagery": "Imagery",
"projects.formInputs.imagery.note": "Follow this format for TMS URLs: {exampleUrl}",
"projects.formInputs.priority_areas.options.polygon": "Draw polygon",
Expand Down Expand Up @@ -531,6 +538,7 @@
"project.stats.totalEdits": "Total map edits",
"project.stats.changesets": "Changesets",
"project.stats.edits": "Edits",
"project.stats.edits.info": "These stats are retrieved using the default changeset comment of the project",
"project.tasks.unsaved_map_changes.title": "You have some unsaved map changes",
"project.tasks.unsaved_map_changes.split": "Save or undo it to be able to split the task",
"project.tasks.unsaved_map_changes.unlock": "Save or undo it to be able to select another task",
Expand Down