2022-11-09 18:09:15 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2022-11-09 18:09:15 +01:00
|
|
|
|
|
|
|
|
import Label from '@mui/icons-material/Label';
|
|
|
|
|
import MoreHoriz from '@mui/icons-material/MoreHoriz';
|
|
|
|
|
import Refresh from '@mui/icons-material/Refresh';
|
2024-04-14 15:50:12 +02:00
|
|
|
import IconButton from '@mui/material/IconButton';
|
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
|
|
|
import Menu from '@mui/material/Menu';
|
|
|
|
|
import MenuItem from '@mui/material/MenuItem';
|
2024-04-07 15:33:08 +02:00
|
|
|
import React from 'react';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-01-26 20:50:51 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import SyncAltIcon from '@mui/icons-material/SyncAlt';
|
2024-04-14 15:50:12 +02:00
|
|
|
import { useTheme } from '@mui/material/styles';
|
|
|
|
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
2024-07-08 18:02:50 +02:00
|
|
|
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { AppRoutes } from '@/base/AppRoute.constants.ts';
|
2025-10-04 14:47:38 +02:00
|
|
|
import { GlobalDialogManager } from '@/base/global-dialog/GlobalDialogManager.tsx';
|
|
|
|
|
import { CategorySelect } from '@/features/category/components/CategorySelect.tsx';
|
2022-11-09 18:09:15 +01:00
|
|
|
|
|
|
|
|
interface IProps {
|
2024-07-08 18:02:50 +02:00
|
|
|
manga: Pick<MangaType, 'id' | 'inLibrary' | 'sourceId' | 'title'>;
|
2022-11-09 18:09:15 +01:00
|
|
|
onRefresh: () => any;
|
|
|
|
|
refreshing: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const MangaToolbarMenu = ({ manga, onRefresh, refreshing }: IProps) => {
|
2023-03-23 13:59:32 +01:00
|
|
|
const { t } = useTranslation();
|
2024-01-26 20:50:51 +01:00
|
|
|
|
2022-11-09 18:09:15 +01:00
|
|
|
const theme = useTheme();
|
|
|
|
|
const isLargeScreen = useMediaQuery(theme.breakpoints.up('sm'));
|
|
|
|
|
|
|
|
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
|
|
|
const open = Boolean(anchorEl);
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
setAnchorEl(null);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-04 14:47:38 +02:00
|
|
|
const openCategorySelection = () => {
|
|
|
|
|
GlobalDialogManager.show(CategorySelect, { mangaId: manga.id });
|
|
|
|
|
};
|
2022-11-09 18:09:15 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{isLargeScreen && (
|
|
|
|
|
<>
|
2025-02-01 14:24:38 +01:00
|
|
|
<CustomTooltip title={t('manga.label.reload_from_source')} disabled={refreshing}>
|
2023-02-06 10:06:33 +01:00
|
|
|
<IconButton
|
|
|
|
|
onClick={() => {
|
|
|
|
|
onRefresh();
|
|
|
|
|
}}
|
|
|
|
|
disabled={refreshing}
|
2024-09-06 16:59:27 +02:00
|
|
|
color="inherit"
|
2023-02-06 10:06:33 +01:00
|
|
|
>
|
2022-11-09 18:09:15 +01:00
|
|
|
<Refresh />
|
|
|
|
|
</IconButton>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
2022-11-09 18:09:15 +01:00
|
|
|
{manga.inLibrary && (
|
2024-03-04 20:40:47 +01:00
|
|
|
<>
|
2025-02-01 14:24:38 +01:00
|
|
|
<CustomTooltip title={t('global.button.migrate')}>
|
2024-03-04 20:40:47 +01:00
|
|
|
<Link
|
2025-05-21 01:55:32 +02:00
|
|
|
to={AppRoutes.migrate.childRoutes.search.path(
|
|
|
|
|
manga.sourceId,
|
|
|
|
|
manga.id,
|
|
|
|
|
manga.title,
|
|
|
|
|
)}
|
2024-03-04 20:40:47 +01:00
|
|
|
state={{ mangaTitle: manga.title }}
|
|
|
|
|
style={{ textDecoration: 'none', color: 'inherit' }}
|
|
|
|
|
>
|
2024-09-06 16:59:27 +02:00
|
|
|
<IconButton color="inherit">
|
2024-03-04 20:40:47 +01:00
|
|
|
<SyncAltIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Link>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
|
|
|
|
<CustomTooltip title={t('manga.label.edit_categories')}>
|
2024-03-04 20:40:47 +01:00
|
|
|
<IconButton
|
|
|
|
|
onClick={() => {
|
2025-10-04 14:47:38 +02:00
|
|
|
openCategorySelection();
|
2024-03-04 20:40:47 +01:00
|
|
|
}}
|
2024-09-06 16:59:27 +02:00
|
|
|
color="inherit"
|
2024-03-04 20:40:47 +01:00
|
|
|
>
|
|
|
|
|
<Label />
|
|
|
|
|
</IconButton>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
2024-03-04 20:40:47 +01:00
|
|
|
</>
|
2022-11-09 18:09:15 +01:00
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{!isLargeScreen && (
|
|
|
|
|
<>
|
|
|
|
|
<IconButton
|
|
|
|
|
id="chaptersMenuButton"
|
|
|
|
|
aria-controls={open ? 'chaptersMenu' : undefined}
|
|
|
|
|
aria-haspopup="true"
|
|
|
|
|
aria-expanded={open ? 'true' : undefined}
|
|
|
|
|
onClick={(e) => setAnchorEl(e.currentTarget)}
|
2024-09-06 16:59:27 +02:00
|
|
|
color="inherit"
|
2022-11-09 18:09:15 +01:00
|
|
|
>
|
|
|
|
|
<MoreHoriz />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<Menu
|
|
|
|
|
id="chaptersMenu"
|
|
|
|
|
anchorEl={anchorEl}
|
|
|
|
|
open={open}
|
|
|
|
|
onClose={handleClose}
|
|
|
|
|
MenuListProps={{
|
|
|
|
|
'aria-labelledby': 'chaptersMenuButton',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<MenuItem
|
2023-02-06 10:06:33 +01:00
|
|
|
onClick={() => {
|
|
|
|
|
onRefresh();
|
|
|
|
|
handleClose();
|
|
|
|
|
}}
|
2022-11-09 18:09:15 +01:00
|
|
|
disabled={refreshing}
|
|
|
|
|
>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<Refresh fontSize="small" />
|
|
|
|
|
</ListItemIcon>
|
2023-03-23 13:59:32 +01:00
|
|
|
<ListItemText>{t('manga.label.reload_from_source')}</ListItemText>
|
2022-11-09 18:09:15 +01:00
|
|
|
</MenuItem>
|
2024-03-29 00:15:31 +01:00
|
|
|
{manga.inLibrary && [
|
|
|
|
|
<MenuItem
|
|
|
|
|
key="migrate"
|
|
|
|
|
component={Link}
|
2025-05-21 01:55:32 +02:00
|
|
|
to={AppRoutes.migrate.childRoutes.search.path(manga.sourceId, manga.id, manga.title)}
|
2024-03-29 00:15:31 +01:00
|
|
|
state={{ mangaTitle: manga.title }}
|
|
|
|
|
style={{ textDecoration: 'none', color: 'inherit' }}
|
|
|
|
|
>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<SyncAltIcon fontSize="small" />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText>{t('migrate.title')}</ListItemText>
|
|
|
|
|
</MenuItem>,
|
|
|
|
|
<MenuItem
|
|
|
|
|
key="categories"
|
|
|
|
|
onClick={() => {
|
2025-10-04 14:47:38 +02:00
|
|
|
openCategorySelection();
|
2024-03-29 00:15:31 +01:00
|
|
|
handleClose();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<Label fontSize="small" />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText>{t('manga.label.edit_categories')}</ListItemText>
|
|
|
|
|
</MenuItem>,
|
|
|
|
|
]}
|
2022-11-09 18:09:15 +01:00
|
|
|
</Menu>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|