chennaji9 opened a new pull request, #6664:
URL: https://github.com/apache/rocketmq-dashboard/pull/6664
### Which Issue(s) This PR Fixes
None — small self-contained fix found by inspection (no issue tracked).
### Brief Description
The alert notification template preview disagreed with delivery in three
substitutions (`AlertNotificationTemplate` on the server is the contract):
- **`${value}` carried a unit**: the preview's sample value for ratio
metrics was `"91%"` while the server emits the bare scaled number (`91`) with
the percent sign in `${thresholdUnit}` — a template like
`${value}${thresholdUnit}` previewed as `91%%` but delivered `91%`. The preview
sample value is now unit-free.
- **`${metric}` was translated**: the preview substituted the localized
display label while the server substitutes the raw metric key
(`broker.disk.usage_ratio`). The preview now uses the raw key.
- **an empty template previewed as empty**: with no custom template
configured the server still delivers `DEFAULT_TEMPLATE` (`[${level}] ${title} -
${description}\nLabels: ${labels}`), but the preview rendered the
empty/whitespace input. The preview now renders the server default (the
`EMPTY_TEMPLATE` info notice is kept so the "not configured" state stays
visible).
### How Did You Test This Change?
`cd web && npx vitest run src/utils/alertTemplatePreview.test.ts
src/pages/ops/__tests__/AlertsPage.test.tsx` → **2 files, 45 tests passed**.
Red-green on the util: with only the updated test file applied to the
unfixed sources, the two new/updated cases fail (empty-template renders `'
'`; `${value}${thresholdUnit}` renders `91%%`); with the fix applied, all 45
pass, including the AlertsPage preview interactions.
Not run: the full web suite and `npm run build` (the latter is blocked by
the pre-existing license:check chunk gate on a pristine tree as well); the
change is confined to the preview util and its sample-context wiring.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`fix:`)
- [x] Tests added or updated for non-trivial changes (updated empty-template
expectation + new value/unit parity case)
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(n/a — no new UI text)
- [x] Architecture constraints stay green (n/a — no Java change)
- [x] New source files carry the ASF license header (n/a — no new source
file)
- [x] Documentation touched where behaviour changed (n/a — the preview now
shows what delivery actually sends)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]