]> git.proxmox.com Git - proxmox-backup.git/commitdiff
gui: Add button for changing backup group owner
authorDylan Whyte <d.whyte@proxmox.com>
Tue, 3 Nov 2020 08:30:54 +0000 (09:30 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 6 Nov 2020 07:48:00 +0000 (08:48 +0100)
Extension of fix #2847

Adds an action button to the datastore content view,
to change the owner of a backup.

Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
www/BackupGroupChangeOwner.js [new file with mode: 0644]
www/Makefile
www/datastore/Content.js

diff --git a/www/BackupGroupChangeOwner.js b/www/BackupGroupChangeOwner.js
new file mode 100644 (file)
index 0000000..0a7a756
--- /dev/null
@@ -0,0 +1,46 @@
+Ext.define('PBS.BackupGroupChangeOwner', {
+    extend: 'Proxmox.window.Edit',
+    alias: 'widget.pbsBackupGroupChangeOwner',
+
+    submitText: gettext("Change Owner"),
+    subject: gettext("Change Owner"),
+
+    initComponent: function() {
+       let me = this;
+
+       if (!me.datastore) {
+           throw "no datastore specified";
+       }
+       if (!me.backup_type) {
+           throw "no backup_type specified";
+       }
+       if (!me.backup_id) {
+           throw "no backup_id specified";
+       }
+
+       Ext.apply(me, {
+           url: `/api2/extjs/admin/datastore/${me.datastore}/change-owner`,
+           method: 'POST',
+           items: {
+               xtype: 'inputpanel',
+               onGetValues: function(values) {
+                   values["backup-type"] = me.backup_type;
+                   values["backup-id"] = me.backup_id;
+                   return values;
+               },
+
+               column1: [
+                   {
+                       xtype: 'textfield',
+                       name: 'new-owner',
+                       fieldLabel: gettext('Userid'),
+                       minLength: 8,
+                       allowBlank: false,
+                   },
+               ],
+           },
+       });
+
+       me.callParent();
+    },
+});
index b92568ac17e31140a65807d12d6e1d5ebab88176..9fd014b4111ef6a11fe265f3eb61e132be48037f 100644 (file)
@@ -52,6 +52,7 @@ JSSRC=                                                        \
        datastore/Prune.js                              \
        datastore/Content.js                            \
        datastore/Panel.js                              \
+       BackupGroupChangeOwner.js                       \
        ServerStatus.js                                 \
        ServerAdministration.js                         \
        Dashboard.js                                    \
index db912a8366de4fa75c8f29a8e4a5efd9640c9420..7c6395c2fd8f23576cfc7777e4fba3d365478e24 100644 (file)
@@ -268,6 +268,24 @@ Ext.define('PBS.DataStoreContent', {
            }
        },
 
+       onChangeOwner: function(view, rI, cI, item, e, rec) {
+           view = this.getView();
+
+           if (!rec || !rec.data || rec.parentNode.id !== 'root' || !view.datastore) {
+               return;
+           }
+
+           let data = rec.data;
+
+           let win = Ext.create('PBS.BackupGroupChangeOwner', {
+               datastore: view.datastore,
+               backup_type: data.backup_type,
+               backup_id: data.backup_id,
+               autoShow: true,
+           });
+           win.on('destroy', this.reload, this);
+       },
+
        onPrune: function(view, rI, cI, item, e, rec) {
            view = this.getView();
 
@@ -582,7 +600,13 @@ Ext.define('PBS.DataStoreContent', {
                    getTip: (v, m, rec) => Ext.String.format(gettext("Verify '{0}'"), v),
                    getClass: (v, m, rec) => rec.data.leaf ? 'pmx-hidden' : 'pve-icon-verify-lettering',
                    isDisabled: (v, r, c, i, rec) => !!rec.data.leaf,
-               },
+                },
+                {
+                   handler: 'onChangeOwner',
+                   getClass: (v, m, rec) => rec.parentNode.id ==='root' ? 'fa fa-user' : 'pmx-hidden',
+                   getTip: (v, m, rec) => Ext.String.format(gettext("Change owner of '{0}'"), v),
+                   isDisabled: (v, r, c, i, rec) => rec.parentNode.id !=='root',
+                },
                {
                    handler: 'onPrune',
                    getTip: (v, m, rec) => Ext.String.format(gettext("Prune '{0}'"), v),