| 1 | // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt |
| 2 | |
| 3 | import { createElement as h, Fragment } from 'react' |
| 4 | import { Tab, Tabs } from '@mui/material' |
| 5 | import InstalledPlugins from './InstalledPlugins' |
| 6 | import OnlinePlugins from './OnlinePlugins' |
| 7 | import { useRoutedTab } from './routing' |
| 8 | |
| 9 | const TABS = [ |
| 10 | { label: "Installed", path: 'installed', Pane: InstalledPlugins }, |
| 11 | { label: "Get more", path: 'get', Pane: OnlinePlugins }, |
| 12 | { label: "Check updates", path: 'updates', Pane: () => h(InstalledPlugins, { updates: true }) }, |
| 13 | ] |
| 14 | const TAB_PATHS = TABS.map(x => x.path) |
| 15 | export const PLUGIN_ERRORS = { ENOTFOUND: "Cannot reach github.com", ECONNREFUSED: "Cannot reach github.com" } |
| 16 | |
| 17 | export default function PluginsPage() { |
| 18 | const [tab, setTab] = useRoutedTab('plugins', TAB_PATHS) |
| 19 | const { Pane } = TABS[tab] |
| 20 | return h(Fragment, {}, |
| 21 | h(Tabs, { |
| 22 | value: tab, |
| 23 | onChange(ev, i) { |
| 24 | setTab(i) |
| 25 | } |
| 26 | }, TABS.map(x => |
| 27 | h(Tab, { key: x.path, label: x.label }))), |
| 28 | h(Pane) |
| 29 | ) |
| 30 | } |