admin/home: check updates will report also about plugins
Massimo Melina committed
Oct 10, 2023 at 18:25 UTC
035f55e460f1ba788a8f0439fd0f09b686cf2401
1 file changed
+9
-3
admin/src/HomePage.ts
+9
-3
@@ -2,7 +2,7 @@
2
3
import { createElement as h, ReactNode, useState } from 'react'
4
import { Box, Button, Card, CardContent, LinearProgress, Link } from '@mui/material'
5
-import { apiCall, useApiEx, useApiList } from './api'
5
+import { apiCall, apiEvents, useApiEvents, useApiEx, useApiList } from './api'
6
import {
7
Btn,
8
dontBotherWithKeys,
@@ -46,6 +46,8 @@ export default function HomePage() {
46
const { data: account } = useApiEx<Account>(username && 'get_account')
47
const cfg = useApiEx('get_config', { only: ['https_port', 'cert', 'private_key', 'proxies', 'update_to_beta'] })
48
const { list: plugins } = useApiList('get_plugins')
49
+ const [checkPlugins, setCheckPlugins] = useState(false)
50
+ const { list: pluginUpdates} = useApiList(checkPlugins && 'get_plugin_updates')
51
const [updates, setUpdates] = useState<undefined | any[]>()
52
if (statusEl || !status)
53
return statusEl
@@ -100,6 +102,7 @@ export default function HomePage() {
102
h('li',{}, `disable "admin access for localhost" in HFS (safe, but you won't see users' IPs)`),
103
)),
104
entry('', h(Link, { target: 'support', href: REPO_URL + 'discussions' }, "Get support")),
105
+ pluginUpdates.length > 0 && entry('success', "Updates available for plugin(s): " + pluginUpdates.map(p => p.id).join(', ')),
106
status.updatePossible === 'local' ? h(Btn, {
107
icon: UpdateIcon,
108
onClick: () => update()
@@ -107,11 +110,14 @@ export default function HomePage() {
110
: !updates ? h(Btn, {
111
variant: 'outlined',
112
icon: UpdateIcon,
110
- onClick: () => apiCall('check_update').then(x => setUpdates(x.options), alertDialog)
113
+ onClick() {
114
+ setCheckPlugins(true)
115
+ return apiCall('check_update').then(x => setUpdates(x.options), alertDialog)
116
+ }
117
}, "Check for updates")
118
: with_(_.find(updates, 'isNewer'), newer =>
119
!updates.length || !status.updatePossible && !newer ? entry('', "No update available")
114
- : newer && !status.updatePossible ? entry('', `Version ${newer.name} available`)
120
+ : newer && !status.updatePossible ? entry('success', `Version ${newer.name} available`)
121
: h(Flex, { vert: true },
122
updates.map((x: any) =>
123
h(Flex, { key: x.name, alignItems: 'flex-start', flexWrap: 'wrap' },