Files
jellyfin-web/src/apps/modern/components/AppToolbar/index.tsx
T

69 lines
2.1 KiB
TypeScript
Raw Normal View History

import Stack from '@mui/material/Stack';
2024-05-21 00:19:28 +03:00
import React, { type FC } from 'react';
import { useLocation } from 'react-router-dom';
import { appRouter, PUBLIC_PATHS } from 'components/router/appRouter';
2026-06-30 12:17:22 -04:00
import BaseToolbar from 'components/toolbar/AppToolbar';
import ServerButton from 'components/toolbar/ServerButton';
2022-11-28 16:39:13 -05:00
import RemotePlayButton from './RemotePlayButton';
2022-11-28 16:39:13 -05:00
import SyncPlayButton from './SyncPlayButton';
2024-05-21 00:19:28 +03:00
import SearchButton from './SearchButton';
import UserViewNav from './userViews/UserViewNav';
2022-11-28 16:39:13 -05:00
interface AppToolbarProps {
2023-11-28 10:26:14 -05:00
isDrawerAvailable: boolean
2022-11-28 16:39:13 -05:00
isDrawerOpen: boolean
onDrawerButtonClick: (event: React.MouseEvent<HTMLElement>) => void
2022-11-28 16:39:13 -05:00
}
2026-06-30 12:17:22 -04:00
const AppToolbar: FC<AppToolbarProps> = ({
2023-11-28 10:26:14 -05:00
isDrawerAvailable,
2022-11-28 16:39:13 -05:00
isDrawerOpen,
2022-11-28 16:39:13 -05:00
onDrawerButtonClick
2022-11-28 16:39:13 -05:00
}) => {
2022-11-28 16:39:13 -05:00
const location = useLocation();
// The video osd does not show the standard toolbar
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);
2022-11-28 16:39:13 -05:00
return (
2026-06-30 12:17:22 -04:00
<BaseToolbar
buttons={!isPublicPath && (
2022-11-28 16:39:13 -05:00
<>
2023-09-27 02:07:40 -04:00
<SyncPlayButton />
<RemotePlayButton />
<SearchButton />
2022-11-28 16:39:13 -05:00
</>
)}
2023-09-27 02:07:40 -04:00
isDrawerAvailable={isDrawerAvailable}
isDrawerOpen={isDrawerOpen}
onDrawerButtonClick={onDrawerButtonClick}
isBackButtonAvailable={isBackButtonAvailable}
isUserMenuAvailable={!isPublicPath}
className='padded-left padded-right'
2023-09-27 02:07:40 -04:00
>
{!isDrawerAvailable && (
<Stack
direction='row'
spacing={0.5}
>
<ServerButton />
{!isPublicPath && (
<UserViewNav />
)}
</Stack>
)}
2026-06-30 12:17:22 -04:00
</BaseToolbar>
2022-11-28 16:39:13 -05:00
);
};
2026-06-30 12:17:22 -04:00
export default AppToolbar;