Skip to content

feat- 活跃告警列表顶部工具栏新增 “显示触发时值” 开关,打开后可展示触发时值。 - #2237

Merged
jsers merged 2 commits into
n9e:mainfrom
zhen1995:feature-issues/2873
Aug 5, 2026
Merged

feat- 活跃告警列表顶部工具栏新增 “显示触发时值” 开关,打开后可展示触发时值。#2237
jsers merged 2 commits into
n9e:mainfrom
zhen1995:feature-issues/2873

Conversation

@zhen1995

@zhen1995 zhen1995 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

开关存储值到localstorage中,变量名为:alert_cur_events_show_trigger_value
1
2

Summary by CodeRabbit

  • New Features
    • Added a localized “Trigger Value” column to the alerts table.
    • Displays each alert’s value at the time it was triggered.
    • Added translations for English, Japanese, Russian, Simplified Chinese, and Hong Kong Chinese.

 开关存储值到localstorage中,变量名为:alert_cur_events_show_trigger_value
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 604e9ff7-4c08-4ddc-8c37-307a061355c3

📥 Commits

Reviewing files that changed from the base of the PR and between ad6b39f and 018d2e2.

📒 Files selected for processing (6)
  • src/pages/alertCurEvent/locale/en_US.ts
  • src/pages/alertCurEvent/locale/ja_JP.ts
  • src/pages/alertCurEvent/locale/ru_RU.ts
  • src/pages/alertCurEvent/locale/zh_CN.ts
  • src/pages/alertCurEvent/locale/zh_HK.ts
  • src/pages/alertCurEvent/pages/List/AlertTable.tsx
💤 Files with no reviewable changes (5)
  • src/pages/alertCurEvent/locale/ru_RU.ts
  • src/pages/alertCurEvent/locale/zh_HK.ts
  • src/pages/alertCurEvent/locale/zh_CN.ts
  • src/pages/alertCurEvent/locale/ja_JP.ts
  • src/pages/alertCurEvent/locale/en_US.ts

📝 Walkthrough

Walkthrough

The alert event table now always shows trigger values after the duration column. Locale files provide the corresponding trigger_value label in five languages.

Changes

Trigger-value column

Layer / File(s) Summary
Trigger-value localization
src/pages/alertCurEvent/locale/*.ts
Adds the trigger_value label to the English, Japanese, Russian, Simplified Chinese, and Hong Kong Chinese locales.
Alert table rendering
src/pages/alertCurEvent/pages/List/AlertTable.tsx
Adds the localized trigger-value column after duration. Each cell displays the record’s trigger value and uses a minimum width based on the translated header.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • n9e/fe#2236: Modifies the same locale files and AlertTable.tsx for trigger-value column visibility.
  • n9e/fe#2240: Revises existing English alert-event localization strings.

Suggested reviewers: jsers, fiona2016

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies trigger-time values in the active alerts list but incorrectly states that a display switch was added.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/pages/alertCurEvent/pages/List/index.tsx (1)

400-410: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use Tailwind for the new toolbar layout.

Space was added only to align the label and switch. Replace it with a Tailwind wrapper such as <div className='flex items-center gap-2'>.

As per coding guidelines, src/**/*.{ts,tsx} requires Tailwind utility classes for container layout: “Use Tailwind utility classes for container layout (flex, grid, gap, padding, margin, alignment).”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/alertCurEvent/pages/List/index.tsx` around lines 400 - 410, Replace
the Ant Design Space wrapper around the show-trigger-value label and Switch with
a div using Tailwind layout utilities such as flex, items-center, and gap-2,
while preserving the existing label, switch behavior, and spacing.

Source: Coding guidelines

src/pages/alertCurEvent/pages/List/AlertTable.tsx (1)

222-222: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the new any cast.

The cast at Line 222 disables type checking for the trigger-value column. Type the columns collection with the table column type and keep the renderer value typed explicitly. This prevents mismatches between the API field and the renderer.

As per coding guidelines, TypeScript components must use explicit interfaces and avoid any.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/alertCurEvent/pages/List/AlertTable.tsx` at line 222, Remove the
any cast from the columns definition near the trigger-value column in
AlertTable. Type the columns collection with the table’s column type, and
explicitly type the renderer value so the API field and renderer remain
type-checked without using any.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/alertCurEvent/pages/List/AlertTable.tsx`:
- Around line 207-224: Update the column construction around the
showTriggerValue insertion and the production-only claimant insertion so
claimant remains after duration regardless of whether trigger_value is shown.
Insert claimant relative to the duration column or compose the columns without
fixed numeric indices, preserving the existing order in both switch states.

In `@src/pages/alertCurEvent/pages/List/index.tsx`:
- Around line 400-410: Add an accessible name to the Switch in the
show-trigger-value control by setting its aria-label from
t('show_trigger_value'), while preserving the existing checked state and
onChange behavior.

---

Nitpick comments:
In `@src/pages/alertCurEvent/pages/List/AlertTable.tsx`:
- Line 222: Remove the any cast from the columns definition near the
trigger-value column in AlertTable. Type the columns collection with the table’s
column type, and explicitly type the renderer value so the API field and
renderer remain type-checked without using any.

In `@src/pages/alertCurEvent/pages/List/index.tsx`:
- Around line 400-410: Replace the Ant Design Space wrapper around the
show-trigger-value label and Switch with a div using Tailwind layout utilities
such as flex, items-center, and gap-2, while preserving the existing label,
switch behavior, and spacing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 000da82b-efde-477c-9eb2-5ad839898fc8

📥 Commits

Reviewing files that changed from the base of the PR and between 83cc3e5 and ad6b39f.

📒 Files selected for processing (8)
  • src/pages/alertCurEvent/constants.ts
  • src/pages/alertCurEvent/locale/en_US.ts
  • src/pages/alertCurEvent/locale/ja_JP.ts
  • src/pages/alertCurEvent/locale/ru_RU.ts
  • src/pages/alertCurEvent/locale/zh_CN.ts
  • src/pages/alertCurEvent/locale/zh_HK.ts
  • src/pages/alertCurEvent/pages/List/AlertTable.tsx
  • src/pages/alertCurEvent/pages/List/index.tsx

Comment on lines +207 to +224
if (showTriggerValue) {
columns.splice(1, 0, {
title: t('trigger_value'),
dataIndex: 'trigger_value',
render(value) {
return (
<div
style={{
minWidth: getTextWidth(t('trigger_value')),
}}
>
{value}
</div>
);
},
} as any);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the production column order stable.

When showTriggerValue is true, this insertion shifts duration to index 3. The existing production-only insertion at Line 226 still uses index 3, so claimant is placed before duration. When the switch is off, claimant remains after duration. Insert claimant relative to duration or compose the columns without hard-coded positions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/alertCurEvent/pages/List/AlertTable.tsx` around lines 207 - 224,
Update the column construction around the showTriggerValue insertion and the
production-only claimant insertion so claimant remains after duration regardless
of whether trigger_value is shown. Insert claimant relative to the duration
column or compose the columns without fixed numeric indices, preserving the
existing order in both switch states.

Comment on lines +400 to +410
<Space>
<span className='text-sm text-fc-text-3'>{t('show_trigger_value')}</span>
<Switch
size='small'
checked={showTriggerValue}
onChange={(checked) => {
localStorage.setItem(SHOW_TRIGGER_VALUE_CACHE_KEY, String(checked));
setShowTriggerValue(checked);
}}
/>
</Space>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
git ls-files | rg '^src/pages/alertCurEvent/pages/List/index\.tsx$' || true

echo "== relevant lines =="
if [ -f src/pages/alertCurEvent/pages/List/index.tsx ]; then
  nl -ba src/pages/alertCurEvent/pages/List/index.tsx | sed -n '360,440p'
fi

echo "== imports and SWITCH deps =="
nl -ba src/pages/alertCurEvent/pages/List/index.tsx | sed -n '1,80p'
rg -n "from 'antd'|from \"antd\"|import .*Switch|SHOW_TRIGGER_VALUE_CACHE_KEY|showTriggerValue" src/pages/alertCurEvent/pages/List/index.tsx

Repository: n9e/fe

Length of output: 268


🌐 Web query:

React aria-label inaccessible name verification assistive technology aria-label switch antd Switch accessibility

💡 Result:

The "inaccessible name" issue in React and the use of aria-label with components like Ant Design's Switch are governed by established web accessibility (WCAG) standards. Accessible Name Requirements Assistive technologies, such as screen readers, identify interactive elements by their "accessible name." When an element is interactive (e.g., a switch or button), it must have a clear, descriptive name [1][2]. The "inaccessible name" error typically occurs when an element lacks this identifier [1][3]. Best Practices for Naming 1. Native Labels First: Always prefer native HTML labels (like for inputs) [1][3]. 2. Visible Text: If a control has visible text (e.g., a "Save" button), the accessible name should ideally match or include that text [4]. WCAG 2.1 Success Criterion 2.5.3 (Label in Name) mandates that if visible text exists, the accessible name must contain it [4]. 3. aria-labelledby: Use this attribute to reference existing visible text on the page [5][2]. This is preferred over aria-label because it supports automatic translation if the page text is translated [5]. 4. aria-label: Use this only as a fallback when no visible text exists (e.g., icon-only buttons) [5][2][3]. It is not automatically translated by browser tools, which can cause accessibility gaps for non-English speakers [5]. Ant Design (antd) Switch Accessibility The antd Switch component is designed to toggle between two states [6][7]. Because it is a custom interactive component, you must ensure it has an accessible name [1]. - If the Switch has no visible label, you should provide an accessible name via the aria-label attribute [1][2]. - While the antd Switch API (as seen in its source code and documentation) does not explicitly expose an aria-label prop in its public type definitions, you can pass it through via HTML attribute passthrough (standard React behavior for native attributes) or by wrapping it in a labeled structure [8][6][7]. Troubleshooting "Missing Display Name" The "Component definition is missing display name" error you may be encountering while working with custom components or wrappers is a linting warning, not a functional accessibility error [9][10]. It occurs when ESLint cannot automatically infer the name of a component (common with React.forwardRef or anonymous arrow functions) [9][11][12]. You can resolve this by: - Setting the displayName property explicitly: MyComponent.displayName = 'MyComponent'; [10][11][12] - Using a named function instead of an anonymous arrow function [11][13]. Verification To verify your accessibility implementation: - Use Browser DevTools to inspect the "Accessibility" tree and check the "computed name" of your element [3]. - Test with screen readers (e.g., NVDA, VoiceOver) to ensure the component is announced correctly [3]. - Ensure your implementation does not violate the "Label in Name" rule if visible text is present [4]. Sources: [1][4][5][2][3][8][14][6][7][15][9][10][11][12][13]

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== relevant content =="
awk 'NR>=360 && NR<=440 { printf "%5d: %s\n", NR, $0 }' src/pages/alertCurEvent/pages/List/index.tsx

echo "== imports and related usages =="
awk 'NR>=1 && NR<=120 { printf "%5d: %s\n", NR, $0 }' src/pages/alertCurEvent/pages/List/index.tsx

echo "== Switch usage and cache key =="
rg -n "from ['\"]antd['\"]|import .*Switch|SHOW_TRIGGER_VALUE_CACHE_KEY|showTriggerValue|aria-|label" src/pages/alertCurEvent/pages/List/index.tsx

Repository: n9e/fe

Length of output: 11802


Give the Switch an accessible name.

The text label is a sibling of the Switch, so it is not announced as the control’s label. Add aria-label={t('show_trigger_value')} to the Switch or associate it with the label explicitly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/alertCurEvent/pages/List/index.tsx` around lines 400 - 410, Add an
accessible name to the Switch in the show-trigger-value control by setting its
aria-label from t('show_trigger_value'), while preserving the existing checked
state and onChange behavior.

@jsers

jsers commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

改成始终展示吧,不用加 "显示触发时值" 开关

@zhen1995

zhen1995 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

改成始终展示吧,不用加 "显示触发时值" 开关

已修改
PixPin_2026-08-05_08-47-23

@jsers
jsers merged commit c786536 into n9e:main Aug 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants