Commit f8e4d3cd authored by Oleksii Savran's avatar Oleksii Savran Committed by Viacheslav Pavlov
Browse files

Fix: Disappearing highlighter at accessions with doi

-Fixed accession's redirect
parent 9d3d7eb3
......@@ -55,7 +55,7 @@ app.get(':lang(/[a-z]{2})?/a/:uuid(\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12})'
return AccessionService.getByUuid(uuid)
.then((acce) => {
if (acce.doi) {
res.redirect(308, `${ config.frontendPath }${ lang || '' }/${ acce.doi }`);
res.redirect(308, `${ config.frontendPath }${ lang || '' }/a/${ acce.doi }`);
} else {
next();
}
......
......@@ -39,7 +39,7 @@ const publicRoutes = [
},
{
// We need to take out the '10.' prefix for matching to work
path: '/10.:doi(\\d+\/.+)',
path: '/a/10.:doi(\\d+\/.+)',
component: Loadable({ loader: () => import(/* webpackMode:"lazy", webpackChunkName: "accessions" */'accessions/ui/DisplayPage') }),
exact: true,
},
......
......@@ -111,7 +111,7 @@ class BrowsePage extends React.Component<IBrowsePageProps, any> {
const accession = nextProps.accession ? nextProps.accession.details : null;
if (accession && accession.doi && !doi && accession.uuid === uuid) {
navigateTo(`/${accession.doi}`);
navigateTo(`/a/${accession.doi}`);
}
}
......
......@@ -44,7 +44,7 @@ function AccessionLink({ to: accession, edit = false, children = null }
if (accession) {
return (
<Link to={ accession.doi ? `/${accession.doi}` : `/a/${accession.uuid}` }>
<Link to={ accession.doi ? `/a/${accession.doi}` : `/a/${accession.uuid}` }>
{ children || accession.accessionNumber }
</Link>
);
......
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import MenuItem from './MenuItem';
import {checkActiveNavItem} from 'utilities';
const styleSheet = (theme) => ({
/* tslint:disable */
......@@ -27,30 +28,7 @@ interface IMenuBarProps extends React.ClassAttributes<any> {
class MenuBar extends React.Component<IMenuBarProps, any> {
private checkIsActive = (path) => {
const baseLocation = this.props.location.pathname.replace(/\/v((?!ocabulary).+)|\/@.+/, '');
const checkInclude = (path: string): boolean => {
const skipItems = ['/', '/admin', '/dashboard', '/dashboard/profile', '/admin/content'];
if (skipItems.some((skipItem) => skipItem === path)) {
return false;
} else {
const pathWithEndSlash = path[path.length - 1] === '/' ? path : `${path}/`;
return baseLocation.includes(pathWithEndSlash);
}
};
return (
baseLocation === path.to || checkInclude(path.to) ||
(path.tabs && path.tabs.some((tab) => tab === baseLocation || checkInclude(tab))) ||
path.subMenus &&
path.subMenus.some((subMenu) => {
return (
subMenu.to === baseLocation ||
checkInclude(subMenu.to) ||
(subMenu.tabs && subMenu.tabs.some((tab) => tab === baseLocation || checkInclude(tab)))
);
})
);
return checkActiveNavItem(this.props.location, path);
}
private renderMenu = (path: any) => {
......
......@@ -5,6 +5,8 @@ import { translate } from 'react-i18next';
import { compose } from 'redux';
import languages from 'data/Languages';
import {checkActiveNavItem} from 'utilities';
import Drawer from '@material-ui/core/Drawer';
import { NavLink } from 'react-router-dom';
import Close from '@material-ui/icons/Close';
......@@ -178,30 +180,7 @@ class MobileNavigation extends React.Component<IMobileNavigationProps, any> {
}
public checkIsActive = (path) => (match, location) => {
const baseLocation = location.pathname.replace(/\/v((?!ocabulary).+)|\/@.+/, '');
const checkInclude = (path: string): boolean => {
const skipItems = ['/', '/admin', '/dashboard', '/dashboard/profile', '/admin/content'];
if (skipItems.some((skipItem) => skipItem === path)) {
return false;
} else {
const pathWithEndSlash = path[path.length - 1] === '/' ? path : `${path}/`;
return baseLocation.includes(pathWithEndSlash);
}
};
return (
baseLocation === path.to || checkInclude(path.to) ||
(path.tabs && path.tabs.some((tab) => tab === baseLocation || checkInclude(tab))) ||
path.subMenus &&
path.subMenus.some((subMenu) => {
return (
subMenu.to === baseLocation ||
checkInclude(subMenu.to) ||
(subMenu.tabs && subMenu.tabs.some((tab) => tab === baseLocation || checkInclude(tab)))
);
})
);
return checkActiveNavItem(location, path);
}
public render() {
......
......@@ -210,3 +210,30 @@ export function insertAtCaret(element, myValue) {
element.focus();
}
}
export const checkActiveNavItem = (location, path) => {
const baseLocation = location.pathname.replace(/\/v((?!ocabulary).+)|\/@.+/, '');
const checkInclude = (path: string): boolean => {
const skipItems = ['/', '/admin', '/dashboard', '/dashboard/profile', '/admin/content'];
if (skipItems.some((skipItem) => skipItem === path)) {
return false;
} else {
const pathWithEndSlash = path[path.length - 1] === '/' ? path : `${path}/`;
return baseLocation.includes(pathWithEndSlash);
}
};
return (
baseLocation === path.to || checkInclude(path.to) ||
(path.tabs && path.tabs.some((tab) => tab === baseLocation || checkInclude(tab))) ||
path.subMenus &&
path.subMenus.some((subMenu) => {
return (
subMenu.to === baseLocation ||
checkInclude(subMenu.to) ||
(subMenu.tabs && subMenu.tabs.some((tab) => tab === baseLocation || checkInclude(tab)))
);
})
);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment