fix: admin/plugins: order was wrong for plugins with "hfs-" prefix
Massimo Melina committed
Oct 5, 2024 at 00:31 UTC
1c6cf66cdf826cfe684726917c51a5b14d7df765
1 file changed
+9
-5
admin/src/InstalledPlugins.ts
+9
-5
@@ -9,8 +9,7 @@ import { HTTP_FAILED_DEPENDENCY, newObj, prefix, with_, xlate } from './misc'
9
import { alertDialog, confirmDialog, formDialog, toast } from './dialog'
10
import _ from 'lodash'
11
import { Account } from './AccountsPage'
12
-import { BoolField, Field, FieldProps, MultiSelectField, NumberField, SelectField, StringField
13
-} from '@hfs/mui-grid-form'
12
+import { BoolField, Field, FieldProps, MultiSelectField, NumberField, SelectField, StringField } from '@hfs/mui-grid-form'
13
import { ArrayField } from './ArrayField'
14
import FileField from './FileField'
15
import { PLUGIN_ERRORS } from './PluginsPage'
@@ -18,11 +17,11 @@ import { Btn, hTooltip, IconBtn, iconTooltip } from './mui'
17
import VfsPathField from './VfsPathField'
18
19
export default function InstalledPlugins({ updates }: { updates?: true }) {
21
- const { list, updateEntry, error, updateList, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins')
20
+ const { list, error, updateList, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins')
21
useEffect(() => {
22
if (!initializing)
23
updateList(list =>
25
- _.sortBy(list, x => (x.started ? '0' : '1') + x.id))
24
+ _.sortBy(list, x => (x.started ? '0' : '1') + treatPluginName(x.id)))
25
}, [initializing]);
26
const size = 'small'
27
return h(DataTable, {
@@ -137,6 +136,11 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
136
})
137
}
138
139
+// hide the hfs- prefix, as one may want to use it for its repository, because github is the context, but in the hfs context the prefix it's not only redundant, but also ruins the sorting
140
+function treatPluginName(name: string) {
141
+ return name.replace(/hfs-/, '')
142
+}
143
+
144
export function renderName({ row, value }: any) {
145
const { repo } = row
146
return h(Fragment, {},
@@ -145,7 +149,7 @@ export function renderName({ row, value }: any) {
149
repo?.includes('//') ? h(Link, { href: repo, target: 'plugin' }, value)
150
: with_(repo?.split('/'), arr => arr?.length !== 2 ? value
151
: h(Fragment, {},
148
- h(Link, { href: 'https://github.com/' + repo, target: 'plugin', onClick(ev) { ev.stopPropagation() } }, arr[1].replace(/hfs-/, '')),
152
+ h(Link, { href: 'https://github.com/' + repo, target: 'plugin', onClick(ev) { ev.stopPropagation() } }, treatPluginName(arr[1])),
153
'\xa0by ', arr[0]
154
))
155
)