public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/4] gui: Add button for changing backup group owner
Date: Fri,  6 Nov 2020 08:11:36 +0100	[thread overview]
Message-ID: <20201106071138.23547-2-dietmar@proxmox.com> (raw)
In-Reply-To: <20201106071138.23547-1-dietmar@proxmox.com>

From: Dylan Whyte <d.whyte@proxmox.com>

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 | 46 +++++++++++++++++++++++++++++++++++
 www/DataStoreContent.js       | 26 +++++++++++++++++++-
 www/Makefile                  |  1 +
 3 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 www/BackupGroupChangeOwner.js

diff --git a/www/BackupGroupChangeOwner.js b/www/BackupGroupChangeOwner.js
new file mode 100644
index 00000000..0a7a7563
--- /dev/null
+++ b/www/BackupGroupChangeOwner.js
@@ -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();
+    },
+});
diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js
index db912a83..7c6395c2 100644
--- a/www/DataStoreContent.js
+++ b/www/DataStoreContent.js
@@ -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),
diff --git a/www/Makefile b/www/Makefile
index dc23e602..a1e73810 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -52,6 +52,7 @@ JSSRC=							\
 	DataStorePrune.js				\
 	DataStoreContent.js				\
 	DataStorePanel.js				\
+	BackupGroupChangeOwner.js			\
 	ServerStatus.js					\
 	ServerAdministration.js				\
 	Dashboard.js					\
-- 
2.20.1




  reply	other threads:[~2020-11-06  7:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  7:11 [pbs-devel] [PATCH proxmox-backup 1/4] get rid of backup@pam Dietmar Maurer
2020-11-06  7:11 ` Dietmar Maurer [this message]
2020-11-06  7:11 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: use pbsUserSelector for BackupGroupChangeOwner Dietmar Maurer
2020-11-06  7:11 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: require owner for sync jobs Dietmar Maurer

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=20201106071138.23547-2-dietmar@proxmox.com \
    --to=dietmar@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