/* * 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 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import Button from '@mui/material/Button'; import DialogContentText from '@mui/material/DialogContentText'; import PopupState, { bindMenu, bindTrigger } from 'material-ui-popup-state'; import Menu from '@mui/material/Menu'; import MenuItem from '@mui/material/MenuItem'; import { useTranslation } from 'react-i18next'; import Stack from '@mui/material/Stack'; import { useUpdateChecker } from '@/modules/app-updates/hooks/useUpdateChecker.tsx'; interface BaseProps { info: string; actionTitle: string; updateCheckerProps: Parameters; changelogUrl?: string; disabled?: boolean; } interface UrlActionProps extends BaseProps { actionUrl: string; } interface ActionProps extends BaseProps { onAction: () => void; } type VersionUpdateInfoDialogProps = | (UrlActionProps & PropertiesNever>) | (PropertiesNever> & ActionProps); export const VersionUpdateInfoDialog = ({ info, actionUrl, onAction, actionTitle, updateCheckerProps, changelogUrl, disabled, }: VersionUpdateInfoDialogProps) => { const { t } = useTranslation(); const updateChecker = useUpdateChecker(...updateCheckerProps); if (!updateChecker.handleUpdate) { return null; } return ( {t('global.update.label.available')} {info} {changelogUrl && ( )} {(popupState) => ( <> { updateChecker.remindLater(); popupState.close(); }} > {t('global.button.remind_later')} { updateChecker.ignoreUpdate(); popupState.close(); }} > {t('global.button.ignore')} )} {actionUrl ? ( ) : ( )} ); };