From: "Max R. Carrara" <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Alfonso Kuen <gerencia@idkmanager.com>,
Thomas Ellmenreich <t.ellmenreich@proxmox.com>,
Jakob Klocker <j.klocker@proxmox.com>
Subject: [PATCH pve-manager v5 18/19] ui: storage: add basic UI integration for custom storage plugins
Date: Fri, 13 Nov 2026 21:33:22 +0100 [thread overview]
Message-ID: <20261113203330.932813-19-m.carrara@proxmox.com> (raw)
In-Reply-To: <20261113203330.932813-1-m.carrara@proxmox.com>
This commit adds a basic / rudimentary UI integration for custom
storage plugins.
Do this by issuing a request to the new `GET plugins/storage/plugin`
endpoint and checking whether a plugin is custom or not via its Perl
module path. When a user then adds or edits a storage config entry
belonging to a custom storage plugin, the new
`PVE.storage.CustomInputPanel` opens and builds the form's view from
the schemas of the plugin's properties.
In other words, the UI is built completely from the information
provided by the plugin's SectionConfig schema.
Values of sensitive properties are never filled in, so leaving such a
field empty keeps the stored value.
Checkboxes that are left at their default are not submitted when
adding a storage, so that only explicitly set properties end up in the
config.
Custom storage plugins are appended to the "Add" dropdown menu once
the request to `plugins/storage/plugin` succeeds. Built-in storage
types keep using their own editors and do not depend on the request,
so they can still be added and edited right away, and also if the
request fails. Editing a storage of any other type before the request
finishes opens the editor once it does.
Custom plugins whose type the UI already knows, but deliberately does
not offer in the "Add" menu stay hidden there.
Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/dc/StorageView.js | 138 ++++++++++++++-
www/manager6/storage/Base.js | 10 +-
www/manager6/storage/CustomEdit.js | 274 +++++++++++++++++++++++++++++
4 files changed, 412 insertions(+), 11 deletions(-)
create mode 100644 www/manager6/storage/CustomEdit.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index d2ea786b..e8e2bd0b 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -361,10 +361,11 @@ JSSRC= \
storage/BackupView.js \
storage/Base.js \
storage/Browser.js \
storage/CIFSEdit.js \
storage/CephFSEdit.js \
+ storage/CustomEdit.js \
storage/DirEdit.js \
storage/ImageView.js \
storage/IScsiEdit.js \
storage/LVMEdit.js \
storage/LvmThinEdit.js \
diff --git a/www/manager6/dc/StorageView.js b/www/manager6/dc/StorageView.js
index d376e8af..f0f29810 100644
--- a/www/manager6/dc/StorageView.js
+++ b/www/manager6/dc/StorageView.js
@@ -8,31 +8,138 @@ Ext.define(
onlineHelp: 'chapter_storage',
stateful: true,
stateId: 'grid-dc-storage',
+ loadPluginMetadata: function () {
+ let me = this;
+
+ me.pluginMetadataLoading = true;
+ delete me.pluginMetadataError;
+
+ let finishLoading = () => {
+ me.pluginMetadataLoading = false;
+ me.setLoading(false);
+
+ let openEditor = me.pendingEditor;
+ delete me.pendingEditor;
+ openEditor?.();
+ };
+
+ Proxmox.Utils.API2Request({
+ url: '/api2/extjs/plugins/storage/plugin',
+ params: { origin: 'custom' },
+ method: 'GET',
+ success: function ({ result: { data } }) {
+ if (me.destroyed) {
+ return;
+ }
+ me.addCustomPlugins(data);
+ finishLoading();
+ },
+ failure: function ({ htmlStatus }) {
+ if (me.destroyed) {
+ return;
+ }
+ me.pluginMetadataError = htmlStatus;
+ finishLoading();
+ },
+ });
+ },
+
+ addCustomPlugins: function (pluginMetadata) {
+ let me = this;
+
+ for (const metadata of pluginMetadata) {
+ me.pluginMetadata[metadata.type] = metadata;
+
+ // the UI knows some types, but deliberately does not offer them
+ if (PVE.Utils.storageSchema[metadata.type]?.hideAdd) {
+ continue;
+ }
+
+ me.addMenu.add({
+ text: me.renderStorageType(metadata.type),
+ iconCls: 'fa fa-fw fa-folder',
+ handler: () => me.createStorageEditWindow(metadata.type),
+ });
+ }
+
+ // show the display names of custom plugins
+ if (me.rendered) {
+ me.getView().refresh();
+ }
+ },
+
+ renderStorageType: function (type, metaData, record) {
+ let me = this;
+
+ let displayName = me.pluginMetadata[type]?.['display-name'];
+ if (displayName) {
+ return Ext.htmlEncode(displayName);
+ }
+
+ return Ext.htmlEncode(PVE.Utils.format_storage_type(type, metaData, record));
+ },
+
createStorageEditWindow: function (type, sid) {
+ let me = this;
+
let schema = PVE.Utils.storageSchema[type];
- if (!schema || !schema.ipanel) {
+
+ let paneltype;
+ let canDoBackups;
+ let metadata;
+
+ // Built-in types have their own editor and must not depend on the plugin metadata,
+ // which might not be loaded (yet).
+ if (schema?.ipanel) {
+ paneltype = 'PVE.storage.' + schema.ipanel;
+ canDoBackups = schema.backups;
+ } else if (me.pluginMetadata[type] && me.pluginMetadata[type].origin === 'custom') {
+ metadata = me.pluginMetadata[type];
+ paneltype = 'PVE.storage.CustomInputPanel';
+ // the retention panel submits 'prune-backups' unless it is masked
+ canDoBackups =
+ metadata.content.supported.includes('backup') &&
+ Object.hasOwn(metadata.schema, 'prune-backups');
+ } else if (me.pluginMetadataLoading) {
+ // might be a custom plugin, so open the editor once the metadata is there
+ me.pendingEditor = () => me.createStorageEditWindow(type, sid);
+ me.setLoading(true);
+ return;
+ } else if (me.pluginMetadataError) {
+ Ext.Msg.alert(
+ gettext('Error'),
+ Ext.String.format(
+ gettext("Cannot load the storage plugin information for type '{0}': {1}"),
+ Ext.htmlEncode(type),
+ me.pluginMetadataError,
+ ),
+ );
+ me.loadPluginMetadata(); // try again for the next attempt
+ return;
+ } else {
Ext.Msg.alert(
gettext('Error'),
Ext.String.format(
gettext("No editor registered for storage type '{0}'"),
Ext.htmlEncode(type),
),
);
return;
}
Ext.create('PVE.storage.BaseEdit', {
- paneltype: 'PVE.storage.' + schema.ipanel,
+ paneltype: paneltype,
type: type,
storageId: sid,
- canDoBackups: schema.backups,
+ canDoBackups: canDoBackups,
+ metadata: metadata,
autoShow: true,
listeners: {
- destroy: this.reloadStore,
+ destroy: me.reloadStore,
},
});
},
initComponent: function () {
@@ -50,10 +157,12 @@ Ext.define(
},
});
let sm = Ext.create('Ext.selection.RowModel', {});
+ me.pluginMetadata = {};
+
let run_editor = function () {
let rec = sm.getSelection()[0];
if (!rec) {
return;
}
@@ -89,23 +198,25 @@ Ext.define(
iconCls: 'fa fa-fw fa-' + storage.faIcon,
handler: addHandleGenerator(type),
});
}
+ me.addMenu = new Ext.menu.Menu({
+ items: addMenuItems,
+ });
+
Ext.apply(me, {
store: store,
reloadStore: () => store.load(),
selModel: sm,
viewConfig: {
trackOver: false,
},
tbar: [
{
text: gettext('Add'),
- menu: new Ext.menu.Menu({
- items: addMenuItems,
- }),
+ menu: me.addMenu,
},
remove_btn,
edit_btn,
],
columns: [
@@ -118,11 +229,12 @@ Ext.define(
{
header: gettext('Type'),
flex: 1,
sortable: true,
dataIndex: 'type',
- renderer: PVE.Utils.format_storage_type,
+ renderer: (value, metaData, record) =>
+ me.renderStorageType(value, metaData, record),
},
{
header: gettext('Content'),
flex: 3,
sortable: true,
@@ -158,16 +270,24 @@ Ext.define(
sortable: true,
dataIndex: 'bwlimit',
},
],
listeners: {
- activate: () => store.load(),
+ activate: () => {
+ store.load();
+ // otherwise only editing a custom storage would retry
+ if (me.pluginMetadataError && !me.pluginMetadataLoading) {
+ me.loadPluginMetadata();
+ }
+ },
itemdblclick: run_editor,
},
});
me.callParent();
+
+ me.loadPluginMetadata();
},
},
function () {
Ext.define('pve-storage', {
extend: 'Ext.data.Model',
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 04f5f706..8f311016 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -161,27 +161,33 @@ Ext.define('PVE.storage.BaseEdit', {
me.ipanel = Ext.create(me.paneltype, {
title: gettext('General'),
type: me.type,
isCreate: me.isCreate,
storageId: me.storageId,
+ metadata: me.metadata,
});
Ext.apply(me, {
- subject: PVE.Utils.format_storage_type(me.type),
+ subject: Ext.htmlEncode(
+ me.metadata?.['display-name'] || PVE.Utils.format_storage_type(me.type),
+ ),
isAdd: true,
bodyPadding: 0,
items: {
xtype: 'tabpanel',
region: 'center',
layout: 'fit',
bodyPadding: 10,
items: [
me.ipanel,
{
xtype: 'pveBackupJobPrunePanel',
title: gettext('Backup Retention'),
- hasMaxProtected: true,
+ // custom plugins do not necessarily support it
+ hasMaxProtected:
+ !me.metadata ||
+ Object.hasOwn(me.metadata.schema, 'max-protected-backups'),
isCreate: me.isCreate,
keepAllDefaultForCreate: true,
showPBSHint: me.ipanel.isPBS,
fallbackHintHtml: gettext(
"Without any keep option, the node's vzdump.conf or `keep-all` is used as fallback for backup jobs",
diff --git a/www/manager6/storage/CustomEdit.js b/www/manager6/storage/CustomEdit.js
new file mode 100644
index 00000000..bec10661
--- /dev/null
+++ b/www/manager6/storage/CustomEdit.js
@@ -0,0 +1,274 @@
+Ext.define('PVE.storage.CustomInputPanel', {
+ extend: 'PVE.panel.StorageBase',
+
+ buildFormFieldFromProperty: function (propertyName) {
+ let me = this;
+ let schema = me.metadata.schema;
+
+ let property = schema[propertyName];
+
+ if (!property) {
+ console.warn(
+ `Tried to create field for unknown property '${propertyName}'` +
+ ` for storage type '${me.type}'`,
+ );
+ return;
+ }
+
+ // Fixed properties can only be set on creation. Do not rely on the
+ // field being disabled alone, as the storage edit controller
+ // re-enables the preallocation field.
+ let isFixed = !me.isCreate && Boolean(property.fixed);
+ let fixedProps = { disabled: isFixed, readOnly: isFixed, submitValue: !isFixed };
+
+ let volumeChain = PVE.panel.StorageBase.volumeChainFields(me.isCreate, me.type);
+
+ const predefinedFields = {
+ content: {
+ xtype: 'pveContentTypeSelector',
+ cts: me.metadata.content.supported,
+ fieldLabel: gettext('Content'),
+ name: 'content',
+ value: me.metadata.content.default,
+ multiSelect: true,
+ allowBlank: false,
+ ...fixedProps,
+ validator: function () {
+ let contentTypes = Ext.Array.from(this.getValue());
+ if (contentTypes.includes('none') && contentTypes.length > 1) {
+ return gettext("'none' cannot be combined with other content types");
+ }
+ return true;
+ },
+ },
+ preallocation: {
+ xtype: 'pvePreallocationSelector',
+ name: 'preallocation',
+ fieldLabel: gettext('Preallocation'),
+ allowBlank: false,
+ deleteEmpty: !me.isCreate && Boolean(property.optional),
+ ...fixedProps,
+ ...(property.optional
+ ? { value: '__default__' }
+ : {
+ // a required property has no default to fall back to
+ comboItems: PVE.form.preallocationSelector.prototype.comboItems.filter(
+ ([key]) => key !== '__default__',
+ ),
+ value: property.default,
+ }),
+ },
+ 'snapshot-as-volume-chain': {
+ ...volumeChain.checkbox,
+ ...fixedProps,
+ },
+ };
+
+ if (predefinedFields[propertyName]) {
+ return predefinedFields[propertyName];
+ }
+
+ let fieldName = propertyName;
+ let extraAttributes = {
+ readonly: property.fixed && !me.isCreate,
+ sensitive: property.sensitive,
+ };
+ let context = { isCreate: me.isCreate };
+
+ let fieldDef = Proxmox.Utils.getFieldDefFromPropertySchema(
+ fieldName,
+ property,
+ extraAttributes,
+ context,
+ );
+
+ // Fix up any field labels for properties that do not have a title key
+ // by transforming the name of the field like e.g.
+ // "foo_bar-baz" --> "Foo Bar Baz"
+ if (!property.title) {
+ let fieldLabel = fieldName
+ .replace(/([-_]|\s)+/g, ' ')
+ .replace(
+ /\w*/g,
+ (label) => label.charAt(0).toUpperCase() + label.slice(1).toLowerCase(),
+ );
+ fieldDef.fieldLabel = Ext.htmlEncode(fieldLabel);
+ }
+
+ return fieldDef;
+ },
+
+ addWidget: function (widget, isAdvanced) {
+ let me = this;
+
+ let col1, col2, colB;
+
+ if (isAdvanced) {
+ col1 = me.advancedColumn1 = me.advancedColumn1 || [];
+ col2 = me.advancedColumn2 = me.advancedColumn2 || [];
+ colB = me.advancedColumnB = me.advancedColumnB || [];
+ } else {
+ col1 = me.column1 = me.column1 || [];
+ col2 = me.column2 = me.column2 || [];
+ colB = me.columnB = me.columnB || [];
+ }
+
+ const hintClasses = ['pmx-hint'];
+
+ const wideFields = [
+ 'textarea',
+ 'textareafield',
+ 'Ext.form.field.TextArea',
+ 'proxmoxtextarea',
+ 'Proxmox.form.field.TextArea',
+ ];
+
+ if (wideFields.includes(widget.xtype)) {
+ colB.push(widget);
+ return;
+ }
+
+ for (const cls of hintClasses) {
+ if (widget.userCls && widget.userCls.search(cls) !== -1) {
+ colB.push(widget);
+ return;
+ }
+ }
+
+ if (col2.length >= col1.length) {
+ col1.push(widget);
+ } else {
+ col2.push(widget);
+ }
+ },
+
+ onGetValues: function (values) {
+ let me = this;
+ let schema = me.metadata.schema;
+
+ values = me.callParent([values]);
+
+ // set from the 'enable' checkbox, which is hidden in that case
+ if (!schema.disable) {
+ delete values.disable;
+ }
+
+ // Checkboxes always submit a value, but defaults should not end up in
+ // the config.
+ if (me.isCreate) {
+ for (const [name, property] of Object.entries(schema)) {
+ if (
+ property.type !== 'boolean' ||
+ !property.optional ||
+ values[name] === undefined
+ ) {
+ continue;
+ }
+
+ let defaultValue = PVE.Parser.parseBoolean(String(property.default), false);
+ if (PVE.Parser.parseBoolean(String(values[name])) === defaultValue) {
+ delete values[name];
+ }
+ }
+ }
+
+ return values;
+ },
+
+ onSetValues: function (values) {
+ let me = this;
+
+ // Never show and thus resubmit values of sensitive properties, empty means unchanged.
+ for (const [name, property] of Object.entries(me.metadata.schema)) {
+ if (property.sensitive) {
+ delete values[name];
+ }
+ }
+
+ return values;
+ },
+
+ initComponent: function () {
+ let me = this;
+ let schema = me.metadata.schema;
+
+ me.column1 = me.column1 || [];
+ me.column2 = me.column2 || [];
+
+ const reservedFields = new Set([
+ // automatically added in PVE.panel.StorageBase
+ // --> must not be added here
+ 'storage',
+ 'nodes',
+ 'disable',
+
+ // handled by the "Backup Retention" panel
+ // --> must not be added here
+ 'prune-backups',
+ 'max-protected-backups',
+
+ // not an actual property, but used by the UI as an inverse of the
+ // 'disable' property
+ // --> must not be added here
+ 'enable',
+
+ // handled separately for consistency
+ 'content',
+ 'shared',
+ ]);
+
+ // a required property must stay settable on creation
+ let isHidden = (property) => property['x-hidden'] && (property.optional || !me.isCreate);
+
+ // Added first for consistency's sake
+ for (const propertyName of ['content', 'shared']) {
+ let property = schema[propertyName];
+ if (!property || isHidden(property)) {
+ continue;
+ }
+
+ let fieldDef = me.buildFormFieldFromProperty(propertyName);
+ if (property['x-advanced']) {
+ me.advancedColumn1 = me.advancedColumn1 || [];
+ me.advancedColumn1.push(fieldDef);
+ } else {
+ me.column1.push(fieldDef);
+ }
+ }
+
+ // We use regular sort without `localeCompare()`, since we want all properties to be
+ // *always* in the same order, regardless of language.
+ for (const [propertyName, propertySchema] of Object.entries(schema).sort()) {
+ if (reservedFields.has(propertyName) || isHidden(propertySchema)) {
+ continue;
+ }
+
+ let fieldDef = me.buildFormFieldFromProperty(propertyName);
+
+ if (fieldDef === undefined) {
+ continue;
+ }
+
+ me.addWidget(fieldDef, propertySchema['x-advanced']);
+
+ if (propertyName === 'snapshot-as-volume-chain') {
+ let volumeChain = PVE.panel.StorageBase.volumeChainFields(me.isCreate, me.type);
+ me.addWidget(volumeChain.hint, propertySchema['x-advanced']);
+ }
+ }
+
+ me.callParent();
+
+ // PVE.panel.StorageBase adds these for every storage type
+ for (const [fieldName, propertyName] of [
+ ['nodes', 'nodes'],
+ ['enable', 'disable'],
+ ]) {
+ if (!schema[propertyName]) {
+ let field = me.down(`field[name=${fieldName}]`);
+ field.setDisabled(true);
+ field.setHidden(true);
+ }
+ }
+ },
+});
--
2.47.3
next prev parent reply other threads:[~2026-11-13 20:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 20:33 [PATCH common/manager/proxmox-widget-toolkit/storage/storage-plugin-examples v5 00/19] GUI Support for Custom Storage Plugins Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-common v5 01/19] json schema: add multiline validation keyword Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 02/19] api: plugins/storage: add initial routes and endpoints Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 03/19] api: plugins/storage/plugin: include schema in plugin metadata Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 04/19] api: plugins/storage/plugin: handle sensitive properties in schema Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 05/19] api: plugins/storage/plugin: factor plugin metadata code into helper Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 06/19] api: plugins/storage/plugin: add plugins' 'content' to their metadata Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 07/19] all plugins: add 'title' to properties, adapt 'description's Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 08/19] all plugins, api: mark certain properties as advanced in plugindata() Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 09/19] all plugins, api: mark certain properties as hidden " Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-storage v5 10/19] api: plugins/storage/plugin: allow plugins to have display names Max R. Carrara
2026-11-13 20:33 ` [PATCH proxmox-widget-toolkit v5 11/19] form: introduce new 'proxmoxtextarea' field Max R. Carrara
2026-11-13 20:33 ` [PATCH proxmox-widget-toolkit v5 12/19] utils: introduce helper function getFieldDefFromPropertySchema Max R. Carrara
2026-11-13 20:33 ` [PATCH proxmox-widget-toolkit v5 13/19] acme: use helper to construct ExtJS fields from property schemas Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-manager v5 14/19] api: sort modules and API method registrations Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-manager v5 15/19] ui: storage: remove entry of the removed DRBD plugin Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-manager v5 16/19] api: add API routes 'plugins' and 'plugins/storage' Max R. Carrara
2026-11-13 20:33 ` [PATCH pve-manager v5 17/19] ui: storage view: display error when no editor for storage type exists Max R. Carrara
2026-11-13 20:33 ` Max R. Carrara [this message]
2026-11-13 20:33 ` [PATCH pve-storage-plugin-examples v5 19/19] sshfs: Update SSHFS plugin Max R. Carrara
2026-11-16 2:20 ` applied: [PATCH common/manager/proxmox-widget-toolkit/storage/storage-plugin-examples v5 00/19] GUI Support for Custom Storage Plugins Thomas Lamprecht
2026-11-17 8:07 ` Roland Kammerer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113203330.932813-19-m.carrara@proxmox.com \
--to=m.carrara@proxmox.com \
--cc=gerencia@idkmanager.com \
--cc=j.klocker@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
--cc=t.ellmenreich@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.