Frun1na opened a new pull request, #4732:
URL: https://github.com/apache/rocketmq-dashboard/pull/4732
### Which Issue(s) This PR Fixes
### Brief Description
The subscription tables on the consumer page still matched `filterMode`
against the pre-#3349
display strings (`全量` / `Tag 过滤` / `SQL92 过滤`), while both providers have
normalized the
broker expression types to `TAG` / `SQL` / `CLASS_FILTER` through
`SubscriptionFilterModes.fromExpressionType` ever since #3349. Every row
therefore missed the color
map and echoed the raw code into the table:
```tsx
const colorMap: Record<string, string> = {
全量: 'default',
'Tag 过滤': 'blue',
'SQL92 过滤': 'purple',
};
return <Tag color={colorMap[mode] || 'default'}>{mode}</Tag>; // mode ===
'TAG' | 'SQL' | 'CLASS_FILTER'
```
The i18n keys for the labels already existed (`consumer.filterTag`,
`consumer.filterSql92`) but were
never referenced. This maps the three API values to those labels, adds a
`consumer.filterClassFilter` entry for the third value, and keeps unknown
values visible as-is.
The ConsumerPage tests kept the bug alive by mocking the old strings, so the
new test feeds the
values the API actually returns (`TAG`, `SQL`) and asserts the rendered
labels. §6.4 of the API spec
also still documented the old display strings for `filterMode` and `一致` /
`不一致` for
`consistency`; it now documents `TAG` / `SQL` / `CLASS_FILTER` and
`consistent` / `null`.
### How Did You Test This Change?
```
$ npx vitest run src/pages/instance/__tests__/ConsumerPage.test.tsx
✓ src/pages/instance/__tests__/ConsumerPage.test.tsx (34 tests) ...
Test Files 1 passed (1)
Tests 34 passed (34)
$ npx eslint src/pages/instance/consumer.tsx src/i18n/translations.ts \
src/pages/instance/__tests__/ConsumerPage.test.tsx
(no output, exit 0)
$ npx tsc -b
(no output, exit 0)
```
The new test fails on the unfixed code (`Unable to find an element with the
text: Tag 过滤`, the row
rendered `TAG`), and the full ConsumerPage suite (34 tests, including the
existing ones) passes with
the fix.
Contract evidence:
```
$ cat .../common/util/SubscriptionFilterModes.java
public static String fromExpressionType(String expressionType) {
if ("SQL92".equals(expressionType)) { return "SQL"; }
if ("CLASS_FILTER".equals(expressionType)) { return "CLASS_FILTER"; }
return "TAG";
}
$ grep -rn "consumer.filterTag\|consumer.filterSql92\|consumer.filterAll"
web/src --include=*.tsx
(no usages outside translations.ts before this change)
```
### 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, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
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]