Skip to content

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.

fix(dashboard-v2): view-modal, pie chart, and panel fixes (#12033)

Abhi kumarf7aa3cee9c5d
diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.module.scss b/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.module.scss
new file mode 100644
index 0000000000..84ed337199
--- /dev/null
+++ b/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.module.scss
@@ -0,0 +1,4 @@
+.wrapper :global(button[data-color]) {
+ --checkbox-checked-background: var(--series-color);
+ --checkbox-border-color: var(--series-color);
+}
diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.tsx b/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.tsx
index cb3f8cc2fe..5730c95f3c 100644
--- a/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.tsx
+++ b/frontend/src/container/GridCardLayout/GridCard/FullView/TableRender/CustomCheckBox.tsx
@@ -3,6 +3,7 @@ import { Checkbox } from '@signozhq/ui/checkbox';
import { CSSProperties } from 'react';
import { CheckBoxProps } from '../types';
+import styles from './CustomCheckBox.module.scss';
function CustomCheckBox({
data,
@@ -15,12 +16,11 @@ function CustomCheckBox({
const isChecked = graphVisibilityState[index] || false;
const colorStyle = {
- '--checkbox-checked-background': color,
- '--checkbox-border-color': color,
+ '--series-color': color,
} as CSSProperties;
return (
- <span style={colorStyle}>
+ <span className={styles.wrapper} style={colorStyle}>
<Checkbox
onChange={(checked): void => checkBoxOnChangeHandler(checked, index)}
value={isChecked}
diff --git a/frontend/src/hooks/useDimensions.ts b/frontend/src/hooks/useDimensions.ts
index 0f6bad6dee..2be514d32e 100644
--- a/frontend/src/hooks/useDimensions.ts
+++ b/frontend/src/hooks/useDimensions.ts
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useLayoutEffect, useState } from 'react';
import debounce from 'lodash-es/debounce';
export type Dimensions = {
@@ -15,6 +15,15 @@ export function useResizeObserver<T extends HTMLElement>(
height: ref.current?.clientHeight || 0,
});
+ // Measure before paint so the first frame has real dimensions, not 0 (the
+ // debounced observer below only catches up after paint → layout jump).
+ useLayoutEffect(() => {
+ const node = ref.current;
+ if (node) {
+ setSize({ width: node.clientWidth, height: node.clientHeight });
+ }
+ }, [ref]);
+
useEffect(() => {
const handleResize = debounce(
(entries: ResizeObserverEntry[]) => {
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
index e0d9b0b398..76d44ed61a 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
@@ -8,7 +8,7 @@ import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Pan
import { resolveSignal } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';
import type { EQueryType } from 'types/common/dashboard';
-import type { LegendSeries } from '../hooks/useLegendSeries';
+import type { LegendSeries } from '../utils/legendSeries';
import type { TableColumnOption } from '../hooks/useTableColumns';
import ConfigActions from './ConfigActions/ConfigActions';
import SectionSlot from './SectionSlot/SectionSlot';
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.tsx
index b0e53af141..5ac3468653 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx
@@ -5,7 +5,7 @@ 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 type { LegendSeries } from '../../../utils/legendSeries';
import LegendColorRow from './LegendColorRow';
import {
clearSeriesColor,
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.tsx
index 17be050a65..ccf7f44e91 100644
--- 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.tsx
@@ -1,6 +1,6 @@
import { fireEvent, render, screen } from '@testing-library/react';
-import type { LegendSeries } from '../../../../hooks/useLegendSeries';
+import type { LegendSeries } from '../../../../utils/legendSeries';
import LegendColors from '../LegendColors';
const SERIES: LegendSeries[] = [
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.ts
index 373b1c2edb..bcb87806f8 100644
--- 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.ts
@@ -1,4 +1,4 @@
-import type { LegendSeries } from '../../../../hooks/useLegendSeries';
+import type { LegendSeries } from '../../../../utils/legendSeries';
import {
clearSeriesColor,
filterLegendSeries,
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.ts
index 245dd84fa9..d8117d05d2 100644
--- 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.ts
@@ -1,6 +1,6 @@
import type { DashboardtypesLegendDTOCustomColors } from 'api/generated/services/sigNoz.schemas';
-import type { LegendSeries } from '../../../hooks/useLegendSeries';
+import type { LegendSeries } from '../../../utils/legendSeries';
/** Case-insensitive substring filter over series labels. Empty query → all series. */
export function filterLegendSeries(
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionContext.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionContext.ts
index eb64473f5c..8295a14c54 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionContext.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sectionContext.ts
@@ -1,7 +1,7 @@
import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
import type { PanelKind } from '../../Panels/types/panelKind';
-import type { LegendSeries } from '../hooks/useLegendSeries';
+import type { LegendSeries } from '../utils/legendSeries';
import type { TableColumnOption } from '../hooks/useTableColumns';
import { EQueryType } from 'types/common/dashboard';
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.scss
index ee4ffa00c0..cee072ed59 100644
--- 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.scss
@@ -7,4 +7,9 @@
.dropdown {
width: 260px;
+ /* The dropdown portals to body; lift it above the query builder's antd
+ * popups (1050) so it stays clickable, incl. inside the View modal.
+ * TODO: remove after the antd -> @signozhq/ui migration
+ **/
+ z-index: 1100;
}
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.tsx
index 0a79b9f236..e02c3cf12f 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/components/AddColumnDropdown/AddColumnDropdown.tsx
@@ -63,7 +63,7 @@ function AddColumnDropdown({
<Plus size={16} />
</Button>
</ComboboxTrigger>
- <ComboboxContent arrow side="top" align="end" className={styles.dropdown}>
+ <ComboboxContent arrow side="bottom" align="end" className={styles.dropdown}>
<ComboboxCommand shouldFilter={false}>
<ComboboxInput
value={searchText}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.module.scss
index 37e0973ce0..8fc05c5692 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.module.scss
@@ -10,7 +10,9 @@
}
.scrollArea {
- padding: 12px;
+ // Top padding lives on the sticky tab nav instead, so the nav keeps its
+ // breathing room both at rest and when pinned to the top.
+ padding: 0 12px 12px 12px;
}
.tabsContainer {
@@ -24,6 +26,15 @@
background-color: var(--l1-background) !important;
}
:global(.ant-tabs-nav) {
+ // Pin the query-type tabs + Run Query button to the top of the
+ // `.container` scroll area while the query body scrolls underneath.
+ // `padding-top` owns the nav's top spacing (moved off `.scrollArea`).
+ position: sticky;
+ top: 0px;
+ z-index: 1100;
+ padding-top: 12px;
+ background-color: var(--l1-background);
+
&::before {
border-color: var(--l2-border);
}
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.ts
index f785886d1c..208d645fe6 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useLegendSeries.test.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/__tests__/useLegendSeries.test.ts
@@ -2,6 +2,7 @@ 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 { preparePieData } from 'pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData';
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';
@@ -29,18 +30,36 @@ jest.mock(
() => ({
flattenTimeSeries: jest.fn(),
getTimeSeriesResults: jest.fn(() => []),
+ getScalarResults: jest.fn(() => []),
}),
);
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables',
+ () => ({ prepareScalarTables: jest.fn(() => []) }),
+);
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData',
+ () => ({ preparePieData: 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 mockPreparePie = preparePieData as unknown as jest.Mock;
const PANEL = {
kind: 'Panel',
spec: { plugin: { kind: 'signoz/TimeSeriesPanel', spec: {} }, queries: [] },
} as unknown as DashboardtypesPanelDTO;
+const PIE_PANEL = {
+ kind: 'Panel',
+ spec: { plugin: { kind: 'signoz/PieChartPanel', spec: {} }, queries: [] },
+} as unknown as DashboardtypesPanelDTO;
+const HISTOGRAM_PANEL = {
+ kind: 'Panel',
+ spec: { plugin: { kind: 'signoz/HistogramPanel', spec: {} }, queries: [] },
+} as unknown as DashboardtypesPanelDTO;
const DATA = { response: {}, legendMap: {} } as unknown as PanelQueryData;
// Each flattened series carries the label resolveSeriesLabelV5 should report.
@@ -88,6 +107,32 @@ describe('useLegendSeries', () => {
]);
});
+ it('resolves histogram panels via the time-series path', () => {
+ mockFlatten.mockReturnValue(seriesWithLabels(['a', 'b']));
+ const { result } = renderHook(() => useLegendSeries(HISTOGRAM_PANEL, DATA));
+ expect(result.current).toStrictEqual([
+ { label: 'a', defaultColor: 'color:a' },
+ { label: 'b', defaultColor: 'color:b' },
+ ]);
+ // The pie path must not run for a histogram panel.
+ expect(mockPreparePie).not.toHaveBeenCalled();
+ });
+
+ it('resolves pie panels from their scalar slices, deduped by label', () => {
+ mockPreparePie.mockReturnValue([
+ { label: 'x', color: 'c1' },
+ { label: 'y', color: 'c2' },
+ { label: 'x', color: 'c1' },
+ ]);
+ const { result } = renderHook(() => useLegendSeries(PIE_PANEL, DATA));
+ expect(result.current).toStrictEqual([
+ { label: 'x', defaultColor: 'c1' },
+ { label: 'y', defaultColor: 'c2' },
+ ]);
+ // The time-series path must not run for a pie panel.
+ expect(mockFlatten).not.toHaveBeenCalled();
+ });
+
it('uses the dark palette in dark mode and the light palette otherwise', () => {
mockFlatten.mockReturnValue(seriesWithLabels(['a']));
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts
index 3275c28171..b57674ef35 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/useLegendSeries.ts
@@ -1,30 +1,19 @@
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;
-}
+import {
+ type LegendSeries,
+ resolvePieLegendSeries,
+ resolveTimeSeriesLegendSeries,
+} from '../utils/legendSeries';
/**
- * 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.
+ * Resolves the panel's rendered series into `{ label, defaultColor }` pairs so the
+ * legend-colors control can key overrides by the exact labels the chart draws. Only the
+ * kinds that expose a colors control resolve series (Pie from its scalar slices, Time
+ * Series from its flat series); every other kind returns none.
*/
export function useLegendSeries(
panel: DashboardtypesPanelDTO,
@@ -33,27 +22,15 @@ export function useLegendSeries(
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]);
+ switch (panel.spec.plugin.kind) {
+ case 'signoz/PieChartPanel':
+ return resolvePieLegendSeries(data, isDarkMode);
+ case 'signoz/TimeSeriesPanel':
+ case 'signoz/BarChartPanel':
+ case 'signoz/HistogramPanel':
+ return resolveTimeSeriesLegendSeries(panel.spec.queries, data, isDarkMode);
+ default:
+ return [];
+ }
+ }, [panel.spec.plugin.kind, panel.spec.queries, data, isDarkMode]);
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/utils/legendSeries.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/utils/legendSeries.ts
new file mode 100644
index 0000000000..3497af35ca
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/utils/legendSeries.ts
@@ -0,0 +1,96 @@
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { themeColors } from 'constants/theme';
+import getLabelName from 'lib/getLabelName';
+import { generateColor } from 'lib/uPlotLib/utils/generateColor';
+import { preparePieData } from 'pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/prepareData';
+import { getBuilderQueries } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';
+import { resolveSeriesLabelV5 } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/resolveSeriesLabel';
+import { prepareScalarTables } from 'pages/DashboardPageV2/DashboardContainer/queryV5/prepareScalarTables';
+import type { PanelQueryData } from 'pages/DashboardPageV2/DashboardContainer/queryV5/types';
+import {
+ flattenTimeSeries,
+ getScalarResults,
+ 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;
+}
+
+type PanelQueries = DashboardtypesPanelDTO['spec']['queries'];
+
+/**
+ * Dedupes `labels` (first-seen order, empties dropped) into `{ label, defaultColor }`
+ * pairs, resolving each unique label's color lazily via `colorFor` — so a repeated
+ * label never resolves a second color.
+ */
+function buildLegendSeries(
+ labels: readonly string[],
+ colorFor: (label: string, index: number) => string,
+): LegendSeries[] {
+ const byLabel = new Map<string, string>();
+ labels.forEach((label, index) => {
+ if (label && !byLabel.has(label)) {
+ byLabel.set(label, colorFor(label, index));
+ }
+ });
+ return Array.from(byLabel, ([label, defaultColor]) => ({
+ label,
+ defaultColor,
+ }));
+}
+
+/**
+ * Pie is fed by scalar results, not time series. Reuse the exact slices the renderer
+ * draws (without overrides, so their colors are the defaults) so the color control keys
+ * overrides by the same labels the chart does.
+ */
+export function resolvePieLegendSeries(
+ data: PanelQueryData,
+ isDarkMode: boolean,
+): LegendSeries[] {
+ const slices = preparePieData({
+ tables: prepareScalarTables({
+ results: getScalarResults(data.response),
+ legendMap: data.legendMap,
+ requestPayload: data.requestPayload,
+ }),
+ isDarkMode,
+ });
+ return buildLegendSeries(
+ slices.map((slice) => slice.label),
+ (_, index) => slices[index].color,
+ );
+}
+
+/**
+ * Time-series kinds: resolve each flattened series' label the way the renderer does
+ * (`getLabelName` → `resolveSeriesLabelV5`) and color it with `generateColor`.
+ */
+export function resolveTimeSeriesLegendSeries(
+ queries: PanelQueries,
+ data: PanelQueryData,
+ isDarkMode: boolean,
+): LegendSeries[] {
+ const palette = isDarkMode
+ ? themeColors.chartcolors
+ : themeColors.lightModeColor;
+ const builderQueries = getBuilderQueries(queries);
+ const series = flattenTimeSeries(
+ getTimeSeriesResults(data.response),
+ data.legendMap,
+ );
+ return buildLegendSeries(
+ series.map((s) =>
+ resolveSeriesLabelV5(
+ s,
+ builderQueries,
+ getLabelName(s.labels, s.queryName, s.legend),
+ ),
+ ),
+ (label) => generateColor(label, palette),
+ );
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/NoData.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/NoData.tsx
index d7b50d69d9..6ed375f36a 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/NoData.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/NoData.tsx
@@ -1,5 +1,7 @@
import { CalendarRange, Clock, RotateCw } from '@signozhq/icons';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { panelHasFixedTimePreference } from '../../../hooks/resolvePanelTimeWindow';
import {
selectViewPanelExtendWindow,
useViewPanelStore,
@@ -15,6 +17,8 @@ interface NoDataProps {
isFetching?: boolean;
/** When provided, renders a Retry button that re-runs the query. */
onRetry?: () => void;
+ /** Hides the global "Extend time range" action when this panel is locked to a fixed time preference. */
+ panel?: DashboardtypesPanelDTO;
'data-testid'?: string;
}
@@ -29,19 +33,30 @@ function NoData({
description = 'Nothing in the selected window. Try widening the range.',
isFetching = false,
onRetry,
+ panel,
'data-testid': testId = 'panel-no-data',
}: NoDataProps): JSX.Element {
const viewExtend = useViewPanelStore(selectViewPanelExtendWindow);
const globalExtend = useExtendTimeWindow();
- const { canExtend, actionLabel, extend } = viewExtend ?? globalExtend;
+ // The View modal's local extender wins; the global one only applies to a panel that
+ // follows the ambient window (a fixed preference can't be widened by it).
+ const hasFixedTimePreference = panel
+ ? panelHasFixedTimePreference(panel)
+ : false;
+ const activeExtend =
+ viewExtend ?? (hasFixedTimePreference ? undefined : globalExtend);
if (isFetching) {
return <PanelLoader />;
}
const extendAction: PanelMessageAction | undefined =
- canExtend && actionLabel
- ? { label: actionLabel, onClick: extend, icon: <CalendarRange size={14} /> }
+ activeExtend?.canExtend && activeExtend.actionLabel
+ ? {
+ label: activeExtend.actionLabel,
+ onClick: activeExtend.extend,
+ icon: <CalendarRange size={14} />,
+ }
: undefined;
const retryAction: PanelMessageAction | undefined = onRetry
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
index fc67513d41..af5ed3cfb7 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/components/NoData/__tests__/NoData.test.tsx
@@ -1,3 +1,7 @@
+import {
+ DashboardtypesTimePreferenceDTO,
+ type DashboardtypesPanelDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { fireEvent, render, screen } from '@testing-library/react';
import { useViewPanelStore } from '../../../../store/useViewPanelStore';
@@ -24,6 +28,15 @@ function extender(over?: Partial<ExtendTimeWindow>): ExtendTimeWindow {
};
}
+/** Minimal panel whose plugin spec carries the given time preference. */
+function panelWith(
+ timePreference?: DashboardtypesTimePreferenceDTO,
+): DashboardtypesPanelDTO {
+ return {
+ spec: { plugin: { spec: { visualization: { timePreference } } } },
+ } as unknown as DashboardtypesPanelDTO;
+}
+
describe('NoData', () => {
beforeEach(() => {
mockUseExtendTimeWindow.mockReturnValue(inert);
@@ -119,4 +132,47 @@ describe('NoData', () => {
expect(screen.getByTestId('number-panel-no-data')).toBeInTheDocument();
});
+
+ it('hides the global extend action for a panel with a fixed time preference', () => {
+ const onRetry = jest.fn();
+ mockUseExtendTimeWindow.mockReturnValue(extender());
+ render(
+ <NoData
+ onRetry={onRetry}
+ panel={panelWith(DashboardtypesTimePreferenceDTO.last_6_hr)}
+ />,
+ );
+
+ // Only Retry — extending the dashboard window can't widen a locked panel span.
+ const action = screen.getByTestId('panel-no-data-action');
+ expect(action).toHaveTextContent('Retry');
+ expect(
+ screen.queryByTestId('panel-no-data-secondary-action'),
+ ).not.toBeInTheDocument();
+ });
+
+ it('still offers the global extend action for a panel that follows the global window', () => {
+ mockUseExtendTimeWindow.mockReturnValue(extender());
+ render(
+ <NoData panel={panelWith(DashboardtypesTimePreferenceDTO.global_time)} />,
+ );
+
+ expect(screen.getByTestId('panel-no-data-action')).toHaveTextContent(
+ 'Extend time range',
+ );
+ });
+
+ it('keeps the View modal extender even when the panel has a fixed time preference', () => {
+ const storeExtend = jest.fn();
+ mockUseExtendTimeWindow.mockReturnValue(extender());
+ useViewPanelStore.setState({
+ viewPanelExtendWindow: extender({ extend: storeExtend }),
+ });
+ render(
+ <NoData panel={panelWith(DashboardtypesTimePreferenceDTO.last_6_hr)} />,
+ );
+
+ fireEvent.click(screen.getByTestId('panel-no-data-action'));
+ expect(storeExtend).toHaveBeenCalledTimes(1);
+ });
});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
index a506c62f9d..5688e07814 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
@@ -193,7 +193,7 @@ function BarPanelRenderer({
className={PanelStyles.panelContainer}
>
{flatSeries.length === 0 && (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
)}
{flatSeries.length > 0 &&
containerDimensions.width > 0 &&
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts
index 222f5db0d2..f49637eabe 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/sections.ts
@@ -13,7 +13,7 @@ export const sections: SectionConfig[] = [
},
{ kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },
{ kind: SectionKind.Axes, controls: { minMax: true, logScale: true } },
- { kind: SectionKind.Legend, controls: { position: true } },
+ { kind: SectionKind.Legend, controls: { position: true, colors: true } },
{
kind: SectionKind.Thresholds,
controls: { variant: ThresholdVariant.LABEL },
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx
index 6f0dc9d821..39b68849a7 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/Renderer.tsx
@@ -106,7 +106,7 @@ function HistogramPanelRenderer({
className={PanelStyles.panelContainer}
>
{flatSeries.length === 0 && (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
)}
{flatSeries.length > 0 &&
containerDimensions.width > 0 &&
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts
index 63e3f7016b..d4e2f73b93 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/HistogramPanel/sections.ts
@@ -9,7 +9,7 @@ export const sections: SectionConfig[] = [
},
{
kind: SectionKind.Legend,
- controls: { position: true },
+ controls: { position: true, colors: true },
// Merging all queries collapses to one distribution with no legend.
isHidden: (spec): boolean =>
Boolean(
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx
index cbdcb29054..0d8335c07e 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/ListPanel/Renderer.tsx
@@ -143,7 +143,7 @@ function ListPanelRenderer({
className={PanelStyles.panelContainer}
>
{!table || dataSource.length === 0 ? (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
) : (
<>
<div
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/Renderer.tsx
index 0d742f779a..a5a60b332d 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/NumberPanel/Renderer.tsx
@@ -130,6 +130,7 @@ function NumberPanelRenderer({
data-testid="number-panel-no-data"
isFetching={isFetching}
onRetry={refetch}
+ panel={panel}
/>
) : (
<ValueDisplay
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/Renderer.tsx
index b2991f74d0..f6e1260737 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/Renderer.tsx
@@ -95,7 +95,7 @@ function PiePanelRenderer({
return (
<div data-testid="pie-panel-renderer" className={PanelStyles.panelContainer}>
{slices.length === 0 ? (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
) : (
<Pie
data={slices}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts
index 24b9a048ed..f59290374a 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/PieChartPanel/sections.ts
@@ -1,13 +1,13 @@
import { SectionKind, type SectionConfig } from '../../types/sections';
-// Pie has no axes, thresholds, or stacking — just value formatting and a legend.
-// Legend `colors` is omitted: the pie legend is always interactive swatches.
+// Pie has no axes, thresholds, or stacking — just value formatting and a legend
+// (position + per-slice color overrides).
export const sections: SectionConfig[] = [
{
kind: SectionKind.Visualization,
controls: { switchPanelKind: true, timePreference: true },
},
{ kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },
- { kind: SectionKind.Legend, controls: { position: true } },
+ { kind: SectionKind.Legend, controls: { position: true, colors: true } },
{ kind: SectionKind.ContextLinks },
];
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx
index 606acbcd5d..2843d454e6 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TablePanel/Renderer.tsx
@@ -160,7 +160,7 @@ function TablePanelRenderer({
className={PanelStyles.panelContainer}
>
{!table || dataSource.length === 0 ? (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
) : (
<div className={styles.container}>
<Table
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
index c155dc7dc1..95d762934f 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
@@ -194,7 +194,7 @@ function TimeSeriesPanelRenderer({
className={PanelStyles.panelContainer}
>
{flatSeries.length === 0 && (
- <NoData isFetching={isFetching} onRetry={refetch} />
+ <NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
)}
{flatSeries.length > 0 &&
containerDimensions.width > 0 &&
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
index 5904312f39..0ba0d29059 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
@@ -1,11 +1,11 @@
import { useState } from 'react';
-import type {
- DashboardtypesPanelDTO,
- DashboardtypesTimePreferenceDTO,
-} from 'api/generated/services/sigNoz.schemas';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
import ContextMenu from 'periscope/components/ContextMenu';
import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';
-import { panelTimePreferenceLabel } from 'pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow';
+import {
+ getPanelTimePreference,
+ panelTimePreferenceLabel,
+} from 'pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow';
import { usePanelQuery } from 'pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery';
import type { DashboardSection } from '../../utils';
@@ -27,7 +27,7 @@ export interface PanelActionsConfig {
interface PanelProps {
panel: DashboardtypesPanelDTO;
panelId: string;
- /** True once this panel's section enters the viewport — gates the fetch. */
+ /** True once this panel enters the viewport — gates the fetch (owned by SectionGridItem). */
isVisible?: boolean;
/** Move/delete actions — present only in editable sectioned mode. */
panelActions?: PanelActionsConfig;
@@ -43,15 +43,7 @@ function Panel({
isVisible,
panelActions,
}: PanelProps): JSX.Element {
- // A per-panel time preference is surfaced as a header pill. `visualization` is
- // common to every plugin-spec variant — localized cast reads it without
- // narrowing on kind.
- const timePreference = (
- panel.spec.plugin.spec as
- | { visualization?: { timePreference?: DashboardtypesTimePreferenceDTO } }
- | undefined
- )?.visualization?.timePreference;
- const timeLabel = panelTimePreferenceLabel(timePreference);
+ const timeLabel = panelTimePreferenceLabel(getPanelTimePreference(panel));
const panelKind = panel.spec.plugin.kind;
const panelDefinition = getPanelDefinition(panelKind);
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/__tests__/usePanelActionItems.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/__tests__/usePanelActionItems.test.tsx
index 1781376de0..0b9d9c4998 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/__tests__/usePanelActionItems.test.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/__tests__/usePanelActionItems.test.tsx
@@ -89,6 +89,14 @@ function section(
const TWO_TITLED_SECTIONS = [section(0, 'Overview'), section(1, 'Latency')];
// Index 0 is the untitled root (free-flow) section; index 1 is a titled section.
const TITLED_WITH_ROOT = [section(0, undefined), section(1, 'Latency')];
+// Untitled root plus two titled sections — exercises the multi-target submenu.
+const ROOT_AND_TWO_TITLED = [
+ section(0, undefined),
+ section(1, 'A'),
+ section(2, 'B'),
+];
+// Just the free-flow root: an ungrouped board with no sections to move between.
+const ONLY_ROOT = [section(0, undefined)];
// Minimal panel — only its presence gates "Create Alerts"; the query→URL
// translation it drives is covered by buildCreateAlertUrl's own tests.
@@ -111,7 +119,9 @@ const baseArgs = {
panelId: 'panel-1',
panel: mockPanel,
data: mockData,
- panelActions: { currentLayoutIndex: 0, sections: TWO_TITLED_SECTIONS },
+ // Panel sits in a titled section with an untitled root present, so every
+ // action — including "Move to section" (→ Dashboard root) — is available.
+ panelActions: { currentLayoutIndex: 1, sections: TITLED_WITH_ROOT },
};
function itemKeys(result: ReturnType<typeof usePanelActionItems>): unknown[] {
@@ -210,7 +220,7 @@ describe('usePanelActionItems', () => {
]);
});
- it('move is disabled when there is no other titled section to move to', () => {
+ it('hides "Move to section" when the only untitled section is not the root (index 0)', () => {
const { result } = renderHook(() =>
usePanelActionItems({
...baseArgs,
@@ -220,8 +230,8 @@ describe('usePanelActionItems', () => {
},
}),
);
- const move = result.current.items.find((i) => 'key' in i && i.key === 'move');
- expect(move).toMatchObject({ disabled: true });
+ // An untitled section only counts as the root at layoutIndex 0.
+ expect(itemKeys(result.current)).not.toContain('move');
});
it('edit opens the panel editor for this panel', () => {
@@ -233,63 +243,93 @@ describe('usePanelActionItems', () => {
expect(mockOpenEditor).toHaveBeenCalledWith('panel-1');
});
- it('move targets call the mutation with from/to layout indexes', () => {
+ it('"Move to section" offers a single "Dashboard (root)" target', () => {
const { result } = renderHook(() => usePanelActionItems(baseArgs));
const move = result.current.items.find(
(i) => 'key' in i && i.key === 'move',
) as {
children: { key: string; onClick: () => void }[];
};
- expect(move.children).toHaveLength(1);
+ expect(move.children.map((c) => c.key)).toStrictEqual(['move-to-root']);
+ });
+
+ it('the "Dashboard (root)" target moves the panel to the untitled root section', () => {
+ const { result } = renderHook(() => usePanelActionItems(baseArgs));
+ const move = result.current.items.find(
+ (i) => 'key' in i && i.key === 'move',
+ ) as {
+ children: { onClick: () => void }[];
+ };
move.children[0].onClick();
expect(mockMovePanel).toHaveBeenCalledWith({
panelId: 'panel-1',
- fromLayoutIndex: 0,
- toLayoutIndex: 1,
+ fromLayoutIndex: 1,
+ toLayoutIndex: 0,
});
});
- it('offers "Move out of section" for a panel in a titled section when an untitled root exists', () => {
+ it('an ungrouped panel (in the root) can move into each titled section', () => {
const { result } = renderHook(() =>
usePanelActionItems({
...baseArgs,
- panelActions: { currentLayoutIndex: 1, sections: TITLED_WITH_ROOT },
+ panelActions: { currentLayoutIndex: 0, sections: ROOT_AND_TWO_TITLED },
}),
);
- expect(itemKeys(result.current)).toContain('move-to-root');
+ const move = result.current.items.find(
+ (i) => 'key' in i && i.key === 'move',
+ ) as { children: { key: string; label: string }[] };
+ expect(move.children.map((c) => c.key)).toStrictEqual(['move-1', 'move-2']);
+ expect(move.children.map((c) => c.label)).toStrictEqual(['A', 'B']);
});
- it('"Move out of section" moves the panel to the untitled root section', () => {
+ it('a panel in a titled section can move to the root and the other titled sections', () => {
const { result } = renderHook(() =>
usePanelActionItems({
...baseArgs,
- panelActions: { currentLayoutIndex: 1, sections: TITLED_WITH_ROOT },
+ panelActions: { currentLayoutIndex: 1, sections: ROOT_AND_TWO_TITLED },
}),
);
- const moveOut = result.current.items.find(
- (i) => 'key' in i && i.key === 'move-to-root',
+ const move = result.current.items.find(
+ (i) => 'key' in i && i.key === 'move',
+ ) as { children: { key: string; label: string }[] };
+ // Root leads, then the other titled section — never the current one (A).
+ expect(move.children.map((c) => c.key)).toStrictEqual([
+ 'move-to-root',
+ 'move-2',
+ ]);
+ expect(move.children.map((c) => c.label)).toStrictEqual([
+ 'Dashboard (root)',
+ 'B',
+ ]);
+ });
+
+ it('moves between titled sections even when the board has no untitled root', () => {
+ const { result } = renderHook(() =>
+ usePanelActionItems({
+ ...baseArgs,
+ panelActions: { currentLayoutIndex: 0, sections: TWO_TITLED_SECTIONS },
+ }),
);
- (moveOut as { onClick: () => void }).onClick();
+ const move = result.current.items.find(
+ (i) => 'key' in i && i.key === 'move',
+ ) as { children: { key: string; onClick: () => void }[] };
+ expect(move.children.map((c) => c.key)).toStrictEqual(['move-1']);
+ move.children[0].onClick();
expect(mockMovePanel).toHaveBeenCalledWith({
panelId: 'panel-1',
- fromLayoutIndex: 1,
- toLayoutIndex: 0,
+ fromLayoutIndex: 0,
+ toLayoutIndex: 1,
});
});
- it('hides "Move out of section" when the panel already sits in the root section', () => {
+ it('hides "Move to section" when the board has no sections (only the root)', () => {
const { result } = renderHook(() =>
usePanelActionItems({
...baseArgs,
- panelActions: { currentLayoutIndex: 0, sections: TITLED_WITH_ROOT },
+ panelActions: { currentLayoutIndex: 0, sections: ONLY_ROOT },
}),
);
- expect(itemKeys(result.current)).not.toContain('move-to-root');
- });
-
- it('hides "Move out of section" when every section is titled (no root)', () => {
- const { result } = renderHook(() => usePanelActionItems(baseArgs));
- expect(itemKeys(result.current)).not.toContain('move-to-root');
+ expect(itemKeys(result.current)).not.toContain('move');
});
it('delete defers to a confirmation: the item opens the dialog, confirm runs the mutation', async () => {
@@ -312,7 +352,7 @@ describe('usePanelActionItems', () => {
});
expect(mockDeletePanel).toHaveBeenCalledWith({
panelId: 'panel-1',
- layoutIndex: 0,
+ layoutIndex: 1,
});
expect(result.current.deleteConfirm.open).toBe(false);
});
@@ -325,7 +365,7 @@ describe('usePanelActionItems', () => {
(clone as { onClick: () => void }).onClick();
expect(mockClonePanel).toHaveBeenCalledWith({
panelId: 'panel-1',
- layoutIndex: 0,
+ layoutIndex: 1,
});
});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.module.scss
index 98738c255d..66c3eab5fa 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.module.scss
@@ -5,6 +5,7 @@
padding: 8px 12px;
border-bottom: 1px solid var(--l2-border);
cursor: grab;
+ min-height: 32px;
}
.headerLeft {
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.tsx
index 66b7fd1766..dec2f17b95 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader.tsx
@@ -1,4 +1,4 @@
-import { useMemo } from 'react';
+import { Fragment, useMemo } from 'react';
import { Info, Loader } from '@signozhq/icons';
import { Typography } from '@signozhq/ui/typography';
import type {
@@ -74,6 +74,14 @@ function PanelHeader({
[warning],
);
+ /**
+ * Hide the entire header when there's no title, description, or status to show,
+ * and the actions menu is suppressed (editor preview).
+ */
+ if (!name && !description && !errorDetail && !warningDetail && hideActions) {
+ return <Fragment />;
+ }
+
return (
<div className={cx(styles.header, 'panel-drag-handle')}>
<div className={styles.headerLeft}>
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.module.scss
index 4ed457b6a9..7d77a7f293 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.module.scss
@@ -1,9 +1,8 @@
@use '../../../../../../styles/scrollbar' as *;
-.modal {
- :global(.ant-modal-body) {
- padding: 0px;
- }
+.dialog[data-width] {
+ max-width: 85%;
+ width: 85%;
}
// Truncate a long panel name so the header stays on one line; the wrapping tooltip
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx
index e528c20f33..3aa82372ad 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx
@@ -1,7 +1,15 @@
+import {
+ Dialog,
+ DialogCloseButton,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@signozhq/ui/dialog';
import { TooltipSimple } from '@signozhq/ui/tooltip';
import { Typography } from '@signozhq/ui/typography';
-import { Modal } from 'antd';
+import { ConfigProvider } from 'antd';
import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { useRef } from 'react';
import ViewPanelModalContent from './ViewPanelModalContent';
import styles from './ViewPanelModal.module.scss';
@@ -25,27 +33,48 @@ function ViewPanelModal({
}: ViewPanelModalProps): JSX.Element {
const name = panel?.spec.display.name ?? '';
+ // Render antd popups into the dialog (not document.body) so they stay inside the
+ // modal's interactive, focus-trapped layer instead of being blocked by Radix.
+ const contentRef = useRef<HTMLDivElement>(null);
+
return (
- <Modal
+ <Dialog
open={open}
- onCancel={onClose}
- footer={null}
- centered
- width="85%"
- destroyOnClose
- className={styles.modal}
- title={
- <TooltipSimple title={name} arrow>
- <Typography.Text className={styles.title}>
- {name} - (View mode)
- </Typography.Text>
- </TooltipSimple>
- }
+ onOpenChange={(isOpen): void => {
+ if (!isOpen) {
+ onClose();
+ }
+ }}
>
- {open && panel && panelId && (
- <ViewPanelModalContent panel={panel} panelId={panelId} onClose={onClose} />
- )}
- </Modal>
+ <DialogContent
+ ref={contentRef}
+ position="center"
+ width="extra-wide"
+ className={styles.dialog}
+ >
+ <DialogHeader>
+ <DialogTitle>
+ <TooltipSimple title={name} arrow>
+ <Typography.Text className={styles.title}>
+ {name ? `${name} - (View mode)` : 'View mode'}
+ </Typography.Text>
+ </TooltipSimple>
+ </DialogTitle>
+ </DialogHeader>
+ <DialogCloseButton />
+ {open && panel && panelId && (
+ <ConfigProvider
+ getPopupContainer={(): HTMLElement => contentRef.current ?? document.body}
+ >
+ <ViewPanelModalContent
+ panel={panel}
+ panelId={panelId}
+ onClose={onClose}
+ />
+ </ConfigProvider>
+ )}
+ </DialogContent>
+ </Dialog>
);
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx
index 334b2efa36..40be64f5e1 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx
@@ -3,6 +3,7 @@ import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schem
import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
import ContextMenu from 'periscope/components/ContextMenu';
+import ListColumnsEditor from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/ListColumnsEditor/ListColumnsEditor';
import PanelEditorQueryBuilder from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder';
import PreviewPane from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane';
import type { DashboardPreference } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/rendererProps';
@@ -44,6 +45,7 @@ function ViewPanelModalContent({
const {
draft,
+ setSpec,
panelDefinition,
signal,
queryType,
@@ -54,7 +56,17 @@ function ViewPanelModalContent({
buildSaveSpec,
applyDrilldownQuery,
} = useViewPanelMode({ panel, panelId, time: timeOverride });
- const { data, isFetching, error, refetch, cancelQuery, pagination } = query;
+ const {
+ data,
+ isFetching,
+ isPreviousData,
+ error,
+ refetch,
+ cancelQuery,
+ pagination,
+ } = query;
+
+ const isListPanel = draft.spec.plugin.kind === 'signoz/ListPanel';
// Grid drill-down, but filter-by-value / breakout refine this view in place. Drills the draft
// so it reflects in-modal edits (and the click's time range follows the per-view window).
@@ -119,6 +131,15 @@ function ViewPanelModalContent({
isLoadingQueries={isFetching}
onStageRunQuery={runQuery}
onCancelQuery={cancelQuery}
+ footer={
+ isListPanel ? (
+ <ListColumnsEditor
+ spec={draft.spec}
+ onChangeSpec={setSpec}
+ signal={signal}
+ />
+ ) : undefined
+ }
/>
</div>
<div className={styles.body}>
@@ -128,6 +149,7 @@ function ViewPanelModalContent({
panelDefinition={panelDefinition}
data={data}
isFetching={isFetching}
+ isPreviousData={isPreviousData}
error={error}
refetch={refetch}
onDragSelect={onDragSelect}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts
index 759257547d..71f0b945da 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts
@@ -35,6 +35,8 @@ interface UseViewPanelModeArgs {
export interface UseViewPanelModeReturn {
/** Local editable copy of the panel — the preview renders this, not the saved panel. */
draft: DashboardtypesPanelDTO;
+ /** Update the draft's spec in place (e.g. the List columns editor). */
+ setSpec: (next: DashboardtypesPanelSpecDTO) => void;
/** Resolved renderer for the draft's current kind (registry always resolves a kind). */
panelDefinition: RenderablePanelDefinition;
/**
@@ -159,6 +161,7 @@ export function useViewPanelMode({
return {
draft,
+ setSpec,
panelDefinition,
signal,
queryType: currentQuery.queryType,
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/utils/buildMoveItems.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/utils/buildMoveItems.tsx
index 96f7e1501f..7786401440 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/utils/buildMoveItems.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/utils/buildMoveItems.tsx
@@ -1,9 +1,12 @@
-import { FolderInput, FolderOutput } from '@signozhq/icons';
+import { FolderInput } from '@signozhq/icons';
import type { MenuItem } from '@signozhq/ui/dropdown-menu';
import { findRootSection, type DashboardSection } from '../../../utils';
import type { MovePanelArgs } from '../hooks/useMovePanelToSection';
+// Matches the root option label in the New Panel picker (SectionPicker).
+const ROOT_LABEL = 'Dashboard (root)';
+
interface MoveItemsArgs {
sections: DashboardSection[];
currentLayoutIndex: number;
@@ -12,9 +15,11 @@ interface MoveItemsArgs {
}
/**
- * The "Move to section" submenu plus a direct "Move out of section" to the
- * untitled root, shown only when the panel sits in a titled section and a root
- * section exists to receive it.
+ * "Move to section" submenu listing every section the panel can move to — the
+ * dashboard root (untitled top level, labelled "Dashboard (root)") plus every
+ * titled section, minus the one the panel already sits in. Hidden entirely when
+ * there is nowhere to move: an ungrouped board with no titled sections, or a
+ * panel that is alone in the only section.
*/
export function buildMoveItems({
sections,
@@ -22,44 +27,38 @@ export function buildMoveItems({
panelId,
movePanel,
}: MoveItemsArgs): MenuItem[] {
+ const rootSection = findRootSection(sections);
+
+ // Sections are already in layout order, so the root (index 0, when present)
+ // naturally leads. Untitled non-root layouts are never a move target.
const targets = sections.filter(
- (s) => s.title && s.layoutIndex !== currentLayoutIndex,
+ (section) =>
+ section.layoutIndex !== currentLayoutIndex &&
+ (section === rootSection || Boolean(section.title)),
);
- const items: MenuItem[] = [
+
+ if (targets.length === 0) {
+ return [];
+ }
+
+ return [
{
key: 'move',
label: 'Move to section',
icon: <FolderInput size={14} />,
- ...(targets.length === 0
- ? { disabled: true }
- : {
- children: targets.map((s) => ({
- key: `move-${s.layoutIndex}`,
- label: s.title,
- onClick: (): void =>
- void movePanel({
- panelId,
- fromLayoutIndex: currentLayoutIndex,
- toLayoutIndex: s.layoutIndex,
- }),
- })),
- }),
+ children: targets.map((section) => {
+ const isRoot = section === rootSection;
+ return {
+ key: isRoot ? 'move-to-root' : `move-${section.layoutIndex}`,
+ label: isRoot ? ROOT_LABEL : (section.title as string),
+ onClick: (): void =>
+ void movePanel({
+ panelId,
+ fromLayoutIndex: currentLayoutIndex,
+ toLayoutIndex: section.layoutIndex,
+ }),
+ };
+ }),
},
];
-
- const rootSection = findRootSection(sections);
- if (rootSection && rootSection.layoutIndex !== currentLayoutIndex) {
- items.push({
- key: 'move-to-root',
- label: 'Move out of section',
- icon: <FolderOutput size={14} />,
- onClick: (): void =>
- void movePanel({
- panelId,
- fromLayoutIndex: currentLayoutIndex,
- toLayoutIndex: rootSection.layoutIndex,
- }),
- });
- }
- return items;
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/Section/Section.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/Section/Section.tsx
index c064110bcb..fa35728e51 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/Section/Section.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/Section/Section.tsx
@@ -1,9 +1,7 @@
-import { useCallback, useRef, useState } from 'react';
+import { useCallback, useState } from 'react';
import { Plus } from '@signozhq/icons';
import { Button } from '@signozhq/ui/button';
-import { useIntersectionObserver } from 'hooks/useIntersectionObserver';
-
import ConfirmDeleteDialog from '../../../components/ConfirmDeleteDialog/ConfirmDeleteDialog';
import DisabledControlTooltip from '../../../components/DisabledControlTooltip/DisabledControlTooltip';
import { DASHBOARD_LOCKED_REASON } from '../../../hooks/useDashboardEditGuard';
@@ -41,12 +39,6 @@ function Section({ section, sections, dragHandle }: SectionProps): JSX.Element {
targetLayoutIndex,
} = useCreatePanel();
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
- const containerRef = useRef<HTMLDivElement>(null);
- // Placeholder signal for lazy panel query-loading (consumed in a later PR):
- // true once the section scrolls into (or near) the viewport.
- const isVisible = useIntersectionObserver(containerRef, {
- rootMargin: '200px',
- });
const { open, toggle } = useToggleSectionCollapse({ sectionId: section.id });
@@ -77,17 +69,14 @@ function Section({ section, sections, dragHandle }: SectionProps): JSX.Element {
<SectionGrid
items={section.items}
layoutIndex={section.layoutIndex}
- isVisible={isVisible}
sections={sections}
/>
);
if (!section.title) {
- // Untitled section — just the grid (no header chrome), but still observed
- // for the viewport signal.
+ // Untitled section — just the grid, no header chrome.
return (
<div
- ref={containerRef}
data-testid={`dashboard-section-${section.id}`}
data-section-layout-index={section.layoutIndex}
>
@@ -98,7 +87,6 @@ function Section({ section, sections, dragHandle }: SectionProps): JSX.Element {
return (
<div
- ref={containerRef}
className={styles.section}
data-testid={`dashboard-section-${section.id}`}
data-section-layout-index={section.layoutIndex}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.module.scss
index 768869b03a..ec4e760f10 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.module.scss
@@ -20,3 +20,9 @@
}
}
}
+
+// Lazy-load observer boundary (SectionGridItem); fills the grid cell.
+.panelWrapper {
+ height: 100%;
+ width: 100%;
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
index f9840e467a..6910f80ad4 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
@@ -2,9 +2,9 @@ import { useMemo } from 'react';
import GridLayout, { WidthProvider, type Layout } from 'react-grid-layout';
import type { DashboardSection } from '../../../utils';
-import Panel from '../../Panel/Panel';
import { useDashboardStore } from '../../../store/useDashboardStore';
import { usePersistLayout } from '../hooks/usePersistLayout';
+import SectionGridItem from './SectionGridItem';
import styles from './SectionGrid.module.scss';
const ResponsiveGridLayout = WidthProvider(GridLayout);
@@ -12,8 +12,6 @@ const ResponsiveGridLayout = WidthProvider(GridLayout);
interface SectionGridProps {
items: DashboardSection['items'];
layoutIndex: number;
- /** Forwarded to panels — true when the parent section is in the viewport. */
- isVisible?: boolean;
/** All sections — layout context for the panel menu's move/delete actions. */
sections?: DashboardSection[];
}
@@ -21,7 +19,6 @@ interface SectionGridProps {
function SectionGrid({
items,
layoutIndex,
- isVisible,
sections,
}: SectionGridProps): JSX.Element {
const isEditable = useDashboardStore((s) => s.isEditable);
@@ -61,10 +58,9 @@ function SectionGrid({
// panel with no content.
<div key={item.id}>
{item.panel && (
- <Panel
+ <SectionGridItem
panel={item.panel}
panelId={item.id}
- isVisible={isVisible}
panelActions={
isEditable
? {
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
new file mode 100644
index 0000000000..64686376de
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
@@ -0,0 +1,47 @@
+import { useRef } from 'react';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { useIntersectionObserver } from 'hooks/useIntersectionObserver';
+
+import Panel, { type PanelActionsConfig } from '../../Panel/Panel';
+import styles from './SectionGrid.module.scss';
+
+const VIEWPORT_OBSERVER_OPTIONS: IntersectionObserverInit = {
+ rootMargin: '200px',
+};
+
+interface SectionGridItemProps {
+ panel: DashboardtypesPanelDTO;
+ panelId: string;
+ panelActions?: PanelActionsConfig;
+}
+
+/**
+ * Lazy-loads a single panel: watches its own viewport intersection (latched) and
+ * passes it to the presentational Panel as `isVisible`, so a board of many panels
+ * only fetches what's on screen.
+ */
+function SectionGridItem({
+ panel,
+ panelId,
+ panelActions,
+}: SectionGridItemProps): JSX.Element {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const isVisible = useIntersectionObserver(
+ containerRef,
+ VIEWPORT_OBSERVER_OPTIONS,
+ true,
+ );
+
+ return (
+ <div ref={containerRef} className={styles.panelWrapper}>
+ <Panel
+ panel={panel}
+ panelId={panelId}
+ isVisible={isVisible}
+ panelActions={panelActions}
+ />
+ </div>
+ );
+}
+
+export default SectionGridItem;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow.ts
index 585d371449..b5fab1bb40 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/resolvePanelTimeWindow.ts
@@ -1,4 +1,7 @@
-import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ DashboardtypesPanelDTO,
+ DashboardtypesTimePreferenceDTO,
+} from 'api/generated/services/sigNoz.schemas';
/** Absolute time window in epoch milliseconds — the V5 request's native unit. */
export interface PanelTimeWindow {
@@ -65,6 +68,28 @@ const TIME_PREFERENCE_LABEL: Partial<
},
};
+/** A panel's saved `visualization.timePreference`, or `undefined` when the kind has none. */
+export function getPanelTimePreference(
+ panel: DashboardtypesPanelDTO,
+): DashboardtypesTimePreferenceDTO | undefined {
+ const pluginSpec = panel.spec.plugin.spec;
+ if (pluginSpec && 'visualization' in pluginSpec) {
+ return pluginSpec.visualization?.timePreference;
+ }
+ return undefined;
+}
+
+/** True when the panel is locked to a fixed relative window, so it ignores the dashboard's ambient time. */
+export function panelHasFixedTimePreference(
+ panel: DashboardtypesPanelDTO,
+): boolean {
+ const timePreference = getPanelTimePreference(panel);
+ return (
+ timePreference !== undefined &&
+ timePreference !== DashboardtypesTimePreferenceDTO.global_time
+ );
+}
+
export interface PanelTimePreferenceLabel {
/** Compact pill label, e.g. `6h`. */
short: string;