plugin.configDialog to directly affect dialog props

Massimo Melina committed Apr 4, 2023 at 19:20 UTC 2edab639b9e1b305b35e8392f44ddcb3cf577def
4 files changed +8 -7
admin/src/InstalledPlugins.ts
+3 -5
@@ -82,13 +82,11 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
82 const values = await formDialog({
83 title: `${id} options`,
84 form: {
85 - fields: [
86 - h(Box, {}, row.description),
87 - ...makeFields(config)
88 - ],
85 + before: h(Box, { mx: 2, mb: 3 }, row.description),
86 + fields: makeFields(config),
87 },
88 values: pl.config,
91 - ...row.configDialog,
89 + dialogProps: row.configDialog,
90 })
91 if (!values || _.isEqual(pl.config, values)) return
92 await apiCall('set_plugin', { id, config: values })
dev-plugins.md
+1 -1
@@ -67,7 +67,7 @@ All the following properties are essentially optional.
67 ```
68 When necessary your plugin will read its value using `api.getConfig('message')`.
69
70 -- `configDialog: FormDialog` object to override dialog options. Please refer to sources for details.
70 +- `configDialog: DialogOptions` object to override dialog options. Please refer to sources for details.
71 - `onFrontendConfig: (config: object) => void | object` manipulate config values exposed to front-end
72
73 ### FieldDescriptor
plugins/antibrute/plugin.js
+1 -1
@@ -7,7 +7,7 @@ exports.config = {
7 max: { type: 'number', min: 1, defaultValue: 60, helperText: "Max seconds to delay before next login is allowed" },
8 }
9 exports.configDialog = {
10 - maxWidth: '25em',
10 + maxWidth: 'xs',
11 }
12
13 const byIp = {}
plugins/download-counter/plugin.js
+3
@@ -5,6 +5,9 @@ exports.apiRequired = 6
5 exports.config = {
6 where: { frontend: true, type: 'select', options: ['list', 'menu'] }
7 }
8 +exports.configDialog = {
9 + sx: { maxWidth: '20em' },
10 +}
11
12 exports.init = async api => {
13 const _ = api.require('lodash')