From 5fc8c803ff1e514a4728fec88be7d5124f5d86ee Mon Sep 17 00:00:00 2001 From: faisalsiddique4400 Date: Fri, 17 Oct 2025 20:08:48 +0500 Subject: [PATCH 1/2] fix(admin-ui): correct Cancel button behavior in Jans Lock page to reset form values properly --- admin-ui/app/utils/Util.ts | 29 ++++++++++++++----- .../components/JansLockConfiguration.tsx | 14 +++++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/admin-ui/app/utils/Util.ts b/admin-ui/app/utils/Util.ts index 2b97830a68..af13452e48 100644 --- a/admin-ui/app/utils/Util.ts +++ b/admin-ui/app/utils/Util.ts @@ -1,7 +1,6 @@ import customColors from '@/customColors' -// @ts-nocheck -export function uuidv4() { +export function uuidv4(): string { // Use Web Crypto API if available if (typeof crypto !== 'undefined' && crypto.randomUUID) { return crypto.randomUUID() @@ -16,7 +15,7 @@ export function uuidv4() { } // Predefined color palette for consistent colors -const colorPalette = [ +const colorPalette: string[] = [ customColors.logo, customColors.white, customColors.black, @@ -27,22 +26,22 @@ const colorPalette = [ customColors.lightBlue, ] -export function getNewColor(index = 0) { +export function getNewColor(index = 0): string { // Use modulo to cycle through the palette return colorPalette[index % colorPalette.length] } -export const getClientScopeByInum = (str) => { +export const getClientScopeByInum = (str: string): string => { const inum = str.split(',')[0] const value = inum.split('=')[1] return value } -export function getYearMonth(date) { +export function getYearMonth(date: Date): string { return date.getFullYear() + getMonth(date) } -export function getMonth(aDate) { +export function getMonth(aDate: Date): string { const value = String(aDate.getMonth() + 1) if (value.length > 1) { return value @@ -51,7 +50,7 @@ export function getMonth(aDate) { } } -export function formatDate(date) { +export function formatDate(date?: string): string { if (!date) { return '-' } @@ -63,3 +62,17 @@ export function formatDate(date) { } return '-' } + +export const trimObjectStrings = >(obj: T): T => { + const trimmed: Record = {} + for (const key in obj) { + if (typeof obj[key] === 'string') { + trimmed[key] = (obj[key] as string).trim() + } else if (obj[key] && typeof obj[key] === 'object' && !Array.isArray(obj[key])) { + trimmed[key] = trimObjectStrings(obj[key] as Record) + } else { + trimmed[key] = obj[key] + } + } + return trimmed as T +} diff --git a/admin-ui/plugins/jans-lock/components/JansLockConfiguration.tsx b/admin-ui/plugins/jans-lock/components/JansLockConfiguration.tsx index 8fe0b68636..7276edc559 100644 --- a/admin-ui/plugins/jans-lock/components/JansLockConfiguration.tsx +++ b/admin-ui/plugins/jans-lock/components/JansLockConfiguration.tsx @@ -15,6 +15,7 @@ import { jansLockConstants, } from '../helper' import { JansLockConfigFormValues, PatchOperation } from '../types' +import { trimObjectStrings } from 'Utils/Util' interface JansLockConfigurationProps { lockConfig: Record @@ -49,9 +50,16 @@ const JansLockConfiguration: React.FC = ({ lockConfi validationSchema, }) + const handleCancel = useCallback(() => { + formik.resetForm() + }, [formik]) + const submitForm = useCallback( (userMessage: string) => { - const patchOperations = createPatchOperations(formik.values, lockConfig) + const trimmedValues = trimObjectStrings( + formik.values as unknown as Record, + ) as unknown as JansLockConfigFormValues + const patchOperations = createPatchOperations(trimmedValues, lockConfig) toggle() @@ -398,7 +406,9 @@ const JansLockConfiguration: React.FC = ({ lockConfi From 79a84bd91e5a817dc199a03b95645813e14baf14 Mon Sep 17 00:00:00 2001 From: faisalsiddique4400 Date: Mon, 20 Oct 2025 16:07:30 +0500 Subject: [PATCH 2/2] fix(admin-ui): token channel field now resetting successfully --- admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx b/admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx index 67fbf3769d..266d21be19 100644 --- a/admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx +++ b/admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx @@ -79,7 +79,7 @@ function GluuTypeAhead({ id={name} data-testid={name} multiple={multiple} - defaultSelected={value} + selected={value} options={options} /> {!hideHelperMessage && (