[pve-devel] [PATCH manager 6/7] ui: node/ACME: only enable order button when it should work

Dominik Csapak d.csapak at proxmox.com
Thu May 7 10:27:12 CEST 2020


to order a ceritificate, we need at least one configured domain, and
the configured account (or default) must exist

so track the domaincount in the viewmodel and introduce a
'canOrder' formula which is only true when domaincount > 0 and
account is set (if the configured account does not exist, or no account
exists at all we set 'account' to 'null')

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/node/ACME.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/www/manager6/node/ACME.js b/www/manager6/node/ACME.js
index 1e91be4e..d21d18e4 100644
--- a/www/manager6/node/ACME.js
+++ b/www/manager6/node/ACME.js
@@ -350,6 +350,7 @@ Ext.define('PVE.node.ACME', {
 
     viewModel: {
 	data: {
+	    domaincount: 0,
 	    account: undefined, // the account we display
 	    configaccount: undefined, // the account set in the config
 	    accountEditable: false,
@@ -357,6 +358,7 @@ Ext.define('PVE.node.ACME', {
 	},
 
 	formulas: {
+	    canOrder: (get) => !!get('account') && get('domaincount') > 0,
 	    editBtnIcon: (get) => 'fa black fa-' + (get('accountEditable') ? 'check' : 'pencil'),
 	    accountTextHidden: (get) => get('accountEditable') || !get('accountsAvailable'),
 	    accountValueHidden: (get) => !get('accountEditable') || !get('accountsAvailable'),
@@ -566,7 +568,7 @@ Ext.define('PVE.node.ACME', {
 	    reference: 'order',
 	    text: gettext('Order Certificates Now'),
 	    bind: {
-		disabled: '{!accountsAvailable}',
+		disabled: '{!canOrder}',
 	    },
 	    handler: 'order',
 	},
@@ -678,6 +680,7 @@ Ext.define('PVE.node.ACME', {
 	    data.push(record);
 	}
 
+	vm.set('domaincount', data.length);
 	me.store.loadData(data, false);
     },
 
-- 
2.20.1





More information about the pve-devel mailing list