SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(dashboards-v2): switch panel visualization type in the editor (#11820)
Abhi kumar570bc0aef1ac
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsxindex caef5816c8..d2bd2da0c0 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx@@ -20,6 +20,8 @@ interface ConfigPaneProps {/** The panel spec — the single editing surface (title/description + section slices). */spec: DashboardtypesPanelSpecDTO;onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;+ /** Switch the panel to another visualization kind. */+ onChangePanelKind: (kind: PanelKind) => void;/** Panel's resolved series, provided to sections that need them (legend colors). */legendSeries: LegendSeries[];/** Table panel's resolved value columns, for the table-only editors. */@@ -36,13 +38,14 @@ function ConfigPane({panelKind,spec,onChangeSpec,+ onChangePanelKind,legendSeries,tableColumns,}: ConfigPaneProps): JSX.Element {const definition = getPanelDefinition(panelKind);const sections = definition.sections;- const signal = getBuilderQueries(spec.queries || [])[0]?.signal as+ const signal = getBuilderQueries(spec.queries)[0]?.signal as| TelemetrytypesSignalDTO| undefined;@@ -95,6 +98,8 @@ function ConfigPane({legendSeries={legendSeries}tableColumns={tableColumns}signal={signal}+ panelKind={panelKind}+ onChangePanelKind={onChangePanelKind}/>))}</div>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scssnew file mode 100644index 0000000000..997dd04e96--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss@@ -0,0 +1,6 @@+// Matches ConfigPane's `.field` so the switcher lines up with the title/description fields.+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsxnew file mode 100644index 0000000000..5112e6f598--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx@@ -0,0 +1,53 @@+import { Typography } from '@signozhq/ui/typography';+import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';++import { getPanelDefinition } from '../../../Panels/registry';+import type { PanelKind } from '../../../Panels/types/panelKind';+import { PANEL_TYPES } from '../../../PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants';+import ConfigSelect from '../controls/ConfigSelect/ConfigSelect';++import styles from './PanelTypeSwitcher.module.scss';++interface PanelTypeSwitcherProps {+ /** The current panel kind (selected value). */+ panelKind: PanelKind;+ /** Panel's current datasource — drives the disabled rule. */+ signal?: TelemetrytypesSignalDTO;+ onChange: (kind: PanelKind) => void;+}++/**+ * Visualization-type selector (rendered inside the Visualization section). Types whose+ * supported signals exclude the panel's current datasource are disabled (V1 parity —+ * e.g. List needs logs/traces, not metrics). The datasource is unknown for+ * PromQL/ClickHouse queries, in which case no type is disabled.+ */+function PanelTypeSwitcher({+ panelKind,+ signal,+ onChange,+}: PanelTypeSwitcherProps): JSX.Element {+ const items = PANEL_TYPES.map(({ panelKind, label, Icon }) => {+ const definition = getPanelDefinition(panelKind);+ return {+ value: panelKind,+ label,+ icon: <Icon size={14} />,+ disabled: !!signal && !definition.supportedSignals.includes(signal),+ };+ });++ return (+ <div className={styles.field}>+ <Typography.Text>Panel Type</Typography.Text>+ <ConfigSelect+ testId="panel-editor-v2-type-switcher"+ value={panelKind}+ items={items}+ onChange={(value): void => onChange(value)}+ />+ </div>+ );+}++export default PanelTypeSwitcher;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsxnew file mode 100644index 0000000000..f082fbd3b2--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx@@ -0,0 +1,73 @@+import { fireEvent, render, screen } from '@testing-library/react';+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';++import PanelTypeSwitcher from '../PanelTypeSwitcher';+import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';++jest.mock('pages/DashboardPageV2/DashboardContainer/Panels/registry', () => ({+ getPanelDefinition: jest.fn(),+}));++const mockGetPanelDefinition = getPanelDefinition as unknown as jest.Mock;++function openDropdown(): void {+ fireEvent.mouseDown(screen.getByRole('combobox'));+}++describe('PanelTypeSwitcher', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ // List supports only logs/traces; every other kind also supports metrics.+ mockGetPanelDefinition.mockImplementation((kind: string) => ({+ supportedSignals:+ kind === 'signoz/ListPanel'+ ? ['logs', 'traces']+ : ['metrics', 'logs', 'traces'],+ }));+ });++ it('fires onChange with the chosen plugin kind', () => {+ const onChange = jest.fn();+ render(+ <PanelTypeSwitcher panelKind="signoz/TimeSeriesPanel" onChange={onChange} />,+ );++ openDropdown();+ fireEvent.click(screen.getByText('List'));++ expect(onChange).toHaveBeenCalledWith('signoz/ListPanel');+ });++ it('disables types whose supported signals exclude the current datasource', () => {+ render(+ <PanelTypeSwitcher+ panelKind="signoz/TimeSeriesPanel"+ signal={TelemetrytypesSignalDTO.metrics}+ onChange={jest.fn()}+ />,+ );++ openDropdown();+ const disabled = Array.from(+ document.querySelectorAll('.ant-select-item-option-disabled'),+ ).map((el) => el.textContent);++ // List can't render a metrics query, so it's disabled; Time Series stays enabled.+ expect(disabled).toContain('List');+ expect(disabled).not.toContain('Time Series');+ });++ it('does not disable any type when the datasource is unknown', () => {+ render(+ <PanelTypeSwitcher+ panelKind="signoz/TimeSeriesPanel"+ onChange={jest.fn()}+ />,+ );++ openDropdown();+ expect(+ document.querySelectorAll('.ant-select-item-option-disabled'),+ ).toHaveLength(0);+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsxindex 1bbc828541..7b34db26af 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx@@ -6,8 +6,10 @@ import {type PanelFormattingSlice,SECTION_METADATA,type SectionConfig,+ SectionKind,} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type { PanelKind } from '../../../Panels/types/panelKind';import type { LegendSeries } from '../../hooks/useLegendSeries';import type { TableColumnOption } from '../../hooks/useTableColumns';import { resolveSectionEditor } from '../sectionRegistry';@@ -23,6 +25,9 @@ interface SectionSlotProps {tableColumns: TableColumnOption[];/** Panel's telemetry signal, for editors that fetch field suggestions (List columns). */signal?: TelemetrytypesSignalDTO;+ /** Current panel kind + switch handler, for the visualization section's type switcher. */+ panelKind: PanelKind;+ onChangePanelKind: (kind: PanelKind) => void;}/**@@ -38,6 +43,8 @@ function SectionSlot({legendSeries,tableColumns,signal,+ panelKind,+ onChangePanelKind,}: SectionSlotProps): JSX.Element | null {// A kind can hide a section based on current spec state (e.g. Histogram legend once// queries are merged) — skip it before resolving the editor.@@ -60,7 +67,12 @@ function SectionSlot({.formatting?.unit;return (- <SettingsSection title={title} icon={<Icon size={15} />}>+ <SettingsSection+ title={title}+ icon={<Icon size={15} />}+ // Open Visualization by default so the type switcher is visible.+ defaultOpen={config.kind === SectionKind.Visualization}+ ><Componentvalue={get(spec)}controls={controls}@@ -69,6 +81,8 @@ function SectionSlot({yAxisUnit={yAxisUnit}tableColumns={tableColumns}signal={signal}+ panelKind={panelKind}+ onChangePanelKind={onChangePanelKind}/></SettingsSection>);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsxindex 7671266300..8707545432 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx@@ -21,6 +21,7 @@ function renderConfigPane(panelKind: 'signoz/TimeSeriesPanel',spec: spec(),onChangeSpec: jest.fn(),+ onChangePanelKind: jest.fn(),legendSeries: [],tableColumns: [],...overrides,diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scssindex 70cc3ca92a..be94ab2e70 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss@@ -1,5 +1,5 @@.group {- width: min(350px, 100%);+ width: 100%;}.segment {diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.tsxindex 4dec0ef99f..8ab531f670 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.tsx@@ -1,21 +1,22 @@+import type { ReactNode } from 'react';import { Select } from 'antd';-import { SegmentIcon, type SegmentIconName } from '../segmentIcons';-import styles from './ConfigSelect.module.scss';-export interface ConfigSelectItem {- value: string;+export interface ConfigSelectItem<T extends string = string> {+ value: T;label: string;- icon?: SegmentIconName;+ /** Optional leading icon node rendered before the label. */+ icon?: ReactNode;+ disabled?: boolean;}-interface ConfigSelectProps {+interface ConfigSelectProps<T extends string = string> {testId: string;- value: string | undefined;+ value: T | undefined;placeholder?: string;- items: ConfigSelectItem[];- onChange: (value: string) => void;+ items: ConfigSelectItem<T>[];+ onChange: (value: T) => void;}/**@@ -23,15 +24,15 @@ interface ConfigSelectProps {* `Select` so it matches the rest of the editor's antd controls; the menu portals to* `document.body` (antd default) so the surrounding `overflow:auto` pane can't clip it.*/-function ConfigSelect({+function ConfigSelect<T extends string = string>({testId,value,placeholder,items,onChange,-}: ConfigSelectProps): JSX.Element {+}: ConfigSelectProps<T>): JSX.Element {return (- <Select<string>+ <Select<T>className={styles.select}data-testid={testId}value={value}@@ -40,9 +41,10 @@ function ConfigSelect({virtual={false}options={items.map((item) => ({value: item.value,+ disabled: item.disabled,label: item.icon ? (<span className={styles.item}>- <SegmentIcon name={item.icon} />+ {item.icon}{item.label}</span>) : (diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsxindex a34ea220d7..d0dad86539 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx@@ -8,12 +8,12 @@ import type {DashboardtypesPanelSpecDTO,DashboardtypesTimeSeriesChartAppearanceDTO,} from 'api/generated/services/sigNoz.schemas';-import type {- AnyThreshold,- PanelFormattingSlice,- SectionEditorProps,+import {SectionKind,- SectionSpecMap,+ type AnyThreshold,+ type PanelFormattingSlice,+ type SectionEditorProps,+ type SectionSpecMap,} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import AxesSection from './sections/AxesSection/AxesSection';@@ -69,27 +69,27 @@ function updatePluginSlice(export const SECTION_REGISTRY: {[K in SectionKind]?: SectionDescriptor<K>;} = {- formatting: {+ [SectionKind.Formatting]: {Component: FormattingSection,get: (spec): PanelFormattingSlice | undefined =>getPluginSlice<PanelFormattingSlice>(spec, 'formatting'),update: (spec, formatting): PanelSpec =>updatePluginSlice(spec, 'formatting', formatting),},- axes: {+ [SectionKind.Axes]: {Component: AxesSection,get: (spec): DashboardtypesAxesDTO | undefined =>getPluginSlice<DashboardtypesAxesDTO>(spec, 'axes'),update: (spec, axes): PanelSpec => updatePluginSlice(spec, 'axes', axes),},- legend: {+ [SectionKind.Legend]: {Component: LegendSection,get: (spec): DashboardtypesLegendDTO | undefined =>getPluginSlice<DashboardtypesLegendDTO>(spec, 'legend'),update: (spec, legend): PanelSpec =>updatePluginSlice(spec, 'legend', legend),},- chartAppearance: {+ [SectionKind.ChartAppearance]: {Component: ChartAppearanceSection,get: (spec): DashboardtypesTimeSeriesChartAppearanceDTO | undefined =>getPluginSlice<DashboardtypesTimeSeriesChartAppearanceDTO>(@@ -99,7 +99,7 @@ export const SECTION_REGISTRY: {update: (spec, chartAppearance): PanelSpec =>updatePluginSlice(spec, 'chartAppearance', chartAppearance),},- visualization: {+ [SectionKind.Visualization]: {Component: VisualizationSection,get: (spec): DashboardtypesBarChartVisualizationDTO | undefined =>getPluginSlice<DashboardtypesBarChartVisualizationDTO>(@@ -109,14 +109,14 @@ export const SECTION_REGISTRY: {update: (spec, visualization): PanelSpec =>updatePluginSlice(spec, 'visualization', visualization),},- buckets: {+ [SectionKind.Buckets]: {Component: BucketsSection,get: (spec): DashboardtypesHistogramBucketsDTO | undefined =>getPluginSlice<DashboardtypesHistogramBucketsDTO>(spec, 'histogramBuckets'),update: (spec, buckets): PanelSpec =>updatePluginSlice(spec, 'histogramBuckets', buckets),},- contextLinks: {+ [SectionKind.ContextLinks]: {Component: ContextLinksSection,// Panel-level slice (spec.links), not under the plugin spec — no cast needed.get: (spec): DashboardLinkDTO[] | undefined => spec.links,@@ -125,7 +125,7 @@ export const SECTION_REGISTRY: {// One editor for every threshold variant (label / comparison / table); the kind's// `controls.variant` picks the row editor + element shape. All persist to the same// plugin.spec.thresholds key.- thresholds: {+ [SectionKind.Thresholds]: {Component: ThresholdsSection,get: (spec): AnyThreshold[] | undefined =>getPluginSlice<AnyThreshold[]>(spec, 'thresholds'),@@ -157,6 +157,10 @@ export interface ErasedSectionDescriptor {// The panel's telemetry signal; read by editors that fetch field-key// suggestions scoped to it (List column picker).signal?: unknown;+ // Current panel kind + switch handler; read by the visualization section's+ // type switcher.+ panelKind?: unknown;+ onChangePanelKind?: unknown;}>;get: (spec: PanelSpec) => unknown;update: (spec: PanelSpec, value: unknown) => PanelSpec;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsxindex 290be168fc..b4af64ab51 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx@@ -1,7 +1,10 @@import type { ChangeEvent } from 'react';import { Typography } from '@signozhq/ui/typography';import { Input } from 'antd';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';@@ -22,7 +25,7 @@ function AxesSection({value,controls,onChange,-}: SectionEditorProps<'axes'>): JSX.Element {+}: SectionEditorProps<SectionKind.Axes>): JSX.Element {// An empty field clears the bound (null); otherwise parse to a number, ignoring// transient non-numeric input (e.g. a lone "-") by leaving the bound unset.const handleBound =diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsxindex a73d39d8e3..70ca778184 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx@@ -2,7 +2,10 @@ import type { ChangeEvent } from 'react';import { Typography } from '@signozhq/ui/typography';import { Input } from 'antd';import type { DashboardtypesHistogramBucketsDTO } from 'api/generated/services/sigNoz.schemas';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';@@ -23,7 +26,7 @@ function BucketsSection({value,controls,onChange,-}: SectionEditorProps<'buckets'>): JSX.Element {+}: SectionEditorProps<SectionKind.Buckets>): JSX.Element {// Empty clears the bound to null (chart auto-sizes); otherwise parse to a number,// ignoring transient non-numeric input by leaving it unset.const handleNumber =diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsxindex e1608a1506..309c547c9c 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx@@ -6,11 +6,15 @@ import {DashboardtypesLineInterpolationDTO,DashboardtypesLineStyleDTO,} from 'api/generated/services/sigNoz.schemas';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';+import { SegmentIcon } from '../../controls/segmentIcons';import styles from './ChartAppearanceSection.module.scss';@@ -31,22 +35,22 @@ const LINE_INTERPOLATION_OPTIONS = [{value: DashboardtypesLineInterpolationDTO.linear,label: 'Linear',- icon: 'interp-linear' as const,+ icon: <SegmentIcon name="interp-linear" />,},{value: DashboardtypesLineInterpolationDTO.spline,label: 'Spline',- icon: 'interp-spline' as const,+ icon: <SegmentIcon name="interp-spline" />,},{value: DashboardtypesLineInterpolationDTO.step_before,label: 'Step before',- icon: 'interp-step-before' as const,+ icon: <SegmentIcon name="interp-step-before" />,},{value: DashboardtypesLineInterpolationDTO.step_after,label: 'Step after',- icon: 'interp-step-after' as const,+ icon: <SegmentIcon name="interp-step-after" />,},];@@ -77,7 +81,7 @@ function ChartAppearanceSection({value,controls,onChange,-}: SectionEditorProps<'chartAppearance'>): JSX.Element {+}: SectionEditorProps<SectionKind.ChartAppearance>): JSX.Element {// `spanGaps.fillLessThan` is a stringified seconds threshold: empty means "connect// every gap" (the chart default), a number means "only bridge gaps shorter than this".const handleSpanGaps = (e: ChangeEvent<HTMLInputElement>): void => {@@ -114,7 +118,7 @@ function ChartAppearanceSection({onChange={(next): void =>onChange({...value,- lineInterpolation: next as DashboardtypesLineInterpolationDTO,+ lineInterpolation: next,})}/>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsxindex fa2970b4e2..a9af752261 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx@@ -4,7 +4,10 @@ import { Switch } from '@signozhq/ui/switch';import { Typography } from '@signozhq/ui/typography';import { Input } from 'antd';import type { DashboardLinkDTO } from 'api/generated/services/sigNoz.schemas';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import styles from './ContextLinksSection.module.scss';@@ -17,7 +20,7 @@ import styles from './ContextLinksSection.module.scss';function ContextLinksSection({value,onChange,-}: SectionEditorProps<'contextLinks'>): JSX.Element {+}: SectionEditorProps<SectionKind.ContextLinks>): JSX.Element {const links = value ?? [];const updateAt = (index: number, patch: Partial<DashboardLinkDTO>): void =>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsxindex 8de2187ab3..8a796f8603 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx@@ -2,7 +2,10 @@ import { Typography } from '@signozhq/ui/typography';import { DashboardtypesPrecisionOptionDTO } from 'api/generated/services/sigNoz.schemas';import YAxisUnitSelector from 'components/YAxisUnitSelector';import { YAxisSource } from 'components/YAxisUnitSelector/types';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import type { TableColumnOption } from '../../../hooks/useTableColumns';import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';@@ -10,7 +13,7 @@ import ColumnUnits from './ColumnUnits';import styles from './FormattingSection.module.scss';-type FormattingSectionProps = SectionEditorProps<'formatting'> & {+type FormattingSectionProps = SectionEditorProps<SectionKind.Formatting> & {/** Table panel's resolved value columns; required for the column-units editor. */tableColumns?: TableColumnOption[];};@@ -65,7 +68,7 @@ function FormattingSection({onChange={(next): void =>onChange({...value,- decimalPrecision: next as DashboardtypesPrecisionOptionDTO,+ decimalPrecision: next,})}/>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsxindex d5b51da221..a50c9f3b10 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx@@ -1,6 +1,9 @@import { Typography } from '@signozhq/ui/typography';import { DashboardtypesLegendPositionDTO } from 'api/generated/services/sigNoz.schemas';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';import LegendColors from '../../controls/LegendColors/LegendColors';@@ -8,7 +11,7 @@ import type { LegendSeries } from '../../../hooks/useLegendSeries';import styles from './LegendSection.module.scss';-type LegendSectionProps = SectionEditorProps<'legend'> & {+type LegendSectionProps = SectionEditorProps<SectionKind.Legend> & {/** Panel's resolved series, forwarded by SectionSlot for the colors control. */legendSeries?: LegendSeries[];};diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsxindex de422ce312..a002c786a7 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx@@ -1,26 +1,51 @@import { Typography } from '@signozhq/ui/typography';-import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.schemas';-import type { SectionEditorProps } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';+import type {+ SectionEditorProps,+ SectionKind,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import type { PanelKind } from '../../../../Panels/types/panelKind';import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';+import PanelTypeSwitcher from '../../PanelTypeSwitcher/PanelTypeSwitcher';import { TIME_PREFERENCE_OPTIONS } from './timePreferenceOptions';import styles from './VisualizationSection.module.scss';+type VisualizationSectionProps =+ SectionEditorProps<SectionKind.Visualization> & {+ /** Current panel kind + switch handler, forwarded by SectionSlot for the type switcher. */+ panelKind?: PanelKind;+ onChangePanelKind?: (kind: PanelKind) => void;+ /** Panel's datasource, forwarded by SectionSlot — scopes the switcher's disabled types. */+ signal?: TelemetrytypesSignalDTO;+ };+/**- * Edits the `visualization` slice: the per-panel time preference (all kinds), bar- * stacking (`stackedBarChart`, Bar only), and gap filling (`fillSpans`, TimeSeries- * only). Each control is gated by its `controls` flag, so a kind only renders — and only- * writes — the visualization fields its spec actually supports.+ * Edits the `visualization` slice: the panel-type switcher (`switchPanelKind`, every+ * kind), the per-panel time preference, bar stacking (`stackedBarChart`, Bar only), and+ * gap filling (`fillSpans`, TimeSeries only). Each control is gated by its `controls`+ * flag, so a kind only renders — and only writes — the fields its spec supports.*/function VisualizationSection({value,controls,onChange,-}: SectionEditorProps<'visualization'>): JSX.Element {+ panelKind,+ onChangePanelKind,+ signal,+}: VisualizationSectionProps): JSX.Element {return (<>+ {controls.switchPanelKind && panelKind && onChangePanelKind && (+ <PanelTypeSwitcher+ panelKind={panelKind}+ signal={signal}+ onChange={onChangePanelKind}+ />+ )}+{controls.timePreference && (<div className={styles.field}><Typography.Text>Panel time preference</Typography.Text>@@ -32,7 +57,7 @@ function VisualizationSection({onChange={(next): void =>onChange({...value,- timePreference: next as DashboardtypesTimePreferenceDTO,+ timePreference: next,})}/>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsxindex a27bdc0022..cc1a68e170 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx@@ -4,6 +4,14 @@ import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.simport VisualizationSection from '../VisualizationSection';+// The type switcher resolves each kind's supported signals; stub it so the test+// doesn't pull the whole panel registry (renderers, chart libs).+jest.mock('pages/DashboardPageV2/DashboardContainer/Panels/registry', () => ({+ getPanelDefinition: jest.fn(() => ({+ supportedSignals: ['metrics', 'logs', 'traces'],+ })),+}));+// Open the antd Select by clicking its selector, then pick the option by label.async function pickOption(triggerTestId: string, label: string): Promise<void> {const user = userEvent.setup();@@ -17,7 +25,12 @@ describe('VisualizationSection', () => {render(<VisualizationSectionvalue={undefined}- controls={{ timePreference: true, stacking: true, fillSpans: true }}+ controls={{+ switchPanelKind: true,+ timePreference: true,+ stacking: true,+ fillSpans: true,+ }}onChange={jest.fn()}/>,);@@ -35,7 +48,10 @@ describe('VisualizationSection', () => {render(<VisualizationSectionvalue={undefined}- controls={{ timePreference: true }}+ controls={{+ switchPanelKind: true,+ timePreference: true,+ }}onChange={jest.fn()}/>,);@@ -56,7 +72,10 @@ describe('VisualizationSection', () => {render(<VisualizationSectionvalue={undefined}- controls={{ timePreference: true }}+ controls={{+ switchPanelKind: true,+ timePreference: true,+ }}onChange={onChange}/>,);@@ -74,7 +93,10 @@ describe('VisualizationSection', () => {timePreference: DashboardtypesTimePreferenceDTO.global_time,stackedBarChart: false,}}- controls={{ stacking: true }}+ controls={{+ switchPanelKind: true,+ stacking: true,+ }}onChange={onChange}/>,);@@ -92,7 +114,10 @@ describe('VisualizationSection', () => {render(<VisualizationSectionvalue={{ fillSpans: false }}- controls={{ fillSpans: true }}+ controls={{+ switchPanelKind: true,+ fillSpans: true,+ }}onChange={onChange}/>,);@@ -101,4 +126,43 @@ describe('VisualizationSection', () => {expect(onChange).toHaveBeenCalledWith({ fillSpans: true });});++ it('renders the type switcher and switches kind when switchPanelKind is set', async () => {+ const onChangePanelKind = jest.fn();+ render(+ <VisualizationSection+ value={undefined}+ controls={{ switchPanelKind: true }}+ onChange={jest.fn()}+ panelKind="signoz/TimeSeriesPanel"+ onChangePanelKind={onChangePanelKind}+ />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-type-switcher'),+ ).toBeInTheDocument();++ await pickOption('panel-editor-v2-type-switcher', 'Table');+ expect(onChangePanelKind).toHaveBeenCalledWith('signoz/TablePanel');+ });++ it('hides the type switcher when switchPanelKind is not set', () => {+ render(+ <VisualizationSection+ value={undefined}+ controls={{+ switchPanelKind: false,+ timePreference: true,+ }}+ onChange={jest.fn()}+ panelKind="signoz/TimeSeriesPanel"+ onChangePanelKind={jest.fn()}+ />,+ );++ expect(+ screen.queryByTestId('panel-editor-v2-type-switcher'),+ ).not.toBeInTheDocument();+ });});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/timePreferenceOptions.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/timePreferenceOptions.tsindex c04305fb2d..6bfe21d24d 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/timePreferenceOptions.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/timePreferenceOptions.ts@@ -4,15 +4,19 @@ import type { ConfigSelectItem } from '../../controls/ConfigSelect/ConfigSelect'// Per-panel time scope. "Global Time" follows the dashboard's time picker; the rest pin// the panel to a fixed relative window regardless of the dashboard range (V1 parity).-export const TIME_PREFERENCE_OPTIONS: ConfigSelectItem[] = [- { value: DashboardtypesTimePreferenceDTO.global_time, label: 'Global Time' },- { value: DashboardtypesTimePreferenceDTO.last_5_min, label: 'Last 5 min' },- { value: DashboardtypesTimePreferenceDTO.last_15_min, label: 'Last 15 min' },- { value: DashboardtypesTimePreferenceDTO.last_30_min, label: 'Last 30 min' },- { value: DashboardtypesTimePreferenceDTO.last_1_hr, label: 'Last 1 hr' },- { value: DashboardtypesTimePreferenceDTO.last_6_hr, label: 'Last 6 hr' },- { value: DashboardtypesTimePreferenceDTO.last_1_day, label: 'Last 1 day' },- { value: DashboardtypesTimePreferenceDTO.last_3_days, label: 'Last 3 days' },- { value: DashboardtypesTimePreferenceDTO.last_1_week, label: 'Last 1 week' },- { value: DashboardtypesTimePreferenceDTO.last_1_month, label: 'Last 1 month' },-];+export const TIME_PREFERENCE_OPTIONS: ConfigSelectItem<DashboardtypesTimePreferenceDTO>[] =+ [+ { value: DashboardtypesTimePreferenceDTO.global_time, label: 'Global Time' },+ { value: DashboardtypesTimePreferenceDTO.last_5_min, label: 'Last 5 min' },+ { value: DashboardtypesTimePreferenceDTO.last_15_min, label: 'Last 15 min' },+ { value: DashboardtypesTimePreferenceDTO.last_30_min, label: 'Last 30 min' },+ { value: DashboardtypesTimePreferenceDTO.last_1_hr, label: 'Last 1 hr' },+ { value: DashboardtypesTimePreferenceDTO.last_6_hr, label: 'Last 6 hr' },+ { value: DashboardtypesTimePreferenceDTO.last_1_day, label: 'Last 1 day' },+ { value: DashboardtypesTimePreferenceDTO.last_3_days, label: 'Last 3 days' },+ { value: DashboardtypesTimePreferenceDTO.last_1_week, label: 'Last 1 week' },+ {+ value: DashboardtypesTimePreferenceDTO.last_1_month,+ label: 'Last 1 month',+ },+ ];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/getSwitchedPluginSpec.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/getSwitchedPluginSpec.test.tsnew file mode 100644index 0000000000..b69aa6f32f--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/getSwitchedPluginSpec.test.ts@@ -0,0 +1,98 @@+import {+ TelemetrytypesSignalDTO,+ type DashboardtypesPanelSpecDTO,+} from 'api/generated/services/sigNoz.schemas';+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';++import { defaultColumnsForSignal } from '../ListColumnsEditor/selectFields';+import { getSwitchedPluginSpec } from '../getSwitchedPluginSpec';++jest.mock('pages/DashboardPageV2/DashboardContainer/Panels/registry', () => ({+ getPanelDefinition: jest.fn(),+}));+jest.mock('../ListColumnsEditor/selectFields', () => ({+ defaultColumnsForSignal: jest.fn(),+}));++const mockGetPanelDefinition = getPanelDefinition as unknown as jest.Mock;+const mockDefaultColumnsForSignal =+ defaultColumnsForSignal as unknown as jest.Mock;++function specWith(pluginSpec: unknown): DashboardtypesPanelSpecDTO {+ return {+ display: { name: 'Panel' },+ plugin: { kind: 'signoz/TablePanel', spec: pluginSpec },+ queries: [],+ } as unknown as DashboardtypesPanelSpecDTO;+}++describe('getSwitchedPluginSpec', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ mockDefaultColumnsForSignal.mockReturnValue([]);+ });++ it('carries only unit + decimalPrecision when the new kind has a formatting section', () => {+ mockGetPanelDefinition.mockReturnValue({+ sections: [{ kind: 'formatting', controls: { unit: true, decimals: true } }],+ });+ const old = specWith({+ formatting: { unit: 'ms', decimalPrecision: 2, columnUnits: { A: 'bytes' } },+ axes: { logScale: true },+ });++ const result = getSwitchedPluginSpec(+ old,+ 'signoz/TimeSeriesPanel',+ TelemetrytypesSignalDTO.logs,+ );++ expect(result.formatting).toStrictEqual({ unit: 'ms', decimalPrecision: 2 });+ // Type-specific config from the old kind is dropped.+ expect((result as { axes?: unknown }).axes).toBeUndefined();+ });++ it('does not carry formatting when the new kind has no formatting section', () => {+ mockGetPanelDefinition.mockReturnValue({ sections: [{ kind: 'columns' }] });+ const old = specWith({ formatting: { unit: 'ms' } });++ const result = getSwitchedPluginSpec(+ old,+ 'signoz/ListPanel',+ TelemetrytypesSignalDTO.logs,+ );++ expect(result.formatting).toBeUndefined();+ });++ it('seeds List columns from the signal when switching into a List', () => {+ const columns = [{ name: 'body' }];+ mockDefaultColumnsForSignal.mockReturnValue(columns);+ mockGetPanelDefinition.mockReturnValue({ sections: [{ kind: 'columns' }] });++ const result = getSwitchedPluginSpec(+ specWith({}),+ 'signoz/ListPanel',+ TelemetrytypesSignalDTO.logs,+ );++ expect(mockDefaultColumnsForSignal).toHaveBeenCalledWith(+ TelemetrytypesSignalDTO.logs,+ );+ expect(result.selectFields).toBe(columns);+ });++ it('includes the kind section defaults (e.g. legend position)', () => {+ mockGetPanelDefinition.mockReturnValue({+ sections: [{ kind: 'legend', controls: { position: true } }],+ });++ const result = getSwitchedPluginSpec(+ specWith({}),+ 'signoz/PieChartPanel',+ TelemetrytypesSignalDTO.logs,+ );++ expect(result.legend?.position).toBe('bottom');+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec.tsnew file mode 100644index 0000000000..33825758f6--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec.ts@@ -0,0 +1,70 @@+import type {+ DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';+import type { PanelKind } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';+import {+ SectionKind,+ type PanelFormattingSlice,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import {+ buildDefaultPluginSpec,+ type DefaultPluginSpec,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/buildDefaultPluginSpec';++import { defaultColumnsForSignal } from './ListColumnsEditor/selectFields';++/**+ * Plugin spec produced on a first-time switch to a new kind. A partial cross-section+ * of the per-kind spec union; the caller assigns it to `plugin.spec` (typed `unknown`)+ * at the boundary.+ */+export interface SwitchedPluginSpec extends DefaultPluginSpec {+ formatting?: Pick<PanelFormattingSlice, 'unit' | 'decimalPrecision'>;+ selectFields?: TelemetrytypesTelemetryFieldKeyDTO[];+}++/**+ * Builds the plugin spec for a first-visit switch to `newKind`: the kind's declared+ * section defaults (so the config pane opens populated, matching new-panel seeding) plus+ * the only cross-kind config worth keeping — unit + decimal precision. Switching into a+ * List seeds the current signal's default columns so the columns control isn't empty.+ *+ * Revisiting a kind restores its stashed spec instead, so this runs only on first visit.+ */+export function getSwitchedPluginSpec(+ oldSpec: DashboardtypesPanelSpecDTO,+ newKind: PanelKind,+ signal: TelemetrytypesSignalDTO,+): SwitchedPluginSpec {+ const sections = getPanelDefinition(newKind).sections;+ const result: SwitchedPluginSpec = buildDefaultPluginSpec(sections);++ if (sections.some((section) => section.kind === SectionKind.Formatting)) {+ const oldFormatting = (+ oldSpec.plugin.spec as {+ formatting?: PanelFormattingSlice;+ }+ ).formatting;+ const carried: Pick<PanelFormattingSlice, 'unit' | 'decimalPrecision'> = {+ ...(oldFormatting?.unit !== undefined && { unit: oldFormatting.unit }),+ ...(oldFormatting?.decimalPrecision !== undefined && {+ decimalPrecision: oldFormatting.decimalPrecision,+ }),+ };+ if (Object.keys(carried).length > 0) {+ result.formatting = carried;+ }+ }++ if (sections.some((section) => section.kind === SectionKind.Columns)) {+ const columns = defaultColumnsForSignal(signal);+ if (columns.length > 0) {+ result.selectFields = columns;+ }+ }++ return result;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/usePanelTypeSwitch.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/usePanelTypeSwitch.test.tsnew file mode 100644index 0000000000..2f0f166991--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/usePanelTypeSwitch.test.ts@@ -0,0 +1,190 @@+import { act, renderHook } from '@testing-library/react';+import type { DashboardtypesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';+import { PANEL_TYPES } from 'constants/queryBuilder';+import { handleQueryChange } from 'container/NewWidget/utils';+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';+import type { Query } from 'types/api/queryBuilder/queryBuilderData';++import { getBuilderQueries } from '../../../Panels/utils/getBuilderQueries';+import { toPerses } from '../../../queryV5/persesQueryAdapters';+import { getSwitchedPluginSpec } from '../../getSwitchedPluginSpec';+import { usePanelTypeSwitch } from '../usePanelTypeSwitch';++jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({+ useQueryBuilder: jest.fn(),+}));+jest.mock('container/NewWidget/utils', () => ({+ handleQueryChange: jest.fn(),+ PANEL_TYPE_TO_QUERY_TYPES: {+ graph: ['builder', 'clickhouse', 'promql'],+ table: ['builder', 'clickhouse'],+ list: ['builder'],+ value: ['builder', 'clickhouse', 'promql'],+ bar: ['builder', 'clickhouse', 'promql'],+ pie: ['builder', 'clickhouse'],+ histogram: ['builder', 'clickhouse', 'promql'],+ },+}));+jest.mock('../../../queryV5/persesQueryAdapters', () => ({+ toPerses: jest.fn(),+}));+jest.mock('../../getSwitchedPluginSpec', () => ({+ getSwitchedPluginSpec: jest.fn(),+}));+jest.mock('../../../Panels/utils/getBuilderQueries', () => ({+ getBuilderQueries: jest.fn(),+}));++const mockUseQueryBuilder = useQueryBuilder as unknown as jest.Mock;+const mockHandleQueryChange = handleQueryChange as unknown as jest.Mock;+const mockToPerses = toPerses as unknown as jest.Mock;+const mockGetSwitchedPluginSpec = getSwitchedPluginSpec as unknown as jest.Mock;+const mockGetBuilderQueries = getBuilderQueries as unknown as jest.Mock;++// Opaque sentinels — the leaf utilities are mocked, so only identity matters.+const TABLE_PLUGIN_SPEC = { table: true } as unknown;+const TABLE_QUERIES = [{ id: 'table-q' }] as unknown as NonNullable<+ DashboardtypesPanelSpecDTO['queries']+>;+const LIST_PLUGIN_SPEC = { list: true } as unknown;+const LIST_QUERIES = [{ id: 'list-q' }] as unknown as NonNullable<+ DashboardtypesPanelSpecDTO['queries']+>;+const TRANSFORMED = {+ id: 'transformed',+ queryType: 'builder',+} as unknown as Query;+const CONVERTED = [{ id: 'converted' }] as unknown as NonNullable<+ DashboardtypesPanelSpecDTO['queries']+>;+const SWITCHED_SPEC = { switched: true } as unknown;++function makeSpec(+ kind: string,+ pluginSpec: unknown,+ queries: NonNullable<DashboardtypesPanelSpecDTO['queries']>,+): DashboardtypesPanelSpecDTO {+ return {+ display: { name: 'Panel' },+ plugin: { kind, spec: pluginSpec },+ queries,+ } as unknown as DashboardtypesPanelSpecDTO;+}++const tableSpec = makeSpec(+ 'signoz/TablePanel',+ TABLE_PLUGIN_SPEC,+ TABLE_QUERIES,+);+const listSpec = makeSpec('signoz/ListPanel', LIST_PLUGIN_SPEC, LIST_QUERIES);++function builderState(currentQuery: Query): {+ currentQuery: Query;+ redirectWithQueryBuilderData: jest.Mock;+} {+ return { currentQuery, redirectWithQueryBuilderData: jest.fn() };+}++describe('usePanelTypeSwitch', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ mockHandleQueryChange.mockReturnValue(TRANSFORMED);+ mockToPerses.mockReturnValue(CONVERTED);+ mockGetSwitchedPluginSpec.mockReturnValue(SWITCHED_SPEC);+ mockGetBuilderQueries.mockReturnValue([{ signal: 'logs' }]);+ });++ it('does nothing when switching to the current kind', () => {+ const setSpec = jest.fn();+ const state = builderState({ id: 'q', queryType: 'builder' } as Query);+ mockUseQueryBuilder.mockReturnValue(state);++ const { result } = renderHook(() =>+ usePanelTypeSwitch({+ spec: tableSpec,+ panelType: PANEL_TYPES.TABLE,+ setSpec,+ }),+ );+ act(() => result.current.onChangePanelKind('signoz/TablePanel'));++ expect(setSpec).not.toHaveBeenCalled();+ expect(state.redirectWithQueryBuilderData).not.toHaveBeenCalled();+ });++ it('on first visit: transforms the query and resets the spec to the new kind', () => {+ const setSpec = jest.fn();+ const tableQuery = { id: 'table-current', queryType: 'builder' } as Query;+ const state = builderState(tableQuery);+ mockUseQueryBuilder.mockReturnValue(state);++ const { result } = renderHook(() =>+ usePanelTypeSwitch({+ spec: tableSpec,+ panelType: PANEL_TYPES.TABLE,+ setSpec,+ }),+ );+ act(() => result.current.onChangePanelKind('signoz/ListPanel'));++ expect(setSpec).toHaveBeenCalledTimes(1);+ const next = setSpec.mock.calls[0][0] as DashboardtypesPanelSpecDTO;+ expect(next.plugin.kind).toBe('signoz/ListPanel');+ expect(next.plugin.spec).toBe(SWITCHED_SPEC);+ expect(next.queries).toBe(CONVERTED);+ expect(state.redirectWithQueryBuilderData).toHaveBeenCalledWith(TRANSFORMED);+ });++ it('coerces the query type when the new kind disallows it (promql → List)', () => {+ const setSpec = jest.fn();+ const promQuery = { id: 'prom', queryType: 'promql' } as Query;+ mockUseQueryBuilder.mockReturnValue(builderState(promQuery));++ const { result } = renderHook(() =>+ usePanelTypeSwitch({+ spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),+ panelType: PANEL_TYPES.TIME_SERIES,+ setSpec,+ }),+ );+ act(() => result.current.onChangePanelKind('signoz/ListPanel'));++ // List allows only Query Builder, so the promql query is coerced to 'builder'.+ const [, queryArg] = mockHandleQueryChange.mock.calls[0];+ expect((queryArg as Query).queryType).toBe('builder');+ });++ it('restores the original kind verbatim on switch-back (reversibility)', () => {+ const setSpec = jest.fn();+ const tableQuery = { id: 'table-current', queryType: 'builder' } as Query;+ const listQuery = { id: 'list-current', queryType: 'builder' } as Query;+ let state = builderState(tableQuery);+ mockUseQueryBuilder.mockImplementation(() => state);++ const { result, rerender } = renderHook(+ (props: { spec: DashboardtypesPanelSpecDTO; panelType: PANEL_TYPES }) =>+ usePanelTypeSwitch({ ...props, setSpec }),+ { initialProps: { spec: tableSpec, panelType: PANEL_TYPES.TABLE } },+ );++ // Leave Table for List (stashes Table in its pristine state).+ act(() => result.current.onChangePanelKind('signoz/ListPanel'));++ // Parent re-renders as a List panel; the builder now holds the List query.+ state = builderState(listQuery);+ rerender({ spec: listSpec, panelType: PANEL_TYPES.LIST });++ // Switch back to Table → restored from the stash, not re-transformed.+ act(() => result.current.onChangePanelKind('signoz/TablePanel'));++ const restored = setSpec.mock.calls[+ setSpec.mock.calls.length - 1+ ][0] as DashboardtypesPanelSpecDTO;+ expect(restored.plugin.kind).toBe('signoz/TablePanel');+ expect(restored.plugin.spec).toBe(TABLE_PLUGIN_SPEC);+ expect(restored.queries).toBe(TABLE_QUERIES);+ expect(state.redirectWithQueryBuilderData).toHaveBeenCalledWith(tableQuery);+ // The restore path must not run the query transform again.+ expect(mockHandleQueryChange).toHaveBeenCalledTimes(1);+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.tsindex 2e4c0ad0a6..3275c28171 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts@@ -40,7 +40,7 @@ export function useLegendSeries(getTimeSeriesResults(data?.response),data.legendMap,);- const builderQueries = getBuilderQueries(panel?.spec?.queries || []);+ const builderQueries = getBuilderQueries(panel.spec.queries);const byLabel = new Map<string, string>();series.forEach((s) => {diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditorQuerySync.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditorQuerySync.tsindex c070a2a339..52cd273553 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditorQuerySync.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditorQuerySync.ts@@ -57,8 +57,8 @@ export function usePanelEditorQuerySync({const { currentQuery, stagedQuery, handleRunQuery } = useQueryBuilder();// Saved queries, captured once: seed the builder and serve as the restore target.- // eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only snapshot- const savedQueries = useMemo(() => draft.spec?.queries ?? [], []);+ const savedQueries = draft.spec.queries;+// A new panel has no saved query: seed from the kind's first supported signal// instead of letting `fromPerses` fall back to the metrics default (which List// doesn't support).@@ -93,7 +93,7 @@ export function usePanelEditorQuerySync({// No-op guard at the V5 envelope level: equivalent wrappers (bare// `signoz/BuilderQuery` vs `signoz/CompositeQuery`) unwrap to the same// envelopes, so a structural compare would falsely dirty the draft.- const current = draft.spec?.queries ?? [];+ const current = draft.spec.queries;if (isEqual(toQueryEnvelopes(next), toQueryEnvelopes(current))) {return false;}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.tsnew file mode 100644index 0000000000..f23edb1412--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelTypeSwitch.ts@@ -0,0 +1,137 @@+import { useCallback, useRef } from 'react';+import type {+ DashboardtypesPanelPluginDTO,+ DashboardtypesPanelSpecDTO,+ DashboardtypesQueryDTO,+ TelemetrytypesSignalDTO,+} from 'api/generated/services/sigNoz.schemas';+import { PANEL_TYPES } from 'constants/queryBuilder';+import {+ handleQueryChange,+ PANEL_TYPE_TO_QUERY_TYPES,+ type PartialPanelTypes,+} from 'container/NewWidget/utils';+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';+import type { Query } from 'types/api/queryBuilder/queryBuilderData';++import {+ PANEL_KIND_TO_PANEL_TYPE,+ type PanelKind,+} from '../../Panels/types/panelKind';+import { getBuilderQueries } from '../../Panels/utils/getBuilderQueries';+import { toPerses } from '../../queryV5/persesQueryAdapters';+import {+ getSwitchedPluginSpec,+ type SwitchedPluginSpec,+} from '../getSwitchedPluginSpec';++/** What a kind looks like when you leave it; restored verbatim if you return. */+interface KindState {+ pluginSpec: DashboardtypesPanelPluginDTO['spec'];+ queries: DashboardtypesQueryDTO[];+ builderQuery: Query;+}++interface UsePanelTypeSwitchArgs {+ spec: DashboardtypesPanelSpecDTO;+ panelType: PANEL_TYPES;+ setSpec: (next: DashboardtypesPanelSpecDTO) => void;+}++interface UsePanelTypeSwitchApi {+ /** Switch the panel to `newKind`, transforming/restoring its query + spec. */+ onChangePanelKind: (newKind: PanelKind) => void;+}++/**+ * Switches the edited panel's visualization kind. Mutating `plugin.kind` re-derives the+ * renderer, config sections, query-builder tabs and request type for free; this hook adds+ * the two things that don't: a per-kind session cache that makes switching reversible+ * (`Table → List → Table` restores the original query + spec), and, on first visit to a+ * kind, a query rebuild (`handleQueryChange`) + spec reset (`getSwitchedPluginSpec`).+ */+export function usePanelTypeSwitch({+ spec,+ panelType,+ setSpec,+}: UsePanelTypeSwitchArgs): UsePanelTypeSwitchApi {+ const { currentQuery, redirectWithQueryBuilderData } = useQueryBuilder();++ const cacheRef = useRef<Map<PanelKind, KindState>>(new Map());++ // Latest spec/query/type, read inside the stable callback without re-subscribing.+ const specRef = useRef(spec);+ specRef.current = spec;+ const queryRef = useRef(currentQuery);+ queryRef.current = currentQuery;+ const panelTypeRef = useRef(panelType);+ panelTypeRef.current = panelType;++ const onChangePanelKind = useCallback(+ (newKind: PanelKind): void => {+ const currentSpec = specRef.current;+ const oldKind = currentSpec.plugin.kind as PanelKind;+ if (newKind === oldKind) {+ return;+ }+ const query = queryRef.current;++ cacheRef.current.set(oldKind, {+ pluginSpec: currentSpec.plugin.spec,+ queries: currentSpec.queries,+ builderQuery: query,+ });++ const newPanelType = PANEL_KIND_TO_PANEL_TYPE[newKind];++ // Only `plugin` needs a cast: it's a discriminated union over `kind`, and a+ // dynamically-chosen kind can't be correlated with its spec statically (as in+ // `createDefaultPanel`). The surrounding spec stays fully typed.+ const buildSpec = (+ pluginSpec: DashboardtypesPanelPluginDTO['spec'] | SwitchedPluginSpec,+ queries: DashboardtypesQueryDTO[],+ ): DashboardtypesPanelSpecDTO => ({+ ...currentSpec,+ plugin: {+ ...currentSpec.plugin,+ kind: newKind,+ spec: pluginSpec,+ } as DashboardtypesPanelPluginDTO,+ queries,+ });++ // Revisit → restore the stash verbatim (the reversibility path).+ const cached = cacheRef.current.get(newKind);+ if (cached) {+ setSpec(buildSpec(cached.pluginSpec, cached.queries));+ redirectWithQueryBuilderData(cached.builderQuery);+ return;+ }++ // First visit → coerce the query type if the new panel disallows it, then+ // rebuild the builder query for the new type.+ const supported = PANEL_TYPE_TO_QUERY_TYPES[newPanelType] ?? [];+ const queryType = supported.includes(query.queryType)+ ? query.queryType+ : supported[0];+ const transformed = handleQueryChange(+ newPanelType as keyof PartialPanelTypes,+ { ...query, queryType },+ panelTypeRef.current,+ );+ const signal = getBuilderQueries(currentSpec.queries)[0]+ ?.signal as TelemetrytypesSignalDTO;++ setSpec(+ buildSpec(+ getSwitchedPluginSpec(currentSpec, newKind, signal),+ toPerses(transformed, newPanelType),+ ),+ );+ redirectWithQueryBuilderData(transformed);+ },+ [setSpec, redirectWithQueryBuilderData],+ );++ return { onChangePanelKind };+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsxindex 97eb6d0b6f..4b010dfb6f 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx@@ -29,6 +29,7 @@ import { usePanelQuery } from '../hooks/usePanelQuery';import { usePanelEditorDraft } from './hooks/usePanelEditorDraft';import { usePanelEditorQuerySync } from './hooks/usePanelEditorQuerySync';import { usePanelEditorSave } from './hooks/usePanelEditorSave';+import { usePanelTypeSwitch } from './hooks/usePanelTypeSwitch';import { useSeedNewListColumns } from './hooks/useSeedNewListColumns';import { useSwitchColumnsOnSignalChange } from './hooks/useSwitchColumnsOnSignalChange';import { useTableColumns } from './hooks/useTableColumns';@@ -113,6 +114,9 @@ function PanelEditorContainer({signal: defaultSignal,});+ // Switch the panel's visualization kind in place (reversible per session).+ const { onChangePanelKind } = usePanelTypeSwitch({ spec, panelType, setSpec });+// Spec and query dirtiness are tracked independently so query re-serialization// never false-dirties. A new panel is always savable (you're creating it).const isDirty = isNew || isSpecDirty || isQueryDirty;@@ -121,8 +125,8 @@ function PanelEditorContainer({// values; cast at this boundary (as ConfigPane does) so the columns editor's// field-key lookup is typed.const listSignal =- (getBuilderQueries(spec.queries || [])[0]- ?.signal as TelemetrytypesSignalDTO) || TelemetrytypesSignalDTO.logs;+ (getBuilderQueries(spec.queries)[0]?.signal as TelemetrytypesSignalDTO) ||+ TelemetrytypesSignalDTO.logs;// Swap the List panel's columns to the new signal's defaults on signal change// (V1 had a per-signal field list; V2 has one `selectFields`).@@ -226,6 +230,7 @@ function PanelEditorContainer({panelKind={draft.spec.plugin.kind}spec={spec}onChangeSpec={setSpec}+ onChangePanelKind={onChangePanelKind}legendSeries={legendSeries}tableColumns={tableColumns}/>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsxindex d8ef8e3e85..70705dd471 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx@@ -49,7 +49,7 @@ function BarPanelRenderer({);const builderQueries = useMemo(- () => getBuilderQueries(panel.spec.queries || []),+ () => getBuilderQueries(panel.spec.queries),[panel.spec.queries],);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.tsindex bd1c06844a..597ec0169f 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts@@ -1,12 +1,15 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';// Bar stacking lives in `visualization.stackedBarChart`, so it's a `visualization`// control, not `chartAppearance`. fillSpans is TimeSeries-only, so Bar omits it (V1 parity).export const sections: SectionConfig[] = [- { kind: 'visualization', controls: { timePreference: true, stacking: true } },- { kind: 'formatting', controls: { unit: true, decimals: true } },- { kind: 'axes', controls: { minMax: true, logScale: true } },- { kind: 'legend', controls: { position: true } },- { kind: 'thresholds', controls: { variant: 'label' } },- { kind: 'contextLinks' },+ {+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true, timePreference: true, stacking: true },+ },+ { kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },+ { kind: SectionKind.Axes, controls: { minMax: true, logScale: true } },+ { kind: SectionKind.Legend, controls: { position: true } },+ { kind: SectionKind.Thresholds, controls: { variant: 'label' } },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsxindex 0aa8bfdf32..41cc022870 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx@@ -41,7 +41,7 @@ function HistogramPanelRenderer({);const builderQueries = useMemo(- () => getBuilderQueries(panel.spec.queries || []),+ () => getBuilderQueries(panel.spec.queries),[panel.spec.queries],);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.tsindex 2cdf475cd1..63e3f7016b 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts@@ -1,10 +1,14 @@import type { DashboardtypesHistogramPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';export const sections: SectionConfig[] = [{- kind: 'legend',+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true },+ },+ {+ kind: SectionKind.Legend,controls: { position: true },// Merging all queries collapses to one distribution with no legend.isHidden: (spec): boolean =>@@ -14,8 +18,8 @@ export const sections: SectionConfig[] = [),},{- kind: 'buckets',+ kind: SectionKind.Buckets,controls: { count: true, width: true, mergeQueries: true },},- { kind: 'contextLinks' },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsxindex 15475443cb..c6aa927030 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx@@ -52,7 +52,7 @@ function ListPanelRenderer({// and row-click behavior. Cast is safe — the query carries the same string values.const signal = useMemo(() =>- (getBuilderQueries(panel.spec.queries || [])[0]+ (getBuilderQueries(panel.spec.queries)[0]?.signal as TelemetrytypesSignalDTO) || TelemetrytypesSignalDTO.logs,[panel.spec.queries],);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/Renderer.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/Renderer.test.tsxindex f9721831dd..60e02f4352 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/Renderer.test.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/Renderer.test.tsx@@ -20,7 +20,7 @@ function panelWith(): PanelOfKind<'signoz/ListPanel'> {return {kind: 'Panel',- spec: { plugin: { kind: 'signoz/ListPanel', spec } },+ spec: { plugin: { kind: 'signoz/ListPanel', spec }, queries: [] },} as unknown as PanelOfKind<'signoz/ListPanel'>;}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.tsindex 204534352b..bffa3161d7 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.ts@@ -1,3 +1,8 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';-export const sections: SectionConfig[] = [];+export const sections: SectionConfig[] = [+ {+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true },+ },+];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/sections.tsindex 2e3f9dfaf6..c7248c3066 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/sections.ts@@ -1,8 +1,11 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';export const sections: SectionConfig[] = [- { kind: 'visualization', controls: { timePreference: true } },- { kind: 'formatting', controls: { unit: true, decimals: true } },- { kind: 'thresholds', controls: { variant: 'comparison' } },- { kind: 'contextLinks' },+ {+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true, timePreference: true },+ },+ { kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },+ { kind: SectionKind.Thresholds, controls: { variant: 'comparison' } },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.tsindex c8a3c80592..24b9a048ed 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts@@ -1,10 +1,13 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';// Pie has no axes, thresholds, or stacking — just value formatting and a legend.// Legend `colors` is omitted: the pie legend is always interactive swatches.export const sections: SectionConfig[] = [- { kind: 'visualization', controls: { timePreference: true } },- { kind: 'formatting', controls: { unit: true, decimals: true } },- { kind: 'legend', controls: { position: true } },- { kind: 'contextLinks' },+ {+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true, timePreference: true },+ },+ { kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },+ { kind: SectionKind.Legend, controls: { position: true } },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.tsindex 2bfd9ea78f..dc7ccf8b16 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.ts@@ -1,11 +1,17 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';// A table panel renders one scalar result (the V5 backend joins every query into a// single column set). It exposes the per-panel time scope, formatting (decimals +// per-column units), per-column thresholds, and context links.export const sections: SectionConfig[] = [- { kind: 'visualization', controls: { timePreference: true } },- { kind: 'formatting', controls: { decimals: true, columnUnits: true } },- { kind: 'thresholds', controls: { variant: 'table' } },- { kind: 'contextLinks' },+ {+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true, timePreference: true },+ },+ {+ kind: SectionKind.Formatting,+ controls: { decimals: true, columnUnits: true },+ },+ { kind: SectionKind.Thresholds, controls: { variant: 'table' } },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsxindex 3ae85b8d9d..e07379f294 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx@@ -49,7 +49,7 @@ function TimeSeriesPanelRenderer({);const builderQueries = useMemo(- () => getBuilderQueries(panel.spec.queries || []),+ () => getBuilderQueries(panel.spec.queries),[panel.spec.queries],);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/sections.tsindex b83bb5fa99..8d19679dc6 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/sections.ts@@ -1,12 +1,15 @@-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';export const sections: SectionConfig[] = [- { kind: 'visualization', controls: { timePreference: true, fillSpans: true } },- { kind: 'formatting', controls: { unit: true, decimals: true } },- { kind: 'axes', controls: { minMax: true, logScale: true } },- { kind: 'legend', controls: { position: true, colors: true } },{- kind: 'chartAppearance',+ kind: SectionKind.Visualization,+ controls: { switchPanelKind: true, timePreference: true, fillSpans: true },+ },+ { kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },+ { kind: SectionKind.Axes, controls: { minMax: true, logScale: true } },+ { kind: SectionKind.Legend, controls: { position: true, colors: true } },+ {+ kind: SectionKind.ChartAppearance,controls: {lineStyle: true,lineInterpolation: true,@@ -15,6 +18,6 @@ export const sections: SectionConfig[] = [spanGaps: true,},},- { kind: 'thresholds', controls: { variant: 'label' } },- { kind: 'contextLinks' },+ { kind: SectionKind.Thresholds, controls: { variant: 'label' } },+ { kind: SectionKind.ContextLinks },];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/sections.tsindex ac3d192cbd..5726653b99 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/sections.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/sections.ts@@ -35,6 +35,22 @@ export interface SectionMetadata {description?: string;}+/**+ * Discriminant for each config section (the `kind` field of a `SectionConfig`). The+ * string values match the keys each slice persists under in the plugin spec.+ */+export enum SectionKind {+ Formatting = 'formatting',+ Axes = 'axes',+ Legend = 'legend',+ ChartAppearance = 'chartAppearance',+ Buckets = 'buckets',+ Visualization = 'visualization',+ Thresholds = 'thresholds',+ ContextLinks = 'contextLinks',+ Columns = 'columns',+}+/*** Which threshold editor a kind uses. All three variants persist to the same* `plugin.spec.thresholds` key with different element shapes:@@ -60,17 +76,17 @@ export type PanelFormattingSlice = DashboardtypesPanelFormattingDTO &Pick<DashboardtypesTableFormattingDTO, 'columnUnits'>;export interface SectionSpecMap {- formatting: PanelFormattingSlice; // spec.plugin.spec.formatting- axes: DashboardtypesAxesDTO; // spec.plugin.spec.axes- legend: DashboardtypesLegendDTO; // spec.plugin.spec.legend- chartAppearance: DashboardtypesTimeSeriesChartAppearanceDTO; // spec.plugin.spec.chartAppearance- buckets: DashboardtypesHistogramBucketsDTO; // spec.plugin.spec.histogramBuckets+ [SectionKind.Formatting]: PanelFormattingSlice; // spec.plugin.spec.formatting+ [SectionKind.Axes]: DashboardtypesAxesDTO; // spec.plugin.spec.axes+ [SectionKind.Legend]: DashboardtypesLegendDTO; // spec.plugin.spec.legend+ [SectionKind.ChartAppearance]: DashboardtypesTimeSeriesChartAppearanceDTO; // spec.plugin.spec.chartAppearance+ [SectionKind.Buckets]: DashboardtypesHistogramBucketsDTO; // spec.plugin.spec.histogramBuckets// spec.plugin.spec.visualization — typed as the Bar shape (widest superset);// the `controls` bag gates which fields each kind writes.- visualization: DashboardtypesBarChartVisualizationDTO;- thresholds: AnyThreshold[]; // spec.plugin.spec.thresholds (variant picks the editor)- contextLinks: DashboardLinkDTO[]; // spec.links (PANEL-level)- columns: TelemetrytypesTelemetryFieldKeyDTO[]; // spec.plugin.spec.selectFields (List)+ [SectionKind.Visualization]: DashboardtypesBarChartVisualizationDTO;+ [SectionKind.Thresholds]: AnyThreshold[]; // spec.plugin.spec.thresholds (variant picks the editor)+ [SectionKind.ContextLinks]: DashboardLinkDTO[]; // spec.links (PANEL-level)+ [SectionKind.Columns]: TelemetrytypesTelemetryFieldKeyDTO[]; // spec.plugin.spec.selectFields (List)}/**@@ -78,33 +94,42 @@ export interface SectionSpecMap {* analogue of V1's `allowSoftMinMax` / `allowLegendColors` flags).*/export interface SectionControls {- formatting: { unit?: boolean; decimals?: boolean; columnUnits?: boolean };- axes: { minMax?: boolean; logScale?: boolean }; // minMax → softMin/softMax- legend: { position?: boolean; colors?: boolean }; // colors → customColors- chartAppearance: {+ [SectionKind.Formatting]: {+ unit?: boolean;+ decimals?: boolean;+ columnUnits?: boolean;+ };+ [SectionKind.Axes]: { minMax?: boolean; logScale?: boolean }; // minMax → softMin/softMax+ [SectionKind.Legend]: { position?: boolean; colors?: boolean }; // colors → customColors+ [SectionKind.ChartAppearance]: {lineStyle?: boolean;lineInterpolation?: boolean;fillMode?: boolean;showPoints?: boolean;spanGaps?: boolean;};- buckets: { count?: boolean; width?: boolean; mergeQueries?: boolean };- // stacking → stackedBarChart (Bar); fillSpans → fill gaps with 0 (TimeSeries).- visualization: {+ [SectionKind.Buckets]: {+ count?: boolean;+ width?: boolean;+ mergeQueries?: boolean;+ };+ // switchPanelKind → the visualization-type switcher (every kind, so you can switch+ // away from any panel); stacking → stackedBarChart (Bar); fillSpans → fill gaps with+ // 0 (TimeSeries).+ [SectionKind.Visualization]: {+ switchPanelKind: boolean;timePreference?: boolean;stacking?: boolean;fillSpans?: boolean;};// Editor discriminator (not a spec field): which threshold variant a kind edits.- thresholds: { variant?: ThresholdVariant };+ [SectionKind.Thresholds]: { variant?: ThresholdVariant };}export type ControlledSectionKind = keyof SectionControls;/** Atomic sections — no sub-controls; a kind either shows them or not. */-export type AtomicSectionKind = 'contextLinks' | 'columns';--export type SectionKind = ControlledSectionKind | AtomicSectionKind;+export type AtomicSectionKind = SectionKind.ContextLinks | SectionKind.Columns;/** Predicate to hide a section from the current spec; returning true removes it. */export type SectionVisibilityPredicate = (@@ -128,15 +153,15 @@ export type SectionConfig =// Per-section title + sidebar icon. Pure data; the editor component + spec lens// live in the ConfigPane section registry.export const SECTION_METADATA = {- formatting: { title: 'Formatting', icon: Hash },- axes: { title: 'Axes', icon: Ruler },- legend: { title: 'Legend', icon: Layers },- chartAppearance: { title: 'Chart appearance', icon: Palette },- visualization: { title: 'Visualization', icon: LayoutDashboard },- buckets: { title: 'Histogram / Buckets', icon: BarChart },- thresholds: { title: 'Thresholds', icon: SlidersHorizontal },- contextLinks: { title: 'Context Links', icon: Link },- columns: { title: 'Columns', icon: Columns3 },+ [SectionKind.Formatting]: { title: 'Formatting', icon: Hash },+ [SectionKind.Axes]: { title: 'Axes', icon: Ruler },+ [SectionKind.Legend]: { title: 'Legend', icon: Layers },+ [SectionKind.ChartAppearance]: { title: 'Chart appearance', icon: Palette },+ [SectionKind.Visualization]: { title: 'Visualization', icon: LayoutDashboard },+ [SectionKind.Buckets]: { title: 'Histogram / Buckets', icon: BarChart },+ [SectionKind.Thresholds]: { title: 'Thresholds', icon: SlidersHorizontal },+ [SectionKind.ContextLinks]: { title: 'Context Links', icon: Link },+ [SectionKind.Columns]: { title: 'Columns', icon: Columns3 },} as const satisfies Record<SectionKind, SectionMetadata>;/**diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/buildDefaultPluginSpec.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/buildDefaultPluginSpec.test.tsindex 1b4ccb6a8a..a59bcdefb1 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/buildDefaultPluginSpec.test.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/buildDefaultPluginSpec.test.ts@@ -10,7 +10,7 @@ import { sections as barSections } from '../../kinds/BarChartPanel/sections';import { sections as histogramSections } from '../../kinds/HistogramPanel/sections';import { sections as listSections } from '../../kinds/ListPanel/sections';import { sections as timeSeriesSections } from '../../kinds/TimeSeriesPanel/sections';-import type { SectionConfig } from '../../types/sections';+import { SectionKind, type SectionConfig } from '../../types/sections';import { buildDefaultPluginSpec } from '../buildDefaultPluginSpec';describe('buildDefaultPluginSpec', () => {@@ -50,17 +50,17 @@ describe('buildDefaultPluginSpec', () => {it('does not seed controls that already show a clear default', () => {// `axes` and `formatting` stay unset — their empty state is the chart default.const sections: SectionConfig[] = [- { kind: 'axes', controls: { minMax: true, logScale: true } },- { kind: 'formatting', controls: { unit: true, decimals: true } },- { kind: 'thresholds', controls: { variant: 'label' } },- { kind: 'contextLinks' },+ { kind: SectionKind.Axes, controls: { minMax: true, logScale: true } },+ { kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },+ { kind: SectionKind.Thresholds, controls: { variant: 'label' } },+ { kind: SectionKind.ContextLinks },];expect(buildDefaultPluginSpec(sections)).toStrictEqual({});});it('only seeds the legend position when the kind exposes that control', () => {const sections: SectionConfig[] = [- { kind: 'legend', controls: { colors: true } },+ { kind: SectionKind.Legend, controls: { colors: true } },];expect(buildDefaultPluginSpec(sections)).toStrictEqual({});});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/buildDefaultPluginSpec.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/buildDefaultPluginSpec.tsindex 315353495b..b7c826f7f9 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/buildDefaultPluginSpec.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/buildDefaultPluginSpec.ts@@ -6,7 +6,11 @@ import {DashboardtypesTimePreferenceDTO,} from 'api/generated/services/sigNoz.schemas';-import type { SectionConfig, SectionSpecMap } from '../types/sections';+import {+ SectionKind,+ type SectionConfig,+ type SectionSpecMap,+} from '../types/sections';/*** Seeded plugin-spec slices, typed as canonical section slices so each value is@@ -14,9 +18,9 @@ import type { SectionConfig, SectionSpecMap } from '../types/sections';* so the union cast stays localized to `createDefaultPanel`.*/export interface DefaultPluginSpec {- visualization?: SectionSpecMap['visualization'];- legend?: SectionSpecMap['legend'];- chartAppearance?: SectionSpecMap['chartAppearance'];+ visualization?: SectionSpecMap[SectionKind.Visualization];+ legend?: SectionSpecMap[SectionKind.Legend];+ chartAppearance?: SectionSpecMap[SectionKind.ChartAppearance];}/**@@ -31,20 +35,20 @@ export function buildDefaultPluginSpec(sections.forEach((section) => {switch (section.kind) {- case 'visualization':+ case SectionKind.Visualization:if (section.controls.timePreference) {spec.visualization = {timePreference: DashboardtypesTimePreferenceDTO.global_time,};}break;- case 'legend':+ case SectionKind.Legend:if (section.controls.position) {spec.legend = { position: DashboardtypesLegendPositionDTO.bottom };}break;- case 'chartAppearance': {- const chartAppearance: SectionSpecMap['chartAppearance'] = {};+ case SectionKind.ChartAppearance: {+ const chartAppearance: SectionSpecMap[SectionKind.ChartAppearance] = {};if (section.controls.lineStyle) {chartAppearance.lineStyle = DashboardtypesLineStyleDTO.solid;}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries.tsindex c437711982..4a14de6084 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries.ts@@ -10,21 +10,15 @@ import type { BuilderQuery } from 'types/api/v5/queryRange';export function getBuilderQueries(queries: DashboardtypesQueryDTO[],): BuilderQuery[] {- if (!queries) {- return [];- }const flattened: BuilderQuery[] = [];queries.forEach((envelope) => {- const plugin = envelope?.spec?.plugin;- if (!plugin) {- return;- }+ const plugin = envelope.spec.plugin;if (plugin.kind === 'signoz/BuilderQuery') {flattened.push(plugin.spec as BuilderQuery);return;}if (plugin.kind === 'signoz/CompositeQuery') {- (plugin.spec.queries ?? []).forEach((sub) => {+ (plugin.spec.queries || []).forEach((sub) => {if (sub.type === 'builder_query') {flattened.push(sub.spec as BuilderQuery);}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType.tsindex b778c4a4c9..8a5c4ed9e7 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType.ts@@ -12,7 +12,7 @@ import { deriveQueryType } from '../../queryV5/persesQueryAdapters';export function getPanelQueryType(panel: DashboardtypesPanelDTO,): EQueryType | undefined {- const envelopes = toQueryEnvelopes(panel.spec.queries || []);+ const envelopes = toQueryEnvelopes(panel.spec.queries);if (envelopes.length === 0) {return undefined;}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsxindex da8f6242db..84ebc0d93d 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx@@ -55,7 +55,7 @@ function PanelBody({// react-query keeps the previous response during refetches, so its presence is// the "have something to show" signal — only fail hard when there's nothing.const hasData = !!data.response;- const queries = panel.spec.queries || [];+ const queries = panel.spec.queries;// Not-configured panel: no runnable query, so nothing to error/load on.if (!hasRunnableQueries(queries)) {diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsxindex 2e67204b71..c6d6a5d017 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeSelectionModal.tsx@@ -8,7 +8,7 @@ import styles from './PanelTypeSelectionModal.module.scss';interface PanelTypeSelectionModalProps {open: boolean;onClose: () => void;- onSelect: (pluginKind: PanelKind) => void;+ onSelect: (panelKind: PanelKind) => void;}function PanelTypeSelectionModal({@@ -25,17 +25,17 @@ function PanelTypeSelectionModal({destroyOnClose><div className={styles.grid}>- {PANEL_TYPES.map((type) => (+ {PANEL_TYPES.map(({ panelKind, label, Icon }) => (<Button- key={type.pluginKind}+ key={panelKind}type="button"variant="ghost"className={styles.typeButton}- data-testid={`panel-type-${type.pluginKind}`}- onClick={(): void => onSelect(type.pluginKind)}+ data-testid={`panel-type-${panelKind}`}+ onClick={(): void => onSelect(panelKind)}>- {type.icon}- {type.label}+ <Icon size={14} />+ {label}</Button>))}</div>diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.tsnew file mode 100644index 0000000000..e106813665--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.ts@@ -0,0 +1,24 @@+import {+ BarChart,+ ChartLine,+ ChartPie,+ Hash,+ List,+ Table,+} from '@signozhq/icons';++import type { PanelType } from './types';++export const PANEL_TYPES: PanelType[] = [+ {+ panelKind: 'signoz/TimeSeriesPanel',+ label: 'Time Series',+ Icon: ChartLine,+ },+ { panelKind: 'signoz/NumberPanel', label: 'Number', Icon: Hash },+ { panelKind: 'signoz/TablePanel', label: 'Table', Icon: Table },+ { panelKind: 'signoz/BarChartPanel', label: 'Bar Chart', Icon: BarChart },+ { panelKind: 'signoz/PieChartPanel', label: 'Pie Chart', Icon: ChartPie },+ { panelKind: 'signoz/HistogramPanel', label: 'Histogram', Icon: BarChart },+ { panelKind: 'signoz/ListPanel', label: 'List', Icon: List },+];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.tsxdeleted file mode 100644index 05e19738c8..0000000000--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants.tsx+++ /dev/null@@ -1,36 +0,0 @@-import {- BarChart,- ChartLine,- ChartPie,- Hash,- List,- Table,-} from '@signozhq/icons';--import type { PanelType } from './types';--export const PANEL_TYPES: PanelType[] = [- {- pluginKind: 'signoz/TimeSeriesPanel',- label: 'Time Series',- icon: <ChartLine size={16} />,- },- { pluginKind: 'signoz/NumberPanel', label: 'Value', icon: <Hash size={16} /> },- { pluginKind: 'signoz/TablePanel', label: 'Table', icon: <Table size={16} /> },- {- pluginKind: 'signoz/BarChartPanel',- label: 'Bar Chart',- icon: <BarChart size={16} />,- },- {- pluginKind: 'signoz/PieChartPanel',- label: 'Pie Chart',- icon: <ChartPie size={16} />,- },- {- pluginKind: 'signoz/HistogramPanel',- label: 'Histogram',- icon: <BarChart size={16} />,- },- { pluginKind: 'signoz/ListPanel', label: 'List', icon: <List size={16} /> },-];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/types.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/types.tsindex a8f4a3d2d7..b66b817348 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/types.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/types.ts@@ -1,7 +1,16 @@+import type { IconSize } from '@signozhq/icons';+import type { ComponentType, SVGProps } from 'react';+import type { PanelKind } from '../../../Panels/types/panelKind';+type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {+ size?: number | IconSize;+ strokeWidth?: number;+};+export interface PanelType {- pluginKind: PanelKind;+ panelKind: PanelKind;label: string;- icon: JSX.Element;+ /** Icon component — the consumer renders it and controls size/color/etc. */+ Icon: ComponentType<IconProps>;}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useClonePanel.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useClonePanel.test.tsindex 88c123d0a3..4ccce6ebc0 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useClonePanel.test.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/__tests__/useClonePanel.test.ts@@ -63,9 +63,10 @@ describe('useClonePanel', () => {op: 'add',path: '/spec/layouts/0/spec/items/-',value: {- // Same dimensions as the source panel (p1: 8x5).+ // Same dimensions as the source panel (p1: 8x5). The last row is+ // full (8 + 4 = 12 cols), so the 8-wide clone wraps to a fresh row+ // at the section bottom: max(y + height) = 5.x: 0,- // Bottom of the section: max(y + height) over existing items = 5.y: 5,width: 8,height: 5,@@ -75,6 +76,27 @@ describe('useClonePanel', () => {]);});+ it('places the clone beside the last row when it fits', async () => {+ const oneNarrowItem: DashboardSection[] = [+ {+ id: 'section-0',+ layoutIndex: 0,+ title: 'Overview',+ repeatVariable: undefined,+ items: [{ id: 'p1', x: 0, y: 0, width: 4, height: 5, panel: sourcePanel }],+ },+ ];+ const { result } = renderHook(() =>+ useClonePanel({ sections: oneNarrowItem }),+ );++ await result.current({ panelId: 'p1', layoutIndex: 0 });++ const ops = mockPatch.mock.calls[0][1];+ // Room in the last row (4 + 4 = 8 ≤ 12 cols) → sits to the right at y:0.+ expect(ops[1].value).toMatchObject({ x: 4, y: 0, width: 4, height: 5 });+ });+it('deep-copies the spec — the cloned value is not the same object reference', async () => {const { result } = renderHook(() => useClonePanel({ sections: sections() }));diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.tsindex f9e4799ea6..34699edcb7 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useClonePanel.ts@@ -5,7 +5,11 @@ import { v4 as uuid } from 'uuid';import { patchDashboardV2 } from 'api/generated/services/dashboard';-import { addPanelToSectionOps, panelRef } from '../../../patchOps';+import {+ addPanelToSectionOps,+ findFreeSlot,+ panelRef,+} from '../../../patchOps';import { useDashboardStore } from '../../../store/useDashboardStore';import type { DashboardSection } from '../../../utils';@@ -20,8 +24,9 @@ export interface ClonePanelArgs {/*** Duplicates a panel: deep-copies the source spec under a fresh id and drops a- * same-size grid item at the bottom of the section, as one atomic patch. Mirrors- * V1's clone (verbatim spec copy, no rename).+ * same-size grid item into the section via `findFreeSlot` (beside the last row+ * if it fits, else a fresh row), as one atomic patch. Mirrors V1's clone+ * (verbatim spec copy, no rename).*/export function useClonePanel({sections,@@ -38,10 +43,7 @@ export function useClonePanel({}const newPanelId = uuid();- const nextY = section.items.reduce(- (max, i) => Math.max(max, i.y + i.height),- 0,- );+ const { x, y } = findFreeSlot(section.items, source.width);const clone = patchDashboardV2({ id: dashboardId },@@ -50,8 +52,8 @@ export function useClonePanel({panel: cloneDeep(source.panel),layoutIndex,item: {- x: 0,- y: nextY,+ x,+ y,width: source.width,height: source.height,content: { $ref: panelRef(newPanelId) },diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.tsindex 61cbd2725b..e7cc207e2e 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts@@ -77,7 +77,7 @@ export function usePanelQuery({const fullKind = panel.spec.plugin.kind;const panelType =(fullKind && PANEL_KIND_TO_PANEL_TYPE[fullKind]) ?? PANEL_TYPES.TIME_SERIES;- const queries = useMemo(() => panel.spec.queries || [], [panel.spec.queries]);+ const queries = panel.spec.queries;// V1 parity: a list query with an explicit `limit` shows without a server pager; without// one it pages server-side at a user-selectable size.diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/patchOps.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/patchOps.tsindex 315a94ddd4..4a6447dec1 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/patchOps.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/patchOps.ts@@ -132,13 +132,16 @@ const NEW_PANEL_SIZE = { width: 6, height: 6 };/** Columns in the section grid — mirrors `cols` on SectionGrid's GridLayout. */const GRID_COLS = 12;+/** Minimal placement fields shared by grid-item DTOs and flattened `GridItem`s. */+type PlacedItem = Pick<DashboardGridItemDTO, 'x' | 'y' | 'width' | 'height'>;+/*** Placement for a new grid item: drop it right of the last row if there's room,* else wrap to a fresh row at the bottom. Only the last row is considered (items* sharing the greatest top-y); gaps in earlier rows are left alone.*/-function findFreeSlot(- items: DashboardGridItemDTO[],+export function findFreeSlot(+ items: PlacedItem[],width: number,): { x: number; y: number } {const w = Math.min(width, GRID_COLS);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/buildQueryRangeRequest.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/buildQueryRangeRequest.tsindex 17b21260a4..20478d9efa 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/buildQueryRangeRequest.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/buildQueryRangeRequest.ts@@ -59,7 +59,7 @@ export function toQueryEnvelopes(queries: DashboardtypesQueryDTO[],): Querybuildertypesv5QueryEnvelopeDTO[] {// Backend invariant: panel.queries.length === 1. Only the first entry is consumed.- if (!queries || queries.length === 0) {+ if (queries.length === 0) {return [];}const plugin = queries[0].spec.plugin;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters.tsindex 46a009f83a..0291654c6d 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters.ts@@ -81,7 +81,7 @@ export function fromPerses(queries: DashboardtypesQueryDTO[],panelType: PANEL_TYPES,): Query {- const envelopes = toQueryEnvelopes(queries ?? []);+ const envelopes = toQueryEnvelopes(queries);if (envelopes.length === 0) {return initialQueriesMap[DataSource.METRICS];}