1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #5789 from thornbill/update-plugin-headings

Add headings and links to plugin pages
This commit is contained in:
Bill Thornton 2024-07-15 16:46:18 -04:00 committed by GitHub
commit 845d237200
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 6 deletions

View file

@ -4,6 +4,8 @@ import { Link, useLocation, useSearchParams } from 'react-router-dom';
interface ListItemLinkProps extends ListItemButtonBaseProps {
to: string
includePaths?: string[]
excludePaths?: string[]
}
const isMatchingParams = (routeParams: URLSearchParams, currentParams: URLSearchParams) => {
@ -19,6 +21,8 @@ const isMatchingParams = (routeParams: URLSearchParams, currentParams: URLSearch
const ListItemLink: FC<ListItemLinkProps> = ({
children,
to,
includePaths = [],
excludePaths = [],
...params
}) => {
const location = useLocation();
@ -27,8 +31,11 @@ const ListItemLink: FC<ListItemLinkProps> = ({
const [ toPath, toParams ] = to.split('?');
// eslint-disable-next-line compat/compat
const toSearchParams = new URLSearchParams(`?${toParams}`);
const selectedPaths = [ toPath, ...includePaths ];
const selected = location.pathname === toPath && (!toParams || isMatchingParams(toSearchParams, searchParams));
const selected = selectedPaths.includes(location.pathname)
&& !excludePaths.includes(location.pathname + location.search)
&& (!toParams || isMatchingParams(toSearchParams, searchParams));
return (
<ListItemButton