From fc40915c7c46fc22d6fa2e1feb3214e7c0fb98a9 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 7 May 2020 14:00:07 +0200 Subject: [PATCH] ui: ACMEAccountCreate: make name only optional if no default exists 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 --- 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',