admin: avoid loading plugins' public

Massimo Melina committed Jun 8, 2026 at 15:29 UTC fbfa480563d7f2ae99a6a1463da9f9360eaf826c
1 file changed +26 -2
admin/src/FileForm.ts
+26 -2
@@ -1,7 +1,7 @@
1 // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3 import { markVfsModified, prepareVfsUndo, state, useSnapState } from './state'
4 -import { createElement as h, forwardRef, ReactElement, ReactNode, useEffect, useMemo, useState } from 'react'
4 +import { createElement as h, forwardRef, memo, ReactElement, ReactNode, useEffect, useMemo, useState } from 'react'
5 import { Alert, Box, Collapse, FormHelperText, Link, MenuItem, MenuList, useTheme } from '@mui/material'
6 import {
7 BoolField, DisplayField, Field, FieldProps, Form, MultiSelectField, NumberField, SelectField, StringField
@@ -27,7 +27,6 @@ import { moveVfs } from './VfsTree'
27 import QrCreator from 'qr-creator'
28 import { AddVfsBtn } from './VfsMenuBar'
29 import { SYS_ICONS } from '@hfs/frontend/src/sysIcons'
30 -import { hIcon } from '@hfs/frontend/src/misc'
30 import { TextEditorField } from './TextEditor'
31 import { account2icon } from './AccountsPage'
32 import apiAccounts from '../../src/api.accounts'
@@ -520,3 +519,28 @@ export async function changeBaseUrl() {
519 })
520 })
521 }
522 +
523 +
524 +interface IconProps { name:string, className?:string, alt?:string, [rest:string]: any }
525 +// name = null ? none : unicode ? unicode : "?" ? file_url : font_icon_class
526 +const Icon = memo(({ name, alt, className='', ...props }: IconProps) => {
527 + if (!name) return null
528 + const [emoji, clazz=name] = SYS_ICONS[name] || []
529 + className += ' icon'
530 + const nameIsTheIcon = name.length === 1 ||
531 + name.match(/^[\uD800-\uDFFF\u2600-\u27BF\u2B00-\u2BFF\u3030-\u303F\u3297\u3299\u00A9\u00AE\u200D\u20E3\uFE0F\u2190-\u21FF\u2300-\u23FF\u2400-\u243F\u25A0-\u25FF\u2600-\u26FF\u2700-\u27BF]*$/)
532 + const nameIsUrl = !nameIsTheIcon && /[/?]/.test(name)
533 + const isFontIcon = clazz
534 + className += nameIsUrl ? ' file-icon' : isFontIcon ? ` font-icon fa-${clazz}` : ' emoji-icon'
535 + return h('span',{
536 + ...alt ? { 'aria-label': alt } : { 'aria-hidden': true },
537 + role: 'img',
538 + ...props,
539 + ...nameIsUrl ? { style: { backgroundImage: `url(${JSON.stringify(name)})`, ...props?.style } } : undefined,
540 + className,
541 + }, nameIsTheIcon ? name : isFontIcon ? null : (emoji||'#'))
542 +})
543 +
544 +function hIcon(name: string, props?: Omit<IconProps, 'name'>) {
545 + return h(Icon, { name, ...props })
546 +}