forked from City-of-Helsinki/varaamo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin users will now have all external links within a dropdown menu 'Links'.
- Loading branch information
Showing
8 changed files
with
201 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import NavDropdown from 'react-bootstrap/lib/NavDropdown'; | ||
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'; | ||
import PropTypes from 'prop-types'; | ||
import MenuItem from 'react-bootstrap/lib/MenuItem'; | ||
|
||
import { injectT } from 'i18n'; | ||
import constants from 'constants/AppConstants'; | ||
import FAIcon from 'shared/fontawesome-icon'; | ||
|
||
function AdminDropdownLinks({ currentLanguage, gitbookURL, t }) { | ||
return ( | ||
<NavDropdown | ||
className="nav-link-dropdown" | ||
eventKey="link-dropdown" | ||
id="nav-admin-dropdown" | ||
title={t('Navbar.links')} | ||
> | ||
<MenuItem | ||
className="nav-dropdown-link" | ||
eventKey="adminMaintenance" | ||
href={constants.NAV_ADMIN_URLS.respa} | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
{t('Navbar.adminMaintenance')} | ||
|
||
<FAIcon icon={faExternalLinkAlt} /> | ||
</MenuItem> | ||
|
||
<MenuItem | ||
className="nav-dropdown-link" | ||
eventKey="adminGuide" | ||
href={gitbookURL} | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
{t('Navbar.adminGuide')} | ||
<FAIcon icon={faExternalLinkAlt} /> | ||
</MenuItem> | ||
|
||
<MenuItem | ||
className="nav-dropdown-link" | ||
eventKey="feedback" | ||
href={`https://opaskartta.turku.fi/eFeedback/${currentLanguage}/Feedback/30/1039`} | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
{t('Navbar.feedback')} | ||
<FAIcon icon={faExternalLinkAlt} /> | ||
</MenuItem> | ||
</NavDropdown> | ||
); | ||
} | ||
|
||
AdminDropdownLinks.propTypes = { | ||
currentLanguage: PropTypes.string.isRequired, | ||
gitbookURL: PropTypes.string.isRequired, | ||
t: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default injectT(AdminDropdownLinks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { MenuItem, NavDropdown } from 'react-bootstrap'; | ||
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import constants from 'constants/AppConstants'; | ||
import AdminDropdownLinks from './AdminDropdownLinks'; | ||
import { shallowWithIntl } from 'utils/testUtils'; | ||
import FAIcon from 'shared/fontawesome-icon'; | ||
|
||
|
||
describe('shared/main-navbar/AdminDropdownLinks', () => { | ||
const defaultProps = { | ||
currentLanguage: 'fi', | ||
gitbookURL: 'https://gitbook.com/abc' | ||
}; | ||
|
||
function getWrapper(props) { | ||
return shallowWithIntl(<AdminDropdownLinks {...defaultProps} {...props} />); | ||
} | ||
|
||
describe('renders', () => { | ||
test('NavDropdown', () => { | ||
const navDropdown = getWrapper().find(NavDropdown); | ||
expect(navDropdown).toHaveLength(1); | ||
expect(navDropdown.prop('className')).toBe('nav-link-dropdown'); | ||
expect(navDropdown.prop('eventKey')).toBe('link-dropdown'); | ||
expect(navDropdown.prop('id')).toBe('nav-admin-dropdown'); | ||
expect(navDropdown.prop('title')).toBe('Navbar.links'); | ||
}); | ||
|
||
test('all MenuItems', () => { | ||
const menuItems = getWrapper().find(MenuItem); | ||
expect(menuItems).toHaveLength(3); | ||
|
||
menuItems.forEach(menuItem => { | ||
expect(menuItem.prop('className')).toBe('nav-dropdown-link'); | ||
expect(menuItem.prop('rel')).toBe('noreferrer'); | ||
expect(menuItem.prop('target')).toBe('_blank'); | ||
}); | ||
}); | ||
|
||
test('first menu item has correct unique props', () => { | ||
const menuItem = getWrapper().find(MenuItem).first(); | ||
expect(menuItem.prop('href')).toBe(constants.NAV_ADMIN_URLS.respa); | ||
expect(menuItem.prop('eventKey')).toBe('adminMaintenance'); | ||
expect(menuItem.prop('children')).toContain('Navbar.adminMaintenance'); | ||
}); | ||
|
||
test('second menu item has correct unique props', () => { | ||
const menuItem = getWrapper().find(MenuItem).at(1); | ||
expect(menuItem.prop('href')).toBe(defaultProps.gitbookURL); | ||
expect(menuItem.prop('eventKey')).toBe('adminGuide'); | ||
expect(menuItem.prop('children')).toContain('Navbar.adminGuide'); | ||
}); | ||
|
||
test('third menu item has correct unique props', () => { | ||
const menuItem = getWrapper().find(MenuItem).at(2); | ||
expect(menuItem.prop('href')).toBe( | ||
`https://opaskartta.turku.fi/eFeedback/${defaultProps.currentLanguage}/Feedback/30/1039` | ||
); | ||
expect(menuItem.prop('eventKey')).toBe('feedback'); | ||
expect(menuItem.prop('children')).toContain('Navbar.feedback'); | ||
}); | ||
|
||
test('all FAIcons', () => { | ||
const icons = getWrapper().find(FAIcon); | ||
expect(icons).toHaveLength(3); | ||
icons.forEach(icon => expect(icon.prop('icon')).toBe(faExternalLinkAlt)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.