public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 2/2] fix #6195: ui: add button/window for moving a namespace
Date: Wed,  3 Sep 2025 14:08:44 +0200	[thread overview]
Message-ID: <20250903120844.211292-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20250903120844.211292-1-h.laimer@proxmox.com>

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 www/Makefile                |  1 +
 www/datastore/Content.js    | 38 ++++++++++++++++++++++++++++++
 www/window/NamespaceMove.js | 47 +++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 www/window/NamespaceMove.js

diff --git a/www/Makefile b/www/Makefile
index 9ebf0445..d0b4592c 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -79,6 +79,7 @@ JSSRC=							\
 	window/CreateDirectory.js			\
 	window/DataStoreEdit.js				\
 	window/NamespaceEdit.js				\
+	window/NamespaceMove.js				\
 	window/MaintenanceOptions.js			\
 	window/NotesEdit.js				\
 	window/RemoteEdit.js				\
diff --git a/www/datastore/Content.js b/www/datastore/Content.js
index 075022e9..ad9733c1 100644
--- a/www/datastore/Content.js
+++ b/www/datastore/Content.js
@@ -447,6 +447,22 @@ Ext.define('PBS.DataStoreContent', {
             win.on('destroy', this.reload, this);
         },
 
+        onMove: function (table, rI, cI, item, e, rec) {
+            let me = this;
+            let view = me.getView();
+            if (!rec.data.ns || rec.data.ty !== 'ns' || !view.datastore) {
+                return;
+            }
+            Ext.create('PBS.NamespaceMove', {
+                autoShow: true,
+                datastore: view.datastore,
+                ns: rec.data.ns,
+                listeners: {
+                    destroy: () => me.reload(),
+                },
+            });
+        },
+
         onPrune: function (table, rI, cI, item, e, rec) {
             let me = this;
             let view = me.getView();
@@ -1058,6 +1074,18 @@ Ext.define('PBS.DataStoreContent', {
                         data.ty === 'group' ? 'fa fa-scissors' : 'pmx-hidden',
                     isActionDisabled: (v, r, c, i, { data }) => data.ty !== 'group',
                 },
+                {
+                    handler: 'onMove',
+                    getTip: (v, m, rec) => Ext.String.format(gettext("Move '{0}'"), v),
+                    getClass: (v, m, { data }) => {
+                        if (data.parentId !== 'root' && !!data.ns && data.ty === 'ns' && !data.isRootNS) {
+                            return 'fa fa-arrow-right';
+                        } else {
+                            return 'pmx-hidden';
+                        }
+                    },
+                    isActionDisabled: (v, r, c, i, { data }) => data.ty !== 'ns',
+                },
                 {
                     handler: 'onProtectionChange',
                     getTip: (v, m, rec) =>
@@ -1439,6 +1467,16 @@ Ext.define('PBS.datastore.GroupCmdMenu', {
                 hidden: '{!onPrune}',
             },
         },
+        {
+            text: gettext('Move'),
+            iconCls: 'fa fa-arrow-right',
+            handler: function () {
+                this.up('menu').onMove();
+            },
+            cbind: {
+                hidden: '{!onMove}',
+            },
+        },
         { xtype: 'menuseparator' },
         {
             text: gettext('Remove'),
diff --git a/www/window/NamespaceMove.js b/www/window/NamespaceMove.js
new file mode 100644
index 00000000..b294bf6f
--- /dev/null
+++ b/www/window/NamespaceMove.js
@@ -0,0 +1,47 @@
+Ext.define('PBS.NamespaceMove', {
+    extend: 'Proxmox.window.Edit',
+    alias: 'widget.pbsNamespaceMove',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    onlineHelp: 'changing-backup-owner',
+
+    submitText: gettext('Move Namespace'),
+    width: 350,
+
+    initComponent: function () {
+        let me = this;
+
+        if (!me.datastore) {
+            throw 'no datastore specified';
+        }
+        if (!me.ns) {
+            throw 'no namespace specified';
+        }
+
+        Ext.apply(me, {
+            url: `/api2/extjs/admin/datastore/${me.datastore}/namespace/move`,
+            method: 'POST',
+            subject: gettext('Move Namespace') + ` - ${me.ns}`,
+            items: {
+                xtype: 'inputpanel',
+                onGetValues: function (values) {
+                    values.ns = me.ns;
+                    return values;
+                },
+
+                items: [
+                    {
+                        xtype: 'pbsNamespaceSelector',
+                        datastore: me.datastore,
+                        name: 'target-ns',
+                        value: me.ns,
+                        fieldLabel: gettext('Target'),
+                        allowBlank: true,
+                    },
+                ],
+            },
+        });
+
+        me.callParent();
+    },
+});
-- 
2.47.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


      parent reply	other threads:[~2025-09-03 12:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 12:08 [pbs-devel] [PATCH proxmox-backup v2 0/2] fixes #6195, add support for moving namespaces Hannes Laimer
2025-09-03 12:08 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #6195: api: datastore: add endpoint " Hannes Laimer
2025-09-03 12:08 ` Hannes Laimer [this message]

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=20250903120844.211292-3-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pbs-devel@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal