Backport pull request #7500 from jellyfin-web/release-10.11.z
Restore back button in experimental layout for apps Original-merge: 6d8c8c0566a7e3cbf96aeb98800b11c6f5c7a332 Merged-by: thornbill <thornbill@users.noreply.github.com> Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import Stack from '@mui/material/Stack';
|
|||||||
import React, { type FC } from 'react';
|
import React, { type FC } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { appRouter, PUBLIC_PATHS } from 'components/router/appRouter';
|
||||||
import AppToolbar from 'components/toolbar/AppToolbar';
|
import AppToolbar from 'components/toolbar/AppToolbar';
|
||||||
import ServerButton from 'components/toolbar/ServerButton';
|
import ServerButton from 'components/toolbar/ServerButton';
|
||||||
|
|
||||||
@@ -16,14 +17,6 @@ interface AppToolbarProps {
|
|||||||
onDrawerButtonClick: (event: React.MouseEvent<HTMLElement>) => void
|
onDrawerButtonClick: (event: React.MouseEvent<HTMLElement>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const PUBLIC_PATHS = [
|
|
||||||
'/addserver',
|
|
||||||
'/selectserver',
|
|
||||||
'/login',
|
|
||||||
'/forgotpassword',
|
|
||||||
'/forgotpasswordpin'
|
|
||||||
];
|
|
||||||
|
|
||||||
const ExperimentalAppToolbar: FC<AppToolbarProps> = ({
|
const ExperimentalAppToolbar: FC<AppToolbarProps> = ({
|
||||||
isDrawerAvailable,
|
isDrawerAvailable,
|
||||||
isDrawerOpen,
|
isDrawerOpen,
|
||||||
@@ -34,6 +27,10 @@ const ExperimentalAppToolbar: FC<AppToolbarProps> = ({
|
|||||||
// The video osd does not show the standard toolbar
|
// The video osd does not show the standard toolbar
|
||||||
if (location.pathname === '/video') return null;
|
if (location.pathname === '/video') return null;
|
||||||
|
|
||||||
|
// Only show the back button in apps when appropriate
|
||||||
|
const isBackButtonAvailable = window.NativeShell && appRouter.canGoBack(location.pathname);
|
||||||
|
|
||||||
|
// Check if the current path is a public path to hide user content
|
||||||
const isPublicPath = PUBLIC_PATHS.includes(location.pathname);
|
const isPublicPath = PUBLIC_PATHS.includes(location.pathname);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -48,6 +45,7 @@ const ExperimentalAppToolbar: FC<AppToolbarProps> = ({
|
|||||||
isDrawerAvailable={isDrawerAvailable}
|
isDrawerAvailable={isDrawerAvailable}
|
||||||
isDrawerOpen={isDrawerOpen}
|
isDrawerOpen={isDrawerOpen}
|
||||||
onDrawerButtonClick={onDrawerButtonClick}
|
onDrawerButtonClick={onDrawerButtonClick}
|
||||||
|
isBackButtonAvailable={isBackButtonAvailable}
|
||||||
isUserMenuAvailable={!isPublicPath}
|
isUserMenuAvailable={!isPublicPath}
|
||||||
>
|
>
|
||||||
{!isDrawerAvailable && (
|
{!isDrawerAvailable && (
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { history } from 'RootAppRouter';
|
|||||||
const START_PAGE_PATHS = ['/home', '/login', '/selectserver'];
|
const START_PAGE_PATHS = ['/home', '/login', '/selectserver'];
|
||||||
|
|
||||||
/** Pages that do not require a user to be logged in to view. */
|
/** Pages that do not require a user to be logged in to view. */
|
||||||
const PUBLIC_PATHS = [
|
export const PUBLIC_PATHS = [
|
||||||
'/addserver',
|
'/addserver',
|
||||||
'/selectserver',
|
'/selectserver',
|
||||||
'/login',
|
'/login',
|
||||||
@@ -122,9 +122,7 @@ class AppRouter {
|
|||||||
return this.baseRoute;
|
return this.baseRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
canGoBack() {
|
canGoBack(path = history.location.pathname) {
|
||||||
const path = history.location.pathname;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!document.querySelector('.dialogContainer')
|
!document.querySelector('.dialogContainer')
|
||||||
&& START_PAGE_PATHS.includes(path)
|
&& START_PAGE_PATHS.includes(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user