[pve-devel] [PATCH manager] dc/Realms: fix adding of new ldap realm

Dominik Csapak d.csapak at proxmox.com
Fri May 8 09:53:31 CEST 2020


we cannot pass 'delete' on create api call, and we have to make
sure that 'default_opts' and 'sync_attributes' are alwyas available,
since they are used in onGetValues
(they were only created during setValues, which is not called
when adding a new realm)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/dc/AuthEditLDAP.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/www/manager6/dc/AuthEditLDAP.js b/www/manager6/dc/AuthEditLDAP.js
index 0ca6f6ac..c5976769 100644
--- a/www/manager6/dc/AuthEditLDAP.js
+++ b/www/manager6/dc/AuthEditLDAP.js
@@ -66,6 +66,8 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 
     editableAttributes: ['email'],
     editableDefaults: ['scope', 'full', 'enable-new', 'purge'],
+    default_opts: {},
+    sync_attributes: {},
 
     // (de)construct the sync-attributes from the list above,
     // not touching all others
@@ -93,12 +95,15 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 	PVE.Utils.delete_if_default(values, 'sync-defaults-options');
 	PVE.Utils.delete_if_default(values, 'sync_attributes');
 
+	if (me.isCreate) {
+	    delete values.delete; // on create we cannot delete values
+	}
+
 	return values;
     },
 
     setValues: function(values) {
 	let me = this;
-	me.sync_attributes = {};
 	if (values.sync_attributes) {
 	    me.sync_attributes = PVE.Parser.parsePropertyString(values.sync_attributes);
 	    delete values.sync_attributes;
@@ -108,7 +113,6 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 		}
 	    });
 	}
-	me.default_opts = {};
 	if (values['sync-defaults-options']) {
 	    me.default_opts = PVE.Parser.parsePropertyString(values['sync-defaults-options']);
 	    delete values.default_opts;
-- 
2.20.1





More information about the pve-devel mailing list