From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 472D61FF15E
	for <inbox@lore.proxmox.com>; Tue, 25 Mar 2025 16:21:44 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 27DCDDD0E;
	Tue, 25 Mar 2025 16:21:38 +0100 (CET)
From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue, 25 Mar 2025 16:20:58 +0100
Message-Id: <20250325152058.100499-1-h.laimer@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.027 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
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH pve-manager v3] ui: storage: add is_mountpoint
 checkbox to dir/btrfs storage edit
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

This came up in support, and there is no reason to not have it in
the UI, while having it in the API.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v2:
 - use Aaron's improved help text

v3, thanks @Fabian and @Fiona:
 - handle if a path is set correctly
 - move to BaseStorage, so we don't have the same code in two places

 www/manager6/storage/Base.js | 44 ++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index c8c735f3..813f961b 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -4,6 +4,13 @@ Ext.define('PVE.panel.StorageBase', {
 
     type: '',
 
+    viewModel: {
+	data: {
+	    isMpReadOnly: false,
+	    isMpChecked: false,
+	},
+    },
+
     onGetValues: function(values) {
 	let me = this;
 
@@ -19,6 +26,16 @@ Ext.define('PVE.panel.StorageBase', {
 	return values;
     },
 
+    setValues: function(values) {
+	let isMp = values.is_mountpoint;
+	let isMpSet = !!isMp && isMp !== '0';
+	let isMpIsPath = isMpSet && isMp !== '1';
+	this.viewModel.set('isMpReadOnly', isMpIsPath);
+	this.viewModel.set('isMpChecked', isMpSet);
+
+	this.callParent([values]);
+    },
+
     initComponent: function() {
 	let me = this;
 
@@ -73,6 +90,33 @@ Ext.define('PVE.panel.StorageBase', {
 	    }
 	}
 
+	const hasIsMountpointStorageTypes = ['dir', 'btrfs'];
+
+	if (hasIsMountpointStorageTypes.includes(me.type)) {
+	    const isMountpointBox = {
+		xtype: 'proxmoxcheckbox',
+		name: 'is_mountpoint',
+		uncheckedValue: 0,
+		fieldLabel: gettext('Mountpoint'),
+		bind: {
+		    disabled: '{isMpReadOnly}',
+		    value: '{isMpChecked}',
+		},
+		autoEl: {
+		    tag: 'div',
+		    'data-qtip': gettext('Enable if something is mounted at this path. Storage is considered offline as long as nothing is mounted.'),
+		},
+	    };
+
+	    me.advancedColumn1 = me.advancedColumn1 || [];
+	    me.advancedColumn2 = me.advancedColumn2 || [];
+	    if (me.advancedColumn2.length < me.advancedColumn1.length) {
+		me.advancedColumn2.unshift(isMountpointBox);
+	    } else {
+		me.advancedColumn1.unshift(isMountpointBox);
+	    }
+	}
+
 	me.callParent();
     },
 });
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel