Files
commafeed/commafeed-client/src/pages/app/AboutPage.tsx

129 lines
5.8 KiB
TypeScript
Raw Normal View History

2022-08-15 13:26:45 +02:00
import { t, Trans } from "@lingui/macro"
2023-05-26 08:28:23 +02:00
import { Anchor, Box, Container, createStyles, List, NativeSelect, SimpleGrid, Title } from "@mantine/core"
2022-08-15 13:26:45 +02:00
import { Constants } from "app/constants"
import { redirectToApiDocumentation } from "app/redirect/thunks"
2022-08-15 15:42:56 +02:00
import { useAppDispatch, useAppSelector } from "app/store"
2022-08-15 13:26:45 +02:00
import { CategorySelect } from "components/content/add/CategorySelect"
import { KeyboardShortcutsHelp } from "components/KeyboardShortcutsHelp"
import { useBrowserExtension } from "hooks/useBrowserExtension"
2022-08-15 13:26:45 +02:00
import React, { useState } from "react"
import { TbHelp, TbKeyboard, TbPuzzle, TbRocket } from "react-icons/tb"
2022-08-15 18:32:18 +02:00
const useStyles = createStyles(() => ({
sectionTitle: {
display: "flex",
alignItems: "center",
},
}))
function Section(props: { title: React.ReactNode; icon: React.ReactNode; children: React.ReactNode }) {
2022-08-15 18:32:18 +02:00
const { classes } = useStyles()
2022-08-15 13:26:45 +02:00
return (
2022-08-15 18:32:18 +02:00
<Box my="xl">
<Box className={classes.sectionTitle} mb="xs">
{props.icon}
<Title order={3} ml="xs">
{props.title}
</Title>
</Box>
2022-08-15 13:26:45 +02:00
<Box>{props.children}</Box>
</Box>
)
}
function NextUnreadBookmarklet() {
2022-08-19 10:34:04 +02:00
const [categoryId, setCategoryId] = useState(Constants.categories.all.id)
2022-08-15 13:26:45 +02:00
const [order, setOrder] = useState("desc")
const baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("#"))
const href = `javascript:window.location.href='${baseUrl}next?category=${categoryId}&order=${order}&t='+new Date().getTime();`
return (
<Box>
<CategorySelect value={categoryId} onChange={c => c && setCategoryId(c)} withAll description={<Trans>Category</Trans>} />
2022-08-15 13:26:45 +02:00
<NativeSelect
data={[
{ value: "desc", label: t`Newest first` },
{ value: "asc", label: t`Oldest first` },
]}
value={order}
onChange={e => setOrder(e.target.value)}
description={<Trans>Order</Trans>}
2022-08-15 13:26:45 +02:00
/>
<Trans>Drag link to bookmark bar</Trans>
<span> </span>
<Anchor href={href} target="_blank" rel="noreferrer">
<Trans>CommaFeed next unread item</Trans>
</Anchor>
</Box>
)
}
export function AboutPage() {
const version = useAppSelector(state => state.server.serverInfos?.version)
const revision = useAppSelector(state => state.server.serverInfos?.gitCommit)
const { isBrowserExtensionInstalled, browserExtensionVersion, isBrowserExtensionInstallable } = useBrowserExtension()
2022-08-15 15:42:56 +02:00
const dispatch = useAppDispatch()
2022-08-15 13:26:45 +02:00
return (
<Container size="xl">
<SimpleGrid cols={2} breakpoints={[{ maxWidth: Constants.layout.mobileBreakpoint, cols: 1 }]}>
<Section title={<Trans>About</Trans>} icon={<TbHelp size={24} />}>
2022-08-15 13:26:45 +02:00
<Box>
<Trans>
CommaFeed version {version} ({revision}).
2022-08-15 13:26:45 +02:00
</Trans>
</Box>
{isBrowserExtensionInstallable && isBrowserExtensionInstalled && (
<Box>
<Trans>CommaFeed browser extension version {browserExtensionVersion}.</Trans>
</Box>
)}
2023-03-16 17:07:58 +01:00
<Box mt="md">
2022-08-15 13:26:45 +02:00
<Trans>
2023-06-01 08:05:52 +02:00
<span>CommaFeed is an open-source project. Sources are hosted on </span>
2022-08-15 13:26:45 +02:00
<Anchor href="https://github.com/Athou/commafeed" target="_blank" rel="noreferrer">
GitHub
</Anchor>
.
</Trans>
</Box>
<Box>
<Trans>If you encounter an issue, please report it on the issues page of the GitHub project.</Trans>
</Box>
</Section>
<Section title={<Trans>Goodies</Trans>} icon={<TbPuzzle size={24} />}>
2022-08-15 13:26:45 +02:00
<List>
<List.Item>
<Anchor href={Constants.browserExtensionUrl} target="_blank" rel="noreferrer">
<Trans>Browser extention</Trans>
2023-06-01 07:43:17 +02:00
</Anchor>
2022-08-15 13:26:45 +02:00
</List.Item>
<List.Item>
<Trans>Subscribe URL</Trans>
<span> </span>
<Anchor href="rest/feed/subscribe?url=FEED_URL_HERE" target="_blank" rel="noreferrer">
rest/feed/subscribe?url=FEED_URL_HERE
</Anchor>
</List.Item>
<List.Item>
<Trans>Next unread item bookmarklet</Trans>
<span> </span>
<Box ml="xl">
<NextUnreadBookmarklet />
</Box>
</List.Item>
</List>
</Section>
<Section title={<Trans>Keyboard shortcuts</Trans>} icon={<TbKeyboard size={24} />}>
2022-08-15 18:32:18 +02:00
<KeyboardShortcutsHelp />
</Section>
<Section title={<Trans>REST API</Trans>} icon={<TbRocket size={24} />}>
2023-12-28 19:54:51 +01:00
<Anchor onClick={async () => await dispatch(redirectToApiDocumentation())}>
2022-08-15 15:42:56 +02:00
<Trans>Go to the API documentation.</Trans>
2022-08-15 13:26:45 +02:00
</Anchor>
</Section>
</SimpleGrid>
</Container>
)
}