public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v4 1/1] ui: realm sync: replace 'full' and 'purge' with 'remove-vanished'
Date: Mon, 28 Mar 2022 14:38:06 +0200	[thread overview]
Message-ID: <20220328123807.233098-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220328123807.233098-1-d.csapak@proxmox.com>

in default sync options and the sync window. We do this by exposing
the individual flags as checkboxes. We get the mapped value from the
backend so we do not have to handle 'old' values here.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/AuthEditLDAP.js | 63 +++++++++++++++++++------------
 www/manager6/dc/SyncWindow.js   | 66 ++++++++++++++++++++-------------
 2 files changed, 80 insertions(+), 49 deletions(-)

diff --git a/www/manager6/dc/AuthEditLDAP.js b/www/manager6/dc/AuthEditLDAP.js
index 015a5a6e..50505ae2 100644
--- a/www/manager6/dc/AuthEditLDAP.js
+++ b/www/manager6/dc/AuthEditLDAP.js
@@ -100,7 +100,7 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
     xtype: 'pveAuthLDAPSyncPanel',
 
     editableAttributes: ['email'],
-    editableDefaults: ['scope', 'full', 'enable-new', 'purge'],
+    editableDefaults: ['scope', 'enable-new'],
     default_opts: {},
     sync_attributes: {},
 
@@ -116,6 +116,15 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 		delete me.default_opts[attr];
 	    }
 	});
+	let vanished_opts = [];
+	['acl', 'entry', 'properties'].forEach((prop) => {
+	    if (values[`remove-vanished-${prop}`]) {
+		vanished_opts.push(prop);
+	    }
+	    delete values[`remove-vanished-${prop}`];
+	});
+	me.default_opts['remove-vanished'] = vanished_opts.join(';');
+
 	values['sync-defaults-options'] = PVE.Parser.printPropertyString(me.default_opts);
 	me.editableAttributes.forEach((attr) => {
 	    if (values[attr]) {
@@ -156,6 +165,13 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 		    values[attr] = me.default_opts[attr];
 		}
 	    });
+
+	    if (me.default_opts['remove-vanished']) {
+		let opts = me.default_opts['remove-vanished'].split(';');
+		for (const opt of opts) {
+		    values[`remove-vanished-${opt}`] = 1;
+		}
+	    }
 	}
 	return me.callParent([values]);
     },
@@ -204,18 +220,6 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 		['both', gettext('Users and Groups')],
 	    ],
 	},
-	{
-	    xtype: 'proxmoxKVComboBox',
-	    value: '__default__',
-	    deleteEmpty: false,
-	    comboItems: [
-		['__default__', Proxmox.Utils.NoneText],
-		['1', Proxmox.Utils.yesText],
-		['0', Proxmox.Utils.noText],
-	    ],
-	    name: 'full',
-	    fieldLabel: gettext('Full'),
-	},
     ],
 
     column2: [
@@ -269,17 +273,30 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', {
 	    name: 'enable-new',
 	    fieldLabel: gettext('Enable new users'),
 	},
+    ],
+
+    columnB: [
 	{
-	    xtype: 'proxmoxKVComboBox',
-	    value: '__default__',
-	    deleteEmpty: false,
-	    comboItems: [
-		['__default__', Proxmox.Utils.NoneText],
-		['1', Proxmox.Utils.yesText],
-		['0', Proxmox.Utils.noText],
-	    ],
-	    name: 'purge',
-	    fieldLabel: gettext('Purge'),
+	    xtype: 'displayfield',
+	    fieldLabel: gettext('Remove Vanished'),
+	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('ACL'),
+	    name: 'remove-vanished-acl',
+	    boxLabel: gettext('Remove ACLs of users and groups which are not in the sync response.'),
+	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('Entry'),
+	    name: 'remove-vanished-entry',
+	    boxLabel: gettext('Remove users and groups that are not in the sync response.'),
+	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('Properties'),
+	    name: 'remove-vanished-properties',
+	    boxLabel: gettext('Remove user-properties that are not in the sync response.'),
 	},
     ],
 });
diff --git a/www/manager6/dc/SyncWindow.js b/www/manager6/dc/SyncWindow.js
index 25a42182..b32926dd 100644
--- a/www/manager6/dc/SyncWindow.js
+++ b/www/manager6/dc/SyncWindow.js
@@ -32,6 +32,18 @@ Ext.define('PVE.dc.SyncWindow', {
 	    let view = me.getView();
 	    let ipanel = me.lookup('ipanel');
 	    let params = ipanel.getValues();
+
+	    let vanished_opts = [];
+	    ['acl', 'entry', 'properties'].forEach((prop) => {
+		if (params[`remove-vanished-${prop}`]) {
+		    vanished_opts.push(prop);
+		}
+		delete params[`remove-vanished-${prop}`];
+	    });
+	    if (vanished_opts.length > 0) {
+		params['remove-vanished'] = vanished_opts.join(';');
+	    }
+
 	    params['dry-run'] = is_preview ? 1 : 0;
 	    Proxmox.Utils.API2Request({
 		url: `/access/domains/${view.realm}/sync`,
@@ -88,19 +100,6 @@ Ext.define('PVE.dc.SyncWindow', {
 			    ['both', gettext('Users and Groups')],
 			],
 		    },
-		    {
-			xtype: 'proxmoxKVComboBox',
-			value: '',
-			emptyText: gettext('No default available'),
-			deleteEmpty: false,
-			allowBlank: false,
-			comboItems: [
-			    ['1', Proxmox.Utils.yesText],
-			    ['0', Proxmox.Utils.noText],
-			],
-			name: 'full',
-			fieldLabel: gettext('Full'),
-		    },
 		],
 
 		column2: [
@@ -116,22 +115,31 @@ Ext.define('PVE.dc.SyncWindow', {
 			name: 'enable-new',
 			fieldLabel: gettext('Enable new'),
 		    },
-		    {
-			xtype: 'proxmoxKVComboBox',
-			value: '',
-			emptyText: gettext('No default available'),
-			deleteEmpty: false,
-			allowBlank: false,
-			comboItems: [
-			    ['1', Proxmox.Utils.yesText],
-			    ['0', Proxmox.Utils.noText],
-			],
-			name: 'purge',
-			fieldLabel: gettext('Purge ACLs'),
-		    },
 		],
 
 		columnB: [
+		    {
+			xtype: 'displayfield',
+			fieldLabel: gettext('Remove Vanished'),
+		    },
+		    {
+			xtype: 'proxmoxcheckbox',
+			fieldLabel: gettext('ACL'),
+			name: 'remove-vanished-acl',
+			boxLabel: gettext('Remove ACLs of users and groups which are not in the sync response.'),
+		    },
+		    {
+			xtype: 'proxmoxcheckbox',
+			fieldLabel: gettext('Entry'),
+			name: 'remove-vanished-entry',
+			boxLabel: gettext('Remove users and groups that are not in the sync response.'),
+		    },
+		    {
+			xtype: 'proxmoxcheckbox',
+			fieldLabel: gettext('Properties'),
+			name: 'remove-vanished-properties',
+			boxLabel: gettext('Remove user-properties that are not in the sync response.'),
+		    },
 		    {
 			xtype: 'displayfield',
 			reference: 'defaulthint',
@@ -183,6 +191,12 @@ Ext.define('PVE.dc.SyncWindow', {
 		let default_options = response.result.data['sync-defaults-options'];
 		if (default_options) {
 		    let options = PVE.Parser.parsePropertyString(default_options);
+		    if (options['remove-vanished']) {
+			let opts = options['remove-vanished'].split(';');
+			for (const opt of opts) {
+			    options[`remove-vanished-${opt}`] = 1;
+			}
+		    }
 		    let ipanel = me.lookup('ipanel');
 		    ipanel.setValues(options);
 		} else {
-- 
2.30.2





  parent reply	other threads:[~2022-03-28 12:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 12:38 [pve-devel] [PATCH access-control/manager/docs v4] fix #3668: improving realm sync Dominik Csapak
2022-03-28 12:38 ` [pve-devel] [PATCH access-control v4 1/4] add regression tests for realm-sync Dominik Csapak
2022-03-28 12:38 ` [pve-devel] [PATCH access-control v4 2/4] fix #3668: realm-sync: replace 'full' and 'purge' options with 'remove-vanished' Dominik Csapak
2022-03-28 12:38 ` [pve-devel] [PATCH access-control v4 3/4] convert regression tests to new 'remove-vanished' parameter Dominik Csapak
2022-03-28 12:38 ` [pve-devel] [PATCH access-control v4 4/4] add realm-sync regression test for new 'remove-vanished' Dominik Csapak
2022-03-28 12:38 ` Dominik Csapak [this message]
2022-03-28 12:38 ` [pve-devel] [PATCH docs v4 1/1] update documentation about sync-options Dominik Csapak
2022-04-26 12:27 ` [pve-devel] applied-series: [PATCH access-control/manager/docs v4] fix #3668: improving realm sync Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220328123807.233098-6-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal