ui: realm sync: replace 'full' and 'purge' with 'remove-vanished'
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>
This commit is contained in:
parent
6e6a64a47a
commit
3e43739f57
@ -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.'),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user