[PATCH proxmox-backup v7 8/9] ui: add move namespace action

Hannes Laimer
2026-04-16T17:19:27Z

Add a "Move" action to the namespace action column. Opens a dialog
where the user selects a new parent namespace and name, then submits
a POST to the move-namespace API endpoint.

The source namespace and its descendants are excluded from the parent
selector to prevent cycles. An advanced section exposes the max-depth
and delete-source options.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
www/Makefile | 1 +
www/datastore/Content.js | 27 +++++++-
www/form/NamespaceSelector.js | 11 +++
www/window/NamespaceMove.js | 126 ++++++++++++++++++++++++++++++++++
4 files changed, 164 insertions(+), 1 deletion(-)
create mode 100644 www/window/NamespaceMove.js

diff --git a/www/Makefile b/www/Makefile
index 06441c02..bad243cf 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -80,6 +80,7 @@ JSSRC= \
window/CreateDirectory.js \
window/DataStoreEdit.js \
window/NamespaceEdit.js \
+ window/NamespaceMove.js \
window/MaintenanceOptions.js \
window/NotesEdit.js \
window/NotificationThresholds.js \
diff --git a/www/datastore/Content.js b/www/datastore/Content.js
index 585a1a2d..b53f9b67 100644
--- a/www/datastore/Content.js
+++ b/www/datastore/Content.js
@@ -668,6 +668,26 @@ Ext.define('PBS.DataStoreContent', {
});
},

+ moveNS: function () {
+ let me = this;
+ let view = me.getView();
+ if (!view.namespace || view.namespace === '') {
+ return;
+ }
+ let win = Ext.create('PBS.window.NamespaceMove', {
+ datastore: view.datastore,
+ namespace: view.namespace,
+ taskDone: (success) => {
+ if (success) {
+ let newNs = win.getNewNamespace();
+ view.down('pbsNamespaceSelector').store?.load();
+ me.nsChange(null, newNs);
+ }
+ },
+ });
+ win.show();
+ },
+
moveGroup: function (data) {
let me = this;
let view = me.getView();
@@ -686,6 +706,8 @@ Ext.define('PBS.DataStoreContent', {
let me = this;
if (data.ty === 'group') {
me.moveGroup(data);
+ } else if (data.ty === 'ns') {
+ me.moveNS();
}
},

@@ -1114,10 +1136,13 @@ Ext.define('PBS.DataStoreContent', {
if (data.ty === 'group') {
return Ext.String.format(gettext("Move group '{0}'"), v);
}
- return '';
+ return Ext.String.format(gettext("Move namespace '{0}'"), v);
},
getClass: (v, m, { data }) => {
if (data.ty === 'group') { return 'fa fa-arrows'; }
+ if (data.ty === 'ns' && !data.isRootNS && data.ns === undefined) {
+ return 'fa fa-arrows';
+ }
return 'pmx-hidden';
},
isActionDisabled: (v, r, c, i, { data }) => false,
diff --git a/www/form/NamespaceSelector.js b/www/form/NamespaceSelector.js
index ddf68254..d349b568 100644
--- a/www/form/NamespaceSelector.js
+++ b/www/form/NamespaceSelector.js
@@ -90,6 +90,17 @@ Ext.define('PBS.form.NamespaceSelector', {
},
});

+ if (me.excludeNs) {
+ me.store.addFilter(
+ new Ext.util.Filter({
+ filterFn: (rec) => {
+ let ns = rec.data.ns;
+ return ns !== me.excludeNs && !ns.startsWith(`${me.excludeNs}/`);
+ },
+ }),
+ );
+ }
+
me.callParent();
},
});
diff --git a/www/window/NamespaceMove.js b/www/window/NamespaceMove.js
new file mode 100644
index 00000000..59dd6d45
--- /dev/null
+++ b/www/window/NamespaceMove.js
@@ -0,0 +1,126 @@
+Ext.define('PBS.window.NamespaceMove', {
+ extend: 'Proxmox.window.Edit',
+ alias: 'widget.pbsNamespaceMove',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ onlineHelp: 'storage-move-namespaces-groups',
+
+ submitText: gettext('Move'),
+ isCreate: true,
+ showTaskViewer: true,
+
+ cbind: {
+ url: '/api2/extjs/admin/datastore/{datastore}/move-namespace',
+ title: (get) => Ext.String.format(gettext("Move Namespace '{0}'"), get('namespace')),
+ },
+ method: 'POST',
+
+ width: 450,
+ fieldDefaults: {
+ labelWidth: 120,
+ },
+
+ cbindData: function (initialConfig) {
+ let ns = initialConfig.namespace ?? '';
+ let parts = ns.split('/');
+ return { nsName: parts[parts.length - 1] };
+ },
+
+ // Returns the target-ns path that was submitted, for use by the caller after success.
+ getNewNamespace: function () {
+ let me = this;
+ let parent = me.down('[name=parent]').getValue() || '';
+ let name = me.down('[name=name]').getValue();
+ return parent ? `${parent}/${name}` : name;
+ },
+
+ items: {
+ xtype: 'inputpanel',
+ onGetValues: function (values) {
+ let parent = values.parent || '';
+ let newNs = parent ? `${parent}/${values.name}` : values.name;
+ let result = {
+ ns: this.up('window').namespace,
+ 'target-ns': newNs,
+ };
+ if (values['delete-source'] !== undefined) {
+ result['delete-source'] = values['delete-source'] ? 1 : 0;
+ }
+ if (values['merge-groups'] !== undefined) {
+ result['merge-groups'] = values['merge-groups'] ? 1 : 0;
+ }
+ if (values['max-depth'] !== undefined && values['max-depth'] !== '') {
+ result['max-depth'] = values['max-depth'];
+ }
+ return result;
+ },
+ items: [
+ {
+ xtype: 'displayfield',
+ fieldLabel: gettext('Namespace'),
+ cbind: {
+ value: '{namespace}',
+ },
+ },
+ {
+ xtype: 'pbsNamespaceSelector',
+ name: 'parent',
+ fieldLabel: gettext('New Parent'),
+ allowBlank: true,
+ cbind: {
+ datastore: '{datastore}',
+ excludeNs: '{namespace}',
+ },
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'name',
+ fieldLabel: gettext('New Name'),
+ allowBlank: false,
+ maxLength: 31,
+ regex: PBS.Utils.SAFE_ID_RE,
+ regexText: gettext("Only alpha numerical, '_' and '-' (if not at start) allowed"),
+ cbind: {
+ value: '{nsName}',
+ },
+ },
+ ],
+ advancedItems: [
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'max-depth',
+ fieldLabel: gettext('Max Depth'),
+ allowBlank: true,
+ emptyText: gettext('Unlimited'),
+ minValue: 0,
+ maxValue: 8,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Limit how many levels of child namespaces to include. Leave empty to move the entire subtree.'),
+ },
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'merge-groups',
+ fieldLabel: gettext('Merge Groups'),
+ checked: true,
+ uncheckedValue: 0,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Merge snapshots into existing groups with the same name in the target namespace. Requires matching ownership and non-overlapping snapshot times.'),
+ },
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'delete-source',
+ fieldLabel: gettext('Delete Source'),
+ checked: true,
+ uncheckedValue: 0,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Remove the empty source namespace directories after moving all groups. Uncheck to keep the namespace structure.'),
+ },
+ },
+ ],
+ },
+});
--
2.47.3