all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/5] ui: datastore content: add context menu to groups and snapshots
Date: Tue, 28 Nov 2023 10:44:00 +0100	[thread overview]
Message-ID: <20231128094402.38115-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231128094402.38115-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
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




  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 ` Dominik Csapak [this message]
2023-11-28 15:27   ` [pbs-devel] applied: [PATCH proxmox-backup 3/5] ui: datastore content: add context menu to groups and snapshots 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 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: datastore content: add 'more actions' menu to actions Dominik Csapak
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-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal