Skip to content

refactor(subscribe): rebuild subscribe form with section cards, auto-naming and shared notification rule select - #2198

Merged
jsers merged 5 commits into
mainfrom
optimize-sub-rule
Jul 22, 2026
Merged

refactor(subscribe): rebuild subscribe form with section cards, auto-naming and shared notification rule select#2198
jsers merged 5 commits into
mainfrom
optimize-sub-rule

Conversation

@710leo

@710leo 710leo commented Jul 21, 2026

Copy link
Copy Markdown
Member
image

Summary by CodeRabbit

  • New Features
    • Added a reusable notification-rule selector with create/view/manage flows and localized rule-selection UI.
    • Enhanced the subscription create/edit experience with collapsible partitioned sections, section summaries, scenario tips, and automatic subscription-name generation.
  • Bug Fixes
    • Improved validation UX by expanding only sections with failing fields.
    • Made notification-rule loading conditional and refined empty-state behavior; preserved existing selections and hardened payload building.
  • Localization
    • Added/expanded UI copy for rule selection, subscription guidance, summaries, and scenario tips across supported locales.
  • Tests
    • Added unit tests for subscription auto-naming logic.

@coderabbitai

coderabbitai Bot commented Jul 21, 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

Run ID: 96147f58-5868-4207-8041-a63e7bb3afce

📥 Commits

Reviewing files that changed from the base of the PR and between 9a32296 and 508f1cb.

📒 Files selected for processing (1)
  • src/pages/warning/subscribe/components/operateForm.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/warning/subscribe/components/operateForm.tsx

📝 Walkthrough

Walkthrough

The PR introduces a reusable notification-rule selector, refactors subscription configuration into collapsible sections with summaries and automatic naming, gates rule loading by authorization, adds empty-state and scenario guidance, centralizes documentation links, and supplies localized strings.

Changes

Notification rule selection

Layer / File(s) Summary
Reusable notification rule selector and integrations
src/pages/notificationRules/components/RuleDropdownSelect/index.tsx, src/pages/notificationRules/locale/*, src/pages/alertRules/FormNG/Notify/index.tsx
RuleDropdownSelect accepts rule data and callbacks through props, supports create/view/manage actions, and replaces the previous selector in alert-rule forms.

Subscription configuration

Layer / File(s) Summary
Partitioned form and automatic naming
src/pages/warning/subscribe/components/operateForm.tsx, src/pages/alertRules/FormNG/components/SectionCard/index.tsx, src/pages/warning/subscribe/components/buildAutoName.*, src/pages/warning/subscribe/components/utils.ts
Subscription configuration uses collapsible sections with summaries, validation-driven expansion, authorized rule loading, preserved group selections, automatic names, normalized fields, and naming tests.

Subscription list and guidance

Layer / File(s) Summary
Authorized loading and empty-state flow
src/pages/warning/subscribe/ListNG.tsx, src/components/EmptyGuide/index.tsx, src/pages/warning/subscribe/{add,edit,index}.tsx, src/pages/warning/subscribe/constants.ts
Notification rules load only when authorized, creation is gated by business-group context, empty states provide conditional actions and documentation access, and documentation URLs are shared.
Scenario guidance card
src/pages/warning/subscribe/components/Scenario{List,Tips}.tsx
A localized, dismissible scenario-tips card renders scenario descriptions and opens subscription documentation.

Subscription localization

Layer / File(s) Summary
Subscription page translations
src/pages/warning/subscribe/locale/*
Localized descriptions, validation messages, automatic-name text, section summaries, scenario tips, and empty-guide content are added.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • n9e/fe#2144: Overlaps with the FormNG SectionCard and notification dropdown integration changes.
  • n9e/fe#2195: Also updates the shared SectionCard header and props.
  • n9e/fe#2197: Contains overlapping SectionCard summary support.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% 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 accurately summarizes the main refactor: section cards, auto-naming, and a shared notification rule selector.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optimize-sub-rule
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch optimize-sub-rule

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

🤖 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/notificationRules/components/RuleDropdownSelect/index.tsx`:
- Around line 324-330: In
src/pages/notificationRules/components/RuleDropdownSelect/index.tsx lines
324-330, add rejection handling to the putNotificationRule(values) promise
chain. Also add equivalent .catch handling to the
createNotificationRules([values]) chain at lines 350-361 before its existing
.finally block, preserving the current success and cleanup behavior.

In `@src/pages/warning/subscribe/components/operateForm.tsx`:
- Around line 626-637: Move the stable key from the inner Form.Item to the outer
Row returned by fields.map, using the mapped field’s stable identifier such as
field.key. Keep the existing Form.Item name, validation rules, and remove
behavior unchanged.
🪄 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

Run ID: 7cc5bfce-bab6-4674-8163-83b7f0f6b742

📥 Commits

Reviewing files that changed from the base of the PR and between d466664 and d2f5eec.

📒 Files selected for processing (19)
  • src/pages/alertRules/FormNG/Notify/index.tsx
  • src/pages/alertRules/FormNG/components/SectionCard/index.tsx
  • src/pages/notificationRules/components/RuleDropdownSelect/index.tsx
  • src/pages/notificationRules/locale/en_US.ts
  • src/pages/notificationRules/locale/ja_JP.ts
  • src/pages/notificationRules/locale/ru_RU.ts
  • src/pages/notificationRules/locale/zh_CN.ts
  • src/pages/notificationRules/locale/zh_HK.ts
  • src/pages/warning/subscribe/ListNG.tsx
  • src/pages/warning/subscribe/components/buildAutoName.test.ts
  • src/pages/warning/subscribe/components/buildAutoName.ts
  • src/pages/warning/subscribe/components/operateForm.tsx
  • src/pages/warning/subscribe/components/utils.ts
  • src/pages/warning/subscribe/index.tsx
  • src/pages/warning/subscribe/locale/en_US.ts
  • src/pages/warning/subscribe/locale/ja_JP.ts
  • src/pages/warning/subscribe/locale/ru_RU.ts
  • src/pages/warning/subscribe/locale/zh_CN.ts
  • src/pages/warning/subscribe/locale/zh_HK.ts

Comment on lines 324 to 330
onOk={(values) => {
putNotificationRule(values).then(() => {
message.success(t('common:success.edit'));
handleCloseViewDrawer();
refreshNotificationRules();
refresh?.();
});
}}

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

Add error handling for asynchronous requests.

As per coding guidelines, all asynchronous requests must have error handling (try/catch, .catch, onError, etc.) consistent with existing patterns. These API calls are missing a .catch block to safely handle potential promise rejections.

  • src/pages/notificationRules/components/RuleDropdownSelect/index.tsx#L324-L330: Append .catch(console.error) or equivalent handling to the putNotificationRule(values).then(...) chain.
  • src/pages/notificationRules/components/RuleDropdownSelect/index.tsx#L350-L361: Append .catch(...) to the createNotificationRules([values]).then(...) chain before the .finally(...) block.
📍 Affects 1 file
  • src/pages/notificationRules/components/RuleDropdownSelect/index.tsx#L324-L330 (this comment)
  • src/pages/notificationRules/components/RuleDropdownSelect/index.tsx#L350-L361
🤖 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/notificationRules/components/RuleDropdownSelect/index.tsx` around
lines 324 - 330, In
src/pages/notificationRules/components/RuleDropdownSelect/index.tsx lines
324-330, add rejection handling to the putNotificationRule(values) promise
chain. Also add equivalent .catch handling to the
createNotificationRules([values]) chain at lines 350-361 before its existing
.finally block, preserving the current success and cleanup behavior.

Source: Coding guidelines

Comment on lines +626 to +637
{fields.map((field, index) => (
<Row gutter={10}>
<Col flex='auto'>
<Form.Item name={[field.name]} key={index} rules={[{ required: true, message: t('webhooks_msg') }]}>
<Input />
</Form.Item>
</Col>
<Col flex='32px'>
<MinusCircleOutlined style={{ marginTop: '8px' }} onClick={() => remove(field.name)} />
</Col>
</Row>
))}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add a stable key to the mapped <Row>.

The top-level element returned from fields.map is <Row>, but the key is placed on the inner <Form.Item> instead. React needs the key on the outermost mapped node, otherwise rows can be mismatched to data on reorder/removal.

🐛 Proposed fix
-                        {fields.map((field, index) => (
-                          <Row gutter={10}>
+                        {fields.map((field, index) => (
+                          <Row gutter={10} key={field.key}>
                             <Col flex='auto'>
-                              <Form.Item name={[field.name]} key={index} rules={[{ required: true, message: t('webhooks_msg') }]}>
+                              <Form.Item name={[field.name]} rules={[{ required: true, message: t('webhooks_msg') }]}>
                                 <Input />
                               </Form.Item>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{fields.map((field, index) => (
<Row gutter={10}>
<Col flex='auto'>
<Form.Item name={[field.name]} key={index} rules={[{ required: true, message: t('webhooks_msg') }]}>
<Input />
</Form.Item>
</Col>
<Col flex='32px'>
<MinusCircleOutlined style={{ marginTop: '8px' }} onClick={() => remove(field.name)} />
</Col>
</Row>
))}
{fields.map((field, index) => (
<Row gutter={10} key={field.key}>
<Col flex='auto'>
<Form.Item name={[field.name]} rules={[{ required: true, message: t('webhooks_msg') }]}>
<Input />
</Form.Item>
</Col>
<Col flex='32px'>
<MinusCircleOutlined style={{ marginTop: '8px' }} onClick={() => remove(field.name)} />
</Col>
</Row>
))}
🧰 Tools
🪛 React Doctor (0.7.6)

[error] 627-627: Your users can see the wrong data when this list reorders.

Add a stable key prop so React can keep list items matched to the right data when the list changes.

(jsx-key)

🤖 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/warning/subscribe/components/operateForm.tsx` around lines 626 -
637, Move the stable key from the inner Form.Item to the outer Row returned by
fields.map, using the mapped field’s stable identifier such as field.key. Keep
the existing Form.Item name, validation rules, and remove behavior unchanged.

Source: Linters/SAST tools

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/warning/subscribe/components/operateForm.tsx (1)

262-264: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include severities in the hasAnyFilter check.

If a user unchecks some severities (e.g., leaving only Critical [1]), the subscription no longer hits "all alert events". However, hasAnyFilter does not check severitiesValue, so the warning about hitting all events might incorrectly display when only specific severities are selected.

🐛 Proposed fix
-  const hasAnyFilter = !!cate || !!filterCounts.rules || !!filterCounts.busiGroups || !!filterCounts.tags || !!forDurationValue;
+  const hasAnyFilter = !!cate || !!filterCounts.rules || !!filterCounts.busiGroups || !!filterCounts.tags || !!forDurationValue || _.size(severitiesValue) < 3;
🤖 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/warning/subscribe/components/operateForm.tsx` around lines 262 -
264, Update the hasAnyFilter calculation in operateForm so it also evaluates
severitiesValue, preventing the all-events warning when the user selects
specific severities. Preserve the existing checks for category, rules, business
groups, tags, and duration.
🧹 Nitpick comments (1)
src/pages/warning/subscribe/components/operateForm.tsx (1)

512-514: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Use field.key as the key prop when mapping Form.List fields.

Using index as a key in dynamic lists can cause React to mismatch component state when items are added, removed, or reordered. Ant Design provides a stable field.key for this purpose.

♻️ Proposed fix
-                      {fields.map((field, index) => (
-                        <BusiGroupsTagItem key={index} field={field} fields={fields} index={index} remove={remove} add={add} form={form} />
-                      ))}
+                      {fields.map((field, index) => (
+                        <BusiGroupsTagItem key={field.key} field={field} fields={fields} index={index} remove={remove} add={add} form={form} />
+                      ))}
🤖 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/warning/subscribe/components/operateForm.tsx` around lines 512 -
514, Update the fields.map rendering in the BusiGroupsTagItem list to use each
Form.List field’s stable field.key for the React key prop instead of the array
index, while leaving the remaining props unchanged.
🤖 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.

Outside diff comments:
In `@src/pages/warning/subscribe/components/operateForm.tsx`:
- Around line 262-264: Update the hasAnyFilter calculation in operateForm so it
also evaluates severitiesValue, preventing the all-events warning when the user
selects specific severities. Preserve the existing checks for category, rules,
business groups, tags, and duration.

---

Nitpick comments:
In `@src/pages/warning/subscribe/components/operateForm.tsx`:
- Around line 512-514: Update the fields.map rendering in the BusiGroupsTagItem
list to use each Form.List field’s stable field.key for the React key prop
instead of the array index, while leaving the remaining props unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c870022-f099-47d1-b454-2c57d36b98fb

📥 Commits

Reviewing files that changed from the base of the PR and between d2f5eec and d7fa09d.

📒 Files selected for processing (14)
  • src/components/EmptyGuide/index.tsx
  • src/pages/warning/subscribe/ListNG.tsx
  • src/pages/warning/subscribe/add.tsx
  • src/pages/warning/subscribe/components/ScenarioList.tsx
  • src/pages/warning/subscribe/components/ScenarioTips.tsx
  • src/pages/warning/subscribe/components/operateForm.tsx
  • src/pages/warning/subscribe/constants.ts
  • src/pages/warning/subscribe/edit.tsx
  • src/pages/warning/subscribe/index.tsx
  • src/pages/warning/subscribe/locale/en_US.ts
  • src/pages/warning/subscribe/locale/ja_JP.ts
  • src/pages/warning/subscribe/locale/ru_RU.ts
  • src/pages/warning/subscribe/locale/zh_CN.ts
  • src/pages/warning/subscribe/locale/zh_HK.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/pages/warning/subscribe/index.tsx
  • src/pages/warning/subscribe/locale/ru_RU.ts
  • src/pages/warning/subscribe/locale/ja_JP.ts
  • src/pages/warning/subscribe/locale/zh_HK.ts
  • src/pages/warning/subscribe/locale/en_US.ts
  • src/pages/warning/subscribe/locale/zh_CN.ts
  • src/pages/warning/subscribe/ListNG.tsx

710leo added 3 commits July 22, 2026 13:05
…ped error sections

- 告警级别未全选也算筛选条件,避免只收敛级别时仍提示「将命中所有告警事件」
- 校验失败时若出错字段未登记在分区映射表里,兜底展开全部分区,
  防止错误项藏在 display:none 的分区中导致提交像没反应
- 把散落的 [1, 2, 3] 收敛为 SEVERITIES 常量
# Conflicts:
#	src/pages/alertRules/FormNG/components/SectionCard/index.tsx
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