From 109b27594a96bc12fca8427ec2ccc8f7318db8e3 Mon Sep 17 00:00:00 2001 From: Marcelo Rydel Date: Tue, 12 Oct 2021 14:51:43 -0300 Subject: [PATCH] save settings draft (#5872) --- .../ldap-settings/ldap-settings.controller.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/portainer/settings/authentication/ldap/ldap-settings/ldap-settings.controller.js b/app/portainer/settings/authentication/ldap/ldap-settings/ldap-settings.controller.js index b989393ab..b9a43d880 100644 --- a/app/portainer/settings/authentication/ldap/ldap-settings/ldap-settings.controller.js +++ b/app/portainer/settings/authentication/ldap/ldap-settings/ldap-settings.controller.js @@ -4,7 +4,7 @@ const SERVER_TYPES = { AD: 2, }; -import { buildOpenLDAPSettingsModel } from '@/portainer/settings/authentication/ldap/ldap-settings.model'; +import { buildLdapSettingsModel, buildOpenLDAPSettingsModel } from '@/portainer/settings/authentication/ldap/ldap-settings.model'; import { EXTERNAL_AUTH_LDAP } from '@/portainer/feature-flags/feature-ids'; const DEFAULT_GROUP_FILTER = '(objectClass=groupOfNames)'; @@ -16,6 +16,7 @@ export default class LdapSettingsController { Object.assign(this, { LDAPService, SERVER_TYPES }); this.tlscaCert = null; + this.settingsDrafts = {}; this.boxSelectorOptions = [ { id: 'ldap_custom', value: SERVER_TYPES.CUSTOM, label: 'Custom', icon: 'fa fa-server' }, @@ -37,18 +38,23 @@ export default class LdapSettingsController { } onChangeServerType(serverType) { + this.settingsDrafts[this.settings.ServerType] = this.settings; + + if (this.settingsDrafts[serverType]) { + this.settings = this.settingsDrafts[serverType]; + return; + } + switch (serverType) { case SERVER_TYPES.OPEN_LDAP: - return this.onChangeToOpenLDAP(); - default: + this.settings = buildOpenLDAPSettingsModel(); + break; + case SERVER_TYPES.CUSTOM: + this.settings = buildLdapSettingsModel(); break; } } - onChangeToOpenLDAP() { - this.settings = buildOpenLDAPSettingsModel(); - } - searchUsers() { const settings = { ...this.settings,