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 C9DD59E8AC for ; Tue, 28 Nov 2023 10:44:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B04FA13AFD 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:03 +0100 (CET) Received: by bookworm-dev.localdomain (Postfix, from userid 1000) id CFAC160B47; 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:02 +0100 Message-Id: <20231128094402.38115-6-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 5/5] ui: datastore content: add 'more actions' menu to actions 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:34 -0000 and move change owner and change protection there, since these are not that often used. Also add the 'Show Information' action there for snapshots, as this was not available via actions. Refactor the menu creation for this. Signed-off-by: Dominik Csapak --- sadly also here no keyboard ineraction for the menu www/datastore/Content.js | 96 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/www/datastore/Content.js b/www/datastore/Content.js index d9e9d0b4..981ab300 100644 --- a/www/datastore/Content.js +++ b/www/datastore/Content.js @@ -806,6 +806,48 @@ Ext.define('PBS.DataStoreContent', { }).show(); }, + onMoreActions: function(panel, rI, cI, item, event, record) { + this.showContextMenu(panel, record, event, false); + }, + + showContextMenu: function(panel, record, event, rightClick) { + let me = this; + event.stopEvent(); + let menu; + let view = me.getView(); + let createControllerCallback = function(name) { + return function() { + me[name](view, undefined, undefined, undefined, undefined, record); + }; + }; + if (record.data.ty === 'group') { + let params = { + title: gettext('Group'), + onChangeOwner: createControllerCallback('onChangeOwner'), + }; + if (rightClick) { + params.onVerify = createControllerCallback('onVerify'); + params.onPrune = createControllerCallback('onPrune'); + params.onForget = createControllerCallback('onForget'); + } + menu = Ext.create('PBS.datastore.GroupCmdMenu', params); + } else if (record.data.ty === 'dir') { + let params = { + title: gettext('Snapshot'), + onProtectionChange: createControllerCallback('onProtectionChange'), + onShowInformation: createControllerCallback('onShowInformation'), + }; + if (rightClick) { + params.onVerify = createControllerCallback('onVerify'); + params.onForget = createControllerCallback('onForget'); + } + menu = Ext.create('PBS.datastore.SnapshotCmdMenu', params); + } + if (menu) { + menu.showAt(event.getXY()); + } + }, + filter: function(item, value) { if (item.data.text.indexOf(value) !== -1) { return true; @@ -882,35 +924,7 @@ Ext.define('PBS.DataStoreContent', { } }, 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'), - onShowInformation: createControllerCallback('onShowInformation'), - onForget: createControllerCallback('onForget'), - }); - } - if (menu) { - menu.showAt(event.getXY()); - } + this.getController().showContextMenu(panel, record, event, true); }, }, @@ -1000,30 +1014,12 @@ Ext.define('PBS.DataStoreContent', { ? 'pve-icon-verify-lettering' : 'pmx-hidden', isActionDisabled: (v, r, c, i, rec) => !!rec.data.leaf, }, - { - handler: 'onChangeOwner', - getClass: (v, m, { data }) => data.ty === 'group' ? 'fa fa-user' : 'pmx-hidden', - getTip: (v, m, rec) => Ext.String.format(gettext("Change owner of '{0}'"), v), - isActionDisabled: (v, r, c, i, { data }) => data.ty !== 'group', - }, { handler: 'onPrune', getTip: (v, m, rec) => Ext.String.format(gettext("Prune '{0}'"), v), getClass: (v, m, { data }) => data.ty === 'group' ? 'fa fa-scissors' : 'pmx-hidden', isActionDisabled: (v, r, c, i, { data }) => data.ty !== 'group', }, - { - handler: 'onProtectionChange', - getTip: (v, m, rec) => Ext.String.format(gettext("Change protection of '{0}'"), v), - getClass: (v, m, rec) => { - if (rec.data.ty === 'dir') { - let extraCls = rec.data.protected ? 'good' : 'faded'; - return `fa fa-shield ${extraCls}`; - } - return 'pmx-hidden'; - }, - isActionDisabled: (v, r, c, i, rec) => rec.data.ty !== 'dir', - }, { handler: 'onForget', getTip: (v, m, { data }) => { @@ -1044,6 +1040,12 @@ Ext.define('PBS.DataStoreContent', { : 'pmx-hidden', isActionDisabled: (v, r, c, i, { data }) => false, }, + { + handler: 'onMoreActions', + getTip: (v, m, { data }) => gettext('Show more actions'), + getClass: (v, m, { data }) => data.ty === 'group' || data.ty === 'dir' ? 'fa fa-bars' : 'pmx-hidden', + isActionDisabled: (v, r, c, i, { data }) => data.ty !== 'group' && data.ty !== 'dir', + }, { handler: 'downloadFile', getTip: (v, m, rec) => Ext.String.format(gettext("Download '{0}'"), v), -- 2.39.2