From 1f13a9619ced568ce70ff51b931990945c9070ff Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 20 Jul 2021 12:30:11 +0100 Subject: [PATCH] fix save button --- .../builder/portal/manage/auth/index.svelte | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte index 78c0a5a52c..70abf7d376 100644 --- a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte @@ -99,10 +99,10 @@ let googleSaveButtonDisabled let oidcSaveButtonDisabled $: { - isEqual(providers.google, originalGoogleDoc) + isEqual(providers.google?.config, originalGoogleDoc?.config) ? (googleSaveButtonDisabled = true) : (googleSaveButtonDisabled = false) - isEqual(providers.oidc, originalOidcDoc) + isEqual(providers.oidc?.config, originalOidcDoc?.config) ? (oidcSaveButtonDisabled = true) : (oidcSaveButtonDisabled = false) } @@ -147,7 +147,6 @@ // only if the user has provided an image, upload it. image && uploadLogo(image) let calls = [] - let completed = [] docs.forEach(element => { if (element.type === ConfigTypes.OIDC) { //Add a UUID here so each config is distinguishable when it arrives at the login page. @@ -161,7 +160,9 @@ ) } else { calls.push(api.post(`/api/admin/configs`, element)) - completed.push(ConfigTypes.OIDC) + // turn the save button grey when clicked + oidcSaveButtonDisabled = true + originalOidcDoc = cloneDeep(providers.oidc) } } } @@ -173,7 +174,8 @@ ) } else { calls.push(api.post(`/api/admin/configs`, element)) - completed.push(ConfigTypes.Google) + googleSaveButtonDisabled = true + originalGoogleDoc = cloneDeep(providers.google) } } } @@ -213,8 +215,9 @@ type: ConfigTypes.Google, config: { activated: true }, } + originalGoogleDoc = cloneDeep(googleDoc) } else { - originalGoogleDoc = googleDoc + originalGoogleDoc = cloneDeep(googleDoc) providers.google = googleDoc } @@ -237,8 +240,9 @@ } const oidcResponse = await api.get(`/api/admin/configs/${ConfigTypes.OIDC}`) const oidcDoc = await oidcResponse.json() - console.log("teaste") if (!oidcDoc._id) { + console.log("hi") + providers.oidc = { type: ConfigTypes.OIDC, config: { configs: [{ activated: true }] },