Skip to content

Commit 65cbd01

Browse files
committed
Add patron blocking rules help modal with live template variables (PP-3866)
Adds a "?" help button next to "Add Rule" in the patron blocking rules editor that opens a modal presenting: (1) a live table of available template variable names and sample values, fetched automatically on mount via the validation endpoint using a trivial rule; (2) rendered HTML documentation of the available functions, sourced from circulation/docs/FUNCTIONS.md and pre-processed at build time by a new sync script (npm run sync-patron-blocking-docs); and (3) a link to the simpleeval syntax reference. Also adds the onServerValidationStateChange prop to PatronBlockingRulesEditorProps (already consumed by PatronAuthServiceEditForm), and updates tests, styles, webpack config, Jest config, and the README accordingly.
1 parent 5c4d823 commit 65cbd01

14 files changed

Lines changed: 979 additions & 265 deletions

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,48 @@ There are end-to-end tests that run on Nightwatch. This selenium-based test runn
138138

139139
To set up credentials and run the tests, check out the [README](/tests/README.md) in `/tests/.
140140

141+
## Patron Blocking Rules — Keeping Documentation in Sync
142+
143+
The help modal displayed alongside the patron blocking rules editor renders
144+
documentation sourced from
145+
[`circulation/docs/FUNCTIONS.md`](../circulation/docs/FUNCTIONS.md).
146+
Because `circulation-admin` is a separate package, this content is
147+
pre-processed and committed as a generated TypeScript file:
148+
149+
```
150+
src/content/patronBlockingFunctionsHtml.ts ← auto-generated, do not edit by hand
151+
```
152+
153+
### When to run the sync script
154+
155+
Run the sync script any time `circulation/docs/FUNCTIONS.md` is updated:
156+
157+
```bash
158+
npm run sync-patron-blocking-docs
159+
```
160+
161+
The script (`scripts/syncPatronBlockingDocs.js`) reads the markdown from the
162+
sibling `circulation` repository, converts it to HTML, and overwrites
163+
`src/content/patronBlockingFunctionsHtml.ts`. Commit the regenerated file
164+
alongside any other changes.
165+
166+
### Expected repository layout
167+
168+
The script assumes both repositories are checked out as siblings:
169+
170+
```
171+
/path/to/
172+
├── circulation/ ← Palace Project Circulation Manager
173+
│ └── docs/
174+
│ └── FUNCTIONS.md ← source of truth for allowed functions
175+
└── circulation-admin/ ← this repository
176+
└── src/content/
177+
└── patronBlockingFunctionsHtml.ts ← generated output
178+
```
179+
180+
If your layout differs, update the source path at the top of
181+
`scripts/syncPatronBlockingDocs.js`.
182+
141183
## Debugging
142184

143185
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.

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
55
"<rootDir>/tests/__mocks__/fileMock.js",
66
"\\.(css|less)$": "<rootDir>/tests/__mocks__/styleMock.js",
7+
"\\.md$": "<rootDir>/tests/__mocks__/fileMock.js",
78
},
89
preset: "ts-jest",
910
testEnvironment: "jest-fixed-jsdom",

package-lock.json

Lines changed: 2 additions & 199 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"dev-server": "dotenv -c -- webpack serve --progress --hot --config webpack.dev-server.config",
3333
"dev-test-axe": "TEST_AXE=true npm run dev",
3434
"prod": "webpack --progress --config webpack.prod.config",
35-
"build-docs": "typedoc --tsconfig tsconfig.json src"
35+
"build-docs": "typedoc --tsconfig tsconfig.json src",
36+
"sync-patron-blocking-docs": "node scripts/syncPatronBlockingDocs.js"
3637
},
3738
"dependencies": {
3839
"@nypl/dgx-svg-icons": "0.3.4",

0 commit comments

Comments
 (0)