From fccd46f7baf0264fddbf5a34b992ce37c41a9bdf Mon Sep 17 00:00:00 2001 From: Roni Saha Date: Fri, 16 Jan 2026 20:25:09 +0600 Subject: [PATCH] Fix Federation Cache Policy details not shown when editing provider (#42222) (#45375) When the SelectControl component was refactored to use ui-shared controls, the comparison logic for cache policy values was not updated correctly. The refactored SelectControl returns string values ('EVICT_WEEKLY', 'EVICT_DAILY', etc.) when using string options, but the code was still comparing against arrays (['EVICT_WEEKLY']). This caused the conditional rendering of cache policy detail fields (evictionDay, evictionHour, evictionMinute, maxLifespan) to always fail when editing an existing federation provider. Changes: - Changed direct string comparisons instead of array comparisons - Updated defaultValue from array to string format - Removed array indexing from field names (e.g., 'config.evictionDay[0]' to 'config.evictionDay') - Removed unused isEqual import from lodash-es Signed-off-by: Roni Saha --- .../user-federation/shared/SettingsCache.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/apps/admin-ui/src/user-federation/shared/SettingsCache.tsx b/js/apps/admin-ui/src/user-federation/shared/SettingsCache.tsx index 84a6433a939..8e007058be3 100644 --- a/js/apps/admin-ui/src/user-federation/shared/SettingsCache.tsx +++ b/js/apps/admin-ui/src/user-federation/shared/SettingsCache.tsx @@ -3,7 +3,6 @@ import { SelectControl, SelectControlOption, } from "@keycloak/keycloak-ui-shared"; -import { isEqual } from "lodash-es"; import { UseFormReturn, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { FormAccess } from "../../components/form/FormAccess"; @@ -16,6 +15,13 @@ export type SettingsCacheProps = { unWrap?: boolean; }; +const getValue = (value: string | string[] | undefined) => { + if (Array.isArray(value)) { + return value[0]; + } + return value; +}; + const CacheFields = ({ form }: { form: UseFormReturn }) => { const { t } = useTranslation(); @@ -24,6 +30,8 @@ const CacheFields = ({ form }: { form: UseFormReturn }) => { name: "config.cachePolicy", }); + const cachePolicy = getValue(cachePolicyType); + const hourOptions: SelectControlOption[] = []; let hourDisplay = ""; for (let index = 0; index < 24; index++) { @@ -65,7 +73,7 @@ const CacheFields = ({ form }: { form: UseFormReturn }) => { "NO_CACHE", ]} /> - {isEqual(cachePolicyType, ["EVICT_WEEKLY"]) ? ( + {cachePolicy === "EVICT_WEEKLY" ? ( { ]} /> ) : null} - {isEqual(cachePolicyType, ["EVICT_DAILY"]) || - isEqual(cachePolicyType, ["EVICT_WEEKLY"]) ? ( + {cachePolicy === "EVICT_DAILY" || cachePolicy === "EVICT_WEEKLY" ? ( <> ) : null} - {isEqual(cachePolicyType, ["MAX_LIFESPAN"]) ? ( + {cachePolicy === "MAX_LIFESPAN" ? (