refactor(ui): split alerts into reusable hooks and components#29708
Conversation
🟡 Playwright Results — all passed (25 flaky)✅ 4480 passed · ❌ 0 failed · 🟡 25 flaky · ⏭️ 38 skipped
🟡 25 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
Code Review ✅ Approved 1 resolved / 1 findingsRefactors observability alert logic into reusable hooks and components, improving maintainability while fixing a detail refetching issue upon FQN changes. Addresses the ✅ 1 resolved✅ Quality: as ComponentProps cast suppresses filter-item prop type checks
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |



Describe your changes:
Ref: openmetadata-collate#4839
Refactors alert UI pages by moving listing, details, create, and edit logic into reusable hooks and smaller components while keeping the existing OpenMetadata/Collate-side UI behavior unchanged.
useObservabilityAlertswith smaller header, table, and row-action components.useObservabilityAlertForm, resource/template hooks, and reusable form components.useAlertDetailsPage, permission hooks, and reusable details content components.Type of change:
High-level design:
The refactor keeps the existing route/page entry points intact while moving reusable alert page logic into hooks. Page components now compose smaller presentational components with hook outputs, making the alert UI easier to reuse and customize in future AskCollate AI-mode flows without duplicating fetch, permission, pagination, save, update, owner, description, and delete behavior.
Tests:
Use cases covered
Unit tests
src/pages/ObservabilityAlertsPage/ObservabilityAlertsPage.test.tsxsrc/pages/AddObservabilityPage/AddObservabilityPage.test.tsxsrc/pages/AlertDetailsPage/AlertDetailsPage.test.tsxsrc/components/Alerts/AlertFormSourceItem/AlertFormSourceItem.test.tsxsrc/components/Alerts/ObservabilityFormFiltersItem/ObservabilityFormFiltersItem.test.tsxBackend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
./node_modules/.bin/jest src/pages/ObservabilityAlertsPage/ObservabilityAlertsPage.test.tsx src/pages/AddObservabilityPage/AddObservabilityPage.test.tsx src/pages/AlertDetailsPage/AlertDetailsPage.test.tsx src/components/Alerts/AlertFormSourceItem/AlertFormSourceItem.test.tsx src/components/Alerts/ObservabilityFormFiltersItem/ObservabilityFormFiltersItem.test.tsx --runInBand --silent--max-warnings=0.git diff --check.UI screen recording / screenshots:
Not applicable. Structural UI refactor with no intended visual behavior change.
Checklist:
Refonly.Summary by Gitar
useAlertDetailsPage,useObservabilityAlerts, anduseObservabilityAlertFormto improve maintainability and reuse.AlertDetailsContentandObservabilityAlertsTable.AlertDetailsPagewhen thefqnprop changes by updating the hook dependencies.AlertDetailsPage.test.tsxto verify correct data refetching onfqnupdates.This will update automatically on new commits.
Greptile Summary
This PR refactors the observability alert UI pages by extracting listing, create/edit form, and details logic into reusable hooks (
useObservabilityAlerts,useObservabilityAlertForm,useAlertDetailsPage) and smaller presentational components, while keeping the existing route entry-points and visible behavior identical.ObservabilityAlertsPage,AddObservabilityPage,AlertDetailsPage) now simply call a hook and spread the result into a single presentational child component.fqnon prop change,as unknown asdouble-cast, unusedviewPermissiondep) are resolved by theuseCallback/[fqn]dep pattern, explicit enum mapping inObservabilityAlertForm.utils.ts, and a cleaned-uptabItemsmemo.Confidence Score: 5/5
Safe to merge — the change is a pure structural refactor with no functional modifications; all existing alert page behavior is preserved through thin shell components that compose the extracted hooks.
The three previously reported bugs (stale fqn on prop change, double-cast type suppression, spurious viewPermission memo dep) are all addressed. The remaining findings are exhaustive-deps omissions in useObservabilityAlerts that have no observable runtime impact given the stability of the affected dependencies.
openmetadata-ui/src/main/resources/ui/src/pages/ObservabilityAlertsPage/hooks/useObservabilityAlerts.ts has two useEffect dependency arrays that are missing their respective useCallback references.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[ObservabilityAlertsPage] --> B[useObservabilityAlerts] A --> C[ObservabilityAlertsHeader] A --> D[ObservabilityAlertsTable] D --> E[ObservabilityAlertActions] B --> F[usePaging] B --> G[usePermissionProvider] B --> H[useLimitStore] I[AddObservabilityPage] --> J[useObservabilityAlertForm] I --> K[ObservabilityAlertForm] K --> L[ObservabilityAlertFormFields] J --> M[useObservabilityAlertResources] J --> N[useObservabilityAlertTemplates] M --> O[ObservabilityAlertForm.utils: toObservabilityFilterResourceDescriptor] P[AlertDetailsPage] --> Q[useAlertDetailsPage] P --> R[AlertDetailsContent] Q --> S[useAlertDetailsPermissions] Q --> T[observabilityAPI / alertsAPI]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[ObservabilityAlertsPage] --> B[useObservabilityAlerts] A --> C[ObservabilityAlertsHeader] A --> D[ObservabilityAlertsTable] D --> E[ObservabilityAlertActions] B --> F[usePaging] B --> G[usePermissionProvider] B --> H[useLimitStore] I[AddObservabilityPage] --> J[useObservabilityAlertForm] I --> K[ObservabilityAlertForm] K --> L[ObservabilityAlertFormFields] J --> M[useObservabilityAlertResources] J --> N[useObservabilityAlertTemplates] M --> O[ObservabilityAlertForm.utils: toObservabilityFilterResourceDescriptor] P[AlertDetailsPage] --> Q[useAlertDetailsPage] P --> R[AlertDetailsContent] Q --> S[useAlertDetailsPermissions] Q --> T[observabilityAPI / alertsAPI]Reviews (7): Last reviewed commit: "fix(ui): refetch alert details on fqn ch..." | Re-trigger Greptile