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): config pane + section editors (#11770)
Abhi kumarb2acf3e85648
diff --git a/frontend/src/constants/localStorage.ts b/frontend/src/constants/localStorage.tsindex 32a7fd60c7..e8c50d3c14 100644--- a/frontend/src/constants/localStorage.ts+++ b/frontend/src/constants/localStorage.ts@@ -44,4 +44,5 @@ export enum LOCALSTORAGE {ACTIVE_SIGNOZ_INSTANCE_URL = 'ACTIVE_SIGNOZ_INSTANCE_URL',DASHBOARDS_LIST_VISIBLE_COLUMNS = 'DASHBOARDS_LIST_VISIBLE_COLUMNS',DASHBOARDS_LIST_VIEWS = 'DASHBOARDS_LIST_VIEWS',+ DASHBOARD_V2_PANEL_COLUMN_WIDTHS = 'DASHBOARD_V2_PANEL_COLUMN_WIDTHS',}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scssnew file mode 100644index 0000000000..00d543cdc6--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss@@ -0,0 +1,90 @@+.config {+ display: flex;+ flex-direction: column;+ flex: 1;+ // padding: 18px 18px 44px;+ background-color: var(--l1-background);+ overflow-y: auto;+ overflow-x: hidden;++ //TODO: replace this with custom-scrollbar mixin+ // Thin, unobtrusive scrollbar (replaces the chunky native bar).+ $thumb: color-mix(in srgb, var(--bg-vanilla-100) 16%, transparent);++ scrollbar-width: thin;+ scrollbar-color: $thumb transparent;++ &::-webkit-scrollbar {+ width: 8px;+ }++ &::-webkit-scrollbar-track {+ background: transparent;+ }++ &::-webkit-scrollbar-thumb {+ background: $thumb;+ border-radius: 999px;+ border: 2px solid transparent;+ background-clip: padding-box;+ }+}++.heading {+ margin-bottom: 18px;+ padding: 16px 16px 0 16px;+}++.title {+ display: flex;+ align-items: baseline;+ gap: 9px;+ white-space: nowrap;+}++.subtitle {+ font-size: 12px;+ color: var(--text-vanilla-400);+}++.eyebrow {+ display: block;+ margin: 0 2px 10px;+ font-size: 11px;+ font-weight: 600;+ letter-spacing: 0.06em;+ text-transform: uppercase;+ color: var(--l1-foreground);+}++.group {+ display: flex;+ flex-direction: column;+ gap: 16px;+ padding: 0 16px;+}++.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}++.divider {+ height: 1px;+ background: var(--l2-border);+ margin: 18px 0;+}++.sectionsContainer {+ padding: 0 16px;+}++.sections {+ display: flex;+ flex-direction: column;++ & > * + * {+ border-top: 1px solid var(--l2-border);+ }+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsxnew file mode 100644index 0000000000..066b35a63a--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx@@ -0,0 +1,108 @@+import { Input } from 'antd';+import { Typography } from '@signozhq/ui/typography';+import type {+ DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+} from 'api/generated/services/sigNoz.schemas';+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';+import { getBuilderQueries } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';++import type { LegendSeries } from '../hooks/useLegendSeries';+import type { TableColumnOption } from '../hooks/useTableColumns';+import SectionSlot from './SectionSlot/SectionSlot';++import styles from './ConfigPane.module.scss';+import { PanelKind } from '../../Panels/types/panelKind';++interface ConfigPaneProps {+ /** Full plugin kind (e.g. `signoz/TimeSeriesPanel`); drives which sections show. */+ panelKind: PanelKind;+ /** The panel spec — the single editing surface (title/description + section slices). */+ spec: DashboardtypesPanelSpecDTO;+ onChangeSpec: (next: DashboardtypesPanelSpecDTO) => 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. */+ tableColumns: TableColumnOption[];+}++/**+ * Right-hand configuration pane. Renders the always-present general fields (title ++ * description) followed by the panel kind's configuration sections (Formatting, Axes,+ * …). The section list is declared per kind (`PanelDefinition.sections`) and rendered+ * generically via the section registry — only sections with a built editor appear.+ */+function ConfigPane({+ panelKind,+ spec,+ onChangeSpec,+ legendSeries,+ tableColumns,+}: ConfigPaneProps): JSX.Element {+ const definition = getPanelDefinition(panelKind);+ const sections = definition?.sections ?? [];++ const signal = getBuilderQueries(spec.queries)[0]?.signal as+ | TelemetrytypesSignalDTO+ | undefined;++ // Title/description are just a slice of the spec — edit them through the same+ // onChangeSpec path the sections use, so there's a single editing surface.+ const setDisplayField = (field: 'name' | 'description', value: string): void =>+ onChangeSpec({ ...spec, display: { ...spec.display, [field]: value } });++ return (+ <div className={styles.config}>+ <header className={styles.heading}>+ <Typography.Text>Panel settings</Typography.Text>+ </header>++ <div className={styles.group}>+ <div className={styles.field}>+ <Typography.Text>Title</Typography.Text>+ <Input+ data-testid="panel-editor-v2-title"+ value={spec.display.name}+ placeholder="Panel title"+ onChange={(e): void => setDisplayField('name', e.target.value)}+ />+ </div>++ <div className={styles.field}>+ <Typography.Text>Description</Typography.Text>+ <Input.TextArea+ data-testid="panel-editor-v2-description"+ value={spec.display.description ?? ''}+ placeholder="Add a description"+ rows={3}+ onChange={(e): void => setDisplayField('description', e.target.value)}+ />+ </div>+ </div>++ {sections.length > 0 && (+ <>+ <div className={styles.divider} />+ <div className={styles.sectionsContainer}>+ <span className={styles.eyebrow}>Display</span>+ <div className={styles.sections}>+ {sections.map((config) => (+ <SectionSlot+ key={config.kind}+ config={config}+ spec={spec}+ onChangeSpec={onChangeSpec}+ legendSeries={legendSeries}+ tableColumns={tableColumns}+ signal={signal}+ />+ ))}+ </div>+ </div>+ </>+ )}+ </div>+ );+}++export default ConfigPane;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsxnew file mode 100644index 0000000000..1bbc828541--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx@@ -0,0 +1,77 @@+import type {+ DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+} from 'api/generated/services/sigNoz.schemas';+import {+ type PanelFormattingSlice,+ SECTION_METADATA,+ type SectionConfig,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';++import type { LegendSeries } from '../../hooks/useLegendSeries';+import type { TableColumnOption } from '../../hooks/useTableColumns';+import { resolveSectionEditor } from '../sectionRegistry';+import SettingsSection from '../SettingsSection/SettingsSection';++interface SectionSlotProps {+ config: SectionConfig;+ spec: DashboardtypesPanelSpecDTO;+ onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;+ /** Resolved series, forwarded to editors that need them (legend colors). */+ legendSeries: LegendSeries[];+ /** Table panel's resolved value columns, for the table-only editors. */+ tableColumns: TableColumnOption[];+ /** Panel's telemetry signal, for editors that fetch field suggestions (List columns). */+ signal?: TelemetrytypesSignalDTO;+}++/**+ * Renders one configuration section: its collapsible wrapper plus the registered editor+ * for `config.kind`, wired through the registry's spec lens. Renders nothing when the+ * kind has no editor yet (sections roll out incrementally), so a kind can declare a+ * section before its editor exists.+ */+function SectionSlot({+ config,+ spec,+ onChangeSpec,+ legendSeries,+ tableColumns,+ signal,+}: 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.+ if (config.isHidden?.(spec)) {+ return null;+ }++ const editor = resolveSectionEditor(config.kind);+ if (!editor) {+ return null;+ }++ const { title, icon: Icon } = SECTION_METADATA[config.kind];+ const { Component, get, update } = editor;+ // Atomic sections carry no `controls`; controlled ones do.+ const controls = 'controls' in config ? config.controls : undefined;+ // The panel's formatting unit, forwarded to editors that scope to it (thresholds+ // restrict their unit picker to this unit's category, as in V1).+ const yAxisUnit = (spec.plugin.spec as { formatting?: PanelFormattingSlice })+ .formatting?.unit;++ return (+ <SettingsSection title={title} icon={<Icon size={15} />}>+ <Component+ value={get(spec)}+ controls={controls}+ onChange={(next): void => onChangeSpec(update(spec, next))}+ legendSeries={legendSeries}+ yAxisUnit={yAxisUnit}+ tableColumns={tableColumns}+ signal={signal}+ />+ </SettingsSection>+ );+}++export default SectionSlot;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scssnew file mode 100644index 0000000000..5da958312d--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss@@ -0,0 +1,54 @@+.header {+ display: flex;+ align-items: center;+ gap: 11px;+ width: 100%;+ height: 44px;+ padding: 0 4px;+ border: none;+ background: transparent;+ cursor: pointer;+ color: var(--text-vanilla-100);+ border-radius: 4px;+}++.iconTile {+ display: grid;+ place-items: center;+ width: 27px;+ height: 27px;+ flex: none;+ border-radius: 3px;+ background: var(--l3-background);+ color: var(--l3-foreground);+ transition: all 0.15s ease;+}++.iconTileOpen {+ background: color-mix(in srgb, var(--bg-robin-400) 14%, transparent);+ color: var(--bg-robin-400);+}++.title {+ flex: 1;+ text-align: left;+ font-weight: 600;+ color: var(--l2-foreground);+}++.chevron {+ flex: none;+ color: var(--l2-border);+ transition: transform 0.15s ease;++ &.open {+ transform: rotate(180deg);+ }+}++.body {+ display: flex;+ flex-direction: column;+ gap: 16px;+ padding: 2px 0 18px;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsxnew file mode 100644index 0000000000..f3233b06ef--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx@@ -0,0 +1,54 @@+import { type ReactNode, useState } from 'react';+import { ChevronDown } from '@signozhq/icons';+import { Typography } from '@signozhq/ui/typography';+import cx from 'classnames';++import styles from './SettingsSection.module.scss';++interface SettingsSectionProps {+ title: string;+ icon?: ReactNode;+ defaultOpen?: boolean;+ children: ReactNode;+}++/**+ * Collapsible container for one configuration section in the V2 panel editor's+ * ConfigPane. Header shows an icon tile (accented when expanded), the title, and a+ * rotating chevron; sections are separated by hairline dividers (no surrounding boxes),+ * matching the Configure-panel design.+ */+function SettingsSection({+ title,+ icon,+ defaultOpen = false,+ children,+}: SettingsSectionProps): JSX.Element {+ const [isOpen, setIsOpen] = useState(defaultOpen);++ return (+ <section className={styles.section}>+ <button+ type="button"+ className={styles.header}+ aria-expanded={isOpen}+ data-testid={`config-section-${title}`}+ onClick={(): void => setIsOpen((prev) => !prev)}+ >+ {icon && (+ <span className={cx(styles.iconTile, { [styles.iconTileOpen]: isOpen })}>+ {icon}+ </span>+ )}+ <Typography.Text className={styles.title}>{title}</Typography.Text>+ <ChevronDown+ size={15}+ className={cx(styles.chevron, { [styles.open]: isOpen })}+ />+ </button>+ {isOpen && <div className={styles.body}>{children}</div>}+ </section>+ );+}++export default 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.tsxnew file mode 100644index 0000000000..c980e42a26--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx@@ -0,0 +1,69 @@+import { fireEvent, render, screen } from '@testing-library/react';+import type { DashboardtypesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';++import ConfigPane from '../ConfigPane';+import { PanelKind } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';++function spec(unit?: string): DashboardtypesPanelSpecDTO {+ return {+ display: { name: 'CPU', description: 'usage' },+ plugin: {+ kind: 'signoz/TimeSeriesPanel',+ spec: unit ? { formatting: { unit } } : {},+ },+ queries: [],+ } as unknown as DashboardtypesPanelSpecDTO;+}++function renderConfigPane(+ overrides: Partial<React.ComponentProps<typeof ConfigPane>> = {},+): React.ComponentProps<typeof ConfigPane> {+ const props: React.ComponentProps<typeof ConfigPane> = {+ panelKind: 'signoz/TimeSeriesPanel',+ spec: spec(),+ onChangeSpec: jest.fn(),+ legendSeries: [],+ tableColumns: [],+ ...overrides,+ };+ render(<ConfigPane {...props} />);+ return props;+}++describe('ConfigPane', () => {+ it('renders the seeded title and description', () => {+ renderConfigPane();++ expect(screen.getByTestId('panel-editor-v2-title')).toHaveValue('CPU');+ expect(screen.getByTestId('panel-editor-v2-description')).toHaveValue(+ 'usage',+ );+ });++ it('reports title edits through onChangeSpec (into spec.display)', () => {+ const { onChangeSpec } = renderConfigPane();++ fireEvent.change(screen.getByTestId('panel-editor-v2-title'), {+ target: { value: 'Memory' },+ });++ expect(onChangeSpec).toHaveBeenCalledWith(+ expect.objectContaining({+ display: { name: 'Memory', description: 'usage' },+ }),+ );+ });++ it('renders the Formatting section for a kind that declares it', () => {+ renderConfigPane();+ // The TimeSeries kind declares a Formatting section; its collapsible header shows.+ expect(screen.getByTestId('config-section-Formatting')).toBeInTheDocument();+ });++ it('omits the Formatting section for an unknown kind', () => {+ renderConfigPane({ panelKind: 'signoz/UnknownPanel' as PanelKind });+ expect(+ screen.queryByTestId('config-section-Formatting'),+ ).not.toBeInTheDocument();+ });+});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.scssnew file mode 100644index 0000000000..70cc3ca92a--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss@@ -0,0 +1,10 @@+.group {+ width: min(350px, 100%);+}++.segment {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ white-space: nowrap;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsxnew file mode 100644index 0000000000..eb1ab99342--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsx@@ -0,0 +1,59 @@+import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';++import { SegmentIcon, type SegmentIconName } from '../segmentIcons';++import styles from './ConfigSegmented.module.scss';++export interface ConfigSegmentedItem {+ value: string;+ label: string;+ icon?: SegmentIconName;+}++interface ConfigSegmentedProps {+ testId: string;+ value: string | undefined;+ items: ConfigSegmentedItem[];+ onChange: (value: string) => void;+}++/**+ * Inline segmented control for short option sets in the config pane (line style, fill+ * mode, axis scale, legend position). Each segment carries an optional muted glyph that+ * brightens with the selected state (it inherits the toggle's `currentColor`). Built on+ * the Periscope ToggleGroup so it stays theme-faithful.+ */+function ConfigSegmented({+ testId,+ value,+ items,+ onChange,+}: ConfigSegmentedProps): JSX.Element {+ return (+ <ToggleGroupSimple+ type="single"+ testId={testId}+ className={styles.group}+ value={value}+ items={items.map((item) => ({+ value: item.value,+ 'aria-label': item.label,+ label: (+ <span className={styles.segment}>+ {item.icon && <SegmentIcon name={item.icon} />}+ {item.label}+ </span>+ ),+ }))}+ // Single toggle-groups emit '' when the active segment is re-clicked; ignore that+ // so a required choice (e.g. scale, position) can't be cleared to an empty value.+ onChange={(next: string): void => {+ if (next) {+ onChange(next);+ }+ }}+ />+ );+}++export default ConfigSegmented;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.module.scssnew file mode 100644index 0000000000..70bcd8f3a6--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.module.scss@@ -0,0 +1,10 @@+// Fill the section field so the select lines up with the other full-width controls.+.select {+ width: 100%;+}++.item {+ display: inline-flex;+ align-items: center;+ gap: 9px;+}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.tsxnew file mode 100644index 0000000000..4dec0ef99f--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect.tsx@@ -0,0 +1,56 @@+import { Select } from 'antd';++import { SegmentIcon, type SegmentIconName } from '../segmentIcons';++import styles from './ConfigSelect.module.scss';++export interface ConfigSelectItem {+ value: string;+ label: string;+ icon?: SegmentIconName;+}++interface ConfigSelectProps {+ testId: string;+ value: string | undefined;+ placeholder?: string;+ items: ConfigSelectItem[];+ onChange: (value: string) => void;+}++/**+ * Single-select dropdown for the panel editor's config sections. Built on antd's+ * `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({+ testId,+ value,+ placeholder,+ items,+ onChange,+}: ConfigSelectProps): JSX.Element {+ return (+ <Select<string>+ className={styles.select}+ data-testid={testId}+ value={value}+ placeholder={placeholder}+ onChange={onChange}+ virtual={false}+ options={items.map((item) => ({+ value: item.value,+ label: item.icon ? (+ <span className={styles.item}>+ <SegmentIcon name={item.icon} />+ {item.label}+ </span>+ ) : (+ item.label+ ),+ }))}+ />+ );+}++export default ConfigSelect;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scssnew file mode 100644index 0000000000..f693b42dfc--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss@@ -0,0 +1,30 @@+.card {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ padding: 12px 14px;+ border: 1px solid var(--l2-border);+ border-radius: 6px;+ background: var(--l2-background-60);+}++.text {+ display: flex;+ flex-direction: column;+ gap: 2px;+ min-width: 0;+}++.title {+ font-size: 12px;+ font-weight: 600;+ letter-spacing: 0.06em;+ text-transform: uppercase;+ color: var(--l2-foreground);+}++.description {+ font-size: 12px;+ color: var(--l3-foreground);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsxnew file mode 100644index 0000000000..bdf5f9cec0--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx@@ -0,0 +1,43 @@+import { Switch } from '@signozhq/ui/switch';+import { Typography } from '@signozhq/ui/typography';++import styles from './ConfigSwitch.module.scss';++interface ConfigSwitchProps {+ testId: string;+ /** Shown uppercased as the card title. */+ title: string;+ /** Optional helper line under the title. */+ description?: string;+ value: boolean;+ onChange: (checked: boolean) => void;+}++/**+ * Boolean toggle rendered as a bordered card: an uppercase title with an optional+ * description on the left and a Switch on the right. The standard presentation for+ * on/off panel-config controls (e.g. "Show points").+ */+function ConfigSwitch({+ testId,+ title,+ description,+ value,+ onChange,+}: ConfigSwitchProps): JSX.Element {+ return (+ <div className={styles.card}>+ <div className={styles.text}>+ <span className={styles.title}>{title}</span>+ {description && (+ <Typography.Text className={styles.description}>+ {description}+ </Typography.Text>+ )}+ </div>+ <Switch testId={testId} value={value} onChange={onChange} />+ </div>+ );+}++export default ConfigSwitch;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsxnew file mode 100644index 0000000000..367a047ca8--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx@@ -0,0 +1,64 @@+import { ColorPicker } from 'antd';+import { Button } from '@signozhq/ui/button';+import { Typography } from '@signozhq/ui/typography';++import styles from './LegendColors.module.scss';++interface LegendColorRowProps {+ label: string;+ /** Effective color shown in the swatch (override or auto). */+ color: string;+ /** True when the series has an explicit override (enables Reset). */+ isOverridden: boolean;+ onChange: (hex: string) => void;+ onReset: () => void;+}++/**+ * One series row in the legend-colors list: an antd ColorPicker swatch trigger, the+ * series label, and a Reset action shown only when the color is overridden. `onChange`+ * fires on commit (`onChangeComplete`) so dragging the picker doesn't churn the spec.+ */+function LegendColorRow({+ label,+ color,+ isOverridden,+ onChange,+ onReset,+}: LegendColorRowProps): JSX.Element {+ return (+ <div className={styles.row}>+ <ColorPicker+ value={color}+ size="small"+ showText={false}+ trigger="click"+ onChangeComplete={(next): void => onChange(next.toHexString())}+ >+ <button+ type="button"+ className={styles.trigger}+ data-testid={`legend-color-${label}`}+ >+ <span className={styles.swatch} style={{ backgroundColor: color }} />+ <Typography.Text className={styles.label} title={label}>+ {label}+ </Typography.Text>+ </button>+ </ColorPicker>+ {isOverridden && (+ <Button+ size="sm"+ color="secondary"+ variant="ghost"+ onClick={onReset}+ testId={`legend-color-reset-${label}`}+ >+ Reset+ </Button>+ )}+ </div>+ );+}++export default LegendColorRow;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scssnew file mode 100644index 0000000000..ddb570325b--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss@@ -0,0 +1,51 @@+.container {+ display: flex;+ flex-direction: column;+ gap: 8px;+}++.list {+ width: 100%;+}++.row {+ display: flex;+ align-items: center;+ gap: 8px;+ min-width: 0;+ height: 34px;+}++.trigger {+ display: flex;+ flex: 1;+ align-items: center;+ gap: 10px;+ min-width: 0;+ padding: 0;+ border: none;+ background: transparent;+ cursor: pointer;+ text-align: left;+}++.swatch {+ width: 18px;+ height: 18px;+ flex: none;+ border: 1px solid var(--l2-border);+ border-radius: 4px;+}++.label {+ overflow: hidden;+ font-size: 12px;+ color: var(--l2-foreground);+ white-space: nowrap;+ text-overflow: ellipsis;+}++.empty {+ font-size: 12px;+ color: var(--text-vanilla-400);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsxnew file mode 100644index 0000000000..b0e53af141--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx@@ -0,0 +1,83 @@+import { useState } from 'react';+import { Search } from '@signozhq/icons';+import { Typography } from '@signozhq/ui/typography';+import { Input } from 'antd';+import type { DashboardtypesLegendDTOCustomColors } from 'api/generated/services/sigNoz.schemas';+import { Virtuoso } from 'react-virtuoso';++import type { LegendSeries } from '../../../hooks/useLegendSeries';+import LegendColorRow from './LegendColorRow';+import {+ clearSeriesColor,+ filterLegendSeries,+ resolveSeriesColor,+ setSeriesColor,+} from './legendColors.utils';++import styles from './LegendColors.module.scss';++interface LegendColorsProps {+ /** Panel's resolved series (from the shared preview query). */+ series: LegendSeries[];+ value: DashboardtypesLegendDTOCustomColors | undefined;+ onChange: (next: Record<string, string>) => void;+}++/**+ * Per-series color overrides for the legend: a searchable, virtualized list of the+ * panel's resolved series, each with an antd ColorPicker swatch. Picking a color writes+ * `{ [seriesLabel]: hex }` into `legend.customColors` — the same label the chart keys its+ * color lookup on; Reset drops the override. Virtualized so panels with hundreds of+ * series stay responsive. Until the query produces series, shows a hint.+ */+function LegendColors({+ series,+ value,+ onChange,+}: LegendColorsProps): JSX.Element {+ const [query, setQuery] = useState('');++ if (series.length === 0) {+ return (+ <Typography.Text className={styles.empty}>+ Run the panel to customise series colors.+ </Typography.Text>+ );+ }++ const filtered = filterLegendSeries(series, query);++ return (+ <div className={styles.container} data-testid="panel-editor-v2-legend-colors">+ <Input+ data-testid="panel-editor-v2-legend-search"+ placeholder="Search series…"+ value={query}+ prefix={<Search size={14} />}+ onChange={(e): void => setQuery(e.target.value)}+ />+ {filtered.length === 0 ? (+ <Typography.Text className={styles.empty}>+ No series match “{query}”.+ </Typography.Text>+ ) : (+ <Virtuoso+ className={styles.list}+ style={{ height: Math.min(filtered.length * 34, 240) }}+ data={filtered}+ itemContent={(_, s): JSX.Element => (+ <LegendColorRow+ label={s.label}+ color={resolveSeriesColor(value, s.label, s.defaultColor)}+ isOverridden={value?.[s.label] !== undefined}+ onChange={(hex): void => onChange(setSeriesColor(value, s.label, hex))}+ onReset={(): void => onChange(clearSeriesColor(value, s.label))}+ />+ )}+ />+ )}+ </div>+ );+}++export default LegendColors;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsxnew file mode 100644index 0000000000..17be050a65--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx@@ -0,0 +1,42 @@+import { fireEvent, render, screen } from '@testing-library/react';++import type { LegendSeries } from '../../../../hooks/useLegendSeries';+import LegendColors from '../LegendColors';++const SERIES: LegendSeries[] = [+ { label: 'frontend', defaultColor: '#ff0000' },+ { label: 'cartservice', defaultColor: '#00ff00' },+];++describe('LegendColors', () => {+ it('shows a hint when there are no resolved series', () => {+ render(<LegendColors series={[]} value={undefined} onChange={jest.fn()} />);++ expect(+ screen.queryByTestId('panel-editor-v2-legend-colors'),+ ).not.toBeInTheDocument();+ expect(screen.getByText(/run the panel/i)).toBeInTheDocument();+ });++ it('renders the search box once series are present', () => {+ render(+ <LegendColors series={SERIES} value={undefined} onChange={jest.fn()} />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-legend-search'),+ ).toBeInTheDocument();+ });++ it('shows a no-match message when the search filters everything out', () => {+ render(+ <LegendColors series={SERIES} value={undefined} onChange={jest.fn()} />,+ );++ fireEvent.change(screen.getByTestId('panel-editor-v2-legend-search'), {+ target: { value: 'zzz' },+ });++ expect(screen.getByText(/no series match/i)).toBeInTheDocument();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/legendColors.utils.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/legendColors.utils.test.tsnew file mode 100644index 0000000000..373b1c2edb--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/legendColors.utils.test.ts@@ -0,0 +1,63 @@+import type { LegendSeries } from '../../../../hooks/useLegendSeries';+import {+ clearSeriesColor,+ filterLegendSeries,+ resolveSeriesColor,+ setSeriesColor,+} from '../legendColors.utils';++const SERIES: LegendSeries[] = [+ { label: 'frontend', defaultColor: '#ff0000' },+ { label: 'cartservice', defaultColor: '#00ff00' },+ { label: 'frontendproxy', defaultColor: '#0000ff' },+];++describe('legendColors.utils', () => {+ describe('filterLegendSeries', () => {+ it('returns all series for an empty/whitespace query', () => {+ expect(filterLegendSeries(SERIES, '')).toHaveLength(3);+ expect(filterLegendSeries(SERIES, ' ')).toHaveLength(3);+ });++ it('matches case-insensitive substrings', () => {+ expect(+ filterLegendSeries(SERIES, 'FRONT').map((s) => s.label),+ ).toStrictEqual(['frontend', 'frontendproxy']);+ expect(filterLegendSeries(SERIES, 'cart')).toHaveLength(1);+ expect(filterLegendSeries(SERIES, 'zzz')).toHaveLength(0);+ });+ });++ describe('resolveSeriesColor', () => {+ it('prefers the override, falling back to the default', () => {+ expect(resolveSeriesColor({ frontend: '#111' }, 'frontend', '#ff0000')).toBe(+ '#111',+ );+ expect(resolveSeriesColor(undefined, 'frontend', '#ff0000')).toBe('#ff0000');+ expect(resolveSeriesColor(null, 'frontend', '#ff0000')).toBe('#ff0000');+ });+ });++ describe('setSeriesColor', () => {+ it('adds/overwrites a label without mutating the input', () => {+ const value = { frontend: '#111' };+ const next = setSeriesColor(value, 'cartservice', '#222');+ expect(next).toStrictEqual({ frontend: '#111', cartservice: '#222' });+ expect(value).toStrictEqual({ frontend: '#111' });+ });++ it('handles null/undefined base', () => {+ expect(setSeriesColor(undefined, 'a', '#1')).toStrictEqual({ a: '#1' });+ expect(setSeriesColor(null, 'a', '#1')).toStrictEqual({ a: '#1' });+ });+ });++ describe('clearSeriesColor', () => {+ it('removes a label without mutating the input', () => {+ const value = { frontend: '#111', cartservice: '#222' };+ const next = clearSeriesColor(value, 'frontend');+ expect(next).toStrictEqual({ cartservice: '#222' });+ expect(value).toStrictEqual({ frontend: '#111', cartservice: '#222' });+ });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/legendColors.utils.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/legendColors.utils.tsnew file mode 100644index 0000000000..245dd84fa9--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/legendColors.utils.ts@@ -0,0 +1,43 @@+import type { DashboardtypesLegendDTOCustomColors } from 'api/generated/services/sigNoz.schemas';++import type { LegendSeries } from '../../../hooks/useLegendSeries';++/** Case-insensitive substring filter over series labels. Empty query → all series. */+export function filterLegendSeries(+ series: LegendSeries[],+ query: string,+): LegendSeries[] {+ const q = query.trim().toLowerCase();+ if (!q) {+ return series;+ }+ return series.filter((s) => s.label.toLowerCase().includes(q));+}++/** The effective color for a series: the override if set, else its auto color. */+export function resolveSeriesColor(+ value: DashboardtypesLegendDTOCustomColors | undefined,+ label: string,+ defaultColor: string,+): string {+ return value?.[label] ?? defaultColor;+}++/** Set an override for `label`, returning a new customColors record. */+export function setSeriesColor(+ value: DashboardtypesLegendDTOCustomColors | undefined,+ label: string,+ hex: string,+): Record<string, string> {+ return { ...value, [label]: hex };+}++/** Drop the override for `label` (revert to the auto color), returning a new record. */+export function clearSeriesColor(+ value: DashboardtypesLegendDTOCustomColors | undefined,+ label: string,+): Record<string, string> {+ const next = { ...value };+ delete next[label];+ return next;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsxnew file mode 100644index 0000000000..f07d661eb5--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsx@@ -0,0 +1,145 @@+/**+ * Small glyph icons for the panel-editor segmented/select controls, ported from the+ * Configure-panel design. They render at 14px and inherit `currentColor` so the+ * surrounding control can dim them when unselected and brighten them when active.+ */+export type SegmentIconName =+ | 'solid-line'+ | 'dashed-line'+ | 'fill-none'+ | 'fill-solid'+ | 'fill-gradient'+ | 'pos-bottom'+ | 'pos-right'+ | 'scale-linear'+ | 'scale-log'+ | 'interp-linear'+ | 'interp-spline'+ | 'interp-step-before'+ | 'interp-step-after';++function Svg({ children }: { children: React.ReactNode }): JSX.Element {+ return (+ <svg+ width={14}+ height={14}+ viewBox="0 0 16 16"+ fill="none"+ stroke="currentColor"+ strokeWidth={1.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ style={{ flex: 'none' }}+ aria-hidden+ >+ {children}+ </svg>+ );+}++const FILLED = { fill: 'currentColor', stroke: 'none' } as const;++export function SegmentIcon({+ name,+}: {+ name: SegmentIconName;+}): JSX.Element | null {+ switch (name) {+ case 'solid-line':+ return (+ <Svg>+ <path d="M2 8 H14" />+ </Svg>+ );+ case 'dashed-line':+ return (+ <Svg>+ <path d="M2 8 H4.5" />+ <path d="M6.75 8 H9.25" />+ <path d="M11.5 8 H14" />+ </Svg>+ );+ case 'fill-none':+ return (+ <Svg>+ <path d="M2 11 L6 6 L10 9 L14 5" />+ </Svg>+ );+ case 'fill-solid':+ return (+ <Svg>+ <path+ d="M2 10.5 L6 5.5 L10 8.5 L14 4.5 V13.5 H2 Z"+ fill="currentColor"+ fillOpacity={0.85}+ stroke="none"+ />+ <path d="M2 10.5 L6 5.5 L10 8.5 L14 4.5" />+ </Svg>+ );+ case 'fill-gradient':+ return (+ <Svg>+ <path+ d="M2 10.5 L6 5.5 L10 8.5 L14 4.5 V13.5 H2 Z"+ fill="currentColor"+ fillOpacity={0.3}+ stroke="none"+ />+ <path d="M2 10.5 L6 5.5 L10 8.5 L14 4.5" />+ </Svg>+ );+ case 'pos-bottom':+ return (+ <Svg>+ <rect x={2} y={2.5} width={12} height={9} rx={1.2} />+ <rect x={2} y={9} width={12} height={2.5} {...FILLED} />+ </Svg>+ );+ case 'pos-right':+ return (+ <Svg>+ <rect x={2} y={2.5} width={12} height={9} rx={1.2} />+ <rect x={10.5} y={2.5} width={3.5} height={9} {...FILLED} />+ </Svg>+ );+ case 'scale-linear':+ return (+ <Svg>+ <path d="M2.5 13 L13.5 3" />+ </Svg>+ );+ case 'scale-log':+ return (+ <Svg>+ <path d="M2.5 13 C5 13, 8 4.5, 13.5 3" />+ </Svg>+ );+ case 'interp-linear':+ return (+ <Svg>+ <path d="M2 12 L6 5 L10 9 L14 4" />+ </Svg>+ );+ case 'interp-spline':+ return (+ <Svg>+ <path d="M2 12 C5 3, 9 3, 14 8" />+ </Svg>+ );+ case 'interp-step-before':+ return (+ <Svg>+ <path d="M2 6 H6 V10 H10 V4.5 H14" />+ </Svg>+ );+ case 'interp-step-after':+ return (+ <Svg>+ <path d="M2 10 H6 V5 H10 V9.5 H14" />+ </Svg>+ );+ default:+ return null;+ }+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsxnew file mode 100644index 0000000000..a34ea220d7--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx@@ -0,0 +1,171 @@+import type { ComponentType } from 'react';+import type {+ DashboardLinkDTO,+ DashboardtypesAxesDTO,+ DashboardtypesBarChartVisualizationDTO,+ DashboardtypesHistogramBucketsDTO,+ DashboardtypesLegendDTO,+ DashboardtypesPanelSpecDTO,+ DashboardtypesTimeSeriesChartAppearanceDTO,+} from 'api/generated/services/sigNoz.schemas';+import type {+ AnyThreshold,+ PanelFormattingSlice,+ SectionEditorProps,+ SectionKind,+ SectionSpecMap,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';++import AxesSection from './sections/AxesSection/AxesSection';+import BucketsSection from './sections/BucketsSection/BucketsSection';+import ChartAppearanceSection from './sections/ChartAppearanceSection/ChartAppearanceSection';+import ContextLinksSection from './sections/ContextLinksSection/ContextLinksSection';+import FormattingSection from './sections/FormattingSection/FormattingSection';+import LegendSection from './sections/LegendSection/LegendSection';+import ThresholdsSection from './sections/ThresholdsSection/ThresholdsSection';+import VisualizationSection from './sections/VisualizationSection/VisualizationSection';++type PanelSpec = DashboardtypesPanelSpecDTO;++/**+ * Pairs a section kind with its editor component and a typed lens into the panel spec.+ * The lens reads/writes over the WHOLE panel spec, so a section can target either the+ * plugin spec (`spec.plugin.spec.<key>`) or a panel-level field (e.g. `spec.links`).+ */+export interface SectionDescriptor<K extends SectionKind> {+ Component: ComponentType<SectionEditorProps<K>>;+ get: (spec: PanelSpec) => SectionSpecMap[K] | undefined;+ update: (spec: PanelSpec, value: SectionSpecMap[K]) => PanelSpec;+}++// The plugin spec is a discriminated union over panel kinds; reading/writing a shared+// slice (formatting, axes, …) by key is the one place the union must be narrowed. The+// helper concentrates that cast so the registry entries stay declarative.+type PluginSpecSlice = Partial<Record<string, unknown>>;++function getPluginSlice<T>(spec: PanelSpec, key: string): T | undefined {+ return (spec.plugin.spec as PluginSpecSlice)[key] as T | undefined;+}++function updatePluginSlice(+ spec: PanelSpec,+ key: string,+ value: unknown,+): PanelSpec {+ return {+ ...spec,+ plugin: {+ ...spec.plugin,+ spec: { ...(spec.plugin.spec as PluginSpecSlice), [key]: value },+ },+ } as PanelSpec;+}++/**+ * Registry of section editors. Partial by design: only sections with a built editor+ * appear here, so ConfigPane renders exactly those and silently skips the rest. Adding+ * a section editor = one entry here + one component file.+ */+export const SECTION_REGISTRY: {+ [K in SectionKind]?: SectionDescriptor<K>;+} = {+ formatting: {+ Component: FormattingSection,+ get: (spec): PanelFormattingSlice | undefined =>+ getPluginSlice<PanelFormattingSlice>(spec, 'formatting'),+ update: (spec, formatting): PanelSpec =>+ updatePluginSlice(spec, 'formatting', formatting),+ },+ axes: {+ Component: AxesSection,+ get: (spec): DashboardtypesAxesDTO | undefined =>+ getPluginSlice<DashboardtypesAxesDTO>(spec, 'axes'),+ update: (spec, axes): PanelSpec => updatePluginSlice(spec, 'axes', axes),+ },+ legend: {+ Component: LegendSection,+ get: (spec): DashboardtypesLegendDTO | undefined =>+ getPluginSlice<DashboardtypesLegendDTO>(spec, 'legend'),+ update: (spec, legend): PanelSpec =>+ updatePluginSlice(spec, 'legend', legend),+ },+ chartAppearance: {+ Component: ChartAppearanceSection,+ get: (spec): DashboardtypesTimeSeriesChartAppearanceDTO | undefined =>+ getPluginSlice<DashboardtypesTimeSeriesChartAppearanceDTO>(+ spec,+ 'chartAppearance',+ ),+ update: (spec, chartAppearance): PanelSpec =>+ updatePluginSlice(spec, 'chartAppearance', chartAppearance),+ },+ visualization: {+ Component: VisualizationSection,+ get: (spec): DashboardtypesBarChartVisualizationDTO | undefined =>+ getPluginSlice<DashboardtypesBarChartVisualizationDTO>(+ spec,+ 'visualization',+ ),+ update: (spec, visualization): PanelSpec =>+ updatePluginSlice(spec, 'visualization', visualization),+ },+ buckets: {+ Component: BucketsSection,+ get: (spec): DashboardtypesHistogramBucketsDTO | undefined =>+ getPluginSlice<DashboardtypesHistogramBucketsDTO>(spec, 'histogramBuckets'),+ update: (spec, buckets): PanelSpec =>+ updatePluginSlice(spec, 'histogramBuckets', buckets),+ },+ contextLinks: {+ Component: ContextLinksSection,+ // Panel-level slice (spec.links), not under the plugin spec — no cast needed.+ get: (spec): DashboardLinkDTO[] | undefined => spec.links,+ update: (spec, links): PanelSpec => ({ ...spec, links }),+ },+ // 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: {+ Component: ThresholdsSection,+ get: (spec): AnyThreshold[] | undefined =>+ getPluginSlice<AnyThreshold[]>(spec, 'thresholds'),+ update: (spec, thresholds): PanelSpec =>+ updatePluginSlice(spec, 'thresholds', thresholds),+ },+};++/**+ * A section descriptor with the kind correlation erased. `SECTION_REGISTRY[kind]` and a+ * `SectionConfig` are both unions keyed by the same `kind`, but TS can't prove the lookup+ * and the config refer to the same member — the classic correlated-union limitation. The+ * resolver below narrows once here (the single localized cast), so render sites compose+ * `get` → `Component` → `update` without any further casts.+ */+export interface ErasedSectionDescriptor {+ Component: ComponentType<{+ value: unknown;+ controls?: unknown;+ onChange: (next: unknown) => void;+ // Forwarded to every editor; only sections that need the panel's resolved series+ // (legend colors) read it. Optional so editors can ignore it.+ legendSeries?: unknown;+ // The panel's formatting unit; read by editors that scope to it (thresholds).+ yAxisUnit?: unknown;+ // The Table panel's resolved value columns; read by the table-only editors+ // (column units, per-column thresholds) to offer real columns.+ tableColumns?: unknown;+ // The panel's telemetry signal; read by editors that fetch field-key+ // suggestions scoped to it (List column picker).+ signal?: unknown;+ }>;+ get: (spec: PanelSpec) => unknown;+ update: (spec: PanelSpec, value: unknown) => PanelSpec;+}++export function resolveSectionEditor(+ kind: SectionKind,+): ErasedSectionDescriptor | undefined {+ return SECTION_REGISTRY[kind] as unknown as+ | ErasedSectionDescriptor+ | undefined;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scssnew file mode 100644index 0000000000..b3ee5bffd9--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss@@ -0,0 +1,11 @@+.bounds {+ display: flex;+ gap: 8px;+}++.field {+ display: flex;+ flex: 1;+ flex-direction: column;+ gap: 8px;+}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.tsxnew file mode 100644index 0000000000..290be168fc--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx@@ -0,0 +1,80 @@+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 ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';++import styles from './AxesSection.module.scss';++type SoftBound = 'softMin' | 'softMax';++const SCALE_OPTIONS = [+ { value: 'linear', label: 'Linear', icon: 'scale-linear' as const },+ { value: 'log', label: 'Log', icon: 'scale-log' as const },+];++/**+ * Edits the `axes` slice of a panel spec: soft Y-axis min/max bounds and the+ * linear/logarithmic scale toggle. Each control is gated by its `controls` flag.+ */+function AxesSection({+ value,+ controls,+ onChange,+}: SectionEditorProps<'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 =+ (bound: SoftBound) =>+ (e: ChangeEvent<HTMLInputElement>): void => {+ const raw = e.target.value;+ const next = raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw);+ onChange({ ...value, [bound]: next });+ };++ return (+ <>+ {controls.minMax && (+ <div className={styles.bounds}>+ <div className={styles.field}>+ <Typography.Text>Soft min</Typography.Text>+ <Input+ data-testid="panel-editor-v2-soft-min"+ type="number"+ placeholder="Auto"+ value={value?.softMin ?? ''}+ onChange={handleBound('softMin')}+ />+ </div>+ <div className={styles.field}>+ <Typography.Text>Soft max</Typography.Text>+ <Input+ data-testid="panel-editor-v2-soft-max"+ type="number"+ placeholder="Auto"+ value={value?.softMax ?? ''}+ onChange={handleBound('softMax')}+ />+ </div>+ </div>+ )}++ {controls.logScale && (+ <div className={styles.field}>+ <Typography.Text>Y-axis scale</Typography.Text>+ <ConfigSegmented+ testId="panel-editor-v2-log-scale"+ value={value?.isLogScale ? 'log' : 'linear'}+ items={SCALE_OPTIONS}+ onChange={(next): void =>+ onChange({ ...value, isLogScale: next === 'log' })+ }+ />+ </div>+ )}+ </>+ );+}++export default AxesSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsxnew file mode 100644index 0000000000..ec9bf65c15--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx@@ -0,0 +1,82 @@+import { render, screen, userEvent } from 'tests/test-utils';++import AxesSection from '../AxesSection';++describe('AxesSection', () => {+ it('renders soft bounds and the log-scale switch when both controls are enabled', () => {+ render(+ <AxesSection+ value={undefined}+ controls={{ minMax: true, logScale: true }}+ onChange={jest.fn()}+ />,+ );++ expect(screen.getByTestId('panel-editor-v2-soft-min')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-soft-max')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-log-scale')).toBeInTheDocument();+ });++ it('hides the soft bounds when minMax is off', () => {+ render(+ <AxesSection+ value={undefined}+ controls={{ logScale: true }}+ onChange={jest.fn()}+ />,+ );++ expect(+ screen.queryByTestId('panel-editor-v2-soft-min'),+ ).not.toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-log-scale')).toBeInTheDocument();+ });++ it('writes a numeric soft min through onChange', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <AxesSection+ value={undefined}+ controls={{ minMax: true }}+ onChange={onChange}+ />,+ );++ await user.type(screen.getByTestId('panel-editor-v2-soft-min'), '5');++ expect(onChange).toHaveBeenCalledWith({ softMin: 5 });+ });++ it('clears a soft bound to null when the field is emptied', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <AxesSection+ value={{ softMax: 100 }}+ controls={{ minMax: true }}+ onChange={onChange}+ />,+ );++ await user.clear(screen.getByTestId('panel-editor-v2-soft-max'));++ expect(onChange).toHaveBeenCalledWith({ softMax: null });+ });++ it('toggles the logarithmic scale through onChange', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <AxesSection+ value={{ isLogScale: false }}+ controls={{ logScale: true }}+ onChange={onChange}+ />,+ );++ await user.click(screen.getByText('Log'));++ expect(onChange).toHaveBeenCalledWith({ isLogScale: true });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scssnew file mode 100644index 0000000000..6c02dc4661--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scss@@ -0,0 +1,5 @@+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}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.tsxnew file mode 100644index 0000000000..a73d39d8e3--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx@@ -0,0 +1,80 @@+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 ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';++import styles from './BucketsSection.module.scss';++// The two numeric bounds of the histogram-buckets spec (derived from the BE DTO).+type NumericBound = keyof Pick<+ DashboardtypesHistogramBucketsDTO,+ 'bucketCount' | 'bucketWidth'+>;++/**+ * Edits the `histogramBuckets` slice of a Histogram panel spec: bucket count / width+ * and whether to merge all active queries into one set of buckets. Each control is gated+ * by its `controls` flag.+ */+function BucketsSection({+ value,+ controls,+ onChange,+}: SectionEditorProps<'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 =+ (bound: NumericBound) =>+ (e: ChangeEvent<HTMLInputElement>): void => {+ const raw = e.target.value;+ const next = raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw);+ onChange({ ...value, [bound]: next });+ };++ return (+ <>+ {controls.count && (+ <div className={styles.field}>+ <Typography.Text>Bucket count</Typography.Text>+ <Input+ data-testid="panel-editor-v2-bucket-count"+ type="number"+ placeholder="Auto"+ value={value?.bucketCount ?? ''}+ onChange={handleNumber('bucketCount')}+ />+ </div>+ )}++ {controls.width && (+ <div className={styles.field}>+ <Typography.Text>Bucket width</Typography.Text>+ <Input+ data-testid="panel-editor-v2-bucket-width"+ type="number"+ placeholder="Auto"+ value={value?.bucketWidth ?? ''}+ onChange={handleNumber('bucketWidth')}+ />+ </div>+ )}++ {controls.mergeQueries && (+ <ConfigSwitch+ testId="panel-editor-v2-merge-queries"+ title="Merge active queries"+ description="Bucket all active queries together into one distribution"+ value={value?.mergeAllActiveQueries ?? false}+ onChange={(checked): void =>+ onChange({ ...value, mergeAllActiveQueries: checked })+ }+ />+ )}+ </>+ );+}++export default BucketsSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/__tests__/BucketsSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/__tests__/BucketsSection.test.tsxnew file mode 100644index 0000000000..0d15eb8fd3--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/__tests__/BucketsSection.test.tsx@@ -0,0 +1,41 @@+import { render, screen, userEvent } from 'tests/test-utils';++import BucketsSection from '../BucketsSection';++describe('BucketsSection', () => {+ it('renders only the controls whose flag is set', () => {+ render(+ <BucketsSection+ value={undefined}+ controls={{ count: true }}+ onChange={jest.fn()}+ />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-bucket-count'),+ ).toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-bucket-width'),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-merge-queries'),+ ).not.toBeInTheDocument();+ });++ it('toggles merge-active-queries through onChange', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <BucketsSection+ value={{ mergeAllActiveQueries: false }}+ controls={{ mergeQueries: true }}+ onChange={onChange}+ />,+ );++ await user.click(screen.getByTestId('panel-editor-v2-merge-queries'));++ expect(onChange).toHaveBeenCalledWith({ mergeAllActiveQueries: true });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scssnew file mode 100644index 0000000000..6c02dc4661--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss@@ -0,0 +1,5 @@+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}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.tsxnew file mode 100644index 0000000000..e1608a1506--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx@@ -0,0 +1,164 @@+import type { ChangeEvent } from 'react';+import { Typography } from '@signozhq/ui/typography';+import { Input } from 'antd';+import {+ DashboardtypesFillModeDTO,+ DashboardtypesLineInterpolationDTO,+ DashboardtypesLineStyleDTO,+} from 'api/generated/services/sigNoz.schemas';+import type { SectionEditorProps } 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 styles from './ChartAppearanceSection.module.scss';++const LINE_STYLE_OPTIONS = [+ {+ value: DashboardtypesLineStyleDTO.solid,+ label: 'Solid',+ icon: 'solid-line' as const,+ },+ {+ value: DashboardtypesLineStyleDTO.dashed,+ label: 'Dashed',+ icon: 'dashed-line' as const,+ },+];++const LINE_INTERPOLATION_OPTIONS = [+ {+ value: DashboardtypesLineInterpolationDTO.linear,+ label: 'Linear',+ icon: 'interp-linear' as const,+ },+ {+ value: DashboardtypesLineInterpolationDTO.spline,+ label: 'Spline',+ icon: 'interp-spline' as const,+ },+ {+ value: DashboardtypesLineInterpolationDTO.step_before,+ label: 'Step before',+ icon: 'interp-step-before' as const,+ },+ {+ value: DashboardtypesLineInterpolationDTO.step_after,+ label: 'Step after',+ icon: 'interp-step-after' as const,+ },+];++const FILL_MODE_OPTIONS = [+ {+ value: DashboardtypesFillModeDTO.none,+ label: 'None',+ icon: 'fill-none' as const,+ },+ {+ value: DashboardtypesFillModeDTO.solid,+ label: 'Solid',+ icon: 'fill-solid' as const,+ },+ {+ value: DashboardtypesFillModeDTO.gradient,+ label: 'Gradient',+ icon: 'fill-gradient' as const,+ },+];++/**+ * Edits the `chartAppearance` slice of a TimeSeries panel spec: line style /+ * interpolation, fill mode, point markers, and the connect-null-gaps threshold. Each+ * control is gated by its `controls` flag.+ */+function ChartAppearanceSection({+ value,+ controls,+ onChange,+}: SectionEditorProps<'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 => {+ const raw = e.target.value;+ onChange({+ ...value,+ spanGaps: raw === '' ? undefined : { ...value?.spanGaps, fillLessThan: raw },+ });+ };+ return (+ <>+ {controls.lineStyle && (+ <div className={styles.field}>+ <Typography.Text>Line style</Typography.Text>+ <ConfigSegmented+ testId="panel-editor-v2-line-style"+ value={value?.lineStyle}+ items={LINE_STYLE_OPTIONS}+ onChange={(next): void =>+ onChange({ ...value, lineStyle: next as DashboardtypesLineStyleDTO })+ }+ />+ </div>+ )}++ {controls.lineInterpolation && (+ <div className={styles.field}>+ <Typography.Text>Line interpolation</Typography.Text>+ <ConfigSelect+ testId="panel-editor-v2-line-interpolation"+ placeholder="Select interpolation…"+ value={value?.lineInterpolation}+ items={LINE_INTERPOLATION_OPTIONS}+ onChange={(next): void =>+ onChange({+ ...value,+ lineInterpolation: next as DashboardtypesLineInterpolationDTO,+ })+ }+ />+ </div>+ )}++ {controls.fillMode && (+ <div className={styles.field}>+ <Typography.Text>Fill mode</Typography.Text>+ <ConfigSegmented+ testId="panel-editor-v2-fill-mode"+ value={value?.fillMode}+ items={FILL_MODE_OPTIONS}+ onChange={(next): void =>+ onChange({ ...value, fillMode: next as DashboardtypesFillModeDTO })+ }+ />+ </div>+ )}++ {controls.showPoints && (+ <ConfigSwitch+ testId="panel-editor-v2-show-points"+ title="Show points"+ description="Display individual data points on the chart"+ value={value?.showPoints ?? false}+ onChange={(checked): void => onChange({ ...value, showPoints: checked })}+ />+ )}++ {controls.spanGaps && (+ <div className={styles.field}>+ <Typography.Text>Connect gaps shorter than (s)</Typography.Text>+ <Input+ data-testid="panel-editor-v2-span-gaps"+ type="number"+ placeholder="All gaps"+ value={value?.spanGaps?.fillLessThan ?? ''}+ onChange={handleSpanGaps}+ />+ </div>+ )}+ </>+ );+}++export default ChartAppearanceSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsxnew file mode 100644index 0000000000..61bcd48925--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx@@ -0,0 +1,140 @@+import { fireEvent, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { DashboardtypesLineStyleDTO } from 'api/generated/services/sigNoz.schemas';++import ChartAppearanceSection from '../ChartAppearanceSection';++// Open the antd Select by clicking its selector, then pick the option by label. The+// line-style and fill-mode controls are ConfigSegmented (buttons), so this helper is+// only used for the line-interpolation ConfigSelect.+async function pickOption(triggerTestId: string, label: string): Promise<void> {+ const user = userEvent.setup();+ const trigger = screen.getByTestId(triggerTestId);+ await user.click(trigger.querySelector('.ant-select-selector') as HTMLElement);+ await user.click(await screen.findByRole('option', { name: label }));+}++const ALL_CONTROLS = {+ lineStyle: true,+ lineInterpolation: true,+ fillMode: true,+ showPoints: true,+ spanGaps: true,+};++describe('ChartAppearanceSection', () => {+ it('renders every control that is enabled', () => {+ render(+ <ChartAppearanceSection+ value={undefined}+ controls={ALL_CONTROLS}+ onChange={jest.fn()}+ />,+ );++ expect(screen.getByTestId('panel-editor-v2-line-style')).toBeInTheDocument();+ expect(+ screen.getByTestId('panel-editor-v2-line-interpolation'),+ ).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-fill-mode')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-show-points')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-span-gaps')).toBeInTheDocument();+ });++ it('renders only the controls whose flag is set', () => {+ render(+ <ChartAppearanceSection+ value={undefined}+ controls={{ lineStyle: true, fillMode: true }}+ onChange={jest.fn()}+ />,+ );++ expect(screen.getByTestId('panel-editor-v2-line-style')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-fill-mode')).toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-line-interpolation'),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-show-points'),+ ).not.toBeInTheDocument();+ });++ it('writes the chosen fill mode through the segmented control', () => {+ const onChange = jest.fn();+ render(+ <ChartAppearanceSection+ value={{ lineStyle: DashboardtypesLineStyleDTO.solid }}+ controls={{ fillMode: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByText('Gradient'));++ expect(onChange).toHaveBeenCalledWith({+ lineStyle: 'solid',+ fillMode: 'gradient',+ });+ });++ it('writes the chosen line interpolation through the dropdown', async () => {+ const onChange = jest.fn();+ render(+ <ChartAppearanceSection+ value={undefined}+ controls={{ lineInterpolation: true }}+ onChange={onChange}+ />,+ );++ await pickOption('panel-editor-v2-line-interpolation', 'Spline');++ expect(onChange).toHaveBeenCalledWith({ lineInterpolation: 'spline' });+ });++ it('toggles show points through onChange', () => {+ const onChange = jest.fn();+ render(+ <ChartAppearanceSection+ value={{ showPoints: false }}+ controls={{ showPoints: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByTestId('panel-editor-v2-show-points'));++ expect(onChange).toHaveBeenCalledWith({ showPoints: true });+ });++ it('writes a span-gaps threshold and clears it when emptied', () => {+ const onChange = jest.fn();+ const { rerender } = render(+ <ChartAppearanceSection+ value={undefined}+ controls={{ spanGaps: true }}+ onChange={onChange}+ />,+ );++ fireEvent.change(screen.getByTestId('panel-editor-v2-span-gaps'), {+ target: { value: '60' },+ });+ expect(onChange).toHaveBeenLastCalledWith({+ spanGaps: { fillLessThan: '60' },+ });++ rerender(+ <ChartAppearanceSection+ value={{ spanGaps: { fillLessThan: '60' } }}+ controls={{ spanGaps: true }}+ onChange={onChange}+ />,+ );+ fireEvent.change(screen.getByTestId('panel-editor-v2-span-gaps'), {+ target: { value: '' },+ });+ expect(onChange).toHaveBeenLastCalledWith({ spanGaps: undefined });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scssnew file mode 100644index 0000000000..9556886e12--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss@@ -0,0 +1,32 @@+.list {+ display: flex;+ flex-direction: column;+ gap: 12px;+}++.row {+ display: flex;+ flex-direction: column;+ gap: 8px;+ padding: 10px;+ border: 1px solid var(--l2-border);+ border-radius: 6px;+}++.rowFooter {+ display: flex;+ align-items: center;+ justify-content: space-between;+}++.newTab {+ display: flex;+ align-items: center;+ gap: 8px;+ cursor: pointer;+}++.newTabLabel {+ font-size: 12px;+ color: var(--text-vanilla-400);+}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.tsxnew file mode 100644index 0000000000..fa2970b4e2--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx@@ -0,0 +1,94 @@+import { Plus, Trash2 } from '@signozhq/icons';+import { Button } from '@signozhq/ui/button';+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 styles from './ContextLinksSection.module.scss';++/**+ * Edits the panel's context links (`spec.links`): a list of label + URL rows with an+ * "open in new tab" toggle, plus add/remove. Atomic section — no per-kind sub-controls.+ * URLs may reference dashboard/query variables; that interpolation is resolved at render+ * time, so this editor just captures the raw strings.+ */+function ContextLinksSection({+ value,+ onChange,+}: SectionEditorProps<'contextLinks'>): JSX.Element {+ const links = value ?? [];++ const updateAt = (index: number, patch: Partial<DashboardLinkDTO>): void =>+ onChange(+ links.map((link, i) => (i === index ? { ...link, ...patch } : link)),+ );++ const addLink = (): void =>+ onChange([...links, { name: '', url: '', targetBlank: true }]);++ const removeAt = (index: number): void =>+ onChange(links.filter((_, i) => i !== index));++ return (+ <div className={styles.list}>+ {links.map((link, index) => (+ // Links have no stable id on the wire; index is the row identity here.+ // eslint-disable-next-line react/no-array-index-key+ <div className={styles.row} key={index}>+ <Input+ data-testid={`context-link-label-${index}`}+ placeholder="Label"+ value={link.name ?? ''}+ onChange={(e): void => updateAt(index, { name: e.target.value })}+ />+ <Input+ data-testid={`context-link-url-${index}`}+ placeholder="https://… or /path?var=$variable"+ value={link.url ?? ''}+ onChange={(e): void => updateAt(index, { url: e.target.value })}+ />+ <div className={styles.rowFooter}>+ <div className={styles.newTab}>+ <Switch+ testId={`context-link-newtab-${index}`}+ value={link.targetBlank ?? false}+ onChange={(checked: boolean): void =>+ updateAt(index, { targetBlank: checked })+ }+ />+ <Typography.Text className={styles.newTabLabel}>+ Open in new tab+ </Typography.Text>+ </div>+ <Button+ type="button"+ variant="ghost"+ color="destructive"+ size="icon"+ aria-label={`Remove link ${index + 1}`}+ data-testid={`context-link-remove-${index}`}+ onClick={(): void => removeAt(index)}+ >+ <Trash2 size={14} />+ </Button>+ </div>+ </div>+ ))}++ <Button+ type="button"+ variant="dashed"+ color="secondary"+ prefix={<Plus size={14} />}+ data-testid="panel-editor-v2-add-link"+ onClick={addLink}+ >+ Add link+ </Button>+ </div>+ );+}++export default ContextLinksSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/__tests__/ContextLinksSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/__tests__/ContextLinksSection.test.tsxnew file mode 100644index 0000000000..be2f15e1fb--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/__tests__/ContextLinksSection.test.tsx@@ -0,0 +1,54 @@+import { fireEvent, render, screen } from '@testing-library/react';+import type { DashboardLinkDTO } from 'api/generated/services/sigNoz.schemas';++import ContextLinksSection from '../ContextLinksSection';++const LINKS: DashboardLinkDTO[] = [+ { name: 'Docs', url: 'https://signoz.io', targetBlank: true },+];++describe('ContextLinksSection', () => {+ it('renders only the add button when there are no links', () => {+ render(<ContextLinksSection value={undefined} onChange={jest.fn()} />);++ expect(screen.getByTestId('panel-editor-v2-add-link')).toBeInTheDocument();+ expect(screen.queryByTestId('context-link-label-0')).not.toBeInTheDocument();+ });++ it('appends a blank link (open-in-new-tab on) when Add link is clicked', () => {+ const onChange = jest.fn();+ render(<ContextLinksSection value={[]} onChange={onChange} />);++ fireEvent.click(screen.getByTestId('panel-editor-v2-add-link'));++ expect(onChange).toHaveBeenCalledWith([+ { name: '', url: '', targetBlank: true },+ ]);+ });++ it('renders existing links and edits a label through onChange', () => {+ const onChange = jest.fn();+ render(<ContextLinksSection value={LINKS} onChange={onChange} />);++ expect(screen.getByTestId('context-link-label-0')).toHaveValue('Docs');+ expect(screen.getByTestId('context-link-url-0')).toHaveValue(+ 'https://signoz.io',+ );++ fireEvent.change(screen.getByTestId('context-link-label-0'), {+ target: { value: 'Runbook' },+ });+ expect(onChange).toHaveBeenCalledWith([+ { name: 'Runbook', url: 'https://signoz.io', targetBlank: true },+ ]);+ });++ it('removes a link through onChange', () => {+ const onChange = jest.fn();+ render(<ContextLinksSection value={LINKS} onChange={onChange} />);++ fireEvent.click(screen.getByTestId('context-link-remove-0'));++ expect(onChange).toHaveBeenCalledWith([]);+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsxnew file mode 100644index 0000000000..8b6b9a7f1a--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx@@ -0,0 +1,65 @@+import { Typography } from '@signozhq/ui/typography';+import YAxisUnitSelector from 'components/YAxisUnitSelector';+import { YAxisSource } from 'components/YAxisUnitSelector/types';++import type { TableColumnOption } from '../../../hooks/useTableColumns';++import styles from './FormattingSection.module.scss';++interface ColumnUnitsProps {+ /** Resolved value columns of the panel's current table result. */+ columns: TableColumnOption[];+ /** Current per-column unit map (`formatting.columnUnits`), keyed by column key. */+ value: Record<string, string>;+ onChange: (next: Record<string, string>) => void;+}++/**+ * Per-column unit picker for Table panels: one unit selector per resolved value+ * column, writing `{ [columnKey]: unitId }` keyed by the query identifier (V1+ * parity). Clearing a column's unit drops its entry. Until the panel produces+ * columns, shows a hint.+ */+function ColumnUnits({+ columns,+ value,+ onChange,+}: ColumnUnitsProps): JSX.Element {+ if (columns.length === 0) {+ return (+ <Typography.Text className={styles.columnUnitsHint}>+ Run the panel to set per-column units.+ </Typography.Text>+ );+ }++ const setUnit = (columnKey: string, unit: string | undefined): void => {+ const next = { ...value };+ if (unit) {+ next[columnKey] = unit;+ } else {+ delete next[columnKey];+ }+ onChange(next);+ };++ return (+ <div className={styles.columnUnits}>+ {columns.map((column) => (+ <div className={styles.columnField} key={column.key}>+ <Typography.Text>{column.label}</Typography.Text>+ <YAxisUnitSelector+ data-testid={`panel-editor-v2-column-unit-${column.key}`}+ placeholder="Select unit"+ source={YAxisSource.DASHBOARDS}+ value={value[column.key]}+ containerClassName={styles.columnUnitSelector}+ onChange={(unit): void => setUnit(column.key, unit)}+ />+ </div>+ ))}+ </div>+ );+}++export default ColumnUnits;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scssnew file mode 100644index 0000000000..cd235ddf9a--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss@@ -0,0 +1,37 @@+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}++.unitSelector {+ :global(.ant-select) {+ width: 100%;+ }+}++// Stacked per-column unit pickers; each column keeps the standard field layout.+.columnUnits {+ display: flex;+ flex-direction: column;+ gap: 12px;++ :global(.ant-select) {+ width: 100%;+ }+}++.columnUnitsHint {+ font-size: 12px;+ color: var(--l2-foreground);+}++.columnField {+ display: flex;+ flex-direction: row;+ align-items: center;+ gap: 16px;+}+.columnUnitSelector {+ flex: 1;+}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.tsxnew file mode 100644index 0000000000..8de2187ab3--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx@@ -0,0 +1,89 @@+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 { TableColumnOption } from '../../../hooks/useTableColumns';+import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';+import ColumnUnits from './ColumnUnits';++import styles from './FormattingSection.module.scss';++type FormattingSectionProps = SectionEditorProps<'formatting'> & {+ /** Table panel's resolved value columns; required for the column-units editor. */+ tableColumns?: TableColumnOption[];+};++// `full` means "show the raw value, no rounding"; the digits round to that many places.+const DECIMAL_OPTIONS: {+ value: DashboardtypesPrecisionOptionDTO;+ label: string;+}[] = [+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_0, label: '0 decimals' },+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_1, label: '1 decimal' },+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_2, label: '2 decimals' },+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_3, label: '3 decimals' },+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_4, label: '4 decimals' },+ { value: DashboardtypesPrecisionOptionDTO.full, label: 'Full' },+];++/**+ * Edits the `formatting` slice of a panel spec (unit + decimal precision). Which+ * controls show is driven by the per-kind `controls` flags; the spec slice itself+ * is uniform across every kind that declares the Formatting section.+ */+function FormattingSection({+ value,+ controls,+ onChange,+ tableColumns = [],+}: FormattingSectionProps): JSX.Element {+ return (+ <>+ {controls.unit && (+ <div className={styles.field}>+ <Typography.Text>Unit</Typography.Text>+ <YAxisUnitSelector+ containerClassName={styles.unitSelector}+ data-testid="panel-editor-v2-unit"+ source={YAxisSource.DASHBOARDS}+ value={value?.unit}+ onChange={(unit): void => onChange({ ...value, unit })}+ />+ </div>+ )}++ {controls.decimals && (+ <div className={styles.field}>+ <Typography.Text>Decimals</Typography.Text>+ <ConfigSelect+ testId="panel-editor-v2-decimals"+ placeholder="Select decimals…"+ value={value?.decimalPrecision}+ items={DECIMAL_OPTIONS}+ onChange={(next): void =>+ onChange({+ ...value,+ decimalPrecision: next as DashboardtypesPrecisionOptionDTO,+ })+ }+ />+ </div>+ )}++ {controls.columnUnits && (+ <div className={styles.field}>+ <Typography.Text>Column units</Typography.Text>+ <ColumnUnits+ columns={tableColumns}+ value={value?.columnUnits ?? {}}+ onChange={(columnUnits): void => onChange({ ...value, columnUnits })}+ />+ </div>+ )}+ </>+ );+}++export default FormattingSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsxnew file mode 100644index 0000000000..710d25a598--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx@@ -0,0 +1,74 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';++import FormattingSection from '../FormattingSection';++// Open the Decimals select (clicking its antd selector) and pick the option with the+// given visible label.+async function pickDecimal(label: string): Promise<void> {+ const user = userEvent.setup();+ const trigger = screen.getByTestId('panel-editor-v2-decimals');+ await user.click(trigger.querySelector('.ant-select-selector') as HTMLElement);+ await user.click(await screen.findByRole('option', { name: label }));+}++describe('FormattingSection', () => {+ it('renders Unit and Decimals when both controls are enabled', () => {+ render(+ <FormattingSection+ value={undefined}+ controls={{ unit: true, decimals: true }}+ onChange={jest.fn()}+ />,+ );++ expect(screen.getByTestId('panel-editor-v2-unit')).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-decimals')).toBeInTheDocument();+ });++ it('hides a control when its flag is off', () => {+ render(+ <FormattingSection+ value={undefined}+ controls={{ decimals: true }}+ onChange={jest.fn()}+ />,+ );++ expect(screen.queryByTestId('panel-editor-v2-unit')).not.toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-decimals')).toBeInTheDocument();+ });++ it('writes the chosen decimal precision through onChange', async () => {+ const onChange = jest.fn();+ render(+ <FormattingSection+ value={undefined}+ controls={{ decimals: true }}+ onChange={onChange}+ />,+ );++ await pickDecimal('Full');++ expect(onChange).toHaveBeenCalledWith({ decimalPrecision: 'full' });+ });++ it('merges the edit into the existing formatting slice', async () => {+ const onChange = jest.fn();+ render(+ <FormattingSection+ value={{ unit: 'bytes' }}+ controls={{ decimals: true }}+ onChange={onChange}+ />,+ );++ await pickDecimal('2 decimals');++ expect(onChange).toHaveBeenCalledWith({+ unit: 'bytes',+ decimalPrecision: '2',+ });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scssnew file mode 100644index 0000000000..6c02dc4661--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scss@@ -0,0 +1,5 @@+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}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.tsxnew file mode 100644index 0000000000..d5b51da221--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx@@ -0,0 +1,73 @@+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 ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';+import LegendColors from '../../controls/LegendColors/LegendColors';+import type { LegendSeries } from '../../../hooks/useLegendSeries';++import styles from './LegendSection.module.scss';++type LegendSectionProps = SectionEditorProps<'legend'> & {+ /** Panel's resolved series, forwarded by SectionSlot for the colors control. */+ legendSeries?: LegendSeries[];+};++const POSITION_OPTIONS = [+ {+ value: DashboardtypesLegendPositionDTO.bottom,+ label: 'Bottom',+ icon: 'pos-bottom' as const,+ },+ {+ value: DashboardtypesLegendPositionDTO.right,+ label: 'Right',+ icon: 'pos-right' as const,+ },+];++/**+ * Edits the `legend` slice of a panel spec: legend position and per-series color+ * overrides. The colors control reads the panel's resolved series from context (the+ * shared preview query) and writes `customColors` keyed by series label.+ */+function LegendSection({+ value,+ controls,+ onChange,+ legendSeries,+}: LegendSectionProps): JSX.Element {+ return (+ <>+ {controls.position && (+ <div className={styles.field}>+ <Typography.Text>Position</Typography.Text>+ <ConfigSegmented+ testId="panel-editor-v2-legend-position"+ items={POSITION_OPTIONS}+ value={value?.position}+ onChange={(next): void =>+ onChange({+ ...value,+ position: next as DashboardtypesLegendPositionDTO,+ })+ }+ />+ </div>+ )}++ {controls.colors && (+ <div className={styles.field}>+ <Typography.Text>Series colors</Typography.Text>+ <LegendColors+ series={legendSeries ?? []}+ value={value?.customColors}+ onChange={(customColors): void => onChange({ ...value, customColors })}+ />+ </div>+ )}+ </>+ );+}++export default LegendSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsxnew file mode 100644index 0000000000..4e61951ca5--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx@@ -0,0 +1,68 @@+import { fireEvent, render, screen } from '@testing-library/react';+import { DashboardtypesLegendPositionDTO } from 'api/generated/services/sigNoz.schemas';++import LegendSection from '../LegendSection';++describe('LegendSection', () => {+ it('renders the position toggle with both options when position is enabled', () => {+ render(+ <LegendSection+ value={undefined}+ controls={{ position: true }}+ onChange={jest.fn()}+ />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-legend-position'),+ ).toBeInTheDocument();+ expect(screen.getByText('Bottom')).toBeInTheDocument();+ expect(screen.getByText('Right')).toBeInTheDocument();+ });++ it('renders nothing when position is not enabled', () => {+ render(+ <LegendSection value={undefined} controls={{}} onChange={jest.fn()} />,+ );++ expect(+ screen.queryByTestId('panel-editor-v2-legend-position'),+ ).not.toBeInTheDocument();+ });++ it('writes the chosen position through onChange', () => {+ const onChange = jest.fn();+ render(+ <LegendSection+ value={{ position: undefined }}+ controls={{ position: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByText('Right'));++ expect(onChange).toHaveBeenCalledWith({ position: 'right' });+ });++ it('preserves other legend fields when changing position', () => {+ const onChange = jest.fn();+ render(+ <LegendSection+ value={{+ position: DashboardtypesLegendPositionDTO.bottom,+ customColors: { a: '#fff' },+ }}+ controls={{ position: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByText('Right'));++ expect(onChange).toHaveBeenCalledWith({+ position: 'right',+ customColors: { a: '#fff' },+ });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsxnew file mode 100644index 0000000000..685f920e67--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsx@@ -0,0 +1,50 @@+import { ChevronDown } from '@signozhq/icons';+import { ColorPicker } from 'antd';++import styles from './ThresholdsSection.module.scss';++interface ThresholdColorSelectProps {+ value: string;+ testId?: string;+ onChange: (hex: string) => void;+}++// Named presets from the SigNoz palette (cherry / amber / forest / robin). They surface+// as quick swatches in the picker; the full picker below covers any custom color.+const PRESETS: { label: string; value: string }[] = [+ { label: 'Red', value: '#F1575F' },+ { label: 'Orange', value: '#F5B225' },+ { label: 'Green', value: '#2BB673' },+ { label: 'Blue', value: '#4E74F8' },+];++/**+ * Threshold color control: an antd ColorPicker with the palette presets plus a full+ * custom picker, in a single popover (so moving from the trigger into the picker never+ * dismisses it). The trigger shows the current swatch and its preset name, or "Custom".+ */+function ThresholdColorSelect({+ value,+ testId,+ onChange,+}: ThresholdColorSelectProps): JSX.Element {+ const current = PRESETS.find(+ (p) => p.value.toLowerCase() === value?.toLowerCase(),+ );++ return (+ <ColorPicker+ value={value}+ onChangeComplete={(c): void => onChange(c.toHexString())}+ presets={[{ label: 'Defaults', colors: PRESETS.map((p) => p.value) }]}+ >+ <button type="button" className={styles.colorTrigger} data-testid={testId}>+ <span className={styles.dot} style={{ backgroundColor: value }} />+ <span className={styles.colorLabel}>{current?.label ?? 'Custom'}</span>+ <ChevronDown size={13} />+ </button>+ </ColorPicker>+ );+}++export default ThresholdColorSelect;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scssnew file mode 100644index 0000000000..5674ef6388--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss@@ -0,0 +1,104 @@+.list {+ display: flex;+ flex-direction: column;+ gap: 8px;+}++// ── View mode: compact summary row ──────────────────────────────────────────+.viewRow {+ display: flex;+ align-items: center;+ gap: 8px;+ height: 40px;+ padding: 0 4px 0 10px;+ border: 1px solid var(--l2-border);+ background-color: var(--l2-background);+ border-radius: 6px;+}++.viewValue {+ flex: none;+ font-size: 13px;+ font-weight: 500;+ color: var(--text-vanilla-100);+}++.viewLabel {+ overflow: hidden;+ font-size: 12px;+ color: var(--text-vanilla-400);+ white-space: nowrap;+ text-overflow: ellipsis;+}++.spacer {+ flex: 1;+}++// ── Edit mode: labelled form ────────────────────────────────────────────────+.editRow {+ display: flex;+ flex-direction: column;+ gap: 12px;+ padding: 12px;+ background-color: var(--l2-background);+ border: 1px solid var(--bg-robin-400);+ border-radius: 6px;+}++.field {+ display: flex;+ flex-direction: column;+ gap: 6px;+}++.fieldLabel {+ font-size: 12px;+ color: var(--text-vanilla-400);+}++.actions {+ display: flex;+ justify-content: flex-end;+ gap: 8px;+}++// ── Shared ──────────────────────────────────────────────────────────────────+.dot {+ width: 12px;+ height: 12px;+ flex: none;+ border-radius: 50%;+}++.colorTrigger {+ display: flex;+ align-items: center;+ gap: 6px;+ width: 100%;+ height: 36px;+ padding: 0 10px;+ border: 1px solid var(--l2-border);+ border-radius: 4px;+ background: transparent;+ color: var(--text-vanilla-100);+ cursor: pointer;+}++.colorLabel {+ flex: 1;+ font-size: 13px;+ text-align: left;+}++// Match Formatting: make the YAxisUnitSelector fill the row width.+.unitSelector {+ :global(.ant-select) {+ width: 100%;+ }+}++.invalidUnit {+ font-size: 11px;+ color: var(--bg-cherry-400);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsxnew file mode 100644index 0000000000..cec66cfba3--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx@@ -0,0 +1,181 @@+import { useState } from 'react';+import { Plus } from '@signozhq/icons';+import { Button } from '@signozhq/ui/button';+import {+ DashboardtypesComparisonOperatorDTO,+ type DashboardtypesComparisonThresholdDTO,+ type DashboardtypesTableThresholdDTO,+ DashboardtypesThresholdFormatDTO,+ type DashboardtypesThresholdWithLabelDTO,+} from 'api/generated/services/sigNoz.schemas';+import type {+ AnyThreshold,+ ThresholdVariant,+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';++import type { TableColumnOption } from '../../../hooks/useTableColumns';+import ComparisonThresholdRow from './rows/ComparisonThresholdRow';+import LabelThresholdRow from './rows/LabelThresholdRow';+import TableThresholdRow from './rows/TableThresholdRow';++import styles from './ThresholdsSection.module.scss';++// New thresholds default to red (the first palette preset); the user recolors per rule.+const DEFAULT_THRESHOLD_COLOR = '#F1575F';++// Add-button testId per variant — kept stable so existing E2E/unit selectors hold.+const ADD_TESTID: Record<ThresholdVariant, string> = {+ label: 'panel-editor-v2-add-threshold',+ comparison: 'panel-editor-v2-add-comparison-threshold',+ table: 'panel-editor-v2-add-table-threshold',+};++// Seed for a freshly-added row, in the shape the variant's editor + spec expect.+function defaultThreshold(+ variant: ThresholdVariant,+ tableColumns: TableColumnOption[],+): AnyThreshold {+ switch (variant) {+ case 'comparison':+ return {+ value: 0,+ color: DEFAULT_THRESHOLD_COLOR,+ operator: DashboardtypesComparisonOperatorDTO.above,+ format: DashboardtypesThresholdFormatDTO.text,+ };+ case 'table':+ return {+ columnName: tableColumns[0]?.key ?? '',+ value: 0,+ color: DEFAULT_THRESHOLD_COLOR,+ operator: DashboardtypesComparisonOperatorDTO.above,+ format: DashboardtypesThresholdFormatDTO.background,+ };+ default:+ return { value: 0, color: DEFAULT_THRESHOLD_COLOR, label: '' };+ }+}++type ThresholdsSectionProps = {+ value: AnyThreshold[] | undefined;+ /** `variant` picks the row editor + element shape; defaults to `label`. */+ controls?: { variant?: ThresholdVariant };+ onChange: (next: AnyThreshold[]) => void;+ /** Panel formatting unit; scopes each row's unit picker to its category (V1 parity). */+ yAxisUnit?: string;+ /** Table panel's resolved value columns (table variant only). */+ tableColumns?: TableColumnOption[];+};++/**+ * Edits the `thresholds` slice for every panel kind. All variants share the same+ * list mechanics (one row edits at a time; a freshly-added row opens in edit mode and+ * is removed if discarded before saving) and differ only in the row editor, picked by+ * `controls.variant`: `label` (TimeSeries/Bar), `comparison` (Number), `table` (Table).+ */+function ThresholdsSection({+ value,+ controls,+ onChange,+ yAxisUnit,+ tableColumns = [],+}: ThresholdsSectionProps): JSX.Element {+ const variant = controls?.variant ?? 'label';+ const thresholds = value ?? [];+ // Which row is being edited, and whether it was just added (so Discard removes it).+ const [editingIndex, setEditingIndex] = useState<number | null>(null);+ const [unsavedIndex, setUnsavedIndex] = useState<number | null>(null);++ const addThreshold = (): void => {+ const nextIndex = thresholds.length;+ onChange([...thresholds, defaultThreshold(variant, tableColumns)]);+ setEditingIndex(nextIndex);+ setUnsavedIndex(nextIndex);+ };++ const saveAt =+ (index: number) =>+ (next: AnyThreshold): void => {+ onChange(thresholds.map((t, i) => (i === index ? next : t)));+ setEditingIndex(null);+ setUnsavedIndex(null);+ };++ const removeAt = (index: number): void => {+ onChange(thresholds.filter((_, i) => i !== index));+ setEditingIndex(null);+ setUnsavedIndex(null);+ };++ const discardAt = (index: number) => (): void => {+ // Discarding a row that was never saved removes it; otherwise just exit edit.+ if (index === unsavedIndex) {+ removeAt(index);+ return;+ }+ setEditingIndex(null);+ };++ const renderRow = (threshold: AnyThreshold, index: number): JSX.Element => {+ // Shared row controls; the threshold value is narrowed per variant at this+ // branch boundary — the slice only ever holds the active variant's shape.+ const common = {+ index,+ yAxisUnit,+ isEditing: editingIndex === index,+ onEdit: (): void => setEditingIndex(index),+ onSave: saveAt(index),+ onDiscard: discardAt(index),+ onRemove: (): void => removeAt(index),+ };++ if (variant === 'comparison') {+ return (+ <ComparisonThresholdRow+ // eslint-disable-next-line react/no-array-index-key+ key={index}+ threshold={threshold as DashboardtypesComparisonThresholdDTO}+ {...common}+ />+ );+ }+ if (variant === 'table') {+ return (+ <TableThresholdRow+ // eslint-disable-next-line react/no-array-index-key+ key={index}+ threshold={threshold as DashboardtypesTableThresholdDTO}+ tableColumns={tableColumns}+ {...common}+ />+ );+ }+ return (+ <LabelThresholdRow+ // eslint-disable-next-line react/no-array-index-key+ key={index}+ threshold={threshold as DashboardtypesThresholdWithLabelDTO}+ {...common}+ />+ );+ };++ return (+ <div className={styles.list}>+ {thresholds.map(renderRow)}++ <Button+ type="button"+ variant="dashed"+ color="secondary"+ prefix={<Plus size={14} />}+ data-testid={ADD_TESTID[variant]}+ onClick={addThreshold}+ >+ Add threshold+ </Button>+ </div>+ );+}++export default ThresholdsSection;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsxnew file mode 100644index 0000000000..9102e3f532--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx@@ -0,0 +1,202 @@+import { useState } from 'react';+import {+ DashboardtypesComparisonOperatorDTO,+ type DashboardtypesComparisonThresholdDTO,+ DashboardtypesThresholdFormatDTO,+} from 'api/generated/services/sigNoz.schemas';+import type { AnyThreshold } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import { render, screen, userEvent } from 'tests/test-utils';++import UnifiedThresholdsSection from '../ThresholdsSection';++// The comparison editor is the unified ThresholdsSection in its `comparison` variant;+// this wrapper pins the variant so the suite reads as the comparison editor's spec.+function ComparisonThresholdsSection(props: {+ value: DashboardtypesComparisonThresholdDTO[] | undefined;+ onChange: (next: DashboardtypesComparisonThresholdDTO[]) => void;+ yAxisUnit?: string;+}): JSX.Element {+ return (+ <UnifiedThresholdsSection+ value={props.value}+ onChange={props.onChange as (next: AnyThreshold[]) => void}+ yAxisUnit={props.yAxisUnit}+ controls={{ variant: 'comparison' }}+ />+ );+}++const THRESHOLDS: DashboardtypesComparisonThresholdDTO[] = [+ {+ value: 80,+ color: '#F5B225',+ operator: DashboardtypesComparisonOperatorDTO.above,+ unit: 'percent',+ format: DashboardtypesThresholdFormatDTO.background,+ },+];++// Stateful harness for flows that depend on the value updating (add/discard).+function Harness({ yAxisUnit }: { yAxisUnit?: string }): JSX.Element {+ const [value, setValue] = useState<DashboardtypesComparisonThresholdDTO[]>([]);+ return (+ <ComparisonThresholdsSection+ value={value}+ onChange={setValue}+ yAxisUnit={yAxisUnit}+ />+ );+}++describe('ComparisonThresholdsSection', () => {+ it('renders only the add button when there are no thresholds', () => {+ render(+ <ComparisonThresholdsSection value={undefined} onChange={jest.fn()} />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-add-comparison-threshold'),+ ).toBeInTheDocument();+ expect(+ screen.queryByTestId('comparison-threshold-edit-0'),+ ).not.toBeInTheDocument();+ });++ it('shows an existing threshold in view mode (no form until Edit)', () => {+ render(+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={jest.fn()} />,+ );++ expect(screen.getByTestId('comparison-threshold-edit-0')).toBeInTheDocument();+ // Operator symbol + value render in the summary.+ expect(screen.getByText(/> 80/)).toBeInTheDocument();+ // The editable fields are hidden until the row is edited.+ expect(+ screen.queryByTestId('comparison-threshold-value-0'),+ ).not.toBeInTheDocument();+ });++ it('formats the view-mode value through its unit (e.g. currency symbol)', () => {+ render(+ <ComparisonThresholdsSection+ value={[+ {+ value: 3100,+ color: '#F5B225',+ operator: DashboardtypesComparisonOperatorDTO.below,+ unit: 'currencyUSD',+ },+ ]}+ onChange={jest.fn()}+ />,+ );++ const row = screen.getByTestId('comparison-threshold-edit-0').closest('div');+ // Unit-aware: shows the currency symbol, never the raw unit id.+ expect(row).toHaveTextContent('$');+ expect(row).not.toHaveTextContent('currencyUSD');+ });++ it('edits a threshold value and commits it on Save', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={onChange} />,+ );++ await user.click(screen.getByTestId('comparison-threshold-edit-0'));+ const valueInput = screen.getByTestId('comparison-threshold-value-0');+ expect(valueInput).toHaveValue(80);++ await user.clear(valueInput);+ await user.type(valueInput, '90');+ await user.click(screen.getByTestId('comparison-threshold-save-0'));++ expect(onChange).toHaveBeenCalledWith([+ {+ value: 90,+ color: '#F5B225',+ operator: DashboardtypesComparisonOperatorDTO.above,+ unit: 'percent',+ format: DashboardtypesThresholdFormatDTO.background,+ },+ ]);+ });++ it('does not commit edits when Discard is clicked', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={onChange} />,+ );++ await user.click(screen.getByTestId('comparison-threshold-edit-0'));+ await user.clear(screen.getByTestId('comparison-threshold-value-0'));+ await user.type(screen.getByTestId('comparison-threshold-value-0'), '90');+ await user.click(screen.getByTestId('comparison-threshold-discard-0'));++ expect(onChange).not.toHaveBeenCalled();+ // Back to view mode.+ expect(+ screen.queryByTestId('comparison-threshold-value-0'),+ ).not.toBeInTheDocument();+ expect(screen.getByTestId('comparison-threshold-edit-0')).toBeInTheDocument();+ });++ it('removes a threshold from view mode', async () => {+ const user = userEvent.setup();+ const onChange = jest.fn();+ render(+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={onChange} />,+ );++ await user.click(screen.getByTestId('comparison-threshold-remove-0'));++ expect(onChange).toHaveBeenCalledWith([]);+ });++ it('adds a threshold that opens in edit mode, and discards it away', async () => {+ const user = userEvent.setup();+ render(<Harness />);++ await user.click(+ screen.getByTestId('panel-editor-v2-add-comparison-threshold'),+ );+ // New row opens in edit mode.+ expect(+ screen.getByTestId('comparison-threshold-value-0'),+ ).toBeInTheDocument();++ await user.click(screen.getByTestId('comparison-threshold-discard-0'));+ // Discarding a never-saved row removes it entirely.+ expect(+ screen.queryByTestId('comparison-threshold-value-0'),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId('comparison-threshold-edit-0'),+ ).not.toBeInTheDocument();+ });++ it('flags a threshold unit in a different category than the y-axis unit', async () => {+ const user = userEvent.setup();+ render(+ <ComparisonThresholdsSection+ value={[+ {+ value: 80,+ color: '#F5B225',+ operator: DashboardtypesComparisonOperatorDTO.above,+ unit: 'ms',+ },+ ]}+ yAxisUnit="bytes"+ onChange={jest.fn()}+ />,+ );++ await user.click(screen.getByTestId('comparison-threshold-edit-0'));+ expect(+ screen.getByTestId('comparison-threshold-unit-invalid-0'),+ ).toBeInTheDocument();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsxnew file mode 100644index 0000000000..ceb43c4eae--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx@@ -0,0 +1,122 @@+import { useState } from 'react';+import { fireEvent, render, screen } from '@testing-library/react';+import type { DashboardtypesThresholdWithLabelDTO } from 'api/generated/services/sigNoz.schemas';+import type { AnyThreshold } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';++import ThresholdsSection from '../ThresholdsSection';++const THRESHOLDS: DashboardtypesThresholdWithLabelDTO[] = [+ { value: 80, color: '#F5B225', label: 'High', unit: 'percent' },+];++// Stateful harness for flows that depend on the value updating (add/discard). No+// `controls` is passed, exercising the default `label` variant.+function Harness({ yAxisUnit }: { yAxisUnit?: string }): JSX.Element {+ const [value, setValue] = useState<AnyThreshold[]>([]);+ return (+ <ThresholdsSection value={value} onChange={setValue} yAxisUnit={yAxisUnit} />+ );+}++describe('ThresholdsSection', () => {+ it('renders only the add button when there are no thresholds', () => {+ render(<ThresholdsSection value={undefined} onChange={jest.fn()} />);++ expect(+ screen.getByTestId('panel-editor-v2-add-threshold'),+ ).toBeInTheDocument();+ expect(screen.queryByTestId('threshold-edit-0')).not.toBeInTheDocument();+ });++ it('shows an existing threshold in view mode (no form until Edit)', () => {+ render(<ThresholdsSection value={THRESHOLDS} onChange={jest.fn()} />);++ expect(screen.getByTestId('threshold-edit-0')).toBeInTheDocument();+ expect(screen.getByText('High')).toBeInTheDocument();+ // The editable fields are hidden until the row is edited.+ expect(screen.queryByTestId('threshold-value-0')).not.toBeInTheDocument();+ });++ it('edits a threshold value and commits it on Save', () => {+ const onChange = jest.fn();+ render(<ThresholdsSection value={THRESHOLDS} onChange={onChange} />);++ fireEvent.click(screen.getByTestId('threshold-edit-0'));+ expect(screen.getByTestId('threshold-value-0')).toHaveValue(80);++ fireEvent.change(screen.getByTestId('threshold-value-0'), {+ target: { value: '90' },+ });+ fireEvent.click(screen.getByTestId('threshold-save-0'));++ expect(onChange).toHaveBeenCalledWith([+ { value: 90, color: '#F5B225', label: 'High', unit: 'percent' },+ ]);+ });++ it('does not commit edits when Discard is clicked', () => {+ const onChange = jest.fn();+ render(<ThresholdsSection value={THRESHOLDS} onChange={onChange} />);++ fireEvent.click(screen.getByTestId('threshold-edit-0'));+ fireEvent.change(screen.getByTestId('threshold-value-0'), {+ target: { value: '90' },+ });+ fireEvent.click(screen.getByTestId('threshold-discard-0'));++ expect(onChange).not.toHaveBeenCalled();+ // Back to view mode.+ expect(screen.queryByTestId('threshold-value-0')).not.toBeInTheDocument();+ expect(screen.getByTestId('threshold-edit-0')).toBeInTheDocument();+ });++ it('removes a threshold from view mode', () => {+ const onChange = jest.fn();+ render(<ThresholdsSection value={THRESHOLDS} onChange={onChange} />);++ fireEvent.click(screen.getByTestId('threshold-remove-0'));++ expect(onChange).toHaveBeenCalledWith([]);+ });++ it('adds a threshold that opens in edit mode, and discards it away', () => {+ render(<Harness />);++ fireEvent.click(screen.getByTestId('panel-editor-v2-add-threshold'));+ // New row opens in edit mode.+ expect(screen.getByTestId('threshold-value-0')).toBeInTheDocument();++ fireEvent.click(screen.getByTestId('threshold-discard-0'));+ // Discarding a never-saved row removes it entirely.+ expect(screen.queryByTestId('threshold-value-0')).not.toBeInTheDocument();+ expect(screen.queryByTestId('threshold-edit-0')).not.toBeInTheDocument();+ });++ it('flags a threshold unit in a different category than the y-axis unit', () => {+ render(+ <ThresholdsSection+ value={[{ value: 80, color: '#F5B225', label: '', unit: 'ms' }]}+ yAxisUnit="bytes"+ onChange={jest.fn()}+ />,+ );++ fireEvent.click(screen.getByTestId('threshold-edit-0'));+ expect(screen.getByTestId('threshold-unit-invalid-0')).toBeInTheDocument();+ });++ it('does not flag a threshold unit in the same category as the y-axis unit', () => {+ render(+ <ThresholdsSection+ value={[{ value: 80, color: '#F5B225', label: '', unit: 'ms' }]}+ yAxisUnit="s"+ onChange={jest.fn()}+ />,+ );++ fireEvent.click(screen.getByTestId('threshold-edit-0'));+ expect(+ screen.queryByTestId('threshold-unit-invalid-0'),+ ).not.toBeInTheDocument();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsxnew file mode 100644index 0000000000..8b59a83e90--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx@@ -0,0 +1,117 @@+import {+ type DashboardtypesComparisonOperatorDTO,+ type DashboardtypesComparisonThresholdDTO,+ type DashboardtypesThresholdFormatDTO,+} from 'api/generated/services/sigNoz.schemas';+import { formatPanelValue } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/formatPanelValue';++import {+ FORMAT_OPTIONS,+ OPERATOR_OPTIONS,+ OPERATOR_SYMBOL,+} from '../thresholdOptions';+import ThresholdColorField from './shared/ThresholdColorField';+import ThresholdRowShell from './shared/ThresholdRowShell';+import ThresholdSelectField from './shared/ThresholdSelectField';+import ThresholdUnitField from './shared/ThresholdUnitField';+import { useThresholdDraft } from './shared/useThresholdDraft';+import ThresholdValueField from './shared/ThresholdValueField';++import styles from '../ThresholdsSection.module.scss';++interface ComparisonThresholdRowProps {+ index: number;+ threshold: DashboardtypesComparisonThresholdDTO;+ /** Panel formatting unit — scopes the unit picker to its category (V1 parity). */+ yAxisUnit?: string;+ isEditing: boolean;+ onEdit: () => void;+ onSave: (next: DashboardtypesComparisonThresholdDTO) => void;+ onDiscard: () => void;+ onRemove: () => void;+}++/**+ * Comparison threshold (Number): value crosses an operator → recolor. Edit form is+ * condition (operator), value, unit, color, display format.+ */+function ComparisonThresholdRow({+ index,+ threshold,+ yAxisUnit,+ isEditing,+ onEdit,+ onSave,+ onDiscard,+ onRemove,+}: ComparisonThresholdRowProps): JSX.Element {+ const { draft, setDraft, setValue } = useThresholdDraft(threshold, isEditing);++ const symbol = threshold.operator ? OPERATOR_SYMBOL[threshold.operator] : '';+ const summary = (+ <span className={styles.viewValue}>+ {symbol} {formatPanelValue(threshold.value, threshold.unit)}+ </span>+ );++ return (+ <ThresholdRowShell+ index={index}+ testIdPrefix="comparison-threshold"+ color={threshold.color}+ isEditing={isEditing}+ summary={summary}+ onEdit={onEdit}+ onSave={(): void => onSave(draft)}+ onDiscard={onDiscard}+ onRemove={onRemove}+ >+ <ThresholdSelectField+ label="If value is"+ testId={`comparison-threshold-operator-${index}`}+ placeholder="Select condition"+ value={draft.operator}+ items={OPERATOR_OPTIONS}+ onChange={(operator): void =>+ setDraft((d) => ({+ ...d,+ operator: operator as DashboardtypesComparisonOperatorDTO,+ }))+ }+ />+ <ThresholdValueField+ testId={`comparison-threshold-value-${index}`}+ value={draft.value}+ onChange={setValue}+ />+ <ThresholdUnitField+ testId={`comparison-threshold-unit-${index}`}+ invalidTestId={`comparison-threshold-unit-invalid-${index}`}+ value={draft.unit}+ scopeUnit={yAxisUnit}+ scopeLabel="y-axis unit"+ onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}+ />+ <ThresholdColorField+ testId={`comparison-threshold-color-${index}`}+ value={draft.color}+ onChange={(color): void => setDraft((d) => ({ ...d, color }))}+ />+ <ThresholdSelectField+ label="Display"+ testId={`comparison-threshold-format-${index}`}+ placeholder="Select display"+ value={draft.format}+ items={FORMAT_OPTIONS}+ onChange={(format): void =>+ setDraft((d) => ({+ ...d,+ format: format as DashboardtypesThresholdFormatDTO,+ }))+ }+ />+ </ThresholdRowShell>+ );+}++export default ComparisonThresholdRow;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsxnew file mode 100644index 0000000000..2f5f661790--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx@@ -0,0 +1,96 @@+import { Typography } from '@signozhq/ui/typography';+import { Input } from 'antd';+import type { DashboardtypesThresholdWithLabelDTO } from 'api/generated/services/sigNoz.schemas';+import { formatPanelValue } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/formatPanelValue';++import ThresholdColorField from './shared/ThresholdColorField';+import ThresholdRowShell from './shared/ThresholdRowShell';+import ThresholdUnitField from './shared/ThresholdUnitField';+import { useThresholdDraft } from './shared/useThresholdDraft';+import ThresholdValueField from './shared/ThresholdValueField';++import styles from '../ThresholdsSection.module.scss';++interface LabelThresholdRowProps {+ index: number;+ threshold: DashboardtypesThresholdWithLabelDTO;+ /** Panel formatting unit — scopes the unit picker to its category (V1 parity). */+ yAxisUnit?: string;+ isEditing: boolean;+ onEdit: () => void;+ onSave: (next: DashboardtypesThresholdWithLabelDTO) => void;+ onDiscard: () => void;+ onRemove: () => void;+}++/**+ * Value + color + label threshold (TimeSeries / Bar): a line drawn on the chart. Edit+ * form is color, value, unit, label.+ */+function LabelThresholdRow({+ index,+ threshold,+ yAxisUnit,+ isEditing,+ onEdit,+ onSave,+ onDiscard,+ onRemove,+}: LabelThresholdRowProps): JSX.Element {+ const { draft, setDraft, setValue } = useThresholdDraft(threshold, isEditing);++ const summary = (+ <>+ <span className={styles.viewValue}>+ {formatPanelValue(threshold.value, threshold.unit)}+ </span>+ {threshold.label && (+ <span className={styles.viewLabel}>{threshold.label}</span>+ )}+ </>+ );++ return (+ <ThresholdRowShell+ index={index}+ testIdPrefix="threshold"+ color={threshold.color}+ isEditing={isEditing}+ summary={summary}+ onEdit={onEdit}+ onSave={(): void => onSave(draft)}+ onDiscard={onDiscard}+ onRemove={onRemove}+ >+ <ThresholdColorField+ testId={`threshold-color-${index}`}+ value={draft.color}+ onChange={(color): void => setDraft((d) => ({ ...d, color }))}+ />+ <ThresholdValueField+ testId={`threshold-value-${index}`}+ value={draft.value}+ onChange={setValue}+ />+ <ThresholdUnitField+ testId={`threshold-unit-${index}`}+ invalidTestId={`threshold-unit-invalid-${index}`}+ value={draft.unit}+ scopeUnit={yAxisUnit}+ scopeLabel="y-axis unit"+ onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}+ />+ <div className={styles.field}>+ <Typography.Text className={styles.fieldLabel}>Label</Typography.Text>+ <Input+ data-testid={`threshold-label-${index}`}+ placeholder="Optional"+ value={draft.label ?? ''}+ onChange={(e): void => setDraft((d) => ({ ...d, label: e.target.value }))}+ />+ </div>+ </ThresholdRowShell>+ );+}++export default LabelThresholdRow;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsxnew file mode 100644index 0000000000..e0ab46fcab--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx@@ -0,0 +1,141 @@+import {+ type DashboardtypesComparisonOperatorDTO,+ type DashboardtypesTableThresholdDTO,+ type DashboardtypesThresholdFormatDTO,+} from 'api/generated/services/sigNoz.schemas';+import { formatPanelValue } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/formatPanelValue';++import type { TableColumnOption } from '../../../../hooks/useTableColumns';+import {+ FORMAT_OPTIONS,+ OPERATOR_OPTIONS,+ OPERATOR_SYMBOL,+} from '../thresholdOptions';+import ThresholdColorField from './shared/ThresholdColorField';+import ThresholdRowShell from './shared/ThresholdRowShell';+import ThresholdSelectField from './shared/ThresholdSelectField';+import ThresholdUnitField from './shared/ThresholdUnitField';+import { useThresholdDraft } from './shared/useThresholdDraft';+import ThresholdValueField from './shared/ThresholdValueField';++import styles from '../ThresholdsSection.module.scss';++interface TableThresholdRowProps {+ index: number;+ threshold: DashboardtypesTableThresholdDTO;+ /** Resolved value columns (with their configured units); the rule targets one. */+ tableColumns: TableColumnOption[];+ isEditing: boolean;+ onEdit: () => void;+ onSave: (next: DashboardtypesTableThresholdDTO) => void;+ onDiscard: () => void;+ onRemove: () => void;+}++/**+ * Per-column comparison threshold (Table): value in a column crosses an operator →+ * recolor that column's cells. Edit form is column, condition (operator), value, unit,+ * color, display format. The unit picker scopes to the selected column's unit (Table+ * panels have no single panel-wide unit — V1 parity).+ */+function TableThresholdRow({+ index,+ threshold,+ tableColumns,+ isEditing,+ onEdit,+ onSave,+ onDiscard,+ onRemove,+}: TableThresholdRowProps): JSX.Element {+ const { draft, setDraft, setValue } = useThresholdDraft(threshold, isEditing);++ // Stored columnName is the query key; resolve its label + configured unit.+ const columnUnit = tableColumns.find((c) => c.key === draft.columnName)?.unit;+ const columnLabel =+ tableColumns.find((c) => c.key === threshold.columnName)?.label ??+ threshold.columnName;+ const columnItems = tableColumns.map((column) => ({+ value: column.key,+ label: column.label,+ }));++ const symbol = threshold.operator ? OPERATOR_SYMBOL[threshold.operator] : '';+ const summary = (+ <>+ <span className={styles.viewLabel}>{columnLabel}</span>+ <span className={styles.viewValue}>+ {symbol} {formatPanelValue(threshold.value, threshold.unit)}+ </span>+ </>+ );++ return (+ <ThresholdRowShell+ index={index}+ testIdPrefix="table-threshold"+ color={threshold.color}+ isEditing={isEditing}+ summary={summary}+ onEdit={onEdit}+ onSave={(): void => onSave(draft)}+ onDiscard={onDiscard}+ onRemove={onRemove}+ >+ <ThresholdSelectField+ label="Column"+ testId={`table-threshold-column-${index}`}+ placeholder="Select column"+ value={draft.columnName || undefined}+ items={columnItems}+ onChange={(columnName): void => setDraft((d) => ({ ...d, columnName }))}+ />+ <ThresholdSelectField+ label="If value is"+ testId={`table-threshold-operator-${index}`}+ placeholder="Select condition"+ value={draft.operator}+ items={OPERATOR_OPTIONS}+ onChange={(operator): void =>+ setDraft((d) => ({+ ...d,+ operator: operator as DashboardtypesComparisonOperatorDTO,+ }))+ }+ />+ <ThresholdValueField+ testId={`table-threshold-value-${index}`}+ value={draft.value}+ onChange={setValue}+ />+ <ThresholdUnitField+ testId={`table-threshold-unit-${index}`}+ invalidTestId={`table-threshold-unit-invalid-${index}`}+ value={draft.unit}+ scopeUnit={columnUnit}+ scopeLabel="column unit"+ onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}+ />+ <ThresholdColorField+ testId={`table-threshold-color-${index}`}+ value={draft.color}+ onChange={(color): void => setDraft((d) => ({ ...d, color }))}+ />+ <ThresholdSelectField+ label="Display"+ testId={`table-threshold-format-${index}`}+ placeholder="Select display"+ value={draft.format}+ items={FORMAT_OPTIONS}+ onChange={(format): void =>+ setDraft((d) => ({+ ...d,+ format: format as DashboardtypesThresholdFormatDTO,+ }))+ }+ />+ </ThresholdRowShell>+ );+}++export default TableThresholdRow;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsxnew file mode 100644index 0000000000..15b80abcd1--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx@@ -0,0 +1,27 @@+import { Typography } from '@signozhq/ui/typography';++import ThresholdColorSelect from '../../ThresholdColorSelect';++import styles from '../../ThresholdsSection.module.scss';++interface ThresholdColorFieldProps {+ testId: string;+ value: string;+ onChange: (hex: string) => void;+}++/** Labelled color picker, shared by every threshold variant. */+function ThresholdColorField({+ testId,+ value,+ onChange,+}: ThresholdColorFieldProps): JSX.Element {+ return (+ <div className={styles.field}>+ <Typography.Text className={styles.fieldLabel}>Color</Typography.Text>+ <ThresholdColorSelect value={value} testId={testId} onChange={onChange} />+ </div>+ );+}++export default ThresholdColorField;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsxnew file mode 100644index 0000000000..f5deac5f6c--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx@@ -0,0 +1,103 @@+import type { ReactNode } from 'react';+import { Check, Pencil, Trash2, X } from '@signozhq/icons';+import { Button } from '@signozhq/ui/button';++import styles from '../../ThresholdsSection.module.scss';++interface ThresholdRowShellProps {+ index: number;+ /** testId prefix per variant: `threshold` | `comparison-threshold` | `table-threshold`. */+ testIdPrefix: string;+ /** Swatch color shown in view mode. */+ color: string;+ isEditing: boolean;+ /** Compact view-mode summary, rendered between the color dot and the actions. */+ summary: ReactNode;+ /** Edit-mode fields. */+ children: ReactNode;+ onEdit: () => void;+ onSave: () => void;+ onDiscard: () => void;+ onRemove: () => void;+}++/**+ * Shared chrome for a threshold row's V1-style view/edit modes: the view summary with+ * Edit/Delete, and the edit form's Discard/Save actions. Each variant supplies its own+ * `summary` and field `children`; everything else (layout, buttons, testIds) is shared.+ */+function ThresholdRowShell({+ index,+ testIdPrefix,+ color,+ isEditing,+ summary,+ children,+ onEdit,+ onSave,+ onDiscard,+ onRemove,+}: ThresholdRowShellProps): JSX.Element {+ if (!isEditing) {+ return (+ <div className={styles.viewRow}>+ <span className={styles.dot} style={{ backgroundColor: color }} />+ {summary}+ <div className={styles.spacer} />+ <Button+ type="button"+ variant="ghost"+ color="secondary"+ size="icon"+ aria-label={`Edit threshold ${index + 1}`}+ data-testid={`${testIdPrefix}-edit-${index}`}+ onClick={onEdit}+ >+ <Pencil size={14} />+ </Button>+ <Button+ type="button"+ variant="ghost"+ color="destructive"+ size="icon"+ aria-label={`Remove threshold ${index + 1}`}+ data-testid={`${testIdPrefix}-remove-${index}`}+ onClick={onRemove}+ >+ <Trash2 size={14} />+ </Button>+ </div>+ );+ }++ return (+ <div className={styles.editRow}>+ {children}++ <div className={styles.actions}>+ <Button+ type="button"+ variant="outlined"+ color="secondary"+ prefix={<X size={14} />}+ data-testid={`${testIdPrefix}-discard-${index}`}+ onClick={onDiscard}+ >+ Discard+ </Button>+ <Button+ type="button"+ variant="solid"+ color="primary"+ prefix={<Check size={14} />}+ data-testid={`${testIdPrefix}-save-${index}`}+ onClick={onSave}+ >+ Save+ </Button>+ </div>+ </div>+ );+}++export default ThresholdRowShell;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdSelectField.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdSelectField.tsxnew file mode 100644index 0000000000..5a0d0a82b8--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdSelectField.tsx@@ -0,0 +1,44 @@+import { Typography } from '@signozhq/ui/typography';++import ConfigSelect, {+ type ConfigSelectItem,+} from '../../../../controls/ConfigSelect/ConfigSelect';++import styles from '../../ThresholdsSection.module.scss';++interface ThresholdSelectFieldProps {+ label: string;+ testId: string;+ placeholder?: string;+ value: string | undefined;+ items: ConfigSelectItem[];+ onChange: (value: string) => void;+}++/**+ * Labelled single-select, shared by the threshold variants' enum fields+ * (operator / display format / column).+ */+function ThresholdSelectField({+ label,+ testId,+ placeholder,+ value,+ items,+ onChange,+}: ThresholdSelectFieldProps): JSX.Element {+ return (+ <div className={styles.field}>+ <Typography.Text className={styles.fieldLabel}>{label}</Typography.Text>+ <ConfigSelect+ testId={testId}+ placeholder={placeholder}+ value={value}+ items={items}+ onChange={onChange}+ />+ </div>+ );+}++export default ThresholdSelectField;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsxnew file mode 100644index 0000000000..41404d7ce5--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsx@@ -0,0 +1,57 @@+import { Typography } from '@signozhq/ui/typography';+import YAxisUnitSelector from 'components/YAxisUnitSelector';+import { YAxisSource } from 'components/YAxisUnitSelector/types';++import {+ isThresholdUnitIncompatible,+ thresholdUnitCategories,+} from '../../thresholdUnitCategories';++import styles from '../../ThresholdsSection.module.scss';++interface ThresholdUnitFieldProps {+ testId: string;+ invalidTestId: string;+ value: string | undefined;+ /** Unit whose category scopes the picker (panel y-axis unit, or the column's unit). */+ scopeUnit: string | undefined;+ /** How the scope reads in the mismatch message, e.g. "y-axis unit" / "column unit". */+ scopeLabel: string;+ onChange: (unit: string) => void;+}++/**+ * Labelled unit picker, scoped to `scopeUnit`'s category (V1 parity) and flagging a+ * threshold unit that resolves to a different category. Shared by every variant; only+ * the scope source and its wording differ.+ */+function ThresholdUnitField({+ testId,+ invalidTestId,+ value,+ scopeUnit,+ scopeLabel,+ onChange,+}: ThresholdUnitFieldProps): JSX.Element {+ return (+ <div className={styles.field}>+ <Typography.Text className={styles.fieldLabel}>Unit</Typography.Text>+ <YAxisUnitSelector+ containerClassName={styles.unitSelector}+ data-testid={testId}+ placeholder="Select unit"+ source={YAxisSource.DASHBOARDS}+ categoriesOverride={thresholdUnitCategories(scopeUnit)}+ value={value}+ onChange={onChange}+ />+ {isThresholdUnitIncompatible(value, scopeUnit) && (+ <Typography.Text className={styles.invalidUnit} data-testid={invalidTestId}>+ Threshold unit ({value}) is not valid with the {scopeLabel} ({scopeUnit})+ </Typography.Text>+ )}+ </div>+ );+}++export default ThresholdUnitField;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsxnew file mode 100644index 0000000000..a3ff08c5b2--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsx@@ -0,0 +1,33 @@+import { Typography } from '@signozhq/ui/typography';+import { Input } from 'antd';++import styles from '../../ThresholdsSection.module.scss';++interface ThresholdValueFieldProps {+ testId: string;+ value: number;+ /** Receives the raw input string; the draft hook parses it. */+ onChange: (raw: string) => void;+}++/** Labelled numeric "Value" input, shared by every threshold variant. */+function ThresholdValueField({+ testId,+ value,+ onChange,+}: ThresholdValueFieldProps): JSX.Element {+ return (+ <div className={styles.field}>+ <Typography.Text className={styles.fieldLabel}>Value</Typography.Text>+ <Input+ data-testid={testId}+ type="number"+ placeholder="Value"+ value={value}+ onChange={(e): void => onChange(e.target.value)}+ />+ </div>+ );+}++export default ThresholdValueField;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/useThresholdDraft.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/useThresholdDraft.tsnew file mode 100644index 0000000000..3d16dc9d1b--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/useThresholdDraft.ts@@ -0,0 +1,34 @@+import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';++interface ThresholdDraft<T> {+ draft: T;+ setDraft: Dispatch<SetStateAction<T>>;+ /** Parse a raw input string into `value`, ignoring transient non-numeric input. */+ setValue: (raw: string) => void;+}++/**+ * Local draft for a threshold row, shared by every variant. Snapshots the saved+ * threshold on each entry into edit mode (so Discard simply drops the draft and the+ * next edit starts clean) and exposes the numeric `value` setter all variants use.+ */+export function useThresholdDraft<T extends { value: number }>(+ threshold: T,+ isEditing: boolean,+): ThresholdDraft<T> {+ const [draft, setDraft] = useState<T>(threshold);++ useEffect(() => {+ if (isEditing) {+ setDraft(threshold);+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps -- snapshot only on edit entry+ }, [isEditing]);++ const setValue = (raw: string): void => {+ const next = Number(raw);+ setDraft((d) => ({ ...d, value: Number.isNaN(next) ? d.value : next }));+ };++ return { draft, setDraft, setValue };+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.tsnew file mode 100644index 0000000000..bc47f4a0db--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts@@ -0,0 +1,47 @@+import {+ DashboardtypesComparisonOperatorDTO,+ DashboardtypesThresholdFormatDTO,+} from 'api/generated/services/sigNoz.schemas';++import type { ConfigSelectItem } from '../../controls/ConfigSelect/ConfigSelect';++// Comparison operators offered in the "If value is" condition picker. Labels pair a+// word with its math symbol so the dropdown reads clearly while the view row can show+// the compact symbol (OPERATOR_SYMBOL below).+export const OPERATOR_OPTIONS: ConfigSelectItem[] = [+ { value: DashboardtypesComparisonOperatorDTO.above, label: 'Above (>)' },+ {+ value: DashboardtypesComparisonOperatorDTO.above_or_equal,+ label: 'Above or equal (≥)',+ },+ { value: DashboardtypesComparisonOperatorDTO.below, label: 'Below (<)' },+ {+ value: DashboardtypesComparisonOperatorDTO.below_or_equal,+ label: 'Below or equal (≤)',+ },+ { value: DashboardtypesComparisonOperatorDTO.equal, label: 'Equal (=)' },+ {+ value: DashboardtypesComparisonOperatorDTO.not_equal,+ label: 'Not equal (≠)',+ },+];++// Compact symbol shown in the collapsed (view-mode) summary row.+export const OPERATOR_SYMBOL: Record<+ DashboardtypesComparisonOperatorDTO,+ string+> = {+ [DashboardtypesComparisonOperatorDTO.above]: '>',+ [DashboardtypesComparisonOperatorDTO.above_or_equal]: '≥',+ [DashboardtypesComparisonOperatorDTO.below]: '<',+ [DashboardtypesComparisonOperatorDTO.below_or_equal]: '≤',+ [DashboardtypesComparisonOperatorDTO.equal]: '=',+ [DashboardtypesComparisonOperatorDTO.not_equal]: '≠',+};++// How the threshold recolors the panel: just the number ("text") or the whole tile+// ("background").+export const FORMAT_OPTIONS: ConfigSelectItem[] = [+ { value: DashboardtypesThresholdFormatDTO.background, label: 'Background' },+ { value: DashboardtypesThresholdFormatDTO.text, label: 'Text' },+];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdUnitCategories.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdUnitCategories.tsnew file mode 100644index 0000000000..78e04a09aa--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdUnitCategories.ts@@ -0,0 +1,54 @@+import {+ type YAxisCategory,+ YAxisSource,+} from 'components/YAxisUnitSelector/types';+import {+ getYAxisCategories,+ mapMetricUnitToUniversalUnit,+} from 'components/YAxisUnitSelector/utils';++// The unit category (Time, Data, …) a unit belongs to, or undefined if unrecognized.+function categoryForUnit(unit: string): YAxisCategory | undefined {+ const universal = mapMetricUnitToUniversalUnit(unit);+ return getYAxisCategories(YAxisSource.DASHBOARDS).find((c) =>+ c.units.some((u) => u.id === universal),+ );+}++/**+ * Restricts the threshold unit picker to the panel's y-axis unit family, mirroring V1:+ * a threshold is only meaningfully comparable to the axis when it shares its category+ * (e.g. an `ms` axis → only Time units). Returns the single matching category, or+ * `undefined` (all categories) when the panel has no unit set or it can't be mapped.+ */+export function thresholdUnitCategories(+ yAxisUnit: string | undefined,+): YAxisCategory[] | undefined {+ if (!yAxisUnit) {+ return undefined;+ }+ const category = categoryForUnit(yAxisUnit);+ return category ? [category] : undefined;+}++/**+ * True when a threshold's unit belongs to a different category than the panel's y-axis+ * unit (so the values can't be compared) — drives the V1-style mismatch message. Only+ * flags when both units are set and resolve to distinct categories (e.g. a stale `ms`+ * threshold left over after the axis unit was changed to bytes).+ */+export function isThresholdUnitIncompatible(+ thresholdUnit: string | undefined,+ yAxisUnit: string | undefined,+): boolean {+ if (!thresholdUnit || !yAxisUnit) {+ return false;+ }+ const thresholdCategory = categoryForUnit(thresholdUnit);+ const axisCategory = categoryForUnit(yAxisUnit);+ return Boolean(+ thresholdCategory &&+ axisCategory &&+ thresholdCategory.name !== axisCategory.name,+ );+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scssnew file mode 100644index 0000000000..6c02dc4661--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scss@@ -0,0 +1,5 @@+.field {+ display: flex;+ flex-direction: column;+ gap: 8px;+}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.tsxnew file mode 100644index 0000000000..de422ce312--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx@@ -0,0 +1,67 @@+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 ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';+import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';+import { TIME_PREFERENCE_OPTIONS } from './timePreferenceOptions';++import styles from './VisualizationSection.module.scss';++/**+ * 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.+ */+function VisualizationSection({+ value,+ controls,+ onChange,+}: SectionEditorProps<'visualization'>): JSX.Element {+ return (+ <>+ {controls.timePreference && (+ <div className={styles.field}>+ <Typography.Text>Panel time preference</Typography.Text>+ <ConfigSelect+ testId="panel-editor-v2-time-preference"+ placeholder="Select time scope…"+ value={value?.timePreference}+ items={TIME_PREFERENCE_OPTIONS}+ onChange={(next): void =>+ onChange({+ ...value,+ timePreference: next as DashboardtypesTimePreferenceDTO,+ })+ }+ />+ </div>+ )}++ {controls.stacking && (+ <ConfigSwitch+ testId="panel-editor-v2-stacked-bar-chart"+ title="Stack series"+ description="Stack bars from all series on top of each other"+ value={value?.stackedBarChart ?? false}+ onChange={(checked): void =>+ onChange({ ...value, stackedBarChart: checked })+ }+ />+ )}++ {controls.fillSpans && (+ <ConfigSwitch+ testId="panel-editor-v2-fill-spans"+ title="Fill gaps"+ description="Fill gaps in data with 0 for continuity"+ value={value?.fillSpans ?? false}+ onChange={(checked): void => onChange({ ...value, fillSpans: checked })}+ />+ )}+ </>+ );+}++export default VisualizationSection;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.tsxnew file mode 100644index 0000000000..a27bdc0022--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx@@ -0,0 +1,104 @@+import { fireEvent, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.schemas';++import VisualizationSection from '../VisualizationSection';++// 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();+ const trigger = screen.getByTestId(triggerTestId);+ await user.click(trigger.querySelector('.ant-select-selector') as HTMLElement);+ await user.click(await screen.findByRole('option', { name: label }));+}++describe('VisualizationSection', () => {+ it('renders every control that is enabled', () => {+ render(+ <VisualizationSection+ value={undefined}+ controls={{ timePreference: true, stacking: true, fillSpans: true }}+ onChange={jest.fn()}+ />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-time-preference'),+ ).toBeInTheDocument();+ expect(+ screen.getByTestId('panel-editor-v2-stacked-bar-chart'),+ ).toBeInTheDocument();+ expect(screen.getByTestId('panel-editor-v2-fill-spans')).toBeInTheDocument();+ });++ it('renders only the controls whose flag is set', () => {+ render(+ <VisualizationSection+ value={undefined}+ controls={{ timePreference: true }}+ onChange={jest.fn()}+ />,+ );++ expect(+ screen.getByTestId('panel-editor-v2-time-preference'),+ ).toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-stacked-bar-chart'),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId('panel-editor-v2-fill-spans'),+ ).not.toBeInTheDocument();+ });++ it('writes the chosen time preference through the dropdown', async () => {+ const onChange = jest.fn();+ render(+ <VisualizationSection+ value={undefined}+ controls={{ timePreference: true }}+ onChange={onChange}+ />,+ );++ await pickOption('panel-editor-v2-time-preference', 'Last 1 hr');++ expect(onChange).toHaveBeenCalledWith({ timePreference: 'last_1_hr' });+ });++ it('toggles bar stacking through onChange, preserving other fields', () => {+ const onChange = jest.fn();+ render(+ <VisualizationSection+ value={{+ timePreference: DashboardtypesTimePreferenceDTO.global_time,+ stackedBarChart: false,+ }}+ controls={{ stacking: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByTestId('panel-editor-v2-stacked-bar-chart'));++ expect(onChange).toHaveBeenCalledWith({+ timePreference: 'global_time',+ stackedBarChart: true,+ });+ });++ it('toggles fill spans through onChange', () => {+ const onChange = jest.fn();+ render(+ <VisualizationSection+ value={{ fillSpans: false }}+ controls={{ fillSpans: true }}+ onChange={onChange}+ />,+ );++ fireEvent.click(screen.getByTestId('panel-editor-v2-fill-spans'));++ expect(onChange).toHaveBeenCalledWith({ fillSpans: true });+ });+});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.tsnew file mode 100644index 0000000000..c04305fb2d--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/timePreferenceOptions.ts@@ -0,0 +1,18 @@+import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.schemas';++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' },+];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.module.scssnew file mode 100644index 0000000000..dff8c4f646--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.module.scss@@ -0,0 +1,38 @@+.editor {+ display: flex;+ flex-direction: column;+ gap: 8px;+ padding: 12px;+ border-top: 1px solid var(--l2-border);+ background-color: var(--l1-background);+}++.header {+ display: flex;+ align-items: center;+}++.title {+ font-size: 12px;+ font-weight: 500;+ color: var(--l2-foreground);+}++.body {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 8px;+}++.chips {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 8px;+}++.hint {+ font-size: 11px;+ color: var(--l3-foreground);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.tsxnew file mode 100644index 0000000000..5a3860a34e--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor.tsx@@ -0,0 +1,122 @@+import { useMemo } from 'react';+import {+ closestCenter,+ DndContext,+ type DragEndEvent,+ KeyboardSensor,+ PointerSensor,+ useSensor,+ useSensors,+} from '@dnd-kit/core';+import {+ arrayMove,+ horizontalListSortingStrategy,+ SortableContext,+ sortableKeyboardCoordinates,+} from '@dnd-kit/sortable';+import { Typography } from '@signozhq/ui/typography';+import type {+ DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++import AddColumnDropdown from './components/AddColumnDropdown/AddColumnDropdown';+import SortableColumnChip from './components/SortableColumnChip/SortableColumnChip';+import { readSelectFields, writeSelectFields } from './selectFields';+import styles from './ListColumnsEditor.module.scss';++interface ListColumnsEditorProps {+ spec: DashboardtypesPanelSpecDTO;+ onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;+ /** Committed query's signal — scopes the add-dropdown's field suggestions. */+ signal: TelemetrytypesSignalDTO | undefined;+}++/**+ * The List panel's columns control, rendered below the query builder (V1 parity).+ * Columns are `spec.plugin.spec.selectFields`, shown as draggable chips that can+ * be reordered, removed, or added from a field-search dropdown. Empty means the+ * renderer shows every field the query returns.+ */+function ListColumnsEditor({+ spec,+ onChangeSpec,+ signal,+}: ListColumnsEditorProps): JSX.Element {+ const fields = useMemo(() => readSelectFields(spec), [spec]);+ const names = useMemo(() => fields.map((field) => field.name), [fields]);+ const selectedNames = useMemo(() => new Set(names), [names]);++ const sensors = useSensors(+ useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),+ useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),+ );++ const commit = (next: TelemetrytypesTelemetryFieldKeyDTO[]): void =>+ onChangeSpec(writeSelectFields(spec, next));++ const handleDragEnd = (event: DragEndEvent): void => {+ const { active, over } = event;+ if (!over || active.id === over.id) {+ return;+ }+ const oldIndex = names.indexOf(active.id as string);+ const newIndex = names.indexOf(over.id as string);+ if (oldIndex === -1 || newIndex === -1) {+ return;+ }+ commit(arrayMove(fields, oldIndex, newIndex));+ };++ const handleRemove = (name: string): void =>+ commit(fields.filter((field) => field.name !== name));++ const handleToggle = (field: TelemetrytypesTelemetryFieldKeyDTO): void => {+ if (selectedNames.has(field.name)) {+ handleRemove(field.name);+ return;+ }+ commit([...fields, field]);+ };++ return (+ <div className={styles.editor} data-testid="list-columns-editor">+ <div className={styles.header}>+ <Typography.Text className={styles.title}>Columns</Typography.Text>+ </div>+ <div className={styles.body}>+ <DndContext+ sensors={sensors}+ collisionDetection={closestCenter}+ onDragEnd={handleDragEnd}+ >+ <SortableContext items={names} strategy={horizontalListSortingStrategy}>+ <div className={styles.chips}>+ {fields.map((field) => (+ <SortableColumnChip+ key={field.name}+ id={field.name}+ name={field.name}+ onRemove={handleRemove}+ />+ ))}+ </div>+ </SortableContext>+ </DndContext>+ <AddColumnDropdown+ signal={signal}+ selectedNames={selectedNames}+ onToggle={handleToggle}+ />+ </div>+ {fields.length === 0 && (+ <Typography.Text className={styles.hint}>+ Leave empty to show all fields returned by the query.+ </Typography.Text>+ )}+ </div>+ );+}++export default ListColumnsEditor;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/ListColumnsEditor.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/ListColumnsEditor.test.tsxnew file mode 100644index 0000000000..00d40fd23d--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/ListColumnsEditor.test.tsx@@ -0,0 +1,134 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import {+ TelemetrytypesSignalDTO,+ type DashboardtypesPanelSpecDTO,+ type TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++import ListColumnsEditor from '../ListColumnsEditor';+import { readSelectFields } from '../selectFields';++// The add-dropdown fetches field-key suggestions; stub the generated hook so the+// editor renders without a query client. Each test can override the return value.+const mockUseGetFieldsKeys = jest.fn(+ (..._args: unknown[]): { data: unknown; isFetching: boolean } => ({+ data: undefined,+ isFetching: false,+ }),+);+jest.mock('api/generated/services/fields', () => ({+ useGetFieldsKeys: (+ ...args: unknown[]+ ): { data: unknown; isFetching: boolean } => mockUseGetFieldsKeys(...args),+}));++const FIELDS = [+ { name: 'body', fieldContext: 'attribute' },+ { name: 'level' },+] as TelemetrytypesTelemetryFieldKeyDTO[];++function specWith(+ selectFields: TelemetrytypesTelemetryFieldKeyDTO[] | undefined,+): DashboardtypesPanelSpecDTO {+ return {+ plugin: { kind: 'signoz/ListPanel', spec: { selectFields } },+ } as unknown as DashboardtypesPanelSpecDTO;+}++describe('ListColumnsEditor', () => {+ beforeEach(() => {+ mockUseGetFieldsKeys.mockClear();+ mockUseGetFieldsKeys.mockReturnValue({ data: undefined, isFetching: false });+ });++ it('renders the selected columns as chips', () => {+ render(+ <ListColumnsEditor+ spec={specWith(FIELDS)}+ onChangeSpec={jest.fn()}+ signal={TelemetrytypesSignalDTO.logs}+ />,+ );++ expect(screen.getByText('body')).toBeInTheDocument();+ expect(screen.getByText('level')).toBeInTheDocument();+ });++ it('shows the empty-state hint when no columns are selected', () => {+ render(+ <ListColumnsEditor+ spec={specWith([])}+ onChangeSpec={jest.fn()}+ signal={TelemetrytypesSignalDTO.logs}+ />,+ );++ expect(+ screen.getByText(/Leave empty to show all fields/),+ ).toBeInTheDocument();+ });++ it('scopes the field-key suggestions to the panel signal', () => {+ render(+ <ListColumnsEditor+ spec={specWith(FIELDS)}+ onChangeSpec={jest.fn()}+ signal={TelemetrytypesSignalDTO.traces}+ />,+ );++ expect(mockUseGetFieldsKeys).toHaveBeenCalledWith(+ expect.objectContaining({ signal: TelemetrytypesSignalDTO.traces }),+ expect.anything(),+ );+ });++ it('removing a chip writes the spec without that column', async () => {+ const user = userEvent.setup();+ const onChangeSpec = jest.fn();+ render(+ <ListColumnsEditor+ spec={specWith(FIELDS)}+ onChangeSpec={onChangeSpec}+ signal={TelemetrytypesSignalDTO.logs}+ />,+ );++ await user.click(screen.getByLabelText('Remove body'));++ expect(onChangeSpec).toHaveBeenCalledTimes(1);+ const nextSpec = onChangeSpec.mock.calls[0][0] as DashboardtypesPanelSpecDTO;+ const fields = readSelectFields(nextSpec);+ expect(fields.map((field) => field.name)).toStrictEqual(['level']);+ });++ it('adds a suggestion picked from the dropdown', async () => {+ const user = userEvent.setup();+ mockUseGetFieldsKeys.mockReturnValue({+ data: { data: { keys: { group: [{ name: 'status' }] } } },+ isFetching: false,+ });+ const onChangeSpec = jest.fn();+ render(+ <ListColumnsEditor+ spec={specWith(FIELDS)}+ onChangeSpec={onChangeSpec}+ signal={TelemetrytypesSignalDTO.logs}+ />,+ );++ await user.click(screen.getByTestId('list-columns-add'));+ const suggestion = await screen.findByText('status');+ await user.click(suggestion);++ expect(onChangeSpec).toHaveBeenCalledTimes(1);+ const nextSpec = onChangeSpec.mock.calls[0][0] as DashboardtypesPanelSpecDTO;+ const fields = readSelectFields(nextSpec);+ expect(fields.map((field) => field.name)).toStrictEqual([+ 'body',+ 'level',+ 'status',+ ]);+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/selectFields.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/selectFields.test.tsnew file mode 100644index 0000000000..ba12d774e5--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/__tests__/selectFields.test.ts@@ -0,0 +1,58 @@+import type {+ DashboardtypesPanelSpecDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++import {+ readSelectFields,+ sanitizeSelectFields,+ writeSelectFields,+} from '../selectFields';++// The fields API and default-column constants carry extra runtime keys (e.g.+// `isIndexed`) the save contract rejects; only the DTO keys may be persisted.+const DIRTY_FIELD = {+ name: 'body',+ signal: 'logs',+ fieldContext: 'log',+ fieldDataType: '',+ isIndexed: false,+} as unknown as TelemetrytypesTelemetryFieldKeyDTO;++describe('selectFields', () => {+ describe('sanitizeSelectFields', () => {+ it('drops keys outside the field-key DTO (isIndexed)', () => {+ const [cleaned] = sanitizeSelectFields([DIRTY_FIELD]);++ expect('isIndexed' in cleaned).toBe(false);+ expect(cleaned).toStrictEqual({+ name: 'body',+ signal: 'logs',+ fieldContext: 'log',+ fieldDataType: '',+ });+ });++ it('omits absent optional keys rather than emitting undefined', () => {+ const [cleaned] = sanitizeSelectFields([+ { name: 'level' } as TelemetrytypesTelemetryFieldKeyDTO,+ ]);++ expect(cleaned).toStrictEqual({ name: 'level' });+ });+ });++ describe('writeSelectFields', () => {+ it('sanitizes columns as it writes them onto the spec', () => {+ const spec = {+ plugin: { kind: 'signoz/ListPanel', spec: {} },+ } as unknown as DashboardtypesPanelSpecDTO;++ const next = writeSelectFields(spec, [DIRTY_FIELD]);++ expect(readSelectFields(next)).toStrictEqual([+ { name: 'body', signal: 'logs', fieldContext: 'log', fieldDataType: '' },+ ]);+ });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.module.scssnew file mode 100644index 0000000000..ee4ffa00c0--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.module.scss@@ -0,0 +1,10 @@+// Shrink the icon Button from its 2rem default to the editor's 28px control row.+.addBtn {+ --button-height: 28px;+ --button-width: 28px;+ flex-shrink: 0;+}++.dropdown {+ width: 260px;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.tsxnew file mode 100644index 0000000000..dd212e48ce--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.tsx@@ -0,0 +1,106 @@+import { useState } from 'react';+import { Button } from '@signozhq/ui/button';+import {+ Combobox,+ ComboboxCommand,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxInput,+ ComboboxItem,+ ComboboxList,+ ComboboxLoading,+ ComboboxTrigger,+} from '@signozhq/ui/combobox';+import { Plus } from '@signozhq/icons';+import type {+ TelemetrytypesSignalDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++import { useListColumnSuggestions } from '../../hooks/useListColumnSuggestions';+import styles from './AddColumnDropdown.module.scss';++interface AddColumnDropdownProps {+ signal: TelemetrytypesSignalDTO | undefined;+ /** Names already chosen — drives the checked state + toggle behavior. */+ selectedNames: Set<string>;+ onToggle: (field: TelemetrytypesTelemetryFieldKeyDTO) => void;+}++/**+ * The "+" affordance for the List columns editor: a searchable combobox of+ * field-key suggestions. Picking a suggestion toggles it (checkmark = selected);+ * a non-matching search term can be added verbatim so not-yet-indexed fields are+ * still selectable. Search is server-side, so cmdk filtering is disabled.+ */+function AddColumnDropdown({+ signal,+ selectedNames,+ onToggle,+}: AddColumnDropdownProps): JSX.Element {+ const [open, setOpen] = useState(false);+ const { searchText, setSearchText, suggestions, isFetching } =+ useListColumnSuggestions(signal);++ const trimmed = searchText.trim();+ const hasExactMatch = suggestions.some((field) => field.name === trimmed);+ const showCustomAdd = trimmed.length > 0 && !hasExactMatch;++ return (+ <Combobox open={open} onOpenChange={setOpen}>+ <ComboboxTrigger asChild>+ <Button+ type="button"+ variant="outlined"+ color="secondary"+ size="icon"+ className={styles.addBtn}+ aria-label="Add column"+ // `data-testid` (not the `testId` prop) survives the trigger's+ // `asChild` Slot merge, which otherwise resets it to undefined.+ data-testid="list-columns-add"+ >+ <Plus size={16} />+ </Button>+ </ComboboxTrigger>+ <ComboboxContent arrow side="top" align="end" className={styles.dropdown}>+ <ComboboxCommand shouldFilter={false}>+ <ComboboxInput+ value={searchText}+ onValueChange={setSearchText}+ placeholder="Search fields"+ testId="list-columns-search"+ />+ <ComboboxList>+ {showCustomAdd && (+ <ComboboxItem+ value={trimmed}+ onSelect={(): void => onToggle({ name: trimmed })}+ data-testid="list-columns-add-custom"+ >+ Add "{trimmed}"+ </ComboboxItem>+ )}+ {suggestions.map((field) => (+ <ComboboxItem+ key={field.name}+ value={field.name}+ isSelected={selectedNames.has(field.name)}+ onSelect={(): void => onToggle(field)}+ data-testid="list-columns-suggestion"+ >+ {field.name}+ </ComboboxItem>+ ))}+ {isFetching && <ComboboxLoading>Loading…</ComboboxLoading>}+ {!isFetching && !showCustomAdd && suggestions.length === 0 && (+ <ComboboxEmpty>No fields found</ComboboxEmpty>+ )}+ </ComboboxList>+ </ComboboxCommand>+ </ComboboxContent>+ </Combobox>+ );+}++export default AddColumnDropdown;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.module.scssnew file mode 100644index 0000000000..5e85d9cf76--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.module.scss@@ -0,0 +1,41 @@+.chip {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ height: 28px;+ padding: 0 8px;+ border: 1px solid var(--l2-border);+ border-radius: 4px;+ background-color: var(--l2-background);+}++// Shrink the icon Button to the chip's compact footprint (defaults are 2rem+// square with 0.5rem padding) via the component's CSS-custom-property hooks.+.grip {+ --button-height: 16px;+ --button-width: 16px;+ --button-padding: 0;+ cursor: grab;++ &:active {+ cursor: grabbing;+ }+}++.chipName {+ max-width: 180px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ font-size: 12px;+ color: var(--l1-foreground);+}++.remove {+ --button-height: 16px;+ --button-width: 16px;+ --button-padding: 0;+ // Keep the V1 affordance: neutral by default, cherry-red on hover.+ --button-variant-ghost-hover-color: var(--bg-cherry-400);+ --button-variant-ghost-hover-background-color: transparent;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.tsxnew file mode 100644index 0000000000..21bc47dc34--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/SortableColumnChip/SortableColumnChip.tsx@@ -0,0 +1,70 @@+import { useSortable } from '@dnd-kit/sortable';+import { CSS } from '@dnd-kit/utilities';+import { Button } from '@signozhq/ui/button';+import { GripVertical, X } from '@signozhq/icons';++import styles from './SortableColumnChip.module.scss';++interface SortableColumnChipProps {+ /** Stable sortable id (the column name). */+ id: string;+ name: string;+ onRemove: (name: string) => void;+}++/** A single draggable column chip: grip handle, field name, remove button. */+function SortableColumnChip({+ id,+ name,+ onRemove,+}: SortableColumnChipProps): JSX.Element {+ const {+ attributes,+ listeners,+ setNodeRef,+ transform,+ transition,+ isDragging,+ } = useSortable({ id });++ // dnd-kit drives the drag transform per-frame, so this must be inline.+ const style: React.CSSProperties = {+ transform: CSS.Transform.toString(transform),+ transition,+ opacity: isDragging ? 0.5 : undefined,+ };++ return (+ <div ref={setNodeRef} style={style} className={styles.chip}>+ <Button+ type="button"+ variant="ghost"+ color="secondary"+ size="icon"+ className={styles.grip}+ aria-label={`Reorder ${name}`}+ {...attributes}+ {...listeners}+ >+ <GripVertical size={12} />+ </Button>+ <span className={styles.chipName} title={name}>+ {name}+ </span>+ <Button+ type="button"+ variant="ghost"+ color="secondary"+ size="icon"+ className={styles.remove}+ aria-label={`Remove ${name}`}+ testId="list-column-remove"+ onClick={(): void => onRemove(name)}+ >+ <X size={12} />+ </Button>+ </div>+ );+}++export default SortableColumnChip;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/hooks/useListColumnSuggestions.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/hooks/useListColumnSuggestions.tsnew file mode 100644index 0000000000..b57b017c58--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/hooks/useListColumnSuggestions.ts@@ -0,0 +1,50 @@+import { useMemo, useState } from 'react';+import type {+ TelemetrytypesSignalDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';+import { useGetFieldsKeys } from 'api/generated/services/fields';+import useDebounce from 'hooks/useDebounce';++interface UseListColumnSuggestions {+ searchText: string;+ setSearchText: (value: string) => void;+ suggestions: TelemetrytypesTelemetryFieldKeyDTO[];+ /** Suggestion field keyed by name — enriches a freshly-picked column with its metadata. */+ suggestionByName: Map<string, TelemetrytypesTelemetryFieldKeyDTO>;+ isFetching: boolean;+}++/**+ * Server-side telemetry field-key search scoped to the panel's signal, shared by+ * the List columns editor's add-dropdown. Suggestions arrive grouped by name; we+ * flatten them and index by name so picks can carry their context/data-type.+ */+export function useListColumnSuggestions(+ signal: TelemetrytypesSignalDTO | undefined,+): UseListColumnSuggestions {+ const [searchText, setSearchText] = useState('');+ const debouncedSearch = useDebounce(searchText, 300);++ const { data, isFetching } = useGetFieldsKeys(+ { signal, searchText: debouncedSearch },+ { query: { enabled: !!signal } },+ );++ const suggestions = useMemo(+ () => Object.values(data?.data.keys ?? {}).flat(),+ [data],+ );+ const suggestionByName = useMemo(+ () => new Map(suggestions.map((field) => [field.name, field])),+ [suggestions],+ );++ return {+ searchText,+ setSearchText,+ suggestions,+ suggestionByName,+ isFetching,+ };+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/selectFields.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/selectFields.tsnew file mode 100644index 0000000000..3a4def9a9e--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/selectFields.ts@@ -0,0 +1,56 @@+import type {+ DashboardtypesListPanelSpecDTO,+ DashboardtypesPanelSpecDTO,+ TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++/**+ * The field-key suggestions API and the default-column constants carry extra+ * runtime fields (e.g. `isIndexed`) that the save contract rejects. Reduce each+ * column to the `TelemetrytypesTelemetryFieldKeyDTO` shape so persisted+ * `selectFields` only contain backend-known keys.+ */+function toFieldKeyDTO(+ field: TelemetrytypesTelemetryFieldKeyDTO,+): TelemetrytypesTelemetryFieldKeyDTO {+ const { name, description, fieldContext, fieldDataType, signal, unit } = field;+ return {+ name,+ ...(description !== undefined && { description }),+ ...(fieldContext !== undefined && { fieldContext }),+ ...(fieldDataType !== undefined && { fieldDataType }),+ ...(signal !== undefined && { signal }),+ ...(unit !== undefined && { unit }),+ };+}++export function sanitizeSelectFields(+ fields: TelemetrytypesTelemetryFieldKeyDTO[],+): TelemetrytypesTelemetryFieldKeyDTO[] {+ return fields.map(toFieldKeyDTO);+}++/**+ * `spec.plugin.spec` is a discriminated union over every panel kind; these helpers+ * run only for the List panel, so it's narrowed to the List variant with a single+ * localized cast at the boundary.+ */+export function readSelectFields(+ spec: DashboardtypesPanelSpecDTO,+): TelemetrytypesTelemetryFieldKeyDTO[] {+ return (spec.plugin.spec as DashboardtypesListPanelSpecDTO).selectFields ?? [];+}++export function writeSelectFields(+ spec: DashboardtypesPanelSpecDTO,+ selectFields: TelemetrytypesTelemetryFieldKeyDTO[],+): DashboardtypesPanelSpecDTO {+ const listSpec: DashboardtypesListPanelSpecDTO = {+ ...(spec.plugin.spec as DashboardtypesListPanelSpecDTO),+ selectFields: sanitizeSelectFields(selectFields),+ };+ return {+ ...spec,+ plugin: { ...spec.plugin, spec: listSpec },+ } as DashboardtypesPanelSpecDTO;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useLegendSeries.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useLegendSeries.test.tsnew file mode 100644index 0000000000..f785886d1c--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useLegendSeries.test.ts@@ -0,0 +1,102 @@+import { renderHook } from '@testing-library/react';+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';+import { useIsDarkMode } from 'hooks/useDarkMode';+import { generateColor } from 'lib/uPlotLib/utils/generateColor';+import { resolveSeriesLabelV5 } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/resolveSeriesLabel';+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import { flattenTimeSeries } from 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData';++import { useLegendSeries } from '../useLegendSeries';++jest.mock('hooks/useDarkMode', () => ({ useIsDarkMode: jest.fn() }));+jest.mock('lib/getLabelName', () => jest.fn(() => 'base'));+jest.mock('lib/uPlotLib/utils/generateColor', () => ({+ generateColor: jest.fn((label: string) => `color:${label}`),+}));+jest.mock('constants/theme', () => ({+ themeColors: { chartcolors: ['dark'], lightModeColor: ['light'] },+}));+jest.mock(+ 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries',+ () => ({ getBuilderQueries: jest.fn(() => []) }),+);+jest.mock(+ 'pages/DashboardPageV2/DashboardContainer/Panels/utils/resolveSeriesLabel',+ () => ({ resolveSeriesLabelV5: jest.fn() }),+);+jest.mock(+ 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData',+ () => ({+ flattenTimeSeries: jest.fn(),+ getTimeSeriesResults: jest.fn(() => []),+ }),+);++const mockUseIsDarkMode = useIsDarkMode as unknown as jest.Mock;+const mockFlatten = flattenTimeSeries as unknown as jest.Mock;+const mockResolveLabel = resolveSeriesLabelV5 as unknown as jest.Mock;+const mockGenerateColor = generateColor as unknown as jest.Mock;++const PANEL = {+ kind: 'Panel',+ spec: { plugin: { kind: 'signoz/TimeSeriesPanel', spec: {} }, queries: [] },+} as unknown as DashboardtypesPanelDTO;+const DATA = { response: {}, legendMap: {} } as unknown as PanelQueryData;++// Each flattened series carries the label resolveSeriesLabelV5 should report.+function seriesWithLabels(labels: string[]): { __label: string }[] {+ return labels.map((__label) => ({ __label }));+}++describe('useLegendSeries', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ mockUseIsDarkMode.mockReturnValue(true);+ mockResolveLabel.mockImplementation((s: { __label: string }) => s.__label);+ });++ it('is empty when there are no series', () => {+ mockFlatten.mockReturnValue([]);+ const { result } = renderHook(() => useLegendSeries(PANEL, DATA));+ expect(result.current).toStrictEqual([]);+ });++ it('maps each series to a { label, defaultColor } pair', () => {+ mockFlatten.mockReturnValue(seriesWithLabels(['a', 'b']));+ const { result } = renderHook(() => useLegendSeries(PANEL, DATA));+ expect(result.current).toStrictEqual([+ { label: 'a', defaultColor: 'color:a' },+ { label: 'b', defaultColor: 'color:b' },+ ]);+ });++ it('dedupes by label, keeping first-seen order', () => {+ mockFlatten.mockReturnValue(seriesWithLabels(['a', 'b', 'a', 'c']));+ const { result } = renderHook(() => useLegendSeries(PANEL, DATA));+ expect(result.current.map((s) => s.label)).toStrictEqual(['a', 'b', 'c']);+ // The duplicate 'a' must not generate a second color.+ expect(+ mockGenerateColor.mock.calls.filter(([label]) => label === 'a'),+ ).toHaveLength(1);+ });++ it('skips series that resolve to an empty label', () => {+ mockFlatten.mockReturnValue(seriesWithLabels(['', 'a', '']));+ const { result } = renderHook(() => useLegendSeries(PANEL, DATA));+ expect(result.current).toStrictEqual([+ { label: 'a', defaultColor: 'color:a' },+ ]);+ });++ it('uses the dark palette in dark mode and the light palette otherwise', () => {+ mockFlatten.mockReturnValue(seriesWithLabels(['a']));++ const dark = renderHook(() => useLegendSeries(PANEL, DATA));+ expect(mockGenerateColor).toHaveBeenLastCalledWith('a', ['dark']);+ dark.unmount();++ mockUseIsDarkMode.mockReturnValue(false);+ renderHook(() => useLegendSeries(PANEL, DATA));+ expect(mockGenerateColor).toHaveBeenLastCalledWith('a', ['light']);+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useSwitchColumnsOnSignalChange.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useSwitchColumnsOnSignalChange.test.tsnew file mode 100644index 0000000000..a883fdc1ad--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useSwitchColumnsOnSignalChange.test.ts@@ -0,0 +1,149 @@+import { renderHook } from '@testing-library/react';+import {+ type DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+ type TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';+import {+ defaultLogsSelectedColumns,+ defaultTraceSelectedColumns,+} from 'container/OptionsMenu/constants';++import { sanitizeSelectFields } from '../../ListColumnsEditor/selectFields';+import { useSwitchColumnsOnSignalChange } from '../useSwitchColumnsOnSignalChange';++// The hook applies the datasource defaults reduced to the field-key DTO (the V1+// constants carry extra keys like `isIndexed`); assertions mirror that.+const expectedLogs = sanitizeSelectFields(+ defaultLogsSelectedColumns as TelemetrytypesTelemetryFieldKeyDTO[],+);+const expectedTraces = sanitizeSelectFields(+ defaultTraceSelectedColumns as TelemetrytypesTelemetryFieldKeyDTO[],+);++function makeSpec(+ selectFields: { name: string }[],+): DashboardtypesPanelSpecDTO {+ return {+ plugin: { kind: 'signoz/ListPanel', spec: { selectFields } },+ queries: [],+ } as unknown as DashboardtypesPanelSpecDTO;+}++type Props = {+ enabled: boolean;+ signal: TelemetrytypesSignalDTO | undefined;+ spec: DashboardtypesPanelSpecDTO;+ onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;+};++function renderWith(initial: Props): { rerender: (next: Props) => void } {+ const { rerender } = renderHook(+ (props: Props) => useSwitchColumnsOnSignalChange(props),+ { initialProps: initial },+ );+ return { rerender };+}++function selectFieldsOf(spec: DashboardtypesPanelSpecDTO): unknown[] {+ return (spec.plugin.spec as { selectFields: unknown[] }).selectFields;+}++describe('useSwitchColumnsOnSignalChange', () => {+ it('switches to the trace defaults when going logs → traces', () => {+ const onChangeSpec = jest.fn();+ const spec = makeSpec([{ name: 'body' }]);+ const { rerender } = renderWith({+ enabled: true,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });++ rerender({+ enabled: true,+ signal: TelemetrytypesSignalDTO.traces,+ spec,+ onChangeSpec,+ });++ expect(onChangeSpec).toHaveBeenCalledTimes(1);+ expect(selectFieldsOf(onChangeSpec.mock.calls[0][0])).toStrictEqual(+ expectedTraces,+ );+ });++ it('switches to the log defaults when going traces → logs', () => {+ const onChangeSpec = jest.fn();+ const spec = makeSpec([{ name: 'service.name' }]);+ const { rerender } = renderWith({+ enabled: true,+ signal: TelemetrytypesSignalDTO.traces,+ spec,+ onChangeSpec,+ });++ rerender({+ enabled: true,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });++ expect(selectFieldsOf(onChangeSpec.mock.calls[0][0])).toStrictEqual(+ expectedLogs,+ );+ });++ it('does nothing when the signal is unchanged', () => {+ const onChangeSpec = jest.fn();+ const spec = makeSpec([{ name: 'body' }]);+ const { rerender } = renderWith({+ enabled: true,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });++ rerender({+ enabled: true,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });+ expect(onChangeSpec).not.toHaveBeenCalled();+ });++ it('does not switch on a transient undefined signal', () => {+ const onChangeSpec = jest.fn();+ const spec = makeSpec([{ name: 'body' }]);+ const { rerender } = renderWith({+ enabled: true,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });++ rerender({ enabled: true, signal: undefined, spec, onChangeSpec });+ expect(onChangeSpec).not.toHaveBeenCalled();+ });++ it('does nothing when disabled (non-List kinds)', () => {+ const onChangeSpec = jest.fn();+ const spec = makeSpec([{ name: 'body' }]);+ const { rerender } = renderWith({+ enabled: false,+ signal: TelemetrytypesSignalDTO.logs,+ spec,+ onChangeSpec,+ });++ rerender({+ enabled: false,+ signal: TelemetrytypesSignalDTO.traces,+ spec,+ onChangeSpec,+ });+ expect(onChangeSpec).not.toHaveBeenCalled();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useTableColumns.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useTableColumns.test.tsnew file mode 100644index 0000000000..d5970ae818--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useTableColumns.test.ts@@ -0,0 +1,107 @@+import { renderHook } from '@testing-library/react';+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';+import { prepareScalarTables } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables';+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';++import { useTableColumns } from '../useTableColumns';++jest.mock(+ 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables',+ () => ({ prepareScalarTables: jest.fn() }),+);+jest.mock(+ 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData',+ () => ({ getScalarResults: jest.fn(() => []) }),+);++const mockPrepareScalarTables = prepareScalarTables as unknown as jest.Mock;++const DATA = {+ response: undefined,+ legendMap: {},+ requestPayload: undefined,+} as unknown as PanelQueryData;++function tablePanel(+ columnUnits: Record<string, string> = {},+): DashboardtypesPanelDTO {+ return {+ kind: 'Panel',+ spec: {+ display: { name: 'T' },+ plugin: { kind: 'signoz/TablePanel', spec: { formatting: { columnUnits } } },+ queries: [],+ },+ } as unknown as DashboardtypesPanelDTO;+}++function tableWith(columns: unknown[]): void {+ mockPrepareScalarTables.mockReturnValue([{ columns, rows: [] }]);+}++describe('useTableColumns', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ });++ it('returns [] for a non-table panel kind', () => {+ const panel = {+ kind: 'Panel',+ spec: { plugin: { kind: 'signoz/TimeSeriesPanel', spec: {} }, queries: [] },+ } as unknown as DashboardtypesPanelDTO;++ const { result } = renderHook(() => useTableColumns(panel, DATA));++ expect(result.current).toStrictEqual([]);+ expect(mockPrepareScalarTables).not.toHaveBeenCalled();+ });++ it('returns [] when there is no scalar table with columns', () => {+ mockPrepareScalarTables.mockReturnValue([{ columns: [], rows: [] }]);++ const { result } = renderHook(() => useTableColumns(tablePanel(), DATA));++ expect(result.current).toStrictEqual([]);+ });++ it('keeps only value columns and maps them to key/label', () => {+ tableWith([+ { id: 'service.name', name: 'service.name', isValueColumn: false },+ { id: 'A', name: 'p99', isValueColumn: true },+ ]);++ const { result } = renderHook(() => useTableColumns(tablePanel(), DATA));++ expect(result.current).toStrictEqual([+ { key: 'A', label: 'p99', unit: undefined },+ ]);+ });++ it('falls back to the column name when the column has no id', () => {+ tableWith([{ name: 'count', isValueColumn: true }]);++ const { result } = renderHook(() => useTableColumns(tablePanel(), DATA));++ expect(result.current[0].key).toBe('count');+ });++ it('resolves a column unit by its key', () => {+ tableWith([{ id: 'A', name: 'p99', isValueColumn: true }]);++ const { result } = renderHook(() =>+ useTableColumns(tablePanel({ A: 'ms' }), DATA),+ );++ expect(result.current[0].unit).toBe('ms');+ });++ it('falls back to the base query name for a multi-aggregation column key', () => {+ tableWith([{ id: 'A.p99', name: 'p99', isValueColumn: true }]);++ const { result } = renderHook(() =>+ useTableColumns(tablePanel({ A: 'bytes' }), DATA),+ );++ expect(result.current[0].unit).toBe('bytes');+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.tsnew file mode 100644index 0000000000..a2f6516128--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts@@ -0,0 +1,59 @@+import { useMemo } from 'react';+import { themeColors } from 'constants/theme';+import { useIsDarkMode } from 'hooks/useDarkMode';+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';+import getLabelName from 'lib/getLabelName';+import { generateColor } from 'lib/uPlotLib/utils/generateColor';+import { getBuilderQueries } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';+import { resolveSeriesLabelV5 } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/resolveSeriesLabel';+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import {+ flattenTimeSeries,+ getTimeSeriesResults,+} from 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData';++export interface LegendSeries {+ /** Resolved display label — the key `legend.customColors` is indexed by. */+ label: string;+ /** The series' auto-assigned color, shown when no override is set. */+ defaultColor: string;+}++/**+ * Resolves the panel's rendered series into `{ label, defaultColor }` pairs, using the+ * exact label resolution the time-series renderer applies (`flattenTimeSeries` →+ * `resolveSeriesLabelV5`) and the same `generateColor` default. The legend-colors control+ * keys overrides by these labels, so they must match what the chart draws. Deduplicated,+ * order-preserving; empty until data arrives or for kinds without flat time-series data.+ */+export function useLegendSeries(+ panel: DashboardtypesPanelDTO,+ data: PanelQueryData,+): LegendSeries[] {+ const isDarkMode = useIsDarkMode();++ return useMemo(() => {+ const palette = isDarkMode+ ? themeColors.chartcolors+ : themeColors.lightModeColor;+ const series = flattenTimeSeries(+ getTimeSeriesResults(data?.response),+ data.legendMap,+ );+ const builderQueries = getBuilderQueries(panel?.spec?.queries);++ const byLabel = new Map<string, string>();+ series.forEach((s) => {+ const baseLabel = getLabelName(s.labels, s.queryName, s.legend);+ const label = resolveSeriesLabelV5(s, builderQueries, baseLabel);+ if (label && !byLabel.has(label)) {+ byLabel.set(label, generateColor(label, palette));+ }+ });++ return Array.from(byLabel, ([label, defaultColor]) => ({+ label,+ defaultColor,+ }));+ }, [panel.spec.queries, data.response, data.legendMap, isDarkMode]);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useSwitchColumnsOnSignalChange.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useSwitchColumnsOnSignalChange.tsnew file mode 100644index 0000000000..ce267e06a9--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useSwitchColumnsOnSignalChange.ts@@ -0,0 +1,82 @@+import { useEffect, useRef } from 'react';+import {+ type DashboardtypesPanelSpecDTO,+ TelemetrytypesSignalDTO,+ type TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';+import {+ defaultLogsSelectedColumns,+ defaultTraceSelectedColumns,+} from 'container/OptionsMenu/constants';++import { sanitizeSelectFields } from '../ListColumnsEditor/selectFields';++/**+ * The datasource's default List columns (V1 parity), sanitized to the field-key+ * DTO — the V1 constants carry extra keys (isIndexed) the save contract rejects.+ * Other signals (metrics) don't produce a list, so they clear the selection.+ */+function defaultColumnsForSignal(+ signal: TelemetrytypesSignalDTO,+): TelemetrytypesTelemetryFieldKeyDTO[] {+ if (signal === TelemetrytypesSignalDTO.logs) {+ return sanitizeSelectFields(+ defaultLogsSelectedColumns as TelemetrytypesTelemetryFieldKeyDTO[],+ );+ }+ if (signal === TelemetrytypesSignalDTO.traces) {+ return sanitizeSelectFields(+ defaultTraceSelectedColumns as TelemetrytypesTelemetryFieldKeyDTO[],+ );+ }+ return [];+}++interface UseSwitchColumnsOnSignalChangeArgs {+ /** Gate so the switch only runs for the List kind (the only one with columns). */+ enabled: boolean;+ /** The panel's current telemetry signal (logs / traces / metrics). */+ signal: TelemetrytypesSignalDTO | undefined;+ spec: DashboardtypesPanelSpecDTO;+ onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;+}++/**+ * Switches the List panel's chosen columns to the new datasource's defaults when+ * the panel's telemetry signal changes (e.g. logs → traces). V1 kept a separate+ * field list per datasource; V2 stores a single `selectFields`, so columns picked+ * for one signal are meaningless after switching — replace them with the new+ * source's sensible defaults (matching V1's logs/traces list defaults).+ */+export function useSwitchColumnsOnSignalChange({+ enabled,+ signal,+ spec,+ onChangeSpec,+}: UseSwitchColumnsOnSignalChangeArgs): void {+ const prevSignalRef = useRef(signal);++ useEffect(() => {+ const prev = prevSignalRef.current;+ prevSignalRef.current = signal;++ if (!enabled) {+ return;+ }+ // Only an actual switch between two known signals swaps the columns;+ // transient `undefined` states (mid query-edit) leave the selection intact.+ if (!prev || !signal || prev === signal) {+ return;+ }+ onChangeSpec({+ ...spec,+ plugin: {+ ...spec.plugin,+ spec: {+ ...spec.plugin.spec,+ selectFields: defaultColumnsForSignal(signal),+ },+ },+ } as DashboardtypesPanelSpecDTO);+ }, [enabled, signal, spec, onChangeSpec]);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useTableColumns.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useTableColumns.tsnew file mode 100644index 0000000000..f6c5ea8210--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useTableColumns.ts@@ -0,0 +1,69 @@+import { useMemo } from 'react';+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';+import type { PanelFormattingSlice } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';+import { getColumnUnit } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getColumnUnit';+import { prepareScalarTables } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables';+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import { getScalarResults } from 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData';++export interface TableColumnOption {+ /**+ * Key the column's unit / threshold is stored under — the query identifier+ * (`queryName`, or `queryName.expression` for multi-aggregation queries). Matches+ * `PanelTableColumn.id` and the rendered column's `dataIndex` (V1 parity: column+ * units and thresholds are keyed by the query, not the display name).+ */+ key: string;+ /** Display label shown in the editor — the resolved column name. */+ label: string;+ /**+ * The column's configured unit (`formatting.columnUnits[key]`), if any. The+ * per-column threshold editor scopes its unit picker to this unit's category+ * (V1 parity), since Table panels have no single panel-wide unit.+ */+ unit?: string;+}++/**+ * Resolves a Table panel's value (aggregation) columns into `{ key, label }`+ * options, so the table-only config editors (column units, per-column thresholds)+ * store the query-keyed value the renderer looks up by while showing the readable+ * column name. Empty for non-table kinds or before data arrives.+ */+export function useTableColumns(+ panel: DashboardtypesPanelDTO,+ data: PanelQueryData,+): TableColumnOption[] {+ return useMemo(() => {+ if (panel.spec.plugin.kind !== 'signoz/TablePanel') {+ return [];+ }+ const table = prepareScalarTables({+ results: getScalarResults(data.response),+ legendMap: data.legendMap,+ requestPayload: data.requestPayload,+ }).find((candidate) => candidate.columns.length > 0);+ if (!table) {+ return [];+ }+ const columnUnits =+ (panel.spec.plugin.spec as { formatting?: PanelFormattingSlice }).formatting+ ?.columnUnits ?? {};+ return table.columns+ .filter((column) => column.isValueColumn)+ .map((column) => {+ const key = column.id || column.name;+ return {+ key,+ label: column.name,+ unit: getColumnUnit(key, columnUnits),+ };+ });+ }, [+ panel.spec.plugin.kind,+ panel.spec.plugin.spec,+ data.response,+ data.legendMap,+ data.requestPayload,+ ]);+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsxindex 9aed0bac87..9a898cf2ab 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx@@ -6,23 +6,32 @@ import {useDefaultLayout,} from '@signozhq/ui/resizable';import { toast } from '@signozhq/ui/sonner';-import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';+import type {+ DashboardtypesPanelDTO,+ TelemetrytypesSignalDTO,+} from 'api/generated/services/sigNoz.schemas';import { PANEL_TYPES } from 'constants/queryBuilder';import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';import {PANEL_KIND_TO_PANEL_TYPE,type PanelKind,} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';+import { getBuilderQueries } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';import { usePanelInteractions } from '../PanelsAndSectionsLayout/Panel/hooks/usePanelInteractions';+import ConfigPane from './ConfigPane/ConfigPane';import Header from './Header/Header';import layoutStorage from './layoutStorage';import PanelEditorQueryBuilder from './PanelEditorQueryBuilder/PanelEditorQueryBuilder';import PreviewPane from './PreviewPane/PreviewPane';+import { useLegendSeries } from './hooks/useLegendSeries';import { usePanelQuery } from '../hooks/usePanelQuery';import { usePanelEditorDraft } from './hooks/usePanelEditorDraft';import { usePanelEditorQuerySync } from './hooks/usePanelEditorQuerySync';import { usePanelEditorSave } from './hooks/usePanelEditorSave';+import { useSwitchColumnsOnSignalChange } from './hooks/useSwitchColumnsOnSignalChange';+import { useTableColumns } from './hooks/useTableColumns';+import ListColumnsEditor from './ListColumnsEditor/ListColumnsEditor';import styles from './PanelEditor.module.scss';@@ -48,7 +57,7 @@ function PanelEditorContainer({onClose,onSaved,}: PanelEditorContainerProps): JSX.Element {- const { draft, setSpec, isSpecDirty } = usePanelEditorDraft(panel);+ const { draft, spec, setSpec, isSpecDirty } = usePanelEditorDraft(panel);const { save, isSaving } = usePanelEditorSave({ dashboardId, panelId });const { defaultLayout, onLayoutChanged } = useDefaultLayout({id: 'panel-editor-v2',@@ -96,9 +105,32 @@ function PanelEditorContainer({// Spec and query dirtiness are tracked independently so query re-serialization// never false-dirties.const isDirty = isSpecDirty || isQueryDirty;+ // The List panel edits its columns below the query builder (V1 parity), so the+ // editor container resolves the committed query's signal once and shares it+ // with both the columns control and the datasource-switch effect below.+ const isListPanel = fullKind === 'signoz/ListPanel';+ // The builder-query `signal` literal matches the TelemetrytypesSignalDTO enum+ // 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+ | undefined;++ // When the List panel's datasource changes, swap its columns to the new+ // source's defaults (V1 kept a per-datasource field list; V2 has one+ // `selectFields`). Driven by the committed query's signal, so it lives in the+ // editor container alongside the query sync — ConfigPane stays presentational.+ useSwitchColumnsOnSignalChange({+ enabled: isListPanel,+ signal: listSignal,+ spec,+ onChangeSpec: setSpec,+ });// Drag-to-zoom on the preview updates the URL-synced time window, as on the dashboard.const { onDragSelect } = usePanelInteractions();+ const legendSeries = useLegendSeries(draft, data);+ const tableColumns = useTableColumns(draft, data);const onSave = useCallback(async (): Promise<void> => {try {@@ -153,6 +185,15 @@ function PanelEditorContainer({isLoadingQueries={isFetching}onStageRunQuery={runQuery}onCancelQuery={cancelQuery}+ footer={+ isListPanel ? (+ <ListColumnsEditor+ spec={spec}+ onChangeSpec={setSpec}+ signal={listSignal}+ />+ ) : undefined+ }/></ResizablePanel></ResizablePanelGroup>@@ -164,7 +205,15 @@ function PanelEditorContainer({maxSize="25%"defaultSize="20%"className={styles.right}- />+ >+ <ConfigPane+ panelKind={draft.spec.plugin.kind}+ spec={spec}+ onChangeSpec={setSpec}+ legendSeries={legendSeries}+ tableColumns={tableColumns}+ />+ </ResizablePanel></ResizablePanelGroup></div>);diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.module.scssnew file mode 100644index 0000000000..de1666a357--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.module.scss@@ -0,0 +1,30 @@+.resizableHeader {+ position: relative;+ user-select: none;+ -webkit-user-select: none;+}++// Grip pinned to the column's trailing edge; the offset straddles the border so+// the cursor lands on it without overlapping the adjacent column's content.+.handle {+ position: absolute;+ top: 0;+ bottom: 0;+ inset-inline-end: -5px;+ z-index: 1;+ width: 10px;+ cursor: col-resize;+ touch-action: none;++ &::after {+ content: '';+ position: absolute;+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+ width: 1px;+ height: 1.6em;+ background-color: var(--l3-background);+ transition: background-color 0.2s;+ }+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.tsxnew file mode 100644index 0000000000..f612557b26--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/ResizableTable/ResizableHeader.tsx@@ -0,0 +1,69 @@+import type { HTMLAttributes, SyntheticEvent } from 'react';+import { useMemo } from 'react';+import { Resizable, ResizeCallbackData } from 'react-resizable';++import styles from './ResizableHeader.module.scss';++// react-resizable's user-select hack injects a global style that fights antd's+// own selection handling; disable it (V1 ResizeTable parity).+const DRAGGABLE_OPTS = { enableUserSelectHack: false };+// Don't let a column collapse past a usable width.+const MIN_WIDTH = 80;++export interface ResizableHeaderProps extends Omit<+ HTMLAttributes<HTMLTableCellElement>,+ 'onResize'+> {+ width?: number;+ onResize?: (e: SyntheticEvent<Element>, data: ResizeCallbackData) => void;+}++/**+ * antd header cell (`components.header.cell`) that wraps the `<th>` in a+ * react-resizable handle. `width`/`onResize` are injected per column via the+ * column's `onHeaderCell` (see `useResizableColumns`); a column with neither+ * renders a plain, non-resizable header.+ */+function ResizableHeader({+ width,+ onResize,+ ...restProps+}: ResizableHeaderProps): JSX.Element {+ const handle = useMemo(+ () => (+ <span+ className={styles.handle}+ role="presentation"+ // Stop the grip's click from reaching the column sorter underneath.+ // The grip is a pointer-only resize affordance, not keyboard-actionable.+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions+ onClick={(e): void => e.stopPropagation()}+ />+ ),+ [],+ );++ if (!width || !onResize) {+ return <th {...restProps} />;+ }++ return (+ <Resizable+ width={width}+ height={0}+ handle={handle}+ onResize={onResize}+ draggableOpts={DRAGGABLE_OPTS}+ minConstraints={[MIN_WIDTH, 0]}+ >+ <th {...restProps} className={styles.resizableHeader} />+ </Resizable>+ );+}++ResizableHeader.defaultProps = {+ width: undefined,+ onResize: undefined,+};++export default ResizableHeader;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/__tests__/useResizableColumns.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/__tests__/useResizableColumns.test.tsnew file mode 100644index 0000000000..ee3bb13b4a--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/__tests__/useResizableColumns.test.ts@@ -0,0 +1,102 @@+import { act, renderHook } from '@testing-library/react';+import type { ColumnsType } from 'antd/es/table';+import type { ResizeCallbackData } from 'react-resizable';++import {+ readColumnWidths,+ writeColumnWidths,+} from '../../utils/columnWidthStorage';+import { useResizableColumns } from '../useResizableColumns';++type Row = { key: string; name: string };++const COLUMNS: ColumnsType<Row> = [+ { title: 'Name', dataIndex: 'name', key: 'name' },+ { title: 'Status', dataIndex: 'status', key: 'status' },+];++// Invokes a column's resize handler the way antd's header cell would.+function resize(column: ColumnsType<Row>[number], width: number): void {+ const headerProps = (+ column.onHeaderCell as (c: unknown) => {+ onResize?: (e: unknown, data: ResizeCallbackData) => void;+ }+ )(column);+ headerProps.onResize?.({}, {+ size: { width, height: 0 },+ } as ResizeCallbackData);+}++describe('useResizableColumns', () => {+ beforeEach(() => {+ localStorage.clear();+ });++ it('falls back to the default width when nothing is stored', () => {+ const { result } = renderHook(() =>+ useResizableColumns<Row>({ panelId: 'p1', columns: COLUMNS }),+ );+ expect(result.current.columns.map((c) => c.width)).toStrictEqual([180, 180]);+ });++ it('leaves a flex column width-less (no default) so it fills remaining space', () => {+ const { result } = renderHook(() =>+ useResizableColumns<Row>({+ panelId: 'p1',+ columns: COLUMNS,+ flexColumns: ['status'],+ }),+ );+ const widths = Object.fromEntries(+ result.current.columns.map((c) => [c.key, c.width]),+ );+ // name gets the default; the flex column stays undefined.+ expect(widths).toStrictEqual({ name: 180, status: undefined });+ });++ it('honors a stored width on a flex column once the user resizes it', () => {+ writeColumnWidths('p1', { status: 300 });+ const { result } = renderHook(() =>+ useResizableColumns<Row>({+ panelId: 'p1',+ columns: COLUMNS,+ flexColumns: ['status'],+ }),+ );+ const widths = Object.fromEntries(+ result.current.columns.map((c) => [c.key, c.width]),+ );+ expect(widths).toStrictEqual({ name: 180, status: 300 });+ });++ it('seeds a column with its stored width', () => {+ writeColumnWidths('p1', { name: 250 });+ const { result } = renderHook(() =>+ useResizableColumns<Row>({ panelId: 'p1', columns: COLUMNS }),+ );+ const widths = Object.fromEntries(+ result.current.columns.map((c) => [c.key, c.width]),+ );+ expect(widths).toStrictEqual({ name: 250, status: 180 });+ });++ it('updates the width on resize and persists it (debounced)', () => {+ jest.useFakeTimers();+ try {+ const { result } = renderHook(() =>+ useResizableColumns<Row>({ panelId: 'p1', columns: COLUMNS }),+ );++ act(() => resize(result.current.columns[0], 321));++ expect(result.current.columns[0].width).toBe(321);+ // Not yet flushed to storage.+ expect(readColumnWidths('p1')).toStrictEqual({});++ act(() => jest.advanceTimersByTime(400));+ expect(readColumnWidths('p1')).toStrictEqual({ name: 321 });+ } finally {+ jest.useRealTimers();+ }+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/useResizableColumns.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/useResizableColumns.tsnew file mode 100644index 0000000000..0527a60b3e--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/hooks/useResizableColumns.ts@@ -0,0 +1,147 @@+import {+ SyntheticEvent,+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from 'react';+import type { TableProps } from 'antd';+import type { ResizeCallbackData } from 'react-resizable';+import { debounce } from 'lodash-es';++import ResizableHeader, {+ ResizableHeaderProps,+} from '../components/ResizableTable/ResizableHeader';+import {+ ColumnWidths,+ readColumnWidths,+ writeColumnWidths,+} from '../utils/columnWidthStorage';++type Columns<T> = NonNullable<TableProps<T>['columns']>;+type Column<T> = Columns<T>[number];++// Starting width for a column with no stored or column-declared width. Also the+// floor that makes every column resizable (a column needs a width to get a grip).+const DEFAULT_COLUMN_WIDTH = 180;+// Coalesce the burst of resize events during a drag into a single write.+const PERSIST_DEBOUNCE_MS = 400;++// A column's key for width storage: its antd `key`, falling back to `dataIndex`.+// Both Table and List columns set `key`, so this is effectively always present.+function getColumnKey<T>(column: Column<T>): string | undefined {+ const raw =+ 'key' in column && column.key != null+ ? column.key+ : (column as { dataIndex?: unknown }).dataIndex;+ if (typeof raw === 'string') {+ return raw;+ }+ if (typeof raw === 'number') {+ return String(raw);+ }+ return undefined;+}++interface UseResizableColumnsArgs<T> {+ /** Scopes the persisted widths so each panel resizes independently. */+ panelId: string;+ columns: Columns<T>;+ defaultWidth?: number;+ /**+ * Column keys that should stay width-less (flexible) unless the user has+ * resized them — they absorb the remaining table width under `tableLayout:+ * fixed` so the table fits its container (e.g. the List panel's `body`).+ */+ flexColumns?: string[];+}++interface UseResizableColumnsResult<T> {+ columns: Columns<T>;+ components: TableProps<T>['components'];+}++/**+ * Makes an antd Table's columns user-resizable, persisting each panel's widths to+ * localStorage so they survive reloads. Returns the merged columns (seeded with+ * stored/default widths and an `onHeaderCell` resize handler) plus the `components`+ * override that swaps in the resizable header cell. Shared by the Table and List+ * panel renderers.+ */+export function useResizableColumns<T>({+ panelId,+ columns,+ defaultWidth = DEFAULT_COLUMN_WIDTH,+ flexColumns,+}: UseResizableColumnsArgs<T>): UseResizableColumnsResult<T> {+ const flexKeys = useMemo(() => new Set(flexColumns ?? []), [flexColumns]);+ // Live widths keyed by column key. Seeded from localStorage so a resized+ // panel renders at its saved widths on first paint.+ const [widths, setWidths] = useState<ColumnWidths>(() =>+ readColumnWidths(panelId),+ );++ // The same renderer instance can be reused across panels (e.g. switching the+ // edited panel), so re-seed from storage whenever the panel identity changes.+ useEffect(() => {+ setWidths(readColumnWidths(panelId));+ }, [panelId]);++ // Debounced persist, recreated per panel so a trailing call always writes to+ // the right entry; cancelled on unmount/panel change to drop pending writes.+ const persist = useMemo(+ () =>+ debounce((next: ColumnWidths) => {+ writeColumnWidths(panelId, next);+ }, PERSIST_DEBOUNCE_MS),+ [panelId],+ );+ useEffect(() => (): void => persist.cancel(), [persist]);++ // Mirror the latest widths so the resize handler can derive the next map+ // without depending on (and thus rebuilding) on every width change.+ const widthsRef = useRef(widths);+ widthsRef.current = widths;++ const handleResize = useCallback(+ (key: string) =>+ (_e: SyntheticEvent<Element>, { size }: ResizeCallbackData): void => {+ const next = { ...widthsRef.current, [key]: Math.round(size.width) };+ widthsRef.current = next;+ setWidths(next);+ persist(next);+ },+ [persist],+ );++ const resizableColumns = useMemo<Columns<T>>(+ () =>+ columns.map((column) => {+ const key = getColumnKey(column);+ // Flex columns stay width-less (so they fill the remaining width) until+ // the user resizes them; everything else falls back to the default.+ const isFlex = key !== undefined && flexKeys.has(key);+ const width =+ (key ? widths[key] : undefined) ??+ (column.width as number | undefined) ??+ (isFlex ? undefined : defaultWidth);+ return {+ ...column,+ width,+ onHeaderCell: (): ResizableHeaderProps => ({+ width,+ onResize: key && width ? handleResize(key) : undefined,+ }),+ } as Column<T>;+ }),+ [columns, widths, defaultWidth, flexKeys, handleResize],+ );++ const components = useMemo<TableProps<T>['components']>(+ () => ({ header: { cell: ResizableHeader } }),+ [],+ );++ return { columns: resizableColumns, components };+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/ListPanel.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/ListPanel.module.scssnew file mode 100644index 0000000000..fa45db6ce5--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/ListPanel.module.scss@@ -0,0 +1,65 @@+@use '../../../../../../styles/scrollbar' as *;++// Scroll the table within the panel rather than letting it grow the card.+.container {+ flex: 1;+ min-width: 0;+ min-height: 0;+ overflow: auto;++ // Match the chart legend scrollbar (shared mixin).+ @include custom-scrollbar;++ // antd renders its own scroll containers when `scroll={{ x, y }}` is set —+ // the pinned-header body (vertical) and the content (horizontal). Match them+ // to the legend scrollbar too.+ :global(.ant-table-body),+ :global(.ant-table-content) {+ @include custom-scrollbar;+ }+}++// Logs: drop the row separators for a denser log view (V1 logs table parity).+.logRows {+ :global(.ant-table-tbody) > tr > td {+ border-bottom: none;+ }+}++// Traces: every row navigates to its trace, so present the cells as links+// (V1 wraps each trace cell in an anchor).+.traceRows {+ :global(.ant-table-tbody) > tr {+ cursor: pointer;+ }++ :global(.ant-table-tbody) > tr > td,+ :global(.ant-table-tbody) > tr > td :global(.ant-typography) {+ color: var(--bg-robin-400);+ }++ :global(.ant-table-tbody) > tr:hover > td :global(.ant-typography) {+ text-decoration: underline;+ }+}++// Server-side prev/next pager, pinned below the scrolling table body.+.pager {+ display: flex;+ align-items: center;+ justify-content: flex-end;+ gap: 8px;+ padding: 6px 8px;+ flex-shrink: 0;+}++.pagerLabel {+ font-size: 12px;+ color: var(--l3-foreground);+}++// Page-size picker, sat to the right of the prev/next controls.+.pageSize {+ min-width: 96px;+ margin-left: 4px;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsxnew file mode 100644index 0000000000..498f543e93--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx@@ -0,0 +1,213 @@+import { useMemo, useRef } from 'react';+import { Select, Table } from 'antd';+import cx from 'classnames';+import { Button } from '@signozhq/ui/button';+import { ChevronLeft, ChevronRight } from '@signozhq/icons';+import {+ type DashboardtypesListPanelSpecDTO,+ TelemetrytypesSignalDTO,+} from 'api/generated/services/sigNoz.schemas';+import LogDetail from 'components/LogDetail';+import { useResizeObserver } from 'hooks/useDimensions';+import { useTimezone } from 'providers/Timezone';+import { prepareRawTable } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable';+import { getRawResults } from 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData';+import type { IField } from 'types/api/logs/fields';++import PanelStyles from '../../panel.module.scss';+import { PanelRendererProps } from '../../types/rendererProps';+import { useResizableColumns } from '../../hooks/useResizableColumns';+import { getBuilderQueries } from '../../utils/getBuilderQueries';+import NoData from '../../components/NoData/NoData';+import { computeTableLayout, filterTableRows } from '../../utils/recordTable';++import { buildListColumns } from './columns';+import { useListRowInteraction } from './useListRowInteraction';++import styles from './ListPanel.module.scss';++// `body` flexes to fill the remaining table width (module-level so the resize+// hook's memo dependency stays referentially stable across renders).+const BODY_FLEX_COLUMNS = ['body'];++function ListPanelRenderer({+ panelId,+ panel,+ data,+ searchTerm = '',+ pagination,+}: PanelRendererProps<'signoz/ListPanel'>): JSX.Element {+ // Pin the header while the body scrolls (shared with the Table kind).+ const containerRef = useRef<HTMLDivElement>(null);+ const { height } = useResizeObserver(containerRef);+ const { scrollY } = useMemo(() => computeTableLayout(height), [height]);++ // The registry guarantees this Renderer only runs for `signoz/ListPanel`, so+ // the cast is a documented boundary narrowing.+ const spec = useMemo<DashboardtypesListPanelSpecDTO>(+ () => (panel.spec.plugin.spec ?? {}) as DashboardtypesListPanelSpecDTO,+ [panel.spec.plugin.spec],+ );++ // Telemetry signal of the panel's first builder query — drives data flattening,+ // per-signal cell rendering, and the row-click behavior (log drawer vs trace+ // navigation). Cast at this boundary (the query carries the same string values).+ const signal = useMemo(+ () =>+ (getBuilderQueries(panel.spec.queries)[0]+ ?.signal as TelemetrytypesSignalDTO) || TelemetrytypesSignalDTO.logs,+ [panel.spec.queries],+ );++ const table = useMemo(+ () =>+ prepareRawTable({+ results: getRawResults(data.response),+ selectFields: spec.selectFields ?? [],+ signal,+ }),+ [data.response, spec.selectFields, signal],+ );++ const { formatTimezoneAdjustedTimestamp } = useTimezone();++ const columns = useMemo(+ () =>+ table+ ? buildListColumns({+ columns: table.columns,+ signal,+ formatTimestamp: formatTimezoneAdjustedTimestamp,+ })+ : [],+ [table, signal, formatTimezoneAdjustedTimestamp],+ );++ // User-resizable columns, persisted per panel; `body` flexes to fill width.+ const { columns: resizableColumns, components } = useResizableColumns({+ panelId,+ columns,+ flexColumns: BODY_FLEX_COLUMNS,+ });++ const dataSource = useMemo(() => table?.rows ?? [], [table]);++ // Header search filters the current page client-side (V1 parity); paging+ // across pages is server-side via `pagination`.+ const filteredDataSource = useMemo(+ () => filterTableRows(dataSource, searchTerm),+ [dataSource, searchTerm],+ );++ const { onRow, logDetail } = useListRowInteraction({+ signal,+ rows: filteredDataSource,+ });++ // The drawer's "selected fields" tab mirrors the panel's chosen columns.+ const selectedLogFields = useMemo<IField[]>(+ () =>+ (spec.selectFields ?? []).map((field) => ({+ name: field.name,+ type: field.fieldContext ?? '',+ dataType: field.fieldDataType ?? '',+ })),+ [spec.selectFields],+ );++ // Show the footer whenever the panel pages server-side (no explicit query+ // limit), so the page-size picker is always reachable — V1 parity.+ const showPager = !!pagination;++ return (+ <div+ ref={containerRef}+ data-testid="list-panel-renderer"+ className={PanelStyles.panelContainer}+ >+ {!table || dataSource.length === 0 ? (+ <NoData />+ ) : (+ <>+ <div+ className={cx(styles.container, {+ [styles.logRows]: signal === TelemetrytypesSignalDTO.logs,+ [styles.traceRows]: signal === TelemetrytypesSignalDTO.traces,+ })}+ >+ <Table+ size="small"+ tableLayout="fixed"+ columns={resizableColumns}+ components={components}+ dataSource={filteredDataSource}+ pagination={false}+ // Scroll the body vertically only — no `x: 'max-content'`, which+ // forced a content-width min and pushed columns off-screen;+ // `tableLayout="fixed"` fits them to the available width.+ scroll={{ y: scrollY }}+ onRow={onRow}+ />+ </div>+ {showPager && pagination && (+ <div className={styles.pager} data-testid="list-panel-pager">+ <Button+ type="button"+ variant="ghost"+ color="secondary"+ size="icon"+ aria-label="Previous page"+ data-testid="list-panel-prev"+ disabled={!pagination.canPrev}+ onClick={pagination.goPrev}+ >+ <ChevronLeft size={14} />+ </Button>+ <span className={styles.pagerLabel} data-testid="list-panel-page">+ Page {pagination.pageIndex + 1}+ </span>+ <Button+ type="button"+ variant="ghost"+ color="secondary"+ size="icon"+ aria-label="Next page"+ data-testid="list-panel-next"+ disabled={!pagination.canNext}+ onClick={pagination.goNext}+ >+ <ChevronRight size={14} />+ </Button>+ <Select<number>+ size="small"+ className={styles.pageSize}+ value={pagination.pageSize}+ onChange={(value): void => pagination.setPageSize(value)}+ data-testid="list-panel-page-size"+ options={pagination.pageSizeOptions.map((count) => ({+ value: count,+ label: `${count} / page`,+ }))}+ />+ </div>+ )}+ </>+ )}+ {logDetail?.activeLog && (+ <LogDetail+ log={logDetail.activeLog}+ selectedTab={logDetail.selectedTab}+ onClose={logDetail.onClose}+ onAddToQuery={logDetail.onAddToQuery}+ onClickActionItem={logDetail.onAddToQuery}+ onNavigateLog={logDetail.onNavigateLog}+ logs={logDetail.logs}+ isListViewPanel+ listViewPanelSelectedFields={selectedLogFields}+ />+ )}+ </div>+ );+}++export default ListPanelRenderer;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.tsxnew file mode 100644index 0000000000..0799a6cf66--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/Renderer.test.tsx@@ -0,0 +1,163 @@+import {+ type DashboardtypesListPanelSpecDTO,+ type DashboardtypesPanelDTO,+ type QueryRangeV5200,+} from 'api/generated/services/sigNoz.schemas';+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';+import type {+ PanelPagination,+ PanelQueryData,+} from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import { fireEvent, render } from 'tests/test-utils';++import { BaseRendererProps } from '../../../types/rendererProps';+import ListPanelRenderer from '../Renderer';++function panelWith(+ spec: DashboardtypesListPanelSpecDTO,+): DashboardtypesPanelDTO {+ return {+ kind: 'Panel',+ spec: { plugin: { kind: 'signoz/ListPanel', spec } },+ } as unknown as DashboardtypesPanelDTO;+}++// V5 raw response: one result carrying flattened log rows.+function dataWith(+ rows: { timestamp?: string; data: Record<string, unknown> }[],+): PanelQueryData {+ return {+ response: {+ status: 'success',+ data: {+ type: 'raw',+ data: { results: [{ queryName: 'A', rows }] },+ },+ } as unknown as QueryRangeV5200,+ requestPayload: undefined,+ legendMap: {},+ };+}++const emptyData: PanelQueryData = {+ response: {+ status: 'success',+ data: { type: 'raw', data: { results: [] } },+ } as unknown as QueryRangeV5200,+ requestPayload: undefined,+ legendMap: {},+};++function renderPanel(+ props: Partial<BaseRendererProps>,+): ReturnType<typeof render> {+ const baseProps: BaseRendererProps = {+ panelId: 'panel-1',+ panel: panelWith({}),+ data: emptyData,+ isLoading: false,+ error: null,+ panelMode: PanelMode.DASHBOARD_VIEW,+ ...props,+ };+ return render(<ListPanelRenderer {...baseProps} />);+}++describe('ListPanelRenderer', () => {+ it('renders derived columns and row values', () => {+ const { getByText } = renderPanel({+ data: dataWith([+ {+ timestamp: '2026-01-01T00:00:00Z',+ data: { body: 'request ok', level: 'info' },+ },+ {+ timestamp: '2026-01-01T00:00:01Z',+ data: { body: 'boom', level: 'error' },+ },+ ]),+ });++ expect(getByText('body')).toBeInTheDocument();+ expect(getByText('level')).toBeInTheDocument();+ expect(getByText('request ok')).toBeInTheDocument();+ expect(getByText('boom')).toBeInTheDocument();+ });++ it('filters rows by the header search term (case-insensitive)', () => {+ const { getByText, queryByText } = renderPanel({+ data: dataWith([+ { data: { body: 'request ok', level: 'info' } },+ { data: { body: 'boom', level: 'error' } },+ ]),+ searchTerm: 'ERROR',+ });++ expect(getByText('boom')).toBeInTheDocument();+ expect(queryByText('request ok')).not.toBeInTheDocument();+ });++ it('renders No Data when the raw response has no rows', () => {+ const { getByTestId } = renderPanel({ data: emptyData });++ expect(getByTestId('panel-no-data')).toBeInTheDocument();+ });++ it('renders No Data when the response is absent', () => {+ const { getByTestId } = renderPanel({+ data: { response: undefined, requestPayload: undefined, legendMap: {} },+ });++ expect(getByTestId('panel-no-data')).toBeInTheDocument();+ });++ const makePagination = (+ overrides: Partial<PanelPagination> = {},+ ): PanelPagination => ({+ pageIndex: 0,+ canPrev: false,+ canNext: false,+ goPrev: jest.fn(),+ goNext: jest.fn(),+ pageSize: 10,+ pageSizeOptions: [10, 25, 50],+ setPageSize: jest.fn(),+ ...overrides,+ });++ it('shows the pager and calls goNext when Next is clicked', () => {+ const goNext = jest.fn();+ const { getByTestId } = renderPanel({+ data: dataWith([{ data: { body: 'x' } }]),+ pagination: makePagination({+ pageIndex: 1,+ canPrev: true,+ canNext: true,+ goNext,+ }),+ });++ expect(getByTestId('list-panel-page')).toHaveTextContent('Page 2');+ fireEvent.click(getByTestId('list-panel-next'));+ expect(goNext).toHaveBeenCalled();+ });++ it('renders the pager (with the page-size picker) even on a single page', () => {+ const { getByTestId } = renderPanel({+ data: dataWith([{ data: { body: 'x' } }]),+ pagination: makePagination(),+ });++ expect(getByTestId('list-panel-pager')).toBeInTheDocument();+ expect(getByTestId('list-panel-page-size')).toBeInTheDocument();+ });++ it('does not render the pager when the panel is not server-paged', () => {+ const { queryByTestId } = renderPanel({+ data: dataWith([{ data: { body: 'x' } }]),+ pagination: undefined,+ });++ expect(queryByTestId('list-panel-pager')).not.toBeInTheDocument();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/columns.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/columns.test.tsxnew file mode 100644index 0000000000..776cc886ab--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/columns.test.tsx@@ -0,0 +1,111 @@+import { render } from '@testing-library/react';+import type { ColumnType } from 'antd/es/table';+import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';++import type { RawTableRow } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable';++import { buildListColumns } from '../columns';++const fmt = ((value: unknown): string => `FMT(${String(value)})`) as never;++type Col = ColumnType<RawTableRow>;++function colByKey(cols: readonly Col[], key: string): Col {+ const col = cols.find((c) => c.key === key);+ if (!col) {+ throw new Error(`column ${key} not found`);+ }+ return col;+}++function renderCell(col: Col, value: unknown): HTMLElement {+ // antd calls render(value, record, index); only value matters here.+ const node = (col.render as (v: unknown) => JSX.Element)(value);+ return render(<>{node}</>).container;+}++describe('buildListColumns', () => {+ it('formats the timestamp column for any signal', () => {+ const cols = buildListColumns({+ columns: ['timestamp', 'body'],+ signal: TelemetrytypesSignalDTO.logs,+ formatTimestamp: fmt,+ }) as Col[];+ const ts = colByKey(cols, 'timestamp');+ expect(ts.title).toBe('Timestamp');+ expect(renderCell(ts, '2026-01-01T00:00:00Z').textContent).toBe(+ 'FMT(2026-01-01T00:00:00Z)',+ );+ });++ it('normalizes a nanosecond epoch to milliseconds before formatting', () => {+ const cols = buildListColumns({+ columns: ['timestamp'],+ signal: TelemetrytypesSignalDTO.logs,+ formatTimestamp: fmt,+ }) as Col[];+ const ts = colByKey(cols, 'timestamp');+ // 1.7e18 ns → 1.7e12 ms; the formatter must receive the ms value, not raw ns.+ expect(renderCell(ts, '1700000000000000000').textContent).toBe(+ 'FMT(1700000000000)',+ );+ expect(renderCell(ts, 1700000000000000000).textContent).toBe(+ 'FMT(1700000000000)',+ );+ });++ it('passes an ISO timestamp through unchanged', () => {+ const cols = buildListColumns({+ columns: ['timestamp'],+ signal: TelemetrytypesSignalDTO.logs,+ formatTimestamp: fmt,+ }) as Col[];+ expect(+ renderCell(colByKey(cols, 'timestamp'), '2026-01-01T00:00:00Z').textContent,+ ).toBe('FMT(2026-01-01T00:00:00Z)');+ });++ it('leaves the log body column width-less (flexible) and ellipsis-truncated', () => {+ const cols = buildListColumns({+ columns: ['body'],+ signal: TelemetrytypesSignalDTO.logs,+ formatTimestamp: fmt,+ }) as Col[];+ const body = colByKey(cols, 'body');+ expect(body.width).toBeUndefined();+ expect(body.ellipsis).toBe(true);+ });++ it('renders trace http fields as a tag', () => {+ const cols = buildListColumns({+ columns: ['http_method'],+ signal: TelemetrytypesSignalDTO.traces,+ formatTimestamp: fmt,+ }) as Col[];+ expect(renderCell(colByKey(cols, 'http_method'), 'GET').textContent).toBe(+ 'GET',+ );+ });++ it('renders trace duration in milliseconds', () => {+ const cols = buildListColumns({+ columns: ['duration_nano'],+ signal: TelemetrytypesSignalDTO.traces,+ formatTimestamp: fmt,+ }) as Col[];+ expect(+ renderCell(colByKey(cols, 'duration_nano'), '1000000').textContent,+ ).toContain('ms');+ });++ it('shows N/A for empty trace cells', () => {+ const cols = buildListColumns({+ columns: ['service.name'],+ signal: TelemetrytypesSignalDTO.traces,+ formatTimestamp: fmt,+ }) as Col[];+ expect(renderCell(colByKey(cols, 'service.name'), '').textContent).toBe(+ 'N/A',+ );+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/rawRowToILog.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/rawRowToILog.test.tsnew file mode 100644index 0000000000..5b2ec0e383--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/__tests__/rawRowToILog.test.ts@@ -0,0 +1,67 @@+import { rawRowToILog } from '../rawRowToILog';++describe('rawRowToILog', () => {+ it('maps snake_case log fields onto the ILog aliases', () => {+ const log = rawRowToILog({+ key: 0,+ id: 'log-1',+ timestamp: '2026-01-01T00:00:00Z',+ body: 'hello world',+ severity_text: 'INFO',+ severity_number: 9,+ trace_id: 'trace-abc',+ span_id: 'span-xyz',+ });++ expect(log).toMatchObject({+ id: 'log-1',+ date: '2026-01-01T00:00:00Z',+ timestamp: '2026-01-01T00:00:00Z',+ body: 'hello world',+ severityText: 'INFO',+ severity_text: 'INFO',+ severityNumber: 9,+ severity_number: 9,+ traceId: 'trace-abc',+ trace_id: 'trace-abc',+ spanID: 'span-xyz',+ span_id: 'span-xyz',+ });+ });++ it('falls back to the synthetic row key when the row has no id', () => {+ expect(rawRowToILog({ key: 7, body: 'x' }).id).toBe('7');+ });++ it('defaults missing severity/ids to empty/zero without throwing', () => {+ const log = rawRowToILog({ key: 1, body: 'x' });+ expect(log.severityText).toBe('');+ expect(log.severityNumber).toBe(0);+ expect(log.traceId).toBe('');+ expect(log.spanID).toBe('');+ });++ it('guarantees object map fields so the drawer never hits Object.keys(undefined)', () => {+ // A flattened row has no resources_string; the drawer iterates it with+ // Object.keys, so it must be an object, not undefined.+ const log = rawRowToILog({+ key: 2,+ body: 'x',+ 'service.name': 'currencyservice',+ });+ expect(log.resources_string).toStrictEqual({});+ expect(log.attributes_string).toStrictEqual({});+ expect(() => Object.keys(log.resources_string)).not.toThrow();+ });++ it('preserves a structured resources_string when present', () => {+ const log = rawRowToILog({+ key: 3,+ body: 'x',+ resources_string: { 'service.name': 'currencyservice' },+ });+ expect(log.resources_string).toStrictEqual({+ 'service.name': 'currencyservice',+ });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/columns.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/columns.tsxnew file mode 100644index 0000000000..ba1750ab81--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/columns.tsx@@ -0,0 +1,187 @@+import type { ReactNode } from 'react';+import type { TableProps } from 'antd';+import { Badge } from '@signozhq/ui/badge';+import { Typography } from '@signozhq/ui/typography';+import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';+import { DATE_TIME_FORMATS } from 'constants/dateTimeFormats';+import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';+import type {+ FormatTimezoneAdjustedTimestamp,+ TimestampInput,+} from 'hooks/useTimezoneFormatter/useTimezoneFormatter';+import LineClampedText from 'periscope/components/LineClampedText/LineClampedText';+import { coerceToString } from 'utils/stringUtils';++import type { RawTableRow } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable';++type ListColumns = NonNullable<TableProps<RawTableRow>['columns']>;++const TIMESTAMP_COLUMN = 'timestamp';+const BODY_COLUMN = 'body';+// Seed widths mirror V1; the resize hook treats these as the per-column default.+const TIMESTAMP_WIDTH = 180;+const TRACE_COLUMN_WIDTH = 145;+const TRACE_CLAMP_LINES = 3;++// V1 trace columns that render as a coloured tag / formatted duration.+const HTTP_FIELDS = new Set([+ 'httpMethod',+ 'http_method',+ 'responseStatusCode',+ 'response_status_code',+]);+const DURATION_FIELDS = new Set(['durationNano', 'duration_nano']);++function renderCell(value: unknown): ReactNode {+ return <Typography.Text>{coerceToString(value)}</Typography.Text>;+}++/**+ * Scale an epoch integer to milliseconds (what dayjs expects) by its magnitude:+ * logs/traces carry nanoseconds, but be tolerant of µs/ms/s too.+ */+function epochToMillis(n: number): number {+ if (n >= 1e18) {+ return Math.floor(n / 1e6); // nanoseconds+ }+ if (n >= 1e15) {+ return Math.floor(n / 1e3); // microseconds+ }+ if (n >= 1e12) {+ return n; // milliseconds+ }+ if (n >= 1e9) {+ return n * 1e3; // seconds+ }+ return n;+}++/**+ * The timestamp can arrive as an ISO string or a bare epoch (ns/µs/ms/s) — return+ * something `dayjs` parses correctly, or null when there's nothing to show.+ */+function normalizeTimestamp(value: unknown): TimestampInput | null {+ if (value == null) {+ return null;+ }+ if (value instanceof Date || typeof value === 'number') {+ return typeof value === 'number' ? epochToMillis(value) : value;+ }+ if (typeof value === 'string') {+ const trimmed = value.trim();+ if (trimmed === '') {+ return null;+ }+ // All-digits → numeric epoch (string form, e.g. nanoseconds); else ISO.+ return /^\d+$/.test(trimmed) ? epochToMillis(Number(trimmed)) : trimmed;+ }+ return null;+}++/** Timestamp cell: normalize the epoch/ISO value then format in the user's timezone (V1 parity). */+function makeTimestampRenderer(+ formatTimestamp: FormatTimezoneAdjustedTimestamp,+) {+ return (value: unknown): ReactNode => {+ const normalized = normalizeTimestamp(value);+ return (+ <Typography.Text>+ {normalized == null+ ? ''+ : formatTimestamp(normalized, DATE_TIME_FORMATS.ISO_DATETIME_MS)}+ </Typography.Text>+ );+ };+}++/**+ * Trace attribute cell: empty → N/A, http verb/status → tag, duration → ms,+ * everything else → a 3-line-clamped value (V1 `getListColumns`).+ */+function makeTraceRenderer(name: string) {+ return (value: unknown): ReactNode => {+ if (value == null || value === '') {+ return <Typography.Text data-testid={name}>N/A</Typography.Text>;+ }+ if (HTTP_FIELDS.has(name)) {+ return (+ <Badge color="sakura" variant="outline" data-testid={name}>+ {coerceToString(value)}+ </Badge>+ );+ }+ if (DURATION_FIELDS.has(name)) {+ return (+ <Typography.Text data-testid={name}>+ {getMs(coerceToString(value))}ms+ </Typography.Text>+ );+ }+ return (+ <LineClampedText text={coerceToString(value)} lines={TRACE_CLAMP_LINES} />+ );+ };+}++export interface BuildListColumnsArgs {+ /** Prepared column ids in render order (timestamp first when present). */+ columns: string[];+ /** Panel telemetry signal — picks log vs trace cell rendering. */+ signal: TelemetrytypesSignalDTO | undefined;+ /** Timezone-aware timestamp formatter from `useTimezone`. */+ formatTimestamp: FormatTimezoneAdjustedTimestamp;+}++/**+ * Builds antd columns for the List panel, rendering cells per the panel's signal+ * (V1 parity): the `timestamp` column is timezone-formatted for every signal;+ * traces add tag/duration/clamp rendering; logs widen + ellipsis-truncate `body`.+ * Each id is both the title and the `dataIndex` into the flattened row.+ */+export function buildListColumns({+ columns,+ signal,+ formatTimestamp,+}: BuildListColumnsArgs): ListColumns {+ const isTraces = signal === TelemetrytypesSignalDTO.traces;+ const renderTimestamp = makeTimestampRenderer(formatTimestamp);++ return columns.map((name) => {+ if (name === TIMESTAMP_COLUMN) {+ return {+ title: 'Timestamp',+ dataIndex: name,+ key: name,+ width: TIMESTAMP_WIDTH,+ render: renderTimestamp,+ };+ }+ if (isTraces) {+ return {+ title: name,+ dataIndex: name,+ key: name,+ width: TRACE_COLUMN_WIDTH,+ render: makeTraceRenderer(name),+ };+ }+ if (name === BODY_COLUMN) {+ // No fixed width: `body` is the flex column (see the renderer's+ // `flexColumns`), absorbing the remaining table width and truncating.+ return {+ title: name,+ dataIndex: name,+ key: name,+ ellipsis: true,+ render: renderCell,+ };+ }+ return {+ title: name,+ dataIndex: name,+ key: name,+ ellipsis: true,+ render: renderCell,+ };+ });+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/definition.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/definition.tsnew file mode 100644index 0000000000..7d349eec97--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/definition.ts@@ -0,0 +1,22 @@+import { DataSource } from 'types/common/queryBuilder';++import type { PanelDefinition } from '../../types/panelDefinition';+import Renderer from './Renderer';+import { sections } from './sections';++export const definition: PanelDefinition<'signoz/ListPanel'> = {+ kind: 'signoz/ListPanel',+ displayName: 'List',+ Renderer,+ // Raw records come from logs and traces; metrics don't produce row data.+ supportedSignals: [DataSource.LOGS, DataSource.TRACES],+ sections,+ actions: {+ view: true,+ edit: true,+ clone: true,+ download: false,+ createAlert: false,+ search: true,+ },+};diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/rawRowToILog.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/rawRowToILog.tsnew file mode 100644index 0000000000..6798e750c7--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/rawRowToILog.ts@@ -0,0 +1,55 @@+import { isPlainObject } from 'lodash-es';+import type { RawTableRow } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable';+import type { ILog } from 'types/api/logs/log';+import { toFiniteNumber } from 'utils/numericUtils';+import { coerceToString } from 'utils/stringUtils';++// Map-typed fields the LogDetail drawer iterates with `Object.keys` (resource+// filters, attribute/scope tabs). Default to `{}` so a row missing one (or a+// flattened row) never trips `Object.keys(undefined)`.+const MAP_FIELDS = [+ 'resources_string',+ 'attributes_string',+ 'attributes_number',+ 'attributes_bool',+ 'scope_string',+] as const;++/**+ * Best-effort projection of a V5 raw log row into the `ILog` shape the shared+ * `LogDetail` drawer consumes. The raw row already carries the log's fields+ * flattened onto the top level; we surface the canonical aliases the drawer+ * reads and pass everything else through. `id`-less rows fall back to the+ * synthetic table key so navigation/active-log tracking stays stable.+ */+export function rawRowToILog(row: RawTableRow): ILog {+ const data = row as Record<string, unknown>;+ const severityText = data.severity_text ?? data.severityText;+ const severityNumber = data.severity_number ?? data.severityNumber;+ const traceId = data.trace_id ?? data.traceId;+ const spanId = data.span_id ?? data.spanID;++ const maps = Object.fromEntries(+ MAP_FIELDS.map((field) => [+ field,+ isPlainObject(data[field]) ? data[field] : {},+ ]),+ );++ return {+ ...data,+ ...maps,+ id: coerceToString(data.id ?? row.key),+ timestamp: (data.timestamp as string | number) ?? '',+ date: coerceToString(data.timestamp),+ body: (data.body as ILog['body']) ?? '',+ severityText: coerceToString(severityText),+ severity_text: coerceToString(severityText),+ severityNumber: toFiniteNumber(severityNumber),+ severity_number: toFiniteNumber(severityNumber),+ traceId: coerceToString(traceId),+ trace_id: coerceToString(traceId),+ spanID: coerceToString(spanId),+ span_id: coerceToString(spanId),+ } as ILog;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.tsnew file mode 100644index 0000000000..7d7a9891be--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/sections.ts@@ -0,0 +1,5 @@+import type { SectionConfig } from '../../types/sections';++// List columns are edited below the query builder, not in the config pane, so+// only Context Links shows here.+export const sections: SectionConfig[] = [{ kind: 'contextLinks' }];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/useListRowInteraction.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/useListRowInteraction.tsnew file mode 100644index 0000000000..a67e19eed6--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/useListRowInteraction.ts@@ -0,0 +1,109 @@+import { HTMLAttributes, useCallback, useMemo } from 'react';+import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';+import { VIEW_TYPES, type VIEWS } from 'components/LogDetail/constants';+import { getTraceLink } from 'container/TracesExplorer/ListView/utils';+import useLogDetailHandlers from 'hooks/logs/useLogDetailHandlers';+import history from 'lib/history';+import type { RowData } from 'lib/query/createTableColumnsFromQuery';+import type { ILog } from 'types/api/logs/log';+import { openInNewTab } from 'utils/navigation';++import type { RawTableRow } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable';++import { rawRowToILog } from './rawRowToILog';++/** Drawer state surfaced to the renderer when the panel shows logs. */+export interface ListLogDetail {+ activeLog: ILog | null;+ selectedTab: VIEWS;+ logs: ILog[];+ onClose: () => void;+ onAddToQuery: ReturnType<typeof useLogDetailHandlers>['onAddToQuery'];+ onNavigateLog: (log: ILog) => void;+}++interface UseListRowInteractionArgs {+ /** Telemetry signal of the panel's first builder query (logs vs traces). */+ signal: TelemetrytypesSignalDTO;+ /** Current page rows, mapped to `ILog[]` for log-detail navigation. */+ rows: RawTableRow[];+}++interface UseListRowInteractionResult {+ /** antd `onRow` handler: opens the log drawer or navigates to a trace. */+ onRow: (row: RawTableRow) => HTMLAttributes<HTMLElement>;+ /** Log-drawer state — `null` for non-log panels (renderer skips the drawer). */+ logDetail: ListLogDetail | null;+}++/**+ * Signal-aware row interaction for the List panel, reusing the shared surfaces:+ * a `logs` panel opens the `LogDetail` drawer (with prev/next navigation and+ * add-to-query), a `traces` panel navigates to the trace detail page+ * (⌘/Ctrl-click → new tab). Mirrors V1's Logs/Traces list components.+ */+export function useListRowInteraction({+ signal,+ rows,+}: UseListRowInteractionArgs): UseListRowInteractionResult {+ const isLogs = signal === TelemetrytypesSignalDTO.logs;+ const isTraces = signal === TelemetrytypesSignalDTO.traces;++ const {+ activeLog,+ onAddToQuery,+ selectedTab,+ handleSetActiveLog,+ handleCloseLogDetail,+ } = useLogDetailHandlers();++ const logs = useMemo(+ () => (isLogs ? rows.map(rawRowToILog) : []),+ [isLogs, rows],+ );++ const onRow = useCallback(+ (row: RawTableRow): HTMLAttributes<HTMLElement> => ({+ onClick: (event): void => {+ if (isTraces) {+ const link = getTraceLink(row as unknown as RowData);+ if (event.metaKey || event.ctrlKey) {+ openInNewTab(link);+ } else {+ history.push(link);+ }+ return;+ }+ if (isLogs) {+ handleSetActiveLog(rawRowToILog(row));+ }+ },+ }),+ [isLogs, isTraces, handleSetActiveLog],+ );++ const logDetail = useMemo<ListLogDetail | null>(+ () =>+ isLogs+ ? {+ activeLog,+ selectedTab: selectedTab ?? VIEW_TYPES.OVERVIEW,+ logs,+ onClose: handleCloseLogDetail,+ onAddToQuery,+ onNavigateLog: handleSetActiveLog,+ }+ : null,+ [+ isLogs,+ activeLog,+ selectedTab,+ logs,+ handleCloseLogDetail,+ onAddToQuery,+ handleSetActiveLog,+ ],+ );++ return { onRow, logDetail };+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsxnew file mode 100644index 0000000000..ad2cb496b6--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx@@ -0,0 +1,137 @@+import { useEffect, useMemo, useRef, useState } from 'react';+import { Table } from 'antd';+import type { DashboardtypesTablePanelSpecDTO } from 'api/generated/services/sigNoz.schemas';+import { useResizeObserver } from 'hooks/useDimensions';+import { prepareScalarTables } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables';+import { getScalarResults } from 'pages/DashboardPageV2/DashboardContainer/queryV5/v5ResponseData';++import PanelStyles from '../../panel.module.scss';+import { PanelRendererProps } from '../../types/rendererProps';+import { resolveDecimalPrecision } from '../../utils/chartAppearance/resolvers';+import { useResizableColumns } from '../../hooks/useResizableColumns';+import NoData from '../../components/NoData/NoData';++import { computeTableLayout, filterTableRows } from '../../utils/recordTable';++import {+ buildTableColumns,+ mapTableThresholds,+ type TableRowData,+} from './tableColumns';++import styles from './TablePanel.module.scss';++function TablePanelRenderer({+ panelId,+ panel,+ data,+ searchTerm = '',+}: PanelRendererProps<'signoz/TablePanel'>): JSX.Element {+ // Measure the panel so each page roughly fills it (min 10 rows) and the+ // header stays pinned while the body scrolls.+ const containerRef = useRef<HTMLDivElement>(null);+ const { height } = useResizeObserver(containerRef);+ const { pageSize, scrollY } = useMemo(+ () => computeTableLayout(height),+ [height],+ );++ // The registry guarantees this Renderer only runs when+ // `panel.spec.plugin.kind === 'signoz/TablePanel'`, so the cast is a+ // documented boundary narrowing. Memoized so the `?? {}` fallback doesn't+ // produce a fresh object on each render.+ const spec = useMemo<DashboardtypesTablePanelSpecDTO>(+ () => (panel.spec.plugin.spec ?? {}) as DashboardtypesTablePanelSpecDTO,+ [panel.spec.plugin.spec],+ );++ // V5 joins every query into a single scalar result, so the first non-empty+ // table is the whole panel.+ const table = useMemo(+ () =>+ prepareScalarTables({+ results: getScalarResults(data?.response),+ legendMap: data.legendMap ?? {},+ requestPayload: data.requestPayload,+ }).find((candidate) => candidate.columns.length > 0),+ [data.response, data.legendMap, data.requestPayload],+ );++ const decimalPrecision = useMemo(+ () => resolveDecimalPrecision(spec.formatting?.decimalPrecision),+ [spec.formatting?.decimalPrecision],+ );++ const thresholdsByColumn = useMemo(+ () => mapTableThresholds(spec.thresholds),+ [spec.thresholds],+ );++ const columns = useMemo(+ () =>+ table+ ? buildTableColumns({+ table,+ columnUnits: spec.formatting?.columnUnits ?? {},+ decimalPrecision,+ thresholdsByColumn,+ })+ : [],+ [table, spec.formatting?.columnUnits, decimalPrecision, thresholdsByColumn],+ );++ // User-resizable columns, persisted per panel to localStorage.+ const { columns: resizableColumns, components } = useResizableColumns({+ panelId,+ columns: columns ?? [],+ });++ const dataSource = useMemo<TableRowData[]>(+ () =>+ table ? table.rows.map((row, index) => ({ key: index, ...row.data })) : [],+ [table],+ );++ // Header search filters rows client-side (V1 parity). Falls back to the full+ // set when the term is empty, so non-searching tables pay nothing.+ const filteredDataSource = useMemo(+ () => filterTableRows(dataSource, searchTerm),+ [dataSource, searchTerm],+ );++ // Keep pagination in range as the filtered set shrinks: a new term snaps back+ // to the first page so the user never lands on a now-empty page.+ const [page, setPage] = useState(1);+ useEffect(() => setPage(1), [searchTerm]);++ return (+ <div+ ref={containerRef}+ data-testid="table-panel-renderer"+ className={PanelStyles.panelContainer}+ >+ {!table || dataSource.length === 0 ? (+ <NoData />+ ) : (+ <div className={styles.container}>+ <Table+ size="small"+ columns={resizableColumns}+ components={components}+ dataSource={filteredDataSource}+ pagination={{+ current: page,+ pageSize,+ hideOnSinglePage: true,+ size: 'small',+ onChange: setPage,+ }}+ scroll={{ x: 'max-content', y: scrollY }}+ />+ </div>+ )}+ </div>+ );+}++export default TablePanelRenderer;diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/TablePanel.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/TablePanel.module.scssnew file mode 100644index 0000000000..a0af1a7d89--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/TablePanel.module.scss@@ -0,0 +1,20 @@+@use '../../../../../../styles/scrollbar' as *;++// Scroll the table within the panel rather than letting it grow the card.+.container {+ flex: 1;+ min-width: 0;+ min-height: 0;+ overflow: auto;++ // Match the chart legend scrollbar (shared mixin).+ @include custom-scrollbar;++ // antd renders its own scroll containers when `scroll={{ x, y }}` is set —+ // the pinned-header body (vertical) and the content (horizontal). Match them+ // to the legend scrollbar too.+ :global(.ant-table-body),+ :global(.ant-table-content) {+ @include custom-scrollbar;+ }+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/__tests__/Renderer.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/__tests__/Renderer.test.tsxnew file mode 100644index 0000000000..113e617f29--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/__tests__/Renderer.test.tsx@@ -0,0 +1,127 @@+import {+ type DashboardtypesPanelDTO,+ type DashboardtypesTablePanelSpecDTO,+ type QueryRangeV5200,+} from 'api/generated/services/sigNoz.schemas';+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import { render } from 'tests/test-utils';++import { BaseRendererProps } from '../../../types/rendererProps';+import TablePanelRenderer from '../Renderer';++function panelWith(+ spec: DashboardtypesTablePanelSpecDTO,+): DashboardtypesPanelDTO {+ return {+ kind: 'Panel',+ spec: { plugin: { kind: 'signoz/TablePanel', spec } },+ } as unknown as DashboardtypesPanelDTO;+}++// V5 scalar response: one joined result with a group column + an aggregation column.+function dataWith(rows: [string, number][]): PanelQueryData {+ return {+ response: {+ status: 'success',+ data: {+ type: 'scalar',+ data: {+ results: [+ {+ queryName: 'A',+ columns: [+ { name: 'service.name', queryName: 'A', columnType: 'group' },+ {+ name: '__result',+ queryName: 'A',+ columnType: 'aggregation',+ aggregationIndex: 0,+ },+ ],+ data: rows,+ },+ ],+ },+ },+ } as unknown as QueryRangeV5200,+ requestPayload: undefined,+ legendMap: {},+ };+}++const emptyData: PanelQueryData = {+ response: {+ status: 'success',+ data: { type: 'scalar', data: { results: [] } },+ } as unknown as QueryRangeV5200,+ requestPayload: undefined,+ legendMap: {},+};++function renderPanel(+ props: Partial<BaseRendererProps>,+): ReturnType<typeof render> {+ const baseProps: BaseRendererProps = {+ panelId: 'panel-1',+ panel: panelWith({}),+ data: emptyData,+ isLoading: false,+ error: null,+ panelMode: PanelMode.DASHBOARD_VIEW,+ ...props,+ };+ return render(<TablePanelRenderer {...baseProps} />);+}++describe('TablePanelRenderer', () => {+ it('renders the group column header and its row values', () => {+ const { getByText } = renderPanel({+ data: dataWith([+ ['frontend', 1234],+ ['cartservice', 5678],+ ]),+ });++ expect(getByText('service.name')).toBeInTheDocument();+ expect(getByText('frontend')).toBeInTheDocument();+ expect(getByText('cartservice')).toBeInTheDocument();+ });++ it('renders No Data when the response has no scalar results', () => {+ const { getByTestId } = renderPanel({ data: emptyData });++ expect(getByTestId('panel-no-data')).toBeInTheDocument();+ });++ it('renders No Data when the response is absent', () => {+ const { getByTestId } = renderPanel({+ data: { response: undefined, requestPayload: undefined, legendMap: {} },+ });++ expect(getByTestId('panel-no-data')).toBeInTheDocument();+ });++ it('filters rows to those matching the search term (case-insensitive)', () => {+ const { getByText, queryByText } = renderPanel({+ data: dataWith([+ ['frontend', 1234],+ ['cartservice', 5678],+ ]),+ searchTerm: 'CART',+ });++ expect(getByText('cartservice')).toBeInTheDocument();+ expect(queryByText('frontend')).not.toBeInTheDocument();+ });++ it('keeps the table mounted (not No Data) when the search matches no rows', () => {+ const { getByTestId, queryByText } = renderPanel({+ data: dataWith([['frontend', 1234]]),+ searchTerm: 'no-such-row',+ });++ expect(getByTestId('table-panel-renderer')).toBeInTheDocument();+ expect(queryByText('frontend')).not.toBeInTheDocument();+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/definition.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/definition.tsnew file mode 100644index 0000000000..de40827a44--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/definition.ts@@ -0,0 +1,23 @@+import { DataSource } from 'types/common/queryBuilder';++import type { PanelDefinition } from '../../types/panelDefinition';+import Renderer from './Renderer';+import { sections } from './sections';++export const definition: PanelDefinition<'signoz/TablePanel'> = {+ kind: 'signoz/TablePanel',+ displayName: 'Table',+ Renderer,+ sections,+ supportedSignals: [DataSource.METRICS, DataSource.LOGS, DataSource.TRACES],+ // Tables carry tabular data worth exporting (V1 parity: download is table-only).+ actions: {+ view: true,+ edit: true,+ clone: true,+ download: true,+ createAlert: false,+ // V1 parity: only tables (and lists) expose the header search box.+ search: true,+ },+};diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.tsnew file mode 100644index 0000000000..2bfd9ea78f--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/sections.ts@@ -0,0 +1,11 @@+import 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' },+];diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/tableColumns.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/tableColumns.tsxnew file mode 100644index 0000000000..70998dabc8--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/tableColumns.tsx@@ -0,0 +1,116 @@+import type { TableProps } from 'antd';+import type { DashboardtypesTableThresholdDTO } from 'api/generated/services/sigNoz.schemas';+import type { PrecisionOption } from 'components/Graph/types';+import type { PanelTable } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';+import { coerceToString } from 'utils/stringUtils';++import type { PanelThreshold } from '../../types/threshold';+import { resolveActiveThreshold } from '../../utils/evaluateThresholds';+import { formatPanelValue } from '../../utils/formatPanelValue';+import { getColumnUnit } from '../../utils/getColumnUnit';+import { toPanelThreshold } from '../../utils/mapComparisonThreshold';++/** A prepared scalar-table row flattened for the antd Table, with the antd key. */+export type TableRowData = Record<string, unknown> & { key: number };++/**+ * Groups table thresholds by the column they target, mapping each onto the+ * V2-native `PanelThreshold` consumed by `resolveActiveThreshold`. A column with+ * no thresholds simply has no entry.+ */+export function mapTableThresholds(+ thresholds: DashboardtypesTableThresholdDTO[] | null | undefined,+): Record<string, PanelThreshold[]> {+ const byColumn: Record<string, PanelThreshold[]> = {};+ (thresholds ?? []).forEach((threshold) => {+ (byColumn[threshold.columnName] ??= []).push(toPanelThreshold(threshold));+ });+ return byColumn;+}++// Sort comparator: numeric when both cells parse as numbers (value columns and+// numeric group keys), otherwise a locale string compare. Nullish sorts last.+function compareCells(a: unknown, b: unknown): number {+ const aNum = Number(a);+ const bNum = Number(b);+ if (Number.isFinite(aNum) && Number.isFinite(bNum)) {+ return aNum - bNum;+ }+ if (a == null) {+ return b == null ? 0 : 1;+ }+ if (b == null) {+ return -1;+ }+ return coerceToString(a).localeCompare(coerceToString(b));+}++export interface BuildTableColumnsArgs {+ table: PanelTable;+ /** Per-column display unit (`formatting.columnUnits`), keyed by column name. */+ columnUnits: Record<string, string>;+ decimalPrecision?: PrecisionOption;+ /** Thresholds grouped by column name (see `mapTableThresholds`). */+ thresholdsByColumn: Record<string, PanelThreshold[]>;+}++/**+ * Builds antd Table columns from a prepared scalar table. Value columns format+ * their cell through the column's unit + decimal precision and recolor via the+ * matching threshold (text → font colour, background → cell fill); group columns+ * render their raw label. Every column is sortable.+ */+export function buildTableColumns({+ table,+ columnUnits,+ decimalPrecision,+ thresholdsByColumn,+}: BuildTableColumnsArgs): TableProps<TableRowData>['columns'] {+ return table.columns.map((col) => {+ // Column key = query identifier for value columns, group name otherwise. Units+ // and thresholds are stored against this key (V1 parity), matching the dataIndex.+ const key = col.id || col.name;+ const unit = getColumnUnit(key, columnUnits);+ const colThresholds = thresholdsByColumn[key] ?? [];++ return {+ title: col.name,+ dataIndex: key,+ key,+ sorter: (a: TableRowData, b: TableRowData): number =>+ compareCells(a[key], b[key]),+ render: (raw: unknown): React.ReactNode => {+ if (!col.isValueColumn) {+ return coerceToString(raw);+ }+ const num = Number(raw);+ if (!Number.isFinite(num)) {+ return coerceToString(raw);+ }+ const text = formatPanelValue(num, unit, decimalPrecision);+ if (colThresholds.length === 0) {+ return text;+ }+ const { threshold } = resolveActiveThreshold(colThresholds, num, unit);+ if (threshold?.format === 'text') {+ return <span style={{ color: threshold.color }}>{text}</span>;+ }+ return text;+ },+ onCell: (record: TableRowData): { style?: React.CSSProperties } => {+ if (!col.isValueColumn || colThresholds.length === 0) {+ return {};+ }+ const num = Number(record[key]);+ if (!Number.isFinite(num)) {+ return {};+ }+ const { threshold } = resolveActiveThreshold(colThresholds, num, unit);+ if (threshold?.format === 'background') {+ return { style: { backgroundColor: threshold.color } };+ }+ return {};+ },+ };+ });+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/registry.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/registry.tsindex 975f3e1af1..e18a013ea4 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/registry.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/registry.ts@@ -3,6 +3,8 @@ import { definition as Histogram } from './kinds/HistogramPanel/definition';import { definition as NumberValue } from './kinds/NumberPanel/definition';import { definition as PieChart } from './kinds/PieChartPanel/definition';import { definition as TimeSeries } from './kinds/TimeSeriesPanel/definition';+import { definition as Table } from './kinds/TablePanel/definition';+import { definition as List } from './kinds/ListPanel/definition';import type {PanelRegistry,RenderablePanelDefinition,@@ -18,6 +20,8 @@ export const PANELS: PanelRegistry = {[Histogram.kind]: Histogram,[NumberValue.kind]: NumberValue,[PieChart.kind]: PieChart,+ [Table.kind]: Table,+ [List.kind]: List,};export function getPanelDefinition(diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/columnWidthStorage.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/columnWidthStorage.test.tsnew file mode 100644index 0000000000..82ee4c96d0--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/__tests__/columnWidthStorage.test.ts@@ -0,0 +1,33 @@+import { readColumnWidths, writeColumnWidths } from '../columnWidthStorage';++describe('columnWidthStorage', () => {+ beforeEach(() => {+ localStorage.clear();+ });++ it('returns an empty map when nothing is stored', () => {+ expect(readColumnWidths('panel-1')).toStrictEqual({});+ });++ it('round-trips widths for a panel', () => {+ writeColumnWidths('panel-1', { name: 200, status: 80 });+ expect(readColumnWidths('panel-1')).toStrictEqual({ name: 200, status: 80 });+ });++ it('keeps each panel isolated', () => {+ writeColumnWidths('panel-1', { a: 100 });+ writeColumnWidths('panel-2', { b: 300 });++ expect(readColumnWidths('panel-1')).toStrictEqual({ a: 100 });+ expect(readColumnWidths('panel-2')).toStrictEqual({ b: 300 });+ });++ it('overwrites a panel without touching the others', () => {+ writeColumnWidths('panel-1', { a: 100 });+ writeColumnWidths('panel-2', { b: 300 });+ writeColumnWidths('panel-1', { a: 150, c: 50 });++ expect(readColumnWidths('panel-1')).toStrictEqual({ a: 150, c: 50 });+ expect(readColumnWidths('panel-2')).toStrictEqual({ b: 300 });+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/columnWidthStorage.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/columnWidthStorage.tsnew file mode 100644index 0000000000..57e31a26d8--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/columnWidthStorage.ts@@ -0,0 +1,41 @@+import getLocalStorageApi from 'api/browser/localstorage/get';+import setLocalStorageApi from 'api/browser/localstorage/set';+import { LOCALSTORAGE } from 'constants/localStorage';++/** Resized column widths for a single panel, keyed by column key. */+export type ColumnWidths = Record<string, number>;++// All panels' widths live under one localStorage key, keyed by panelId, so the+// store is a single read/write rather than one entry per panel.+type ColumnWidthStore = Record<string, ColumnWidths>;++function readStore(): ColumnWidthStore {+ try {+ const raw = getLocalStorageApi(LOCALSTORAGE.DASHBOARD_V2_PANEL_COLUMN_WIDTHS);+ if (!raw) {+ return {};+ }+ const parsed = JSON.parse(raw);+ return typeof parsed === 'object' && parsed !== null+ ? (parsed as ColumnWidthStore)+ : {};+ } catch {+ // Malformed JSON or storage access denied — fall back to no stored widths.+ return {};+ }+}++/** Reads the stored widths for one panel (empty when none persisted yet). */+export function readColumnWidths(panelId: string): ColumnWidths {+ return readStore()[panelId] ?? {};+}++/** Persists the widths for one panel, leaving every other panel's entry intact. */+export function writeColumnWidths(panelId: string, widths: ColumnWidths): void {+ const store = readStore();+ store[panelId] = widths;+ setLocalStorageApi(+ LOCALSTORAGE.DASHBOARD_V2_PANEL_COLUMN_WIDTHS,+ JSON.stringify(store),+ );+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getColumnUnit.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getColumnUnit.tsnew file mode 100644index 0000000000..d62b1c8b0f--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/getColumnUnit.ts@@ -0,0 +1,23 @@+/**+ * Resolves a Table column's display unit by its key (`queryName`, or+ * `queryName.expression` for multi-aggregation queries), falling back to the base+ * query name for the legacy `queryName.expression` syntax — mirrors V1+ * `getColumnUnit`. An empty entry means "no unit" (and does not inherit the base).+ * Shared by the renderer's column builder and the editor's column options so both+ * resolve a column's unit identically.+ */+export function getColumnUnit(+ key: string,+ columnUnits: Record<string, string>,+): string | undefined {+ if (columnUnits[key] !== undefined) {+ return columnUnits[key] || undefined;+ }+ if (key.includes('.')) {+ const baseQuery = key.split('.')[0];+ if (columnUnits[baseQuery] !== undefined) {+ return columnUnits[baseQuery] || undefined;+ }+ }+ return undefined;+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/recordTable.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/recordTable.tsnew file mode 100644index 0000000000..6e7244830e--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/recordTable.ts@@ -0,0 +1,58 @@+// Shared chrome for the antd-table panel kinds (Table, List): page-size/scroll+// sizing from the measured panel, and the header search-box row filter. Both+// kinds render record rows in an antd Table, so this lives here rather than in+// any one kind's folder.++// antd small-table row / header / pagination heights (px), used to estimate how+// many rows fit the panel so each page roughly fills the available space.+const ROW_HEIGHT = 39;+const HEADER_HEIGHT = 39;+const PAGINATION_HEIGHT = 56;++export const MIN_PAGE_SIZE = 10;++export interface TableLayout {+ /** Rows per page — at least MIN_PAGE_SIZE, otherwise as many as fit. */+ pageSize: number;+ /** tbody scroll height that keeps the header pinned; undefined before measure. */+ scrollY: number | undefined;+}++/**+ * Derives the table's page size and scroll body from the panel's measured+ * height: reserve the header + pagination, then fit whole rows into what's left+ * (never fewer than MIN_PAGE_SIZE). Before the panel is measured (`height` 0),+ * fall back to the minimum page size and let the body render at natural height.+ */+export function computeTableLayout(height: number): TableLayout {+ if (!height) {+ return { pageSize: MIN_PAGE_SIZE, scrollY: undefined };+ }+ const body = Math.max(ROW_HEIGHT, height - HEADER_HEIGHT - PAGINATION_HEIGHT);+ return {+ pageSize: Math.max(MIN_PAGE_SIZE, Math.floor(body / ROW_HEIGHT)),+ scrollY: body,+ };+}++/**+ * Client-side row filter for the header search box (V1 parity): keeps a row when+ * any cell's stringified value contains `term`, case-insensitively. The synthetic+ * antd `key` is skipped so row indices never match. An empty term is a no-op and+ * returns the original array (stable reference for memoization).+ */+export function filterTableRows<T extends Record<string, unknown>>(+ rows: T[],+ term: string,+): T[] {+ const needle = term.trim().toLowerCase();+ if (!needle) {+ return rows;+ }+ return rows.filter((row) =>+ Object.entries(row).some(+ ([key, value]) =>+ key !== 'key' && String(value).toLowerCase().includes(needle),+ ),+ );+}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.tsindex 9733663881..6ceb3615c5 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery.ts@@ -107,7 +107,7 @@ export function usePanelQuery({// `visualization` exists only on variants that declare it — read via `in` narrowing over the// generated union (no cast). `fillSpans` (TimeSeries/Bar only) → formatOptions.fillGaps.- const pluginSpec = panel?.spec.plugin.spec;+ const pluginSpec = panel.spec.plugin.spec;const visualization =pluginSpec && 'visualization' in pluginSpec? pluginSpec.visualization@@ -249,7 +249,6 @@ export function usePanelQuery({data,isLoading: response.isLoading,isFetching: response.isFetching,- // Coerce undefined → null so the contract is a single `Error | null` sentinel.error: response.error ?? null,refetch: response.refetch,cancelQuery,diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareRawTable.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareRawTable.test.tsnew file mode 100644index 0000000000..6a77a5ec2f--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareRawTable.test.ts@@ -0,0 +1,137 @@+import {+ type Querybuildertypesv5RawDataDTO,+ TelemetrytypesSignalDTO,+ type TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';++import { prepareRawTable } from '../prepareRawTable';++function result(+ rows: Querybuildertypesv5RawDataDTO['rows'],+ nextCursor?: string,+): Querybuildertypesv5RawDataDTO {+ return { queryName: 'A', rows, nextCursor };+}++const field = (name: string): TelemetrytypesTelemetryFieldKeyDTO => ({ name });++describe('prepareRawTable', () => {+ it('flattens row data and lifts timestamp as the first column', () => {+ const table = prepareRawTable({+ results: [+ result([+ {+ timestamp: '2026-01-01T00:00:00Z',+ data: { body: 'hello', level: 'info' },+ },+ ]),+ ],+ selectFields: [],+ });++ expect(table?.columns).toStrictEqual(['timestamp', 'body', 'level']);+ expect(table?.rows[0]).toMatchObject({+ key: 0,+ timestamp: '2026-01-01T00:00:00Z',+ body: 'hello',+ level: 'info',+ });+ });++ it('uses selectFields for column order when provided, timestamp still first', () => {+ const table = prepareRawTable({+ results: [+ result([+ { timestamp: '2026-01-01T00:00:00Z', data: { body: 'x', level: 'warn' } },+ ]),+ ],+ selectFields: [field('level'), field('body')],+ });++ expect(table?.columns).toStrictEqual(['timestamp', 'level', 'body']);+ });++ it('omits the timestamp column when no row carries one', () => {+ const table = prepareRawTable({+ results: [result([{ data: { body: 'x' } }])],+ selectFields: [],+ });++ expect(table?.columns).toStrictEqual(['body']);+ });++ it('takes the first result that has rows', () => {+ const table = prepareRawTable({+ results: [result([]), result([{ data: { body: 'y' } }], 'cursor-1')],+ selectFields: [],+ });++ expect(table?.rows).toHaveLength(1);+ expect(table?.nextCursor).toBe('cursor-1');+ });++ it('returns undefined when there is nothing to show', () => {+ expect(prepareRawTable({ results: [], selectFields: [] })).toBeUndefined();+ expect(+ prepareRawTable({ results: [result([])], selectFields: [] }),+ ).toBeUndefined();+ expect(+ prepareRawTable({ results: [result(null)], selectFields: [] }),+ ).toBeUndefined();+ });++ // The V5 raw log row nests resource/attribute maps; selected fields like+ // `service.name` live under `resources_string` (V1 `FlatLogData` parity).+ const logRow = {+ timestamp: '2026-06-17T13:48:29Z',+ data: {+ body: 'GetSupportedCurrencies successful',+ severity_text: 'INFO',+ attributes_string: {},+ resources_string: {+ 'service.name': 'currencyservice',+ 'k8s.pod.name': 'app-demo-currencyservice-74bdf8c78c-zrdlf',+ },+ },+ };++ it('flattens nested attribute/resource maps for logs so selected fields resolve', () => {+ const table = prepareRawTable({+ results: [result([logRow])],+ selectFields: [field('body'), field('service.name'), field('k8s.pod.name')],+ signal: TelemetrytypesSignalDTO.logs,+ });++ expect(table?.rows[0]).toMatchObject({+ body: 'GetSupportedCurrencies successful',+ 'service.name': 'currencyservice',+ 'k8s.pod.name': 'app-demo-currencyservice-74bdf8c78c-zrdlf',+ });+ // The nested map is RETAINED on the row so the log-detail drawer still gets+ // the structured resources, but it's excluded from the derived columns.+ expect(table?.rows[0]).toHaveProperty('resources_string');+ });++ it('keeps nested maps out of derived columns (logs, no selectFields)', () => {+ const table = prepareRawTable({+ results: [result([logRow])],+ selectFields: [],+ signal: TelemetrytypesSignalDTO.logs,+ });++ expect(table?.columns).toContain('service.name'); // lifted child+ expect(table?.columns).not.toContain('resources_string'); // the map itself+ expect(table?.columns).not.toContain('attributes_string');+ });++ it('does not flatten for non-log signals (traces return flat data)', () => {+ const table = prepareRawTable({+ results: [result([logRow])],+ selectFields: [],+ signal: TelemetrytypesSignalDTO.traces,+ });++ expect(table?.rows[0]).toHaveProperty('resources_string');+ expect(table?.rows[0]).not.toHaveProperty('service.name');+ });+});diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareScalarTables.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareScalarTables.test.tsindex 63ed29191f..3d0150f253 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareScalarTables.test.ts+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/__tests__/prepareScalarTables.test.ts@@ -283,7 +283,7 @@ describe('prepareScalarTables', () => {aggregationIndex: 4,},],- [['kuja-api_gateway-service', 99.985, 0.985, 'Healthy ✅', 2181216]],+ [['demo-service', 99.985, 0.985, 'Healthy ✅', 2181216]],),],legendMap: { A: '' },@@ -315,7 +315,7 @@ describe('prepareScalarTables', () => {expect(table.rows).toStrictEqual([{data: {- 'service.name': 'kuja-api_gateway-service',+ 'service.name': 'demo-service',current_availability: 99.985,error_budget_remaining: 0.985,budget_status: 'Healthy ✅',diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable.tsnew file mode 100644index 0000000000..3cd9bd7bba--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/queryV5/prepareRawTable.ts@@ -0,0 +1,110 @@+import {+ type Querybuildertypesv5RawDataDTO,+ TelemetrytypesSignalDTO,+ type TelemetrytypesTelemetryFieldKeyDTO,+} from 'api/generated/services/sigNoz.schemas';+import { isPlainObject } from 'lodash-es';++/** A raw record flattened for the antd Table: `data` keys + `timestamp` lifted, plus a synthetic antd `key`. */+export type RawTableRow = Record<string, unknown> & { key: number };++/** A `raw`/`trace` result prepared for the List renderer. */+export interface RawTable {+ /** Display column ids, in render order (timestamp first when present). */+ columns: string[];+ rows: RawTableRow[];+ /** Next-page cursor from the V5 response; not consumed yet (rows page client-side). */+ nextCursor?: string;+}++const TIMESTAMP_COLUMN = 'timestamp';++interface PrepareRawTableArgs {+ /** `raw`/`trace` results from `getRawResults`. */+ results: Querybuildertypesv5RawDataDTO[];+ /** The panel's chosen columns; when empty, columns are derived from the rows. */+ selectFields: TelemetrytypesTelemetryFieldKeyDTO[];+ /**+ * Panel telemetry signal. `logs` flattens nested attribute/resource maps one+ * level so selected fields (e.g. `service.name`) resolve (V1 `FlatLogData`+ * parity). Absent on the derive-columns fallback.+ */+ signal?: TelemetrytypesSignalDTO;+}++/**+ * Lift object-valued keys' children to the top level so selected fields like+ * `service.name` (nested under `resources_string`) resolve to a column (V1+ * `FlatLogData` parity). Original maps are kept for the log-detail drawer.+ */+function flattenAttributes(+ data: Record<string, unknown>,+): Record<string, unknown> {+ const flat: Record<string, unknown> = { ...data };+ Object.keys(data).forEach((key) => {+ const value = data[key];+ if (isPlainObject(value)) {+ Object.assign(flat, value as Record<string, unknown>);+ }+ });+ return flat;+}++/**+ * Union of every row's scalar keys (first-seen order) — the fallback columns when+ * the panel hasn't picked fields. Nested maps are excluded; their children are+ * surfaced as lifted top-level columns instead.+ */+function deriveColumns(rows: RawTableRow[]): string[] {+ const seen = new Set<string>();+ rows.forEach((row) => {+ Object.keys(row).forEach((key) => {+ if (key === 'key' || isPlainObject((row as Record<string, unknown>)[key])) {+ return;+ }+ seen.add(key);+ });+ });+ return [...seen];+}++/**+ * Flattens a V5 `raw`/`trace` response into rows + ordered columns for the List+ * panel. A raw query returns one result per query, so the first result with rows+ * is the panel's data. Columns come from the panel's `selectFields` when set,+ * otherwise from the union of the rows' keys; `timestamp` is always surfaced+ * first when the rows carry it. Returns `undefined` when there's nothing to show.+ */+export function prepareRawTable({+ results,+ selectFields,+ signal,+}: PrepareRawTableArgs): RawTable | undefined {+ const result = results.find((candidate) => (candidate.rows?.length ?? 0) > 0);+ if (!result?.rows) {+ return undefined;+ }++ const shouldFlatten = signal === TelemetrytypesSignalDTO.logs;+ const rows: RawTableRow[] = result.rows.map((row, index) => {+ const data = row.data ?? {};+ return {+ key: index,+ ...(row.timestamp ? { [TIMESTAMP_COLUMN]: row.timestamp } : {}),+ ...(shouldFlatten ? flattenAttributes(data) : data),+ };+ });++ const selected = selectFields.map((field) => field.name).filter(Boolean);+ const columns = selected.length > 0 ? selected : deriveColumns(rows);++ const withoutTimestamp = columns.filter(+ (column) => column !== TIMESTAMP_COLUMN,+ );+ const hasTimestamp = rows.some((row) => row[TIMESTAMP_COLUMN] != null);+ const ordered = hasTimestamp+ ? [TIMESTAMP_COLUMN, ...withoutTimestamp]+ : withoutTimestamp;++ return { columns: ordered, rows, nextCursor: result.nextCursor };+}diff --git a/frontend/src/utils/numericUtils.ts b/frontend/src/utils/numericUtils.tsindex a1ef76ade2..bc562e3366 100644--- a/frontend/src/utils/numericUtils.ts+++ b/frontend/src/utils/numericUtils.ts@@ -6,3 +6,9 @@ export function formatNumericValue(value: number | string): string {}return (typeof value === 'string' ? parseFloat(value) : value).toFixed(3);}++/** Coerce a value to a finite number, falling back to 0 for non-numeric input. */+export function toFiniteNumber(value: unknown): number {+ const n = Number(value);+ return Number.isFinite(n) ? n : 0;+}diff --git a/frontend/src/utils/stringUtils.ts b/frontend/src/utils/stringUtils.tsindex 4cd0b735f1..ed49f77fe0 100644--- a/frontend/src/utils/stringUtils.ts+++ b/frontend/src/utils/stringUtils.ts@@ -18,3 +18,23 @@ export function isQuoted(str: string): boolean {const trimmed = str.trim();return trimmed.length >= 2 && /^(["'`])(.*)\1$/.test(trimmed);}++/**+ * Coerce an arbitrary value to a string for display/storage: nullish → '',+ * objects/arrays → JSON, other primitives → their string form.+ */+export function coerceToString(value: unknown): string {+ if (value == null) {+ return '';+ }+ if (typeof value === 'string') {+ return value;+ }+ if (typeof value === 'number' || typeof value === 'boolean') {+ return String(value);+ }+ if (typeof value === 'object') {+ return JSON.stringify(value);+ }+ return '';+}