admin/plugins: no need to warn if plugin is from same github account
Massimo Melina committed
Dec 6, 2024 at 12:24 UTC
21eac4093c27e37de34f273d082338dd260d8b92
4 files changed
+8
-5
admin/src/OnlinePlugins.ts
+4
-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, newDialog, wantArray, xlate } from './misc'
6
+import { HFS_REPO, HTTP_FAILED_DEPENDENCY, newDialog, wantArray, xlate } from './misc'
7
import { ArrowBack, ArrowForward, Download, RemoveRedEye, Search, Warning } from '@mui/icons-material'
8
import { StringField } from '@hfs/mui-grid-form'
9
import { useDebounce } from 'usehooks-ts'
@@ -15,6 +15,8 @@ import { PLUGIN_ERRORS } from './PluginsPage'
15
import { Flex, IconBtn } from './mui'
16
import { Box } from '@mui/material'
17
18
+const HFS_GITHUB_ACCOUNT = HFS_REPO.replace(/\/.+/, `/`)
19
+
20
export default function OnlinePlugins() {
21
const [search, setSearch] = useState('')
22
const debouncedSearch = useDebounce(search, 1000)
@@ -78,7 +80,7 @@ export default function OnlinePlugins() {
80
progress: row.downloading,
81
disabled: row.installed && "Already installed",
82
tooltipProps: { placement:'bottom-end' }, // workaround problem with horizontal scrolling by moving the tooltip leftward
81
- confirm: h(Flex, { vert: true, alignItems: 'center' },
83
+ confirm: !id.startsWith(HFS_GITHUB_ACCOUNT) && h(Flex, { vert: true, alignItems: 'center' },
84
h(Warning, { color: 'warning', fontSize: 'large' }),
85
"Proceed only if you trust this plugin",
86
h(Box, { fontSize: '60%' }, "A plugin has the same power of any other software"),
src/const.ts
-1
@@ -10,7 +10,6 @@ export * from './cross-const'
10
11
export const API_VERSION = 10.1
12
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
13
-export const HFS_REPO = 'rejetto/hfs'
13
14
export const argv = minimist(process.argv.slice(2))
15
// you can add arguments with this file, currently used for the update process on mac/linux
src/cross-const.ts
+1
@@ -6,6 +6,7 @@ export const PLUGINS_PUB_URI = SPECIAL_URI + 'plugins/'
6
export const PORT_DISABLED = -1
7
export const NBSP = '\xA0'
8
export const PLUGIN_CUSTOM_REST_PREFIX = '_'
9
+export const HFS_REPO = 'rejetto/hfs'
10
11
export const HTTP_OK = 200
12
export const HTTP_NO_CONTENT = 204
src/cross.ts
+3
-2
@@ -2,11 +2,12 @@
2
// all content here is shared between client and server
3
import _ from 'lodash'
4
import { VfsNodeStored } from './vfs'
5
-import picomatch from 'picomatch/lib/picomatch' // point directly to the browser-compatible source
5
+import picomatch from 'picomatch/lib/picomatch'
6
+import { HFS_REPO } from './cross-const' // point directly to the browser-compatible source
7
export * from './cross-const'
8
9
export const WEBSITE = 'https://rejetto.com/hfs/'
9
-export const REPO_URL = 'https://github.com/rejetto/hfs/'
10
+export const REPO_URL = `https://github.com/${HFS_REPO}/`
11
export const WIKI_URL = REPO_URL + 'wiki/'
12
export const MINUTE = 60_000
13
export const HOUR = 60 * MINUTE