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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 588EF9E83B for ; Tue, 28 Nov 2023 10:44:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 36EB513AFA for ; Tue, 28 Nov 2023 10:44:04 +0100 (CET) Received: from bookworm-dev.localdomain (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Tue, 28 Nov 2023 10:44:02 +0100 (CET) Received: by bookworm-dev.localdomain (Postfix, from userid 1000) id C3AE8604BB; Tue, 28 Nov 2023 10:44:02 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 28 Nov 2023 10:44:00 +0100 Message-Id: <20231128094402.38115-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128094402.38115-1-d.csapak@proxmox.com> References: <20231128094402.38115-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.379 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup 3/5] ui: datastore content: add context menu to groups and snapshots 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: Tue, 28 Nov 2023 09:44:04 -0000 and show the relevant actions. They will be forwarded to the controller, so we can reuse that code without big refactoring them into another class/place. Signed-off-by: Dominik Csapak --- sadly no keyboard navigation in there.. but i'm looking into it www/datastore/Content.js | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/www/datastore/Content.js b/www/datastore/Content.js index 76588a51..8d5d0815 100644 --- a/www/datastore/Content.js +++ b/www/datastore/Content.js @@ -870,6 +870,36 @@ Ext.define('PBS.DataStoreContent', { me.firstLoad = true; } }, + itemcontextmenu: function(panel, record, item, index, event) { + event.stopEvent(); + let menu; + let view = panel.up('pbsDataStoreContent'); + let controller = view.getController(); + let createControllerCallback = function(name) { + return function() { + controller[name](view, undefined, undefined, undefined, undefined, record); + }; + }; + if (record.data.ty === 'group') { + menu = Ext.create('PBS.datastore.GroupCmdMenu', { + title: gettext('Group'), + onVerify: createControllerCallback('onVerify'), + onChangeOwner: createControllerCallback('onChangeOwner'), + onPrune: createControllerCallback('onPrune'), + onForget: createControllerCallback('onForget'), + }); + } else if (record.data.ty === 'dir') { + menu = Ext.create('PBS.datastore.SnapshotCmdMenu', { + title: gettext('Snapshot'), + onVerify: createControllerCallback('onVerify'), + onProtectionChange: createControllerCallback('onProtectionChange'), + onForget: createControllerCallback('onForget'), + }); + } + if (menu) { + menu.showAt(event.getXY()); + } + }, }, viewConfig: { @@ -1248,3 +1278,87 @@ Ext.define('PBS.DataStoreContent', { }, ], }); + +Ext.define('PBS.datastore.GroupCmdMenu', { + extend: 'Ext.menu.Menu', + mixins: ['Proxmox.Mixin.CBind'], + + onVerify: undefined, + onChangeOwner: undefined, + onPrune: undefined, + onForget: undefined, + + items: [ + { + text: gettext('Verify'), + iconCls: 'pve-icon-verify-lettering', + handler: function() { this.up('menu').onVerify(); }, + cbind: { + hidden: '{!onVerify}', + }, + }, + { + text: gettext('Change owner'), + iconCls: 'fa fa-user', + handler: function() { this.up('menu').onChangeOwner(); }, + cbind: { + hidden: '{!onChangeOwner}', + }, + }, + { + text: gettext('Prune'), + iconCls: 'fa fa-scissors', + handler: function() { this.up('menu').onPrune(); }, + cbind: { + hidden: '{!onPrune}', + }, + }, + { + text: gettext('Remove'), + iconCls: 'fa critical fa-trash-o', + handler: function() { this.up('menu').onForget(); }, + cbind: { + hidden: '{!onForget}', + }, + }, + ], +}); + +Ext.define('PBS.datastore.SnapshotCmdMenu', { + extend: 'Ext.menu.Menu', + mixins: ['Proxmox.Mixin.CBind'], + + onVerify: undefined, + onProtectionChange: undefined, + onForget: undefined, + + items: [ + { + text: gettext('Verify'), + iconCls: 'pve-icon-verify-lettering', + handler: function() { this.up('menu').onVerify(); }, + cbind: { + hidden: '{!onVerify}', + disabled: '{!onVerify}', + }, + }, + { + text: gettext('Change Protection'), + iconCls: 'fa fa-shield', + handler: function() { this.up('menu').onProtectionChange(); }, + cbind: { + hidden: '{!onProtectionChange}', + disabled: '{!onProtectionChange}', + }, + }, + { + text: gettext('Remove'), + iconCls: 'fa critical fa-trash-o', + handler: function() { this.up('menu').onForget(); }, + cbind: { + hidden: '{!onForget}', + disabled: '{!onForget}', + }, + }, + ], +}); -- 2.39.2