[pve-devel] [PATCH manager 1/3] ui: ACMEAccountCreate: make name only optional if no default exists

Dominik Csapak d.csapak at proxmox.com
Thu May 7 14:00:07 CEST 2020


if the 'default' account exists, make the name field required and
remove the emptytext

get the information by querying the grid store. this may be not
up-to-date, but it is less intrusive that an extra api call that
blocks the window

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/dc/ACMEClusterView.js | 3 +++
 www/manager6/node/ACME.js          | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/www/manager6/dc/ACMEClusterView.js b/www/manager6/dc/ACMEClusterView.js
index 00db8e9f..aaf2fc19 100644
--- a/www/manager6/dc/ACMEClusterView.js
+++ b/www/manager6/dc/ACMEClusterView.js
@@ -29,7 +29,10 @@ Ext.define('PVE.dc.ACMEAccountView', {
 
 	addAccount: function() {
 	    let me = this;
+	    let view = me.getView();
+	    let defaultExists = view.getStore().findExact('name', 'default') !== -1;
 	    Ext.create('PVE.node.ACMEAccountCreate', {
+		defaultExists,
 		taskDone: function() {
 		    me.reload();
 		},
diff --git a/www/manager6/node/ACME.js b/www/manager6/node/ACME.js
index 0418f406..fd33333b 100644
--- a/www/manager6/node/ACME.js
+++ b/www/manager6/node/ACME.js
@@ -1,5 +1,6 @@
 Ext.define('PVE.node.ACMEAccountCreate', {
     extend: 'Proxmox.window.Edit',
+    mixins: ['Proxmox.Mixin.CBind'],
 
     width: 400,
     title: gettext('Register Account'),
@@ -8,14 +9,17 @@ Ext.define('PVE.node.ACMEAccountCreate', {
     submitText: gettext('Register'),
     url: '/cluster/acme/account',
     showTaskViewer: true,
+    defaultExists: false,
 
     items: [
 	{
 	    xtype: 'proxmoxtextfield',
 	    fieldLabel: gettext('Name'),
 	    name: 'name',
-	    emptyText: 'default',
-	    allowBlank: true,
+	    cbind: {
+		emptyText: (get) => get('defaultExists') ? '' : 'default',
+		allowBlank: (get) => !get('defaultExists'),
+	    },
 	},
 	{
 	    xtype: 'proxmoxComboGrid',
-- 
2.20.1





More information about the pve-devel mailing list