import Badge from '@app/components/Common/Badge'; import Button from '@app/components/Common/Button'; import LoadingSpinner from '@app/components/Common/LoadingSpinner'; import Modal from '@app/components/Common/Modal'; import globalMessages from '@app/i18n/globalMessages'; import { Transition } from '@headlessui/react'; import { DocumentTextIcon } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import { Fragment, useState } from 'react'; import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl'; import useSWR from 'swr'; // dyanmic is having trouble extracting the props for react-markdown here so we are just ignoring it since its really // only children we are using // eslint-disable-next-line @typescript-eslint/no-explicit-any const ReactMarkdown = dynamic(() => import('react-markdown'), { ssr: false, }); const messages = defineMessages({ releases: 'Releases', releasedataMissing: 'Release data is currently unavailable.', versionChangelog: '{version} Changelog', viewongithub: 'View on GitHub', latestversion: 'Latest', currentversion: 'Current', viewchangelog: 'View Changelog', }); const REPO_RELEASE_API = 'https://api.github.com/repos/sct/overseerr/releases?per_page=20'; interface GitHubRelease { url: string; assets_url: string; upload_url: string; html_url: string; id: number; node_id: string; tag_name: string; target_commitish: string; name: string; draft: boolean; prerelease: boolean; created_at: string; published_at: string; tarball_url: string; zipball_url: string; body: string; } interface ReleaseProps { release: GitHubRelease; isLatest: boolean; currentVersion: string; } const Release = ({ currentVersion, release, isLatest }: ReleaseProps) => { const intl = useIntl(); const [isModalOpen, setModalOpen] = useState(false); return (
setModalOpen(false)} title={intl.formatMessage(messages.versionChangelog, { version: release.name, })} cancelText={intl.formatMessage(globalMessages.close)} okText={intl.formatMessage(messages.viewongithub)} onOk={() => { window.open(release.html_url, '_blank'); }} >
{release.body}
{release.name} {isLatest && ( {intl.formatMessage(messages.latestversion)} )} {release.name.includes(currentVersion) && ( {intl.formatMessage(messages.currentversion)} )}
); }; interface ReleasesProps { currentVersion: string; } const Releases = ({ currentVersion }: ReleasesProps) => { const intl = useIntl(); const { data, error } = useSWR(REPO_RELEASE_API); if (!data && !error) { return ; } if (!data) { return (
{intl.formatMessage(messages.releasedataMissing)}
); } return (

{intl.formatMessage(messages.releases)}

{data.map((release, index) => { return (
); })}
); }; export default Releases;