Skip to content

feat(admin): adding uniformity in cancel and back buttons present in Script, Logging & SSA#2415

Merged
moabu merged 61 commits intomainfrom
admin-ui-issue-2361-scripts
Nov 7, 2025
Merged

feat(admin): adding uniformity in cancel and back buttons present in Script, Logging & SSA#2415
moabu merged 61 commits intomainfrom
admin-ui-issue-2361-scripts

Conversation

@faisalsiddique4400
Copy link
Contributor

@faisalsiddique4400 faisalsiddique4400 commented Nov 4, 2025

feat(admin): adding uniformity in cancel and back buttons present in Script, Logging & SSA

Summary

This update introduces consistent behavior for Cancel, Back, and Apply buttons across Admin UI forms, including correct enabling and disabling based on form state.

Improvements

Button Updated Behavior
Cancel Resets all fields to their previous values without navigating away. Disabled until a change is made.
Back Navigates to the previous page. If there is no navigation history, returns to Dashboard. Always enabled.
Apply Saves the changes without leaving the page. Enabled only when the form has unsaved changes.

Additional Enhancements

  • Buttons now correctly detect dirty form states.
  • Apply button is dynamically enabled and disabled based on whether changes exist.
  • Cancel button is disabled until a field is modified.
  • Prevents accidental navigation or state loss in multi step configuration pages.

Affected Modules

This change is applied across all forms where configuration changes are possible, including but not limited to:

  • Script
  • Logging
  • SSA

Parent issue: #2268

Testing Steps

  1. Open suggested config form.
  2. Modify any field.
  3. Verify that:
    • Apply and Cancel buttons become enabled.
    • Apply saves configuration and stays on page.
    • Cancel reverts values and disables itself afterward.
  4. Back button should navigate appropriately.

Summary by CodeRabbit

  • New Features

    • Added richer form footer with Back/Cancel/Apply controls and navigation support.
    • Introduced client-side validation schemas for custom scripts and logging.
    • Commit workflow: draft (pending) payload handling before final submission.
  • Bug Fixes

    • Reset pagination to first page when changing script-type filter.
  • Improvements

    • Improved form state management, error display, and script/language handling.
    • Sanitized and strengthened audit payload handling; added logging defaults.

faisalsiddique4400 and others added 30 commits October 30, 2025 13:55
…Jans Lock (#2405)

* feat(admin): adding uniformity in cancel and back buttons present in Jans Lock

* feat(admin): adding uniformity in cancel and back buttons present in Jans Lock

* Code Rabbit fixes
Copy link
Contributor

@duttarnab duttarnab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • scripts --- review comments bot captured in audit logs
  • logging --- 1. performedOn and payload not required in audit log
image
  • SSA --- payload field do not capture all modified fields

@faisalsiddique4400 faisalsiddique4400 force-pushed the admin-ui-issue-2361-scripts branch from 1748b55 to 4b25dea Compare November 6, 2025 16:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx (2)

219-227: Remove redundant removeModuleProperty call.

The updateModuleProperty function already handles updating existing properties (lines 147-152), so calling removeModuleProperty beforehand is unnecessary and adds overhead.

Apply this diff:

 const scriptPathChange = useCallback(
   (value: string): void => {
     if (!value) return
     formik.setFieldValue('locationPath', value)
-    removeModuleProperty('location_path')
     updateModuleProperty('location_path', value)
   },
-  [formik.setFieldValue, removeModuleProperty, updateModuleProperty],
+  [formik.setFieldValue, updateModuleProperty],
 )

54-59: Back button fallback is incomplete.

When there's no browser history (e.g., direct link or page refresh), navigate(-1) is called but the early return on line 58 prevents any fallback navigation. Based on recent learnings, the Back button should fall back to the respective listing screen rather than the dashboard, keeping users in the script management context.

Apply this diff to add the scripts listing fallback:

 const handleNavigateBack = useCallback(() => {
   if (window.history.length > 1) {
     navigate(-1)
+    return
   }
-  return
+  navigate('/auth-server/config/scripts')
 }, [navigate])

Based on learnings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1748b55 and 4b25dea.

📒 Files selected for processing (6)
  • admin-ui/app/utils/TokenController.ts (1 hunks)
  • admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx (16 hunks)
  • admin-ui/plugins/admin/components/CustomScripts/helper/utils.ts (1 hunks)
  • admin-ui/plugins/admin/components/CustomScripts/types/forms.ts (1 hunks)
  • admin-ui/plugins/auth-server/redux/sagas/LoggingSaga.js (2 hunks)
  • admin-ui/plugins/auth-server/redux/sagas/SsaSaga.js (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2404
File: admin-ui/app/routes/Apps/Gluu/Gluuformfooter.tsx:70-77
Timestamp: 2025-11-03T08:47:33.943Z
Learning: In the admin-ui forms (Gluuformfooter component), the Back button should always navigate to '/home/dashboard' rather than using history-based navigation (navigate(-1)), as clarified by faisalsiddique4400 in PR #2404.
📚 Learning: 2025-11-06T08:23:20.931Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2418
File: admin-ui/plugins/user-management/components/UserForm.tsx:290-297
Timestamp: 2025-11-06T08:23:20.931Z
Learning: In the UserForm component (admin-ui/plugins/user-management/components/UserForm.tsx), the Back button should fall back to '/user/usersmanagement' when browser history is unavailable, not '/home/dashboard', as this keeps users in the user management context. This aligns with the new requirement that users should be redirected to the respective listing screen of the component rather than the dashboard.

Applied to files:

  • admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx
📚 Learning: 2025-11-03T08:47:33.943Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2404
File: admin-ui/app/routes/Apps/Gluu/Gluuformfooter.tsx:70-77
Timestamp: 2025-11-03T08:47:33.943Z
Learning: In the admin-ui forms (Gluuformfooter component), the Back button should always navigate to '/home/dashboard' rather than using history-based navigation (navigate(-1)), as clarified by faisalsiddique4400 in PR #2404.

Applied to files:

  • admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx
📚 Learning: 2025-11-05T19:57:35.134Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2415
File: admin-ui/plugins/auth-server/components/Ssa/SsaAddPage.tsx:148-153
Timestamp: 2025-11-05T19:57:35.134Z
Learning: In the SSA Add page (admin-ui/plugins/auth-server/components/Ssa/SsaAddPage.tsx), the Back button should fall back to '/auth-server/config/ssa' when browser history is unavailable, not '/home/dashboard', as this keeps users in the SSA management context.

Applied to files:

  • admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx
  • admin-ui/plugins/auth-server/redux/sagas/SsaSaga.js
🧬 Code graph analysis (4)
admin-ui/plugins/admin/components/CustomScripts/helper/utils.ts (2)
admin-ui/plugins/admin/components/CustomScripts/types/forms.ts (1)
  • FormValues (15-30)
admin-ui/app/utils/Util.ts (1)
  • filterEmptyObjects (82-84)
admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx (6)
admin-ui/plugins/admin/components/CustomScripts/types/forms.ts (2)
  • CustomScriptFormProps (5-9)
  • FormValues (15-30)
admin-ui/plugins/admin/components/CustomScripts/types/customScript.ts (3)
  • ModuleProperty (3-10)
  • ConfigurationProperty (12-18)
  • CustomScriptItem (29-49)
admin-ui/plugins/admin/components/CustomScripts/helper/utils.ts (2)
  • transformToFormValues (13-32)
  • getModuleProperty (5-11)
admin-ui/plugins/admin/components/CustomScripts/helper/validations.ts (1)
  • customScriptValidationSchema (3-59)
admin-ui/app/utils/Util.ts (1)
  • filterEmptyObjects (82-84)
admin-ui/app/customColors.ts (1)
  • customColors (4-25)
admin-ui/plugins/auth-server/redux/sagas/SsaSaga.js (2)
admin-ui/app/utils/TokenController.ts (1)
  • addAdditionalData (49-124)
admin-ui/app/redux/api/backend-api.ts (1)
  • postUserAction (51-69)
admin-ui/app/utils/TokenController.ts (3)
admin-ui/plugins/auth-server/redux/sagas/LoggingSaga.js (2)
  • issuer (17-17)
  • audit (39-39)
admin-ui/plugins/auth-server/redux/sagas/SsaSaga.js (3)
  • issuer (22-22)
  • audit (71-71)
  • audit (103-103)
admin-ui/plugins/admin/redux/sagas/ApiPermissionSaga.js (1)
  • actionData (125-125)
🔇 Additional comments (4)
admin-ui/plugins/admin/components/CustomScripts/CustomScriptForm.tsx (4)

188-217: LGTM! Location type switching correctly cleans up stale properties.

The function now properly removes the location_path module property when switching to db mode, addressing the previous concern about contradictory data in the payload.


593-614: Excellent! Footer button behavior aligns with PR objectives.

The conditional footer rendering correctly implements the required button behaviors:

  • Cancel: disabled until changes are made (!formik.dirty)
  • Apply: enabled only when form is valid and has changes (!formik.isValid || !formik.dirty)
  • Back: always enabled in both modes

This provides a consistent and intuitive UX across configuration forms.


252-255: LGTM! Cancel correctly resets to initial values.

The handleCancel implementation properly resets all form fields to their original values using transformToFormValues(item), fulfilling the PR requirement that "Cancel resets all fields to their previous values without navigating away."


77-139: LGTM! Formik setup is comprehensive and correct.

The Formik configuration properly handles:

  • Initial values transformation with transformToFormValues(item)
  • Validation via customScriptValidationSchema
  • Conditional payload structure based on location_type ('file' vs 'db')
  • Proper property transformation and filtering for API submission
  • Optional action_message support

The enableReinitialize and validateOnMount flags ensure the form stays synchronized with prop changes and validates immediately, supporting the dirty-state tracking required by the PR objectives.

Signed-off-by: Faisal Siddique <71010439+faisalsiddique4400@users.noreply.github.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

@faisalsiddique4400
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@duttarnab duttarnab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • my question is why in logging and SSA we have only cancel and apply button. We also need back button right?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

@moabu moabu merged commit 305d4a5 into main Nov 7, 2025
9 checks passed
@moabu moabu deleted the admin-ui-issue-2361-scripts branch November 7, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-admin-ui Component affected by issue or PR kind-feature Issue or PR is a new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants