public inbox for pbs-devel@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 v2 4/4] ui: datastore content: add 'more actions' menu to actions
Date: Tue,  5 Dec 2023 11:53:45 +0100	[thread overview]
Message-ID: <20231205105345.1656325-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231205105345.1656325-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>
---
 www/datastore/Content.js | 110 ++++++++++++++++++++++-----------------
 1 file changed, 61 insertions(+), 49 deletions(-)

diff --git a/www/datastore/Content.js b/www/datastore/Content.js
index f715f814..8f063287 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),
@@ -1325,7 +1327,12 @@ Ext.define('PBS.datastore.GroupCmdMenu', {
 		hidden: '{!onPrune}',
 	    },
 	},
-	{ xtype: 'menuseparator' },
+	{
+	    xtype: 'menuseparator',
+	    cbind: {
+		hidden: '{!onForget}',
+	    },
+	},
 	{
 	    text: gettext('Remove'),
 	    iconCls: 'fa critical fa-trash-o',
@@ -1374,7 +1381,12 @@ Ext.define('PBS.datastore.SnapshotCmdMenu', {
 		disabled: '{!onShowInformation}',
 	    },
 	},
-	{ xtype: 'menuseparator' },
+	{
+	    xtype: 'menuseparator',
+	    cbind: {
+		hidden: '{!onForget}',
+	    },
+	},
 	{
 	    text: gettext('Remove'),
 	    iconCls: 'fa critical fa-trash-o',
-- 
2.30.2





      parent reply	other threads:[~2023-12-05 10:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 10:53 [pbs-devel] [PATCH proxmox-backup v2 0/4] add 'show information' for snapshots Dominik Csapak
2023-12-05 10:53 ` [pbs-devel] [PATCH proxmox-backup v2 1/4] api-types: add an UploadStatistic api type Dominik Csapak
2023-12-05 10:53 ` [pbs-devel] [PATCH proxmox-backup v2 2/4] api: datastore admin: add 'snapshot-information' api call Dominik Csapak
2023-12-05 10:53 ` [pbs-devel] [PATCH proxmox-backup v2 3/4] ui: datastore content: add snapshot information to context menu Dominik Csapak
2023-12-05 10:53 ` Dominik Csapak [this message]

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=20231205105345.1656325-5-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal