From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 5/5] ui: datastore content: add 'more actions' menu to actions
Date: Tue, 28 Nov 2023 10:44:02 +0100 [thread overview]
Message-ID: <20231128094402.38115-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231128094402.38115-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2023-11-28 9:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 9:43 [pbs-devel] [PATCH proxmox-backup 0/5] add context menu to datastore content Dominik Csapak
2023-11-28 9:43 ` [pbs-devel] [PATCH proxmox-backup 1/5] api-types: add an UploadStatistic api type Dominik Csapak
2023-11-28 9:43 ` [pbs-devel] [PATCH proxmox-backup 2/5] api: datastore admin: add 'snapshot-information' api call Dominik Csapak
2023-11-28 9:44 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: datastore content: add context menu to groups and snapshots Dominik Csapak
2023-11-28 15:27 ` [pbs-devel] applied: " Thomas Lamprecht
2023-11-29 7:35 ` Dominik Csapak
2023-11-29 7:47 ` Thomas Lamprecht
2023-11-28 9:44 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: datastore content: add snapshot information to context menu Dominik Csapak
2023-11-28 9:44 ` Dominik Csapak [this message]
2023-11-28 11:32 ` [pbs-devel] [PATCH proxmox-backup 0/5] add context menu to datastore content Fabian Grünbichler
2023-11-28 12:48 ` Philipp Hufnagl
2023-11-28 13:41 ` Max Carrara
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=20231128094402.38115-6-d.csapak@proxmox.com \
--to=d.csapak@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