plugins: config as html-string #901

Massimo Melina committed Feb 15, 2025 at 10:35 UTC 71ead3bcb17b6eb7e4693067f766f58170a6f877
3 files changed +7 -4
admin/src/InstalledPlugins.ts
+2 -2
@@ -7,7 +7,7 @@ import { DataTable, DataTableColumn } from './DataTable'
7 import {
8 Clear, Delete, Error as ErrorIcon, FormatPaint as ThemeIcon, PlayCircle, Settings, StopCircle, Upgrade
9 } from '@mui/icons-material'
10 -import { CFG, HTTP_FAILED_DEPENDENCY, md, newObj, prefix, with_, xlate } from './misc'
10 +import { CFG, Html, HTTP_FAILED_DEPENDENCY, md, newObj, prefix, with_, xlate } from './misc'
11 import { alertDialog, confirmDialog, formDialog, toast } from './dialog'
12 import _ from 'lodash'
13 import { Account } from './AccountsPage'
@@ -170,7 +170,7 @@ export function renderName({ row, value }: any) {
170 function makeFields(config: any, values: any) {
171 return Object.entries(config).map(([k,o]: [string,any]) => {
172 if (!_.isPlainObject(o))
173 - return o
173 + return typeof o === 'string' ? h(Html, {}, o) : o
174 let { type, defaultValue, fields, frontend, helperText, showIf, ...rest } = o
175 try {
176 if (typeof showIf === 'string') // compile once
dev-plugins.md
+4 -1
@@ -202,6 +202,8 @@ Based on `type`, other properties are supported:
202 - `multiple: boolean` if you set this to true, the field will allow the selection of multiple accounts,
203 and the resulting value will be array of strings, instead of a string. Default is false.
204
205 +FieldDescriptor can, instead of an object, be a string, but that won't count as an actual field, but will just be displayed as HTML.
206 +
207 ## api object
208
209 The `api` object you get as parameter of the `init` contains the following:
@@ -765,7 +767,7 @@ If you want to override a text regardless of the language, use the special langu
767
768 ## API version history
769
768 -- 11.4 (v0.56.0)
770 +- 11.5 (v0.56.0)
771 - api.setError
772 - frontend events: afterBreadcrumbs, afterFolderStats, afterFilter
773 - config.type.vfs_path: folders, files
@@ -773,6 +775,7 @@ If you want to override a text regardless of the language, use the special langu
775 - api.getAccount, addAccount, delAccount, updateAccount, renameAccount, getUsernames
776 - automatic unload of api.subscribeConfig
777 - api._
778 + - config as html-string
779 - 10.3 (v0.55.0)
780 - HFS.copyTextToClipboard
781 - HFS.urlParams
src/const.ts
+1 -1
@@ -9,7 +9,7 @@ import { formatTimestamp } from './cross'
9 import { argv } from './argv'
10 export * from './cross-const'
11
12 -export const API_VERSION = 11.4
12 +export const API_VERSION = 11.5
13 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
14
15 // you can add arguments with this file, currently used for the update process on mac/linux