From d07a5f7e6f3a323f6b538a868afa4a5480d3c8f9 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Tue, 1 Feb 2022 16:00:23 +0000 Subject: [PATCH] :zap: Remove empty KeyCloak block from edit appConfig --- src/components/InteractiveEditor/EditAppConfig.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/InteractiveEditor/EditAppConfig.vue b/src/components/InteractiveEditor/EditAppConfig.vue index 56779b4c..40fe430c 100644 --- a/src/components/InteractiveEditor/EditAppConfig.vue +++ b/src/components/InteractiveEditor/EditAppConfig.vue @@ -86,8 +86,15 @@ export default { /* Remove any attribute which has an undefined value before saving */ removeUndefinedValues(rawAppConfig) { const raw = rawAppConfig; - const isEmpty = (value) => (value === undefined); - Object.keys(raw).forEach(key => isEmpty(raw[key]) && delete raw[key]); + const isEmptyObject = (obj) => (typeof obj === 'object' && Object.keys(obj).length === 0); + const isEmpty = (value) => (value === undefined || isEmptyObject(value)); + // Delete empty values + Object.keys(raw).forEach(key => { + if (isEmpty(raw[key])) delete raw[key]; + }); + // If KC config empty, delete it + const kcConfig = raw.auth.keycloak; + if (!kcConfig.clientId && !kcConfig.realm && !kcConfig.serverUrl) delete raw.auth.keycloak; return raw; }, },