You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add patron blocking rules help modal with template variables (PP-3866) (#207)
## Description
Adds a patron blocking rules help modal to the SIP2 patron auth service
editor (PP-3866). The modal surfaces template variable names and sample
values fetched live from the ILS, a reference of allowed functions, and
a syntax quick-reference. Several refactors accompany the feature to
keep the codebase clean.
**Features:**
- New `PatronBlockingRulesHelpModal` component with three sections: live
template variables (fetched from the ILS), allowed functions reference
(synced from `circulation/docs/FUNCTIONS.md`), and a Jinja2 syntax
quick-reference
- `?` help button placed directly beside the "Patron Blocking Rules"
label
- Live patron data fields fetched via the existing validation endpoint
and cached with `@tanstack/react-query` via a new `useAvailableFields`
custom hook
**Refactors & fixes:**
- Restored `shiftEntries<T>` helper; `removeRule` was duplicating the
same index-shifting logic inline for `clientErrors` and `serverErrors`
- Replaced manual `useState`/`useEffect` prefetch with `useQuery`;
blur-validation results update the query cache via
`queryClient.setQueryData`
- Added a pending-validation sentinel in `serverErrors` so the Save
button stays blocked while an edited rule expression awaits
re-validation
- Simplified `syncPatronBlockingDocs.js` from ~200 to ~40 lines by
removing a custom Markdown fallback converter and relying directly on
`marked` (added as an explicit devDependency)
- Added a stale-copy warning comment to
`src/content/patronBlockingFunctions.md`
- Added a `Modal.Footer` Close button to `PatronBlockingRulesHelpModal`
**Tests:**
- New `PatronBlockingRulesHelpModal.test.tsx` with 12 isolated unit
tests
- `PatronBlockingRulesEditor.test.tsx` wrapped with
`QueryClientProvider`; significantly expanded test coverage
- `PatronAuthServiceEditForm.test.tsx` wrapped with
`QueryClientProvider` to accommodate `useAvailableFields`
- `patronBlockingRules.test.ts` updated for the new `ValidationResult`
return type; added `availableFields` coverage
## Motivation and Context
PP-3866: Library staff configuring SIP2 patron blocking rules had no
in-app reference for which patron data fields are available or what
syntax is valid. This change adds contextual help that shows live data
pulled from their own ILS, reducing trial-and-error configuration.
## How Has This Been Tested?
- All 227 Jest tests pass (`tests/jest/`)
- TypeScript lint clean (`tslint`)
- Manually verified modal opens/closes, live fields load, and the
functions reference renders correctly
## Checklist:
- [x] I have updated the documentation accordingly.
- [x] All new and existing tests passed.
---------
Co-authored-by: Tim DiLauro <tdilauro@users.noreply.github.com>
If your layout differs, update the source path at the top of
181
+
`scripts/syncPatronBlockingDocs.js`.
182
+
141
183
## Debugging
142
184
143
185
The [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools/tree/main/extension) may be used to easily inspect app states and state transitions.
0 commit comments