diff --git a/frontend/src/Components/Link/Link.js b/frontend/src/Components/Link/Link.js index 6a2b99e33..e061cf9bd 100644 --- a/frontend/src/Components/Link/Link.js +++ b/frontend/src/Components/Link/Link.js @@ -38,7 +38,7 @@ class Link extends Component { const linkProps = { target }; let el = component; - if (to) { + if (to && typeof to === 'string') { if ((/\w+?:\/\//).test(to)) { el = 'a'; linkProps.href = to; @@ -53,6 +53,18 @@ class Link extends Component { linkProps.to = `${window.Radarr.urlBase}/${to.replace(/^\//, '')}`; linkProps.target = target; } + } else if (to && typeof to === 'object') { + el = RouterLink; + linkProps.target = target; + if (to.pathname.startsWith(`${window.Radarr.urlBase}/`)) { + linkProps.to = to; + } else { + const pathname = `${window.Radarr.urlBase}/${to.pathname.replace(/^\//, '')}`; + linkProps.to = { + ...to, + pathname + }; + } } if (el === 'button' || el === 'input') { @@ -83,7 +95,7 @@ class Link extends Component { Link.propTypes = { className: PropTypes.string, component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), - to: PropTypes.string, + to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), target: PropTypes.string, isDisabled: PropTypes.bool, noRouter: PropTypes.bool, diff --git a/frontend/src/Components/Page/Header/PageHeader.js b/frontend/src/Components/Page/Header/PageHeader.js index 28b343edc..c4c5dbb58 100644 --- a/frontend/src/Components/Page/Header/PageHeader.js +++ b/frontend/src/Components/Page/Header/PageHeader.js @@ -53,7 +53,13 @@ class PageHeader extends Component { return (
- +