admin/plugins: better message in case of github unreachable

Massimo Melina committed Dec 1, 2023 at 18:34 UTC 2b762e4fe9319049997657f7dddaa046dca72832
3 files changed +7 -4
admin/src/InstalledPlugins.ts
+3 -2
@@ -5,18 +5,19 @@ import { createElement as h, Fragment, ReactNode } from 'react'
5 import { Box, Link, Tooltip } from '@mui/material'
6 import { DataTable } from './DataTable'
7 import { Delete, Error as ErrorIcon, PlayCircle, Settings, StopCircle, Upgrade } from '@mui/icons-material'
8 -import { Btn, HTTP_FAILED_DEPENDENCY, IconBtn, prefix, with_ } from './misc'
8 +import { Btn, HTTP_FAILED_DEPENDENCY, IconBtn, prefix, with_, xlate } from './misc'
9 import { alertDialog, formDialog, toast } from './dialog'
10 import _ from 'lodash'
11 import { BoolField, Field, MultiSelectField, NumberField, SelectField, StringField } from '@hfs/mui-grid-form'
12 import { ArrayField } from './ArrayField'
13 import FileField from './FileField'
14 +import { PLUGIN_ERRORS } from './PluginsPage'
15
16 export default function InstalledPlugins({ updates }: { updates?: true }) {
17 const { list, updateEntry, error, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins')
18 const size = 'small'
19 return h(DataTable, {
19 - error,
20 + error: xlate(error, PLUGIN_ERRORS),
21 rows: list.length ? list : [], // workaround for DataGrid bug causing 'no rows' message to be not displayed after 'loading' was also used
22 initializing,
23 disableColumnSelector: true,
admin/src/OnlinePlugins.ts
+3 -2
@@ -3,7 +3,7 @@
3 import { apiCall, useApiList } from './api'
4 import { Fragment, createElement as h, useState } from 'react'
5 import { DataTable } from './DataTable'
6 -import { HTTP_FAILED_DEPENDENCY, IconBtn } from './misc'
6 +import { HTTP_FAILED_DEPENDENCY, IconBtn, xlate } from './misc'
7 import { Download, Search } from '@mui/icons-material'
8 import { StringField } from '@hfs/mui-grid-form'
9 import { useDebounce } from 'usehooks-ts'
@@ -11,6 +11,7 @@ import { renderName, startPlugin } from './InstalledPlugins'
11 import { state, useSnapState } from './state'
12 import { alertDialog, confirmDialog, toast } from './dialog'
13 import _ from 'lodash'
14 +import { PLUGIN_ERRORS } from './PluginsPage'
15
16 export default function OnlinePlugins() {
17 const [search, setSearch] = useState('')
@@ -26,7 +27,7 @@ export default function OnlinePlugins() {
27 label: "Search text"
28 }),
29 h(DataTable, {
29 - error,
30 + error: xlate(error, PLUGIN_ERRORS),
31 rows: list.length ? list : [], // workaround for DataGrid bug causing 'no rows' message to be not displayed after 'loading' was also used
32 noRows: "No compatible plugins have been found",
33 initializing,
admin/src/PluginsPage.ts
+1
@@ -13,6 +13,7 @@ const TABS = {
13 }
14 const LABELS = Object.keys(TABS)
15 const PANES = Object.values(TABS)
16 +export const PLUGIN_ERRORS = { ENOTFOUND: "Cannot reach github.com" }
17
18 export default function PluginsPage() {
19 const [tab, setTab] = useState(0)