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 <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-05-07 14:00:07 +02:00 committed by Thomas Lamprecht
parent a72428b8c6
commit fc40915c7c
2 changed files with 9 additions and 2 deletions

View File

@ -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();
},

View File

@ -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',