[APM] Fix metrics tab crash: migrate from controlGroupState to pinned_panels#254999
[APM] Fix metrics tab crash: migrate from controlGroupState to pinned_panels#254999smith merged 14 commits intoelastic:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the APM service metrics tab by migrating the dashboard controls system from the deprecated controlGroupState API to the new pinned_panels format introduced in the "Controls Anywhere" feature.
Changes:
- Replaced
controlGroupStateBuilderwith directpinned_panelsarray configuration - Added
useControlsIntegration: trueflag to enable controls rendering - Removed unused
@kbn/control-group-rendererdependency andUiActionsStartparameter
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx | Migrated controls from deprecated controlGroupState to new pinned_panels format and removed unused imports |
| x-pack/solutions/observability/plugins/apm/tsconfig.json | Updated dependency from @kbn/control-group-renderer to @kbn/controls-constants |
|
/oblt-deploy |
…nned_panels The dashboard plugin removed `controlGroupState` from `DashboardState`, replacing it with `pinned_panels`. The APM static dashboard component was still using `controlGroupStateBuilder.addDataControlFromField()` to build a `controlGroupState` object passed via `getInitialInput()`. This caused the "Node name" options list control to either fail to initialize or be silently dropped. Replace the deprecated pattern with direct `pinned_panels` array construction and enable `useControlsIntegration` in creation options. Co-authored-by: Cursor <cursoragent@cursor.com>
Verify the pinned_panels contract: useControlsIntegration flag, options list control shape, data view ID pass-through, panel forwarding, and error toast on failure. Made-with: Cursor
1b29825 to
b6600a9
Compare
...ions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx
Show resolved
Hide resolved
...ions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx
Show resolved
Hide resolved
|
Pinging @elastic/obs-presentation-team (Team:obs-presentation) |
…pp/metrics/static_dashboard/index.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…pp/metrics/static_dashboard/index.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The pinned_panels array element is a discriminated union of control types. Accessing config.data_view_id without narrowing fails type checking because not all control variants (e.g. timeSlider, esqlControl) have that property. Made-with: Cursor
Heenawter
left a comment
There was a problem hiding this comment.
Solution makes sense to me 🙇 Thanks for tackling this - code review LGTM
| jest.restoreAllMocks(); | ||
| jest.clearAllMocks(); |
There was a problem hiding this comment.
It seems to be redundant to call clearAllMocks(). Are they not overlapping?
|
/ci |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
History
|
…_panels (elastic#254999) ## Summary The APM service metrics tab crashes when loading the static JSON dashboard because the dashboard plugin's `DashboardState` no longer has a `controlGroupState` property — controls are now represented as `pinned_panels`. **Caused by:** [Controls Anywhere] Feature Branch — elastic#245588 That PR refactored the entire controls system, removing the `controlGroup` embeddable and replacing `controlGroupState` with `pinned_panels` in `DashboardState`. The APM `static_dashboard/index.tsx` was updated to use the new `controlGroupStateBuilder` API signature (adding the `uiActions` param), but the fundamental issue was missed: the `controlGroupState` object built by the builder is no longer consumed by the dashboard. The `getInitialInput()` return value spreads into `DashboardState`, which silently ignores the `controlGroupState` property — or worse, the `controlGroupStateBuilder.addDataControlFromField()` call throws during control type detection via `uiActions`, causing `getCreationOptions` to fall into the catch block and return empty options (no panels rendered at all). A follow-up PR ([Dashboards as Code] `snake_case` controls schemas — elastic#249300) snake_cased the field names in the builder call but didn't address the underlying issue. **Fix:** - Replace the `controlGroupStateBuilder` + `controlGroupState` pattern with a direct `pinned_panels` array in the new format - Add `useControlsIntegration: true` to `DashboardCreationOptions` so the controls render - Remove the now-unused `@kbn/control-group-renderer` dependency and `UiActionsStart` parameter ### Changes - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx` — migrated controls from `controlGroupState` to `pinned_panels` - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx` — added Jest tests for `getCreationOptions` contract - `x-pack/solutions/observability/plugins/apm/tsconfig.json` — replaced `@kbn/control-group-renderer` reference with `@kbn/controls-constants` ## Test plan - [x] Navigate to an APM service with a known runtime dashboard (e.g. Java, Node.js) → Metrics tab - [x] Verify the "Node name" options list control renders above the dashboard - [x] Verify dashboard panels load without errors - [x] Verify filtering by node name works correctly - [x] Jest tests pass --------- Co-authored-by: Cursor <cursoragent@cursor.com>
…_panels (elastic#254999) ## Summary The APM service metrics tab crashes when loading the static JSON dashboard because the dashboard plugin's `DashboardState` no longer has a `controlGroupState` property — controls are now represented as `pinned_panels`. **Caused by:** [Controls Anywhere] Feature Branch — elastic#245588 That PR refactored the entire controls system, removing the `controlGroup` embeddable and replacing `controlGroupState` with `pinned_panels` in `DashboardState`. The APM `static_dashboard/index.tsx` was updated to use the new `controlGroupStateBuilder` API signature (adding the `uiActions` param), but the fundamental issue was missed: the `controlGroupState` object built by the builder is no longer consumed by the dashboard. The `getInitialInput()` return value spreads into `DashboardState`, which silently ignores the `controlGroupState` property — or worse, the `controlGroupStateBuilder.addDataControlFromField()` call throws during control type detection via `uiActions`, causing `getCreationOptions` to fall into the catch block and return empty options (no panels rendered at all). A follow-up PR ([Dashboards as Code] `snake_case` controls schemas — elastic#249300) snake_cased the field names in the builder call but didn't address the underlying issue. **Fix:** - Replace the `controlGroupStateBuilder` + `controlGroupState` pattern with a direct `pinned_panels` array in the new format - Add `useControlsIntegration: true` to `DashboardCreationOptions` so the controls render - Remove the now-unused `@kbn/control-group-renderer` dependency and `UiActionsStart` parameter ### Changes - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx` — migrated controls from `controlGroupState` to `pinned_panels` - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx` — added Jest tests for `getCreationOptions` contract - `x-pack/solutions/observability/plugins/apm/tsconfig.json` — replaced `@kbn/control-group-renderer` reference with `@kbn/controls-constants` ## Test plan - [x] Navigate to an APM service with a known runtime dashboard (e.g. Java, Node.js) → Metrics tab - [x] Verify the "Node name" options list control renders above the dashboard - [x] Verify dashboard panels load without errors - [x] Verify filtering by node name works correctly - [x] Jest tests pass --------- Co-authored-by: Cursor <cursoragent@cursor.com>
…_panels (elastic#254999) ## Summary The APM service metrics tab crashes when loading the static JSON dashboard because the dashboard plugin's `DashboardState` no longer has a `controlGroupState` property — controls are now represented as `pinned_panels`. **Caused by:** [Controls Anywhere] Feature Branch — elastic#245588 That PR refactored the entire controls system, removing the `controlGroup` embeddable and replacing `controlGroupState` with `pinned_panels` in `DashboardState`. The APM `static_dashboard/index.tsx` was updated to use the new `controlGroupStateBuilder` API signature (adding the `uiActions` param), but the fundamental issue was missed: the `controlGroupState` object built by the builder is no longer consumed by the dashboard. The `getInitialInput()` return value spreads into `DashboardState`, which silently ignores the `controlGroupState` property — or worse, the `controlGroupStateBuilder.addDataControlFromField()` call throws during control type detection via `uiActions`, causing `getCreationOptions` to fall into the catch block and return empty options (no panels rendered at all). A follow-up PR ([Dashboards as Code] `snake_case` controls schemas — elastic#249300) snake_cased the field names in the builder call but didn't address the underlying issue. **Fix:** - Replace the `controlGroupStateBuilder` + `controlGroupState` pattern with a direct `pinned_panels` array in the new format - Add `useControlsIntegration: true` to `DashboardCreationOptions` so the controls render - Remove the now-unused `@kbn/control-group-renderer` dependency and `UiActionsStart` parameter ### Changes - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx` — migrated controls from `controlGroupState` to `pinned_panels` - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx` — added Jest tests for `getCreationOptions` contract - `x-pack/solutions/observability/plugins/apm/tsconfig.json` — replaced `@kbn/control-group-renderer` reference with `@kbn/controls-constants` ## Test plan - [x] Navigate to an APM service with a known runtime dashboard (e.g. Java, Node.js) → Metrics tab - [x] Verify the "Node name" options list control renders above the dashboard - [x] Verify dashboard panels load without errors - [x] Verify filtering by node name works correctly - [x] Jest tests pass --------- Co-authored-by: Cursor <cursoragent@cursor.com>
…_panels (elastic#254999) ## Summary The APM service metrics tab crashes when loading the static JSON dashboard because the dashboard plugin's `DashboardState` no longer has a `controlGroupState` property — controls are now represented as `pinned_panels`. **Caused by:** [Controls Anywhere] Feature Branch — elastic#245588 That PR refactored the entire controls system, removing the `controlGroup` embeddable and replacing `controlGroupState` with `pinned_panels` in `DashboardState`. The APM `static_dashboard/index.tsx` was updated to use the new `controlGroupStateBuilder` API signature (adding the `uiActions` param), but the fundamental issue was missed: the `controlGroupState` object built by the builder is no longer consumed by the dashboard. The `getInitialInput()` return value spreads into `DashboardState`, which silently ignores the `controlGroupState` property — or worse, the `controlGroupStateBuilder.addDataControlFromField()` call throws during control type detection via `uiActions`, causing `getCreationOptions` to fall into the catch block and return empty options (no panels rendered at all). A follow-up PR ([Dashboards as Code] `snake_case` controls schemas — elastic#249300) snake_cased the field names in the builder call but didn't address the underlying issue. **Fix:** - Replace the `controlGroupStateBuilder` + `controlGroupState` pattern with a direct `pinned_panels` array in the new format - Add `useControlsIntegration: true` to `DashboardCreationOptions` so the controls render - Remove the now-unused `@kbn/control-group-renderer` dependency and `UiActionsStart` parameter ### Changes - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx` — migrated controls from `controlGroupState` to `pinned_panels` - `x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx` — added Jest tests for `getCreationOptions` contract - `x-pack/solutions/observability/plugins/apm/tsconfig.json` — replaced `@kbn/control-group-renderer` reference with `@kbn/controls-constants` ## Test plan - [x] Navigate to an APM service with a known runtime dashboard (e.g. Java, Node.js) → Metrics tab - [x] Verify the "Node name" options list control renders above the dashboard - [x] Verify dashboard panels load without errors - [x] Verify filtering by node name works correctly - [x] Jest tests pass --------- Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
The APM service metrics tab crashes when loading the static JSON dashboard because the dashboard plugin's
DashboardStateno longer has acontrolGroupStateproperty — controls are now represented aspinned_panels.Caused by: [Controls Anywhere] Feature Branch — #245588
That PR refactored the entire controls system, removing the
controlGroupembeddable and replacingcontrolGroupStatewithpinned_panelsinDashboardState. The APMstatic_dashboard/index.tsxwas updated to use the newcontrolGroupStateBuilderAPI signature (adding theuiActionsparam), but the fundamental issue was missed: thecontrolGroupStateobject built by the builder is no longer consumed by the dashboard. ThegetInitialInput()return value spreads intoDashboardState, which silently ignores thecontrolGroupStateproperty — or worse, thecontrolGroupStateBuilder.addDataControlFromField()call throws during control type detection viauiActions, causinggetCreationOptionsto fall into the catch block and return empty options (no panels rendered at all).A follow-up PR ([Dashboards as Code]
snake_casecontrols schemas — #249300) snake_cased the field names in the builder call but didn't address the underlying issue.Fix:
controlGroupStateBuilder+controlGroupStatepattern with a directpinned_panelsarray in the new formatuseControlsIntegration: truetoDashboardCreationOptionsso the controls render@kbn/control-group-rendererdependency andUiActionsStartparameterChanges
x-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.tsx— migrated controls fromcontrolGroupStatetopinned_panelsx-pack/solutions/observability/plugins/apm/public/components/app/metrics/static_dashboard/index.test.tsx— added Jest tests forgetCreationOptionscontractx-pack/solutions/observability/plugins/apm/tsconfig.json— replaced@kbn/control-group-rendererreference with@kbn/controls-constantsTest plan