@@ -2,7 +2,7 @@ import {useStore} from "../store/store.ts";
2
2
import {useEffect, useState} from "react";
3
3
import {InstalledPlugin, PluginDef, SearchParams} from "./Plugin.ts";
4
4
import {useDebounce} from "../utils/useDebounce.ts";
5
- import {Trans} from "react-i18next";
5
+ import {Trans, useTranslation } from "react-i18next";
6
6
7
7
8
8
export const HomePage = () => {
@@ -17,6 +17,7 @@ export const HomePage = () => {
17
17
searchTerm: ''
18
18
})
19
19
const [searchTerm, setSearchTerm] = useState<string>('')
20
+ const {t} = useTranslation()
20
21
21
22
22
23
useEffect(() => {
@@ -30,8 +31,18 @@ export const HomePage = () => {
30
31
setInstalledPlugins(data.installed)
31
32
})
32
33
33
- pluginsSocket.on('results:updatable', () => {
34
- console.log("Finished install")
34
+ pluginsSocket.on('results:updatable', (data) => {
35
+ data.updatable.forEach((pluginName: string) => {
36
+ setInstalledPlugins(installedPlugins.map(plugin => {
37
+ if (plugin.name === pluginName) {
38
+ return {
39
+ ...plugin,
40
+ updatable: true
41
+ }
42
+ }
43
+ return plugin
44
+ }))
45
+ })
35
46
})
36
47
37
48
pluginsSocket.on('finished:install', () => {
@@ -118,19 +129,25 @@ export const HomePage = () => {
118
129
return <tr key={index}>
119
130
<td>{plugin.name}</td>
120
131
<td>{plugin.version}</td>
121
- <td onClick={() => {
122
- }}>
123
- <button disabled={plugin.name == "ep_etherpad-lite"} onClick={() => uninstallPlugin(plugin.name)}><Trans i18nKey="admin_plugins.installed_uninstall.value"/></button>
132
+ <td>
133
+ {
134
+ plugin.updatable ?
135
+ <button onClick={() => installPlugin(plugin.name)}>Update</button>
136
+ : <button disabled={plugin.name == "ep_etherpad-lite"}
137
+ onClick={() => uninstallPlugin(plugin.name)}><Trans
138
+ i18nKey="admin_plugins.installed_uninstall.value"/></button>
139
+
140
+ }
124
141
</td>
125
- </tr>
126
- })}
127
- </tbody>
128
- </table>
142
+ </tr>
143
+ })}
144
+ </tbody>
145
+ </table>
129
146
130
147
131
- <h2><Trans i18nKey="admin_plugins.available"/></h2>
148
+ <h2><Trans i18nKey="admin_plugins.available"/></h2>
132
149
133
- <input type="text" value={searchTerm} onChange={v=>{
150
+ <input className="search-field" placeholder={t('admin_plugins.available_search.placeholder')} type="text" value={searchTerm} onChange={v=>{
134
151
setSearchTerm(v.target.value)
135
152
}}/>
136
153
0 commit comments