zjncs opened a new pull request, #5500:
URL: https://github.com/apache/rocketmq-dashboard/pull/5500

   ## Problem
   
   The `filterMode` column of the consumer-group subscription table renders its 
tag color through a `colorMap` keyed only by the **mock data's Chinese labels**:
   
   ```tsx
   const colorMap: Record<string, string> = {
     全量: 'default',
     'Tag 过滤': 'blue',
     'SQL92 过滤': 'purple',
   };
   return <Tag color={colorMap[mode] || 'default'}>{mode}</Tag>;
   ```
   
   But no real backend ever sends those strings:
   
   - the Apache provider (`RocketMQMetadataProvider`) and the Aliyun provider 
(`AliyunConverters`) both normalize through 
`SubscriptionFilterModes.fromExpressionType()`, which emits **`TAG` / `SQL` / 
`CLASS_FILTER`**;
   - the Tencent provider (`TencentInstanceProvider`) forwards the raw SDK 
`expressionType`, i.e. **`TAG` / `SQL92`**;
   - the mock data (`web/src/mock/consumers.ts`) is the only source of `'全量' / 
'Tag 过滤' / 'SQL92 过滤'`.
   
   So on any real instance every row falls through to `|| 'default'` — the 
blue/purple branches are dead code in production, and `CLASS_FILTER` never gets 
a distinguishing color. (The backend AI tool test 
`ConsumerGroupReadToolHandlersTest` also feeds `filterMode: "TAG"`, confirming 
the value domain that reaches the frontend.)
   
   ## Solution
   
   Extract an exported `filterModeMeta()` helper in `consumer.tsx` that maps 
**every** value domain:
   
   | value | color | label |
   |---|---|---|
   | `TAG`, `Tag 过滤` | blue | `consumer.filterTag` (Tag 过滤 / Tag Filter) |
   | `SQL`, `SQL92`, `SQL92 过滤` | purple | `consumer.filterSql92` (SQL92 过滤 / 
SQL92 Filter) |
   | `CLASS_FILTER` | cyan | raw value |
   | `""`, `全量` | default | `consumer.filterAll` (全量 / Full) |
   | anything else | default | raw value |
   
   The mock's Chinese labels stay supported (demo/tests), the label is 
localized through the existing `consumer.filterTag/filterSql92/filterAll` keys, 
and unknown future values degrade gracefully instead of being silently 
recolored.
   
   ## Verification
   
   - New unit test `web/src/utils/__tests__/filterModeMeta.test.ts` (6 cases: 
TAG/SQL/SQL92/CLASS_FILTER/mock Chinese/unknown).
     - With the fix: **6/6 passed**.
     - Mutation check (revert the switch to the Chinese-only value lists): 
**3/6 fail** — the tests discriminate the fix.
     - Restore the fix: 6/6 passed again.
   - Regression: `ConsumerPage.test.tsx` **36/36 passed**.
   - `tsc -b` clean.
   


-- 
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]

Reply via email to