Feat/custom alert severity names - #2304
Conversation
Add a centralised alertSeverity utility that reads custom severity names from site_info and syncs them into i18next resources, keeping the original translations as fallback. Replace hardcoded "S1/S2/S3" labels across alert/event/subscribe/pipeline pages with the resolved names, and add a multilingual configuration UI in site settings.
…rrectly Add forceRender to severity Tabs.TabPane so the Form.Item fields are always mounted for submit/populate. Use string severity keys so the stored structure is an object (not an array) and survives JSON round trips. Reset the form before setFieldsValue to avoid stale values on reload.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (28)
📝 WalkthroughWalkthroughThe PR adds typed, multilingual alert severity names. Site settings store custom names, application initialization loads them, and alert-related views use localized names for options, tags, and tooltips. ChangesAlert severity naming
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SiteSettings
participant App
participant AlertSeverity
participant AlertView
SiteSettings->>App: provide alert_severity_names
App->>AlertSeverity: normalize and set severity names
AlertSeverity-->>AlertView: resolve configured or default label
AlertView-->>SiteSettings: render localized severity label
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
setAlertSeverityNames can fail to preserve/restore true default translations after overwrites, and there is at least one verified unused import that may break builds under typical TS/lint settings.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces configurable alert severity display names (per language) via site settings, syncs those names into i18next so existing common:severity.* lookups are automatically overridden, and updates multiple UI locations to render severity labels using the new resolver.
Changes:
- Add
src/utils/alertSeverity.tsto normalize configured names, resolve display labels, and sync them into i18next resources. - Add a Site Settings UI section to edit severity names for each supported language.
- Replace hard-coded
S1/S2/S3 (Critical/Warning/Info)strings across several pages withgetAlertSeverityName(...), and exportlanguages/languageLabelsfromsrc/i18n.tsfor reuse.
File summaries
| File | Description |
|---|---|
| src/utils/alertSeverity.ts | Adds severity-name resolution, normalization, and i18next resource syncing. |
| src/utils/alertSeverity.test.ts | Adds unit tests for configured names, fallback behavior, and incident-name mapping. |
| src/pages/warning/subscribe/ListNG.tsx | Updates severity tags to use numeric data + tooltip titles from getAlertSeverityName. |
| src/pages/warning/subscribe/components/ruleModal.tsx | Renders severity tags using getAlertSeverityName. |
| src/pages/siteSettings/locale/zh_HK.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/zh_CN.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/ru_RU.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/pt_BR.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/ko_KR.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/ja_JP.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/id_ID.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/fr_FR.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/es_ES.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/locale/en_US.ts | Adds alert_severity_names label translation. |
| src/pages/siteSettings/index.tsx | Adds a per-language severity-name editor (Tabs + inputs) using exported i18n language metadata and default placeholders. |
| src/pages/historyEvents/ListNG/index.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/eventPipeline/pages/Form/TestModal/EventsTable.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/event/index.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/event/DetailNG/index.tsx | Uses getAlertSeverityName for severity Tag text. |
| src/pages/alertRules/List/ListNG.tsx | Updates severity tags + Select options to use getAlertSeverityName and numeric tag data. |
| src/pages/alertRules/List/EventsDrawer/index.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/alertRules/List/EvalRecordsDrawer/index.tsx | Renders severity tags using getAlertSeverityName. |
| src/pages/alertRules/FormNG/PipelineConfigsNG/Relabel/EventsModal.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/alertRules/FormNG/components/Sidebar/RuleSummary.tsx | Adds tooltip and keeps S# label while sourcing tooltip from getAlertSeverityName. |
| src/pages/alertRules/Form/EventSettings/Relabel/EventsModal.tsx | Replaces hard-coded severity Select options with getAlertSeverityName. |
| src/pages/alertCurEvent/pages/List/index.tsx | Adds import for getAlertSeverityName (currently unused). |
| src/i18n.ts | Exports languages and introduces languageLabels for UI use. |
| src/App.tsx | Loads alert_severity_names from site_info, normalizes them, syncs to i18next, and stores them in common state. |
Review details
- Files reviewed: 28/28 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import { getAlertCards } from '@/services/warning'; | ||
| import { getDefaultValue, parseRange } from '@/components/TimeRangePicker'; | ||
| import { useParamsAiAction } from '@/components/AiChat/utils/useHook'; | ||
| import { getAlertSeverityName } from '@/utils/alertSeverity'; |
| const languages = new Set([...Object.keys(i18next.store.data), ...Object.keys(configuredNames)]); | ||
| languages.forEach((language) => { | ||
| severities.forEach((severity) => { | ||
| i18next.addResource(language, 'common', `severity.${severity}`, getConfiguredName(configuredNames, language, severity) || getDefaultName(language, severity)); | ||
| }); | ||
| }); |
Summary by CodeRabbit
New Features
Bug Fixes