From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id F2FEE63F3A for ; Thu, 29 Oct 2020 11:30:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E2EEF276BA for ; Thu, 29 Oct 2020 11:30:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 916B8276AE for ; Thu, 29 Oct 2020 11:30:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 58CB945A25 for ; Thu, 29 Oct 2020 11:30:28 +0100 (CET) To: Proxmox Backup Server development discussion , Dylan Whyte References: <20201029091657.29095-1-d.whyte@proxmox.com> From: Thomas Lamprecht Message-ID: Date: Thu, 29 Oct 2020 11:30:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Thunderbird/83.0 MIME-Version: 1.0 In-Reply-To: <20201029091657.29095-1-d.whyte@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.336 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.921 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [parentnode.id, win.show, rec.data] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup] gui: Add button for changing backup group owner X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 10:30:30 -0000 On 29.10.20 10:16, Dylan Whyte wrote: > Extension of fix #2847 >=20 > Adds an action button to the datastore content view, > to change the owner of a backup. >=20 > Signed-off-by: Dylan Whyte > --- >=20 > v2: > - Fix whitespace > - BackupGroupChangeOwner: remove unnecessary reload function > - Use let insread of var in "onGetValues" > - Use template literals for URL > - Set autoShow true when creating the window >=20 > In response to comment about reassigning view in onChangeOwner, the > view that is passed to the handler function (Ext.view.Table) is > necessary in the handler definiation/call, but is not used > within the implementaion of onChangeOwner. Thus it is reassigned to the= > change owner window view. This follows the format of the other action > handlers in the file. getting quite there, seems to work out OK, a few comments left, mostly re= garding code structure and missing gettext's - sorry to overlook those when comme= nting v1. >=20 > www/BackupGroupChangeOwner.js | 74 +++++++++++++++++++++++++++++++++++= > www/DataStoreContent.js | 27 ++++++++++++- > www/Makefile | 1 + > 3 files changed, 101 insertions(+), 1 deletion(-) > create mode 100644 www/BackupGroupChangeOwner.js >=20 > diff --git a/www/BackupGroupChangeOwner.js b/www/BackupGroupChangeOwner= =2Ejs > new file mode 100644 > index 00000000..0d24bfe0 > --- /dev/null > +++ b/www/BackupGroupChangeOwner.js > @@ -0,0 +1,74 @@ > +Ext.define('PBS.ChangeOwnerInputPanel', { > + extend: 'Proxmox.panel.InputPanel', > + alias: 'widget.pbsChangeOwnerInputPanel', > + mixins: ['Proxmox.Mixin.CBind'], not sure if it's worth to define this as separate component with only one= single field as element? I'd rather declare it inline in the edit window definition below, the par= ams checking from init here is done there anyway, You could check out 'PBS.window.VerifyJobEdit' as example for this. > + > + onGetValues: function(values) { > + let me =3D this; > + > + values["backup-type"] =3D me.backup_type; > + values["backup-id"] =3D me.backup_id; > + return values; > + }, > + > + controller: { > + xclass: 'Ext.app.ViewController', > + > + init: function(view) { > + if (!view.url) { > + throw "no url specified"; > + } > + if (!view.backup_type) { > + throw "no backup_type specified"; > + } > + if (!view.backup_id) { > + throw "no backup_id specified"; > + } > + }, > + }, > + > + column1: [ > + { > + xtype: 'textfield', > + name: 'new-owner', > + fieldLabel: gettext('Userid'), > + minLength: 8, > + allowBlank: false, > + }, > + ], > + > +}); > + > +Ext.define('PBS.BackupGroupChangeOwner', { > + extend: 'Proxmox.window.Edit', > + > + method: 'POST', > + submitText: "Change Owner", use gettext > + > + initComponent: function() { > + var me =3D 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`, > + title: "Change Owner", title can be above, in declarative config part, also, please use gettext > + items: [{ > + xtype: "pbsChangeOwnerInputPanel", > + url: `/api2/extjs/admin/datastore/${me.datastore}/change-owner`, > + backup_type: me.backup_type, > + backup_id: me.backup_id, > + }], > + }); > + > + me.callParent(); > + }, > +}); > diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js > index 9da18845..35aa2b11 100644 > --- a/www/DataStoreContent.js > +++ b/www/DataStoreContent.js > @@ -268,6 +268,25 @@ Ext.define('PBS.DataStoreContent', { > } > }, > =20 > + onChangeOwner: function(view, rI, cI, item, e, rec) { > + view =3D this.getView(); > + > + if (!rec || !rec.data || rec.parentNode.id !=3D=3D 'root' || !vie= w.datastore) { > + return; > + } > + > + let data =3D rec.data; > + > + let win =3D 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); > + win.show(); once you set autoShow above win.show call is not required anymore ;-) > + }, > + > onPrune: function(view, rI, cI, item, e, rec) { > view =3D this.getView(); > =20 > @@ -582,7 +601,13 @@ Ext.define('PBS.DataStoreContent', { > getTip: (v, m, rec) =3D> Ext.String.format(gettext("Verify '{0}'= "), v), > getClass: (v, m, rec) =3D> rec.data.leaf ? 'pmx-hidden' : 'pve-i= con-verify-lettering', > isDisabled: (v, r, c, i, rec) =3D> !!rec.data.leaf, > - }, > + }, > + { > + handler: 'onChangeOwner', > + tooltip: gettext('Change Owner'), I recently adapted those to a more dynamic one, showing the snapshot/grou= p ID inside the tooltip by using the getTip config property. Maybe it makes sense to adapt that here too? getTip: (v, m, rec) =3D> Ext.String.format(gettext("Change owner of '{0}'= "), v), > + getClass: (v, m, rec) =3D> rec.parentNode.id =3D=3D=3D'root' ? '= fa fa-user' : 'pmx-hidden', > + isDisabled: (v, r, c, i, rec) =3D> rec.parentNode.id !=3D=3D'roo= t', > + }, > { > handler: 'onPrune', > getTip: (v, m, rec) =3D> Ext.String.format(gettext("Prune '{0}'"= ), v), > diff --git a/www/Makefile b/www/Makefile > index cba8bed5..aabc8d9c 100644 > --- a/www/Makefile > +++ b/www/Makefile > @@ -46,6 +46,7 @@ JSSRC=3D \ > DataStorePrune.js \ > DataStoreContent.js \ > DataStorePanel.js \ > + BackupGroupChangeOwner.js \ > ServerStatus.js \ > ServerAdministration.js \ > Dashboard.js \ >=20