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.

feat(dashboards-v2): view (expand) a dashboard panel (#11882)

Abhi kumar5948b5b97017
diff --git a/frontend/src/container/DashboardContainer/visualization/components/ChartManager/ChartManager.tsx b/frontend/src/container/DashboardContainer/visualization/components/ChartManager/ChartManager.tsx
index 97583cc83a..edb8180992 100644
--- a/frontend/src/container/DashboardContainer/visualization/components/ChartManager/ChartManager.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/components/ChartManager/ChartManager.tsx
@@ -3,7 +3,6 @@ import { Input } from '@signozhq/ui/input';
import { Button } from 'antd';
import { PrecisionOption, PrecisionOptionsEnum } from 'components/Graph/types';
import { ResizeTable } from 'components/ResizeTable';
-import { useNotifications } from 'hooks/useNotifications';
import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
import { usePlotContext } from 'lib/uPlotV2/context/PlotContext';
import useLegendsSync from 'lib/uPlotV2/hooks/useLegendsSync';
@@ -11,6 +10,7 @@ import {
selectIsDashboardLocked,
useDashboardStore,
} from 'providers/Dashboard/store/useDashboardStore';
+import { toast } from '@signozhq/ui/sonner';
import { getChartManagerColumns } from './getChartMangerColumns';
import { ExtendedChartDataset, getDefaultTableDataSet } from './utils';
@@ -44,7 +44,6 @@ export default function ChartManager({
decimalPrecision = PrecisionOptionsEnum.TWO,
onCancel,
}: ChartManagerProps): JSX.Element {
- const { notifications } = useNotifications();
const { legendItemsMap } = useLegendsSync({
config,
subscribeToFocusChange: false,
@@ -136,11 +135,9 @@ export default function ChartManager({
const handleSave = useCallback((): void => {
syncSeriesVisibilityToLocalStorage();
- notifications.success({
- message: 'The updated graphs & legends are saved',
- });
+ toast.success('The updated graphs & legends are saved');
onCancel?.();
- }, [syncSeriesVisibilityToLocalStorage, notifications, onCancel]);
+ }, [syncSeriesVisibilityToLocalStorage, onCancel]);
return (
<div className="chart-manager-container">
diff --git a/frontend/src/container/DashboardContainer/visualization/components/ChartManager/__tests__/ChartManager.test.tsx b/frontend/src/container/DashboardContainer/visualization/components/ChartManager/__tests__/ChartManager.test.tsx
index ecaeb74292..75e5103b65 100644
--- a/frontend/src/container/DashboardContainer/visualization/components/ChartManager/__tests__/ChartManager.test.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/components/ChartManager/__tests__/ChartManager.test.tsx
@@ -5,7 +5,7 @@ import { render, screen } from 'tests/test-utils';
import ChartManager from '../ChartManager';
const mockSyncSeriesVisibilityToLocalStorage = jest.fn();
-const mockNotificationsSuccess = jest.fn();
+const mockToastSuccess = jest.fn();
jest.mock('lib/uPlotV2/context/PlotContext', () => ({
usePlotContext: (): {
@@ -46,12 +46,11 @@ jest.mock('providers/Dashboard/store/useDashboardStore', () => ({
}): boolean => s.dashboardData?.locked ?? false,
}));
-jest.mock('hooks/useNotifications', () => ({
- useNotifications: (): { notifications: { success: jest.Mock } } => ({
- notifications: {
- success: mockNotificationsSuccess,
- },
- }),
+jest.mock('@signozhq/ui/sonner', () => ({
+ ...jest.requireActual('@signozhq/ui/sonner'),
+ toast: {
+ success: (...args: unknown[]): unknown => mockToastSuccess(...args),
+ },
}));
jest.mock('components/ResizeTable', () => {
@@ -160,7 +159,7 @@ describe('ChartManager', () => {
expect(screen.queryByTestId('row-2')).not.toBeInTheDocument();
});
- it('calls syncSeriesVisibilityToLocalStorage, notifications.success, and onCancel when Save is clicked', async () => {
+ it('calls syncSeriesVisibilityToLocalStorage, toast.success, and onCancel when Save is clicked', async () => {
render(
<ChartManager
config={createMockConfig() as UPlotConfigBuilder}
@@ -172,9 +171,9 @@ describe('ChartManager', () => {
await userEvent.click(screen.getByRole('button', { name: /Save/ }));
expect(mockSyncSeriesVisibilityToLocalStorage).toHaveBeenCalledTimes(1);
- expect(mockNotificationsSuccess).toHaveBeenCalledWith({
- message: 'The updated graphs & legends are saved',
- });
+ expect(mockToastSuccess).toHaveBeenCalledWith(
+ 'The updated graphs & legends are saved',
+ );
expect(mockOnCancel).toHaveBeenCalledTimes(1);
});
});
diff --git a/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.styles.scss b/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.styles.scss
index e43d078941..5b6e269d4e 100644
--- a/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.styles.scss
+++ b/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.styles.scss
@@ -5,6 +5,14 @@
height: 100%;
flex-direction: column;
+ // Stacked children (the FullView / standalone graph-manager) sit below the chart
+ // in the same container; size the chart region to its content so they aren't
+ // pushed out. Only this case opts out of filling the height — the dashboard grid,
+ // alert preview, and other charts keep 100% so they fill their container.
+ &--with-layout-children {
+ height: auto;
+ }
+
&--legend-right {
flex-direction: row;
}
diff --git a/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.tsx b/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.tsx
index 5ae8967a71..a8a3896beb 100644
--- a/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout.tsx
@@ -63,6 +63,7 @@ export default function ChartLayout({
className={cx('chart-layout', {
'chart-layout--legend-right':
legendConfig.position === LegendPosition.RIGHT,
+ 'chart-layout--with-layout-children': !!layoutChildren,
})}
>
<div className="chart-layout__content">
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
index 3d518f958a..9c04206044 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
@@ -1,19 +1,18 @@
import { Typography } from '@signozhq/ui/typography';
import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
-import { EQueryType } from 'types/common/dashboard';
+import type { EQueryType } from 'types/common/dashboard';
import type { PanelKind } from '../../../Panels/types/panelKind';
-import { PANEL_TYPES } from '../../../PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants';
import ConfigSelect from '../controls/ConfigSelect/ConfigSelect';
import styles from './PanelTypeSwitcher.module.scss';
-import { getPanelTypeDisabledReason } from './utils';
+import { usePanelTypeSelectItems } from './usePanelTypeSelectItems';
interface PanelTypeSwitcherProps {
/** The current panel kind (selected value). */
panelKind: PanelKind;
- /** Active query type — a kind that can't be authored in it is disabled (e.g. List is Query-Builder-only, so PromQL/ClickHouse disable it). Defaults to Query Builder. */
- queryType?: EQueryType;
+ /** Active query type — a kind that can't be authored in it is disabled (e.g. List is Query-Builder-only, so PromQL/ClickHouse disable it). */
+ queryType: EQueryType;
/** Panel's current signal — also gates the disabled rule (List needs logs/traces, not metrics). */
signal?: TelemetrytypesSignalDTO;
onChange: (kind: PanelKind) => void;
@@ -31,22 +30,7 @@ function PanelTypeSwitcher({
signal,
onChange,
}: PanelTypeSwitcherProps): JSX.Element {
- const items = PANEL_TYPES.map(({ panelKind, label, Icon }) => {
- // One reason drives both the disabled flag and the tooltip, so they can't disagree.
- const disabledReason = getPanelTypeDisabledReason({
- kind: panelKind,
- queryType: queryType ?? EQueryType.QUERY_BUILDER,
- signal,
- label,
- });
- return {
- value: panelKind,
- label,
- icon: <Icon size={14} />,
- disabled: !!disabledReason,
- tooltip: disabledReason,
- };
- });
+ const items = usePanelTypeSelectItems({ queryType, signal });
return (
<div className={styles.field}>
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx
index a95aa75965..1ece6dacc8 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/__tests__/PanelTypeSwitcher.test.tsx
@@ -49,7 +49,11 @@ describe('PanelTypeSwitcher', () => {
it('fires onChange with the chosen plugin kind', () => {
const onChange = jest.fn();
render(
- <PanelTypeSwitcher panelKind="signoz/TimeSeriesPanel" onChange={onChange} />,
+ <PanelTypeSwitcher
+ panelKind="signoz/TimeSeriesPanel"
+ queryType={EQueryType.QUERY_BUILDER}
+ onChange={onChange}
+ />,
);
openDropdown();
@@ -62,6 +66,7 @@ describe('PanelTypeSwitcher', () => {
render(
<PanelTypeSwitcher
panelKind="signoz/TimeSeriesPanel"
+ queryType={EQueryType.QUERY_BUILDER}
signal={TelemetrytypesSignalDTO.metrics}
onChange={jest.fn()}
/>,
@@ -77,6 +82,7 @@ describe('PanelTypeSwitcher', () => {
render(
<PanelTypeSwitcher
panelKind="signoz/TimeSeriesPanel"
+ queryType={EQueryType.QUERY_BUILDER}
onChange={jest.fn()}
/>,
);
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/usePanelTypeSelectItems.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/usePanelTypeSelectItems.tsx
new file mode 100644
index 0000000000..4cd6867ad6
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/usePanelTypeSelectItems.tsx
@@ -0,0 +1,48 @@
+import { useMemo } from 'react';
+import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import type { EQueryType } from 'types/common/dashboard';
+
+import type { PanelKind } from '../../../Panels/types/panelKind';
+import { PANEL_TYPES } from '../../../PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/constants';
+import type { ConfigSelectItem } from '../controls/ConfigSelect/ConfigSelect';
+
+import { getPanelTypeDisabledReason } from './utils';
+
+interface UsePanelTypeSelectItemsArgs {
+ /** Active query type — a kind that can't be authored in it is disabled. */
+ queryType: EQueryType;
+ /** Current datasource — also gates the disabled rule (List needs logs/traces, not metrics). */
+ signal?: TelemetrytypesSignalDTO;
+}
+
+/**
+ * Visualization-kind options for a `ConfigSelect`, each disabled (with a reason
+ * tooltip) when the active query type or signal is incompatible — resolved through
+ * the capabilities guard. Shared by the editor's `PanelTypeSwitcher` and the View
+ * modal's header so the two selectors apply the same rule and can't drift.
+ */
+export function usePanelTypeSelectItems({
+ queryType,
+ signal,
+}: UsePanelTypeSelectItemsArgs): ConfigSelectItem<PanelKind>[] {
+ return useMemo(
+ () =>
+ PANEL_TYPES.map(({ panelKind, label, Icon }) => {
+ // One reason drives both the disabled flag and the tooltip, so they can't disagree.
+ const disabledReason = getPanelTypeDisabledReason({
+ kind: panelKind,
+ queryType,
+ signal,
+ label,
+ });
+ return {
+ value: panelKind,
+ label,
+ icon: <Icon size={14} />,
+ disabled: !!disabledReason,
+ tooltip: disabledReason,
+ };
+ }),
+ [queryType, signal],
+ );
+}
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.tsx
index 7c9a61ceef..9d371f55cc 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx
@@ -3,6 +3,7 @@ import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/sections';
+import { EQueryType } from 'types/common/dashboard';
import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
@@ -38,7 +39,9 @@ function VisualizationSection({
{controls.switchPanelKind && panelKind && onChangePanelKind && (
<PanelTypeSwitcher
panelKind={panelKind}
- queryType={queryType}
+ // queryType is optional on the kind-erased section context, but always
+ // supplied in practice; default to Query Builder at this boundary.
+ queryType={queryType ?? EQueryType.QUERY_BUILDER}
signal={signal}
onChange={onChangePanelKind}
/>
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
index 5dfbee757c..066683e9a9 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder.tsx
@@ -164,7 +164,7 @@ function PanelEditorQueryBuilder({
<TextToolTip text="This will temporarily save the current query and graph state. This will persist across tab change" />
<RunQueryBtn
className="run-query-dashboard-btn"
- label="Stage & Run Query"
+ label="Run Query"
onStageRunQuery={onStageRunQuery}
isLoadingQueries={isLoadingQueries}
handleCancelQuery={onCancelQuery}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.module.scss
index ae326f3bb3..7356f2af81 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.module.scss
@@ -49,6 +49,13 @@
background: var(--l2-background);
}
+// Standalone View stacks the graph-manager below the chart inside the surface (it
+// must stay within the chart's PlotContext). Let it flow out of the surface so the
+// modal body scrolls as a whole, instead of clipping it or scrolling the panel.
+.surfaceStacked {
+ overflow: visible;
+}
+
.state {
flex: 1;
display: flex;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
index 20e6b1ecd0..de2fff139b 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane.tsx
@@ -1,11 +1,13 @@
import { useState } from 'react';
import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import cx from 'classnames';
import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
import DateTimeSelectionV2 from 'container/TopNav/DateTimeSelectionV2';
import PanelBody from 'pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody';
import PanelHeader from 'pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeader';
import type { RenderablePanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelDefinition';
import { PANEL_KIND_TO_PANEL_TYPE } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import type { DashboardPreference } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/rendererProps';
import { getPanelQueryType } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getPanelQueryType';
import type {
PanelPagination,
@@ -32,6 +34,14 @@ interface PreviewPaneProps {
onDragSelect: (start: number, end: number) => void;
/** Server-side pager for raw/list panels; absent for non-paginated panels. */
pagination?: PanelPagination;
+ /** Render context — defaults to the editor's DASHBOARD_EDIT; the View modal passes STANDALONE_VIEW. */
+ panelMode?: PanelMode;
+ /** Hide the preview's top row entirely (query-type badge + time picker) — the View modal has its own header. */
+ hideHeader?: boolean;
+ /** Dashboard-wide preferences (cursor sync, …) forwarded to the body; the modal isolates cursor-sync. */
+ dashboardPreference?: DashboardPreference;
+ /** Close the standalone View modal — forwarded to the time-series/bar graph manager. */
+ onCloseStandaloneView?: () => void;
}
/**
@@ -50,6 +60,10 @@ function PreviewPane({
refetch,
onDragSelect,
pagination,
+ panelMode = PanelMode.DASHBOARD_EDIT,
+ hideHeader = false,
+ dashboardPreference,
+ onCloseStandaloneView,
}: PreviewPaneProps): JSX.Element {
const panelType = PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind];
const queryType = getPanelQueryType(panel);
@@ -61,18 +75,24 @@ function PreviewPane({
return (
<div className={styles.preview}>
- <div className={styles.header}>
- <PlotTag
- queryType={queryType}
- panelType={panelType}
- className={styles.queryType}
- />
- <div className={styles.dateTimeSelector}>
- <DateTimeSelectionV2 showAutoRefresh hideShareModal />
+ {!hideHeader && (
+ <div className={styles.header}>
+ <PlotTag
+ queryType={queryType}
+ panelType={panelType}
+ className={styles.queryType}
+ />
+ <div className={styles.dateTimeSelector}>
+ <DateTimeSelectionV2 showAutoRefresh hideShareModal />
+ </div>
</div>
- </div>
+ )}
<div className={styles.container}>
- <div className={styles.surface}>
+ <div
+ className={cx(styles.surface, {
+ [styles.surfaceStacked]: panelMode === PanelMode.STANDALONE_VIEW,
+ })}
+ >
<PanelHeader
panelId={panelId}
panel={panel}
@@ -94,9 +114,11 @@ function PreviewPane({
error={error}
refetch={refetch}
onDragSelect={onDragSelect}
- panelMode={PanelMode.DASHBOARD_EDIT}
+ panelMode={panelMode}
+ dashboardPreference={dashboardPreference}
searchTerm={searchable ? searchTerm : undefined}
pagination={pagination}
+ onCloseStandaloneView={onCloseStandaloneView}
/>
</div>
</div>
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/PanelEditorContainer.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/PanelEditorContainer.test.tsx
new file mode 100644
index 0000000000..eec4594f5b
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/__tests__/PanelEditorContainer.test.tsx
@@ -0,0 +1,274 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';
+
+import PanelEditorContainer from '../index';
+
+/**
+ * Characterization test for the editor's composition: which derived values and
+ * options it forwards to the draft/query/query-sync/type-switch hooks and to its
+ * children. The leaf hooks are mocked as arg-capturing spies so this pins the
+ * wiring; it stays valid (and guards behavior) after that wiring is pulled into a
+ * shared edit-session hook, since the mocks intercept the leaf hooks either way.
+ */
+
+const mockSetSpec = jest.fn();
+const mockRefetch = jest.fn();
+const mockCancelQuery = jest.fn();
+const mockBuildSaveSpec = jest.fn((spec: unknown) => spec);
+const mockOnChangePanelKind = jest.fn();
+const mockSave = jest.fn().mockResolvedValue(undefined);
+
+const mockUseDraft = jest.fn();
+jest.mock('../hooks/usePanelEditorDraft', () => ({
+ usePanelEditorDraft: (panel: unknown): unknown => mockUseDraft(panel),
+}));
+
+const mockUseQuery = jest.fn();
+jest.mock('../../hooks/usePanelQuery', () => ({
+ usePanelQuery: (args: unknown): unknown => mockUseQuery(args),
+}));
+
+const mockUseQuerySync = jest.fn();
+jest.mock('../hooks/usePanelEditorQuerySync', () => ({
+ usePanelEditorQuerySync: (args: unknown): unknown => mockUseQuerySync(args),
+}));
+
+const mockUseTypeSwitch = jest.fn();
+jest.mock('../hooks/usePanelTypeSwitch', () => ({
+ usePanelTypeSwitch: (args: unknown): unknown => mockUseTypeSwitch(args),
+}));
+
+jest.mock('../hooks/usePanelEditorSave', () => ({
+ usePanelEditorSave: (): unknown => ({ save: mockSave, isSaving: false }),
+}));
+
+jest.mock('../hooks/useSwitchColumnsOnSignalChange', () => ({
+ useSwitchColumnsOnSignalChange: jest.fn(),
+}));
+jest.mock('../hooks/useSeedNewListColumns', () => ({
+ useSeedNewListColumns: jest.fn(),
+}));
+jest.mock('../hooks/useLegendSeries', () => ({
+ useLegendSeries: (): [] => [],
+}));
+jest.mock('../hooks/useTableColumns', () => ({
+ useTableColumns: (): [] => [],
+}));
+jest.mock('../hooks/useMetricYAxisUnit', () => ({
+ useMetricYAxisUnit: (): unknown => ({
+ metricUnit: undefined,
+ isLoading: false,
+ }),
+}));
+jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({
+ useQueryBuilder: (): unknown => ({ currentQuery: { queryType: 'builder' } }),
+}));
+jest.mock(
+ '../../PanelsAndSectionsLayout/Panel/hooks/usePanelInteractions',
+ () => ({
+ usePanelInteractions: (): unknown => ({
+ onDragSelect: jest.fn(),
+ dashboardPreference: {},
+ }),
+ }),
+);
+
+jest.mock('@signozhq/ui/resizable', () => ({
+ __esModule: true,
+ ResizablePanelGroup: ({
+ children,
+ }: {
+ children: React.ReactNode;
+ }): JSX.Element => <div>{children}</div>,
+ ResizablePanel: ({ children }: { children: React.ReactNode }): JSX.Element => (
+ <div>{children}</div>
+ ),
+ ResizableHandle: (): null => null,
+ useDefaultLayout: (): unknown => ({
+ defaultLayout: undefined,
+ onLayoutChanged: jest.fn(),
+ }),
+}));
+jest.mock('@signozhq/ui/sonner', () => ({
+ toast: { success: jest.fn(), error: jest.fn() },
+}));
+
+// Children mocked to capture props (and expose a Save trigger / footer slot).
+const mockHeaderProps = jest.fn();
+jest.mock('../Header/Header', () => ({
+ __esModule: true,
+ default: (props: { onSave: () => void }): JSX.Element => {
+ mockHeaderProps(props);
+ return (
+ <button type="button" data-testid="editor-save" onClick={props.onSave}>
+ save
+ </button>
+ );
+ },
+}));
+const mockPreviewProps = jest.fn();
+jest.mock('../PreviewPane/PreviewPane', () => ({
+ __esModule: true,
+ default: (props: unknown): JSX.Element => {
+ mockPreviewProps(props);
+ return <div data-testid="preview" />;
+ },
+}));
+const mockQbProps = jest.fn();
+jest.mock('../PanelEditorQueryBuilder/PanelEditorQueryBuilder', () => ({
+ __esModule: true,
+ default: (props: { footer?: React.ReactNode }): JSX.Element => {
+ mockQbProps(props);
+ return <div data-testid="qb">{props.footer}</div>;
+ },
+}));
+const mockConfigProps = jest.fn();
+jest.mock('../ConfigPane/ConfigPane', () => ({
+ __esModule: true,
+ default: (props: unknown): JSX.Element => {
+ mockConfigProps(props);
+ return <div data-testid="config" />;
+ },
+}));
+jest.mock('../ListColumnsEditor/ListColumnsEditor', () => ({
+ __esModule: true,
+ default: (): JSX.Element => <div data-testid="list-columns" />,
+}));
+
+function makePanel(kind: string): DashboardtypesPanelDTO {
+ return {
+ kind: 'Panel',
+ spec: {
+ display: { name: 'CPU' },
+ plugin: { kind, spec: {} },
+ queries: [],
+ },
+ } as unknown as DashboardtypesPanelDTO;
+}
+
+const baseProps = {
+ dashboardId: 'dash-1',
+ panelId: 'panel-1',
+ onClose: jest.fn(),
+ onSaved: jest.fn(),
+};
+
+function setup(
+ panel: DashboardtypesPanelDTO,
+ overrides?: Partial<React.ComponentProps<typeof PanelEditorContainer>>,
+): void {
+ mockUseDraft.mockReturnValue({
+ draft: panel,
+ spec: panel.spec,
+ setSpec: mockSetSpec,
+ isSpecDirty: false,
+ });
+ mockUseQuery.mockReturnValue({
+ data: { response: undefined },
+ isFetching: false,
+ error: null,
+ cancelQuery: mockCancelQuery,
+ refetch: mockRefetch,
+ pagination: undefined,
+ });
+ mockUseQuerySync.mockReturnValue({
+ runQuery: jest.fn(),
+ isQueryDirty: false,
+ buildSaveSpec: mockBuildSaveSpec,
+ });
+ mockUseTypeSwitch.mockReturnValue({
+ onChangePanelKind: mockOnChangePanelKind,
+ });
+ render(<PanelEditorContainer {...baseProps} panel={panel} {...overrides} />);
+}
+
+describe('PanelEditorContainer composition', () => {
+ beforeEach(() => jest.clearAllMocks());
+
+ it('renders the editor shell with preview, query builder, and config pane', () => {
+ const panel = makePanel('signoz/TimeSeriesPanel');
+ setup(panel);
+
+ expect(screen.getByTestId('panel-editor-v2')).toBeInTheDocument();
+ expect(screen.getByTestId('preview')).toBeInTheDocument();
+ expect(screen.getByTestId('qb')).toBeInTheDocument();
+ expect(screen.getByTestId('config')).toBeInTheDocument();
+
+ expect(mockPreviewProps).toHaveBeenCalledWith(
+ expect.objectContaining({
+ panel,
+ panelDefinition: getPanelDefinition('signoz/TimeSeriesPanel'),
+ }),
+ );
+ expect(mockQbProps).toHaveBeenCalledWith(
+ expect.objectContaining({ panelKind: 'signoz/TimeSeriesPanel' }),
+ );
+ expect(mockConfigProps).toHaveBeenCalledWith(
+ expect.objectContaining({
+ panel,
+ spec: panel.spec,
+ onChangePanelKind: mockOnChangePanelKind,
+ }),
+ );
+ });
+
+ it('forwards the derived panel type + query-sync options to the leaf hooks', () => {
+ const panel = makePanel('signoz/TimeSeriesPanel');
+ setup(panel);
+
+ expect(mockUseQuery).toHaveBeenCalledWith(
+ expect.objectContaining({ panel, panelId: 'panel-1', enabled: true }),
+ );
+ expect(mockUseQuerySync).toHaveBeenCalledWith(
+ expect.objectContaining({
+ panelType: PANEL_TYPES.TIME_SERIES,
+ setSpec: mockSetSpec,
+ refetch: mockRefetch,
+ alwaysSerializeQuery: false,
+ signal: getPanelDefinition('signoz/TimeSeriesPanel').supportedSignals[0],
+ }),
+ );
+ expect(mockUseTypeSwitch).toHaveBeenCalledWith(
+ expect.objectContaining({
+ panelType: PANEL_TYPES.TIME_SERIES,
+ spec: panel.spec,
+ setSpec: mockSetSpec,
+ }),
+ );
+ });
+
+ it('marks a new panel dirty and always serializes its query', () => {
+ setup(makePanel('signoz/TimeSeriesPanel'), { isNew: true });
+
+ expect(mockUseQuerySync).toHaveBeenCalledWith(
+ expect.objectContaining({ alwaysSerializeQuery: true }),
+ );
+ expect(mockHeaderProps).toHaveBeenCalledWith(
+ expect.objectContaining({ isDirty: true }),
+ );
+ });
+
+ it('bakes the live query into the spec on save, then notifies', async () => {
+ const panel = makePanel('signoz/TimeSeriesPanel');
+ setup(panel, { onSaved: baseProps.onSaved });
+
+ await userEvent.click(screen.getByTestId('editor-save'));
+
+ await waitFor(() => expect(baseProps.onSaved).toHaveBeenCalled());
+ expect(mockBuildSaveSpec).toHaveBeenCalledWith(panel.spec);
+ expect(mockSave).toHaveBeenCalledWith(panel.spec);
+ });
+
+ it('renders the list-columns editor only for list panels', () => {
+ setup(makePanel('signoz/ListPanel'));
+ expect(screen.getByTestId('list-columns')).toBeInTheDocument();
+ });
+
+ it('omits the list-columns editor for non-list panels', () => {
+ setup(makePanel('signoz/TimeSeriesPanel'));
+ expect(screen.queryByTestId('list-columns')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts
new file mode 100644
index 0000000000..a46ba8f59a
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditSession.ts
@@ -0,0 +1,119 @@
+import type {
+ DashboardtypesPanelDTO,
+ DashboardtypesPanelSpecDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import type { PANEL_TYPES } from 'constants/queryBuilder';
+import { getPanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/registry';
+import type { RenderablePanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelDefinition';
+import {
+ PANEL_KIND_TO_PANEL_TYPE,
+ type PanelKind,
+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import {
+ usePanelQuery,
+ type PanelQueryTimeOverride,
+ type UsePanelQueryResult,
+} from 'pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery';
+
+import { usePanelEditorDraft } from './usePanelEditorDraft';
+import { usePanelEditorQuerySync } from './usePanelEditorQuerySync';
+import { usePanelTypeSwitch } from './usePanelTypeSwitch';
+
+interface UsePanelEditSessionArgs {
+ panel: DashboardtypesPanelDTO;
+ panelId: string;
+ /** Per-view time window (epoch ms); omit to follow the dashboard's global window. */
+ time?: PanelQueryTimeOverride;
+ /** Serialize the live builder query into the spec on save even if unchanged (new panels). */
+ alwaysSerializeQuery?: boolean;
+ /** Seed an empty builder with the kind's default signal (new panels) — off for drilldown. */
+ seedQuerySignal?: boolean;
+}
+
+export interface UsePanelEditSessionReturn {
+ /** Local editable copy of the panel — the preview renders this, not the saved panel. */
+ draft: DashboardtypesPanelDTO;
+ spec: DashboardtypesPanelSpecDTO;
+ setSpec: (next: DashboardtypesPanelSpecDTO) => void;
+ isSpecDirty: boolean;
+ /** Restore the draft to the originally-loaded panel. */
+ reset: () => void;
+ /** Draft kind → V1 panel type (drives the query builder + preview). */
+ panelType: PANEL_TYPES;
+ panelDefinition: RenderablePanelDefinition;
+ /** The kind's first supported signal — seeds new queries/columns. */
+ defaultSignal: TelemetrytypesSignalDTO;
+ /** Shared query result for the draft over the resolved time window. */
+ query: UsePanelQueryResult;
+ /** Stage & run the live builder query into the draft. */
+ runQuery: () => void;
+ isQueryDirty: boolean;
+ /** Bake the live (possibly un-run) query into a spec — for save / editor handoff. */
+ buildSaveSpec: (
+ spec: DashboardtypesPanelSpecDTO,
+ ) => DashboardtypesPanelSpecDTO;
+ /** Switch the draft's visualization kind in place (reversible per session). */
+ onChangePanelKind: (kind: PanelKind) => void;
+}
+
+/**
+ * The panel-editing pipeline shared by the full-page editor and the View modal's
+ * drilldown editor: a local draft, its query result over the resolved time window,
+ * the staged-query sync, and the visualization-kind switch. Each consumer layers its
+ * own concerns on top (the editor adds save + list seeding; the modal adds per-view
+ * time isolation + reset). Keeping the wiring here stops the two from drifting.
+ */
+export function usePanelEditSession({
+ panel,
+ panelId,
+ time,
+ alwaysSerializeQuery = false,
+ seedQuerySignal = false,
+}: UsePanelEditSessionArgs): UsePanelEditSessionReturn {
+ const { draft, spec, setSpec, isSpecDirty, reset } =
+ usePanelEditorDraft(panel);
+
+ const panelKind = draft.spec.plugin.kind;
+ const panelDefinition = getPanelDefinition(panelKind);
+ const panelType = PANEL_KIND_TO_PANEL_TYPE[panelKind];
+ const defaultSignal = panelDefinition.supportedSignals[0];
+
+ const query = usePanelQuery({
+ panel: draft,
+ panelId,
+ time,
+ enabled: !!panelDefinition,
+ });
+
+ const { runQuery, isQueryDirty, buildSaveSpec } = usePanelEditorQuerySync({
+ draft,
+ panelType,
+ setSpec,
+ refetch: query.refetch,
+ alwaysSerializeQuery,
+ signal: seedQuerySignal ? defaultSignal : undefined,
+ });
+
+ const { onChangePanelKind } = usePanelTypeSwitch({
+ spec: draft.spec,
+ panelType,
+ setSpec,
+ });
+
+ return {
+ draft,
+ spec,
+ setSpec,
+ isSpecDirty,
+ reset,
+ panelType,
+ panelDefinition,
+ defaultSignal,
+ query,
+ runQuery,
+ isQueryDirty,
+ buildSaveSpec,
+ onChangePanelKind,
+ };
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx
index 81a0a1eca6..f66cbbd3a2 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/index.tsx
@@ -12,13 +12,7 @@ import {
type DashboardtypesPanelSpecDTO,
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
-import { PANEL_TYPES } from 'constants/queryBuilder';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
-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 { getExecStats } from '../queryV5/v5ResponseData';
@@ -29,12 +23,9 @@ 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 { useMetricYAxisUnit } from './hooks/useMetricYAxisUnit';
+import { usePanelEditSession } from './hooks/usePanelEditSession';
import { usePanelEditorSave } from './hooks/usePanelEditorSave';
-import { usePanelTypeSwitch } from './hooks/usePanelTypeSwitch';
import { useSeedNewListColumns } from './hooks/useSeedNewListColumns';
import { useSwitchColumnsOnSignalChange } from './hooks/useSwitchColumnsOnSignalChange';
import { useTableColumns } from './hooks/useTableColumns';
@@ -70,7 +61,36 @@ function PanelEditorContainer({
onClose,
onSaved,
}: PanelEditorContainerProps): JSX.Element {
- const { draft, spec, setSpec, isSpecDirty } = usePanelEditorDraft(panel);
+ // Shared editing pipeline (draft + query + staged-query sync + kind switch). A new
+ // panel always serializes its seed query and seeds the builder's default signal.
+ const {
+ draft,
+ spec,
+ setSpec,
+ isSpecDirty,
+ panelDefinition,
+ defaultSignal,
+ query,
+ runQuery,
+ isQueryDirty,
+ buildSaveSpec,
+ onChangePanelKind,
+ } = usePanelEditSession({
+ panel,
+ panelId,
+ alwaysSerializeQuery: isNew,
+ seedQuerySignal: true,
+ });
+ const {
+ data,
+ isFetching,
+ isPreviousData,
+ error,
+ cancelQuery,
+ refetch,
+ pagination,
+ } = query;
+
// Live query type (the selected tab) — the type switcher disables kinds that can't be
// authored in it. Read from the provider, not the spec: a new panel's spec carries no
// query until staged, so the spec would lag the tab.
@@ -94,44 +114,7 @@ function PanelEditorContainer({
storage: layoutStorage,
});
- // Panel kind → V1 panel type, which drives the query builder and preview.
- const fullKind = draft.spec.plugin.kind;
- const panelType =
- (fullKind && PANEL_KIND_TO_PANEL_TYPE[fullKind as PanelKind]) ??
- PANEL_TYPES.TIME_SERIES;
-
- // One shared query result for the whole editor; the preview renders it.
- const panelDefinition = getPanelDefinition(draft.spec.plugin.kind);
- const {
- data,
- isFetching,
- isPreviousData,
- error,
- cancelQuery,
- refetch,
- pagination,
- } = usePanelQuery({
- panel: draft,
- panelId,
- enabled: !!panelDefinition,
- });
-
- // A new panel's default signal (its kind's first supported) — seeds the query and columns.
- const defaultSignal = panelDefinition.supportedSignals[0];
-
- const { runQuery, isQueryDirty, buildSaveSpec } = usePanelEditorQuerySync({
- draft,
- panelType,
- setSpec,
- refetch,
- // New panel's seed query is the builder default, not a real saved query —
- // always serialize it on save.
- alwaysSerializeQuery: isNew,
- signal: defaultSignal,
- });
-
- // Switch the panel's visualization kind in place (reversible per session).
- const { onChangePanelKind } = usePanelTypeSwitch({ spec, panelType, setSpec });
+ const panelKind = draft.spec.plugin.kind;
// At editor level, not the collapsible FormattingSection, so seeding runs while closed.
const formattingUnit = (
@@ -163,7 +146,7 @@ function PanelEditorContainer({
// Spec and query dirtiness are tracked independently so query re-serialization
// never false-dirties. A new panel is always savable (you're creating it).
const isDirty = isNew || isSpecDirty || isQueryDirty;
- const isListPanel = fullKind === 'signoz/ListPanel';
+ const isListPanel = panelKind === '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.
@@ -253,7 +236,7 @@ function PanelEditorContainer({
<ResizableHandle withHandle className={styles.handle} />
<ResizablePanel minSize="35%" maxSize="45%" defaultSize="40%">
<PanelEditorQueryBuilder
- panelKind={fullKind}
+ panelKind={panelKind}
signal={listSignal}
isLoadingQueries={isFetching}
onStageRunQuery={runQuery}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/panelEditorHandoff.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/panelEditorHandoff.ts
new file mode 100644
index 0000000000..ba801cb96d
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelEditor/panelEditorHandoff.ts
@@ -0,0 +1,10 @@
+import type { DashboardtypesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
+
+/**
+ * Router location state for opening the panel editor pre-loaded with edits instead of
+ * the saved panel. The View modal sets this so "Switch to Edit Mode" carries its
+ * drilldown-edited spec (queries/plugin) into the editor.
+ */
+export interface PanelEditorHandoffState {
+ editSpec?: DashboardtypesPanelSpecDTO;
+}
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 70705dd471..f991bed65b 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/BarChartPanel/Renderer.tsx
@@ -1,7 +1,9 @@
import { useCallback, useMemo, useRef } from 'react';
import type { DashboardtypesBarChartPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
import BarChart from 'container/DashboardContainer/visualization/charts/BarChart/BarChart';
+import ChartManager from 'container/DashboardContainer/visualization/components/ChartManager/ChartManager';
import TooltipFooter from 'container/DashboardContainer/visualization/panels/components/TooltipFooter';
+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { useResizeObserver } from 'hooks/useDimensions';
import { IRenderTooltipFooterArgs } from 'lib/uPlotV2/components/types';
@@ -37,6 +39,7 @@ function BarPanelRenderer({
onDragSelect,
dashboardPreference,
panelMode,
+ onCloseStandaloneView,
}: PanelRendererProps<'signoz/BarChartPanel'>): JSX.Element {
const graphRef = useRef<HTMLDivElement>(null);
const containerDimensions = useResizeObserver(graphRef);
@@ -114,6 +117,32 @@ function BarPanelRenderer({
return resolveLegendPosition(spec.legend?.position);
}, [spec.legend?.position]);
+ // The standalone View modal shows V1's graph-manager legend below the chart:
+ // Filter Series + per-series show/hide + Save. Series visibility auto-persists to
+ // localStorage (STANDALONE_VIEW selection prefs), keyed by panelId.
+ const layoutChildren = useMemo(
+ () =>
+ panelMode === PanelMode.STANDALONE_VIEW ? (
+ <div className={PanelStyles.chartManagerContainer}>
+ <ChartManager
+ config={config}
+ alignedData={chartData}
+ yAxisUnit={spec.formatting?.unit}
+ decimalPrecision={decimalPrecision}
+ onCancel={onCloseStandaloneView}
+ />
+ </div>
+ ) : null,
+ [
+ panelMode,
+ config,
+ chartData,
+ spec.formatting?.unit,
+ decimalPrecision,
+ onCloseStandaloneView,
+ ],
+ );
+
const renderTooltipFooter = useCallback(
({ isPinned, dismiss }: IRenderTooltipFooterArgs) => (
<TooltipFooter id={panelId} isPinned={isPinned} dismiss={dismiss} />
@@ -147,6 +176,7 @@ function BarPanelRenderer({
config={config}
data={chartData}
legendConfig={{ position: legendPosition }}
+ layoutChildren={layoutChildren}
groupByPerQuery={groupByPerQuery}
canPinTooltip
timezone={timezone}
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 e07379f294..69598a51b6 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/kinds/TimeSeriesPanel/Renderer.tsx
@@ -1,7 +1,9 @@
import { useCallback, useMemo, useRef } from 'react';
import type { DashboardtypesTimeSeriesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
import TimeSeries from 'container/DashboardContainer/visualization/charts/TimeSeries/TimeSeries';
+import ChartManager from 'container/DashboardContainer/visualization/components/ChartManager/ChartManager';
import TooltipFooter from 'container/DashboardContainer/visualization/panels/components/TooltipFooter';
+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { useResizeObserver } from 'hooks/useDimensions';
import { IRenderTooltipFooterArgs } from 'lib/uPlotV2/components/types';
@@ -37,6 +39,7 @@ function TimeSeriesPanelRenderer({
onDragSelect,
dashboardPreference,
panelMode,
+ onCloseStandaloneView,
}: PanelRendererProps<'signoz/TimeSeriesPanel'>): JSX.Element {
const graphRef = useRef<HTMLDivElement>(null);
const containerDimensions = useResizeObserver(graphRef);
@@ -115,6 +118,32 @@ function TimeSeriesPanelRenderer({
return resolveLegendPosition(spec.legend?.position);
}, [spec.legend?.position]);
+ // The standalone View modal shows V1's graph-manager legend below the chart:
+ // Filter Series + per-series show/hide + Save. Series visibility auto-persists to
+ // localStorage (STANDALONE_VIEW selection prefs), keyed by panelId.
+ const layoutChildren = useMemo(
+ () =>
+ panelMode === PanelMode.STANDALONE_VIEW ? (
+ <div className={PanelStyles.chartManagerContainer}>
+ <ChartManager
+ config={config}
+ alignedData={chartData}
+ yAxisUnit={spec.formatting?.unit}
+ decimalPrecision={decimalPrecision}
+ onCancel={onCloseStandaloneView}
+ />
+ </div>
+ ) : null,
+ [
+ panelMode,
+ config,
+ chartData,
+ spec.formatting?.unit,
+ decimalPrecision,
+ onCloseStandaloneView,
+ ],
+ );
+
const renderTooltipFooter = useCallback(
({ isPinned, dismiss }: IRenderTooltipFooterArgs) => (
<TooltipFooter id={panelId} isPinned={isPinned} dismiss={dismiss} />
@@ -148,6 +177,7 @@ function TimeSeriesPanelRenderer({
config={config}
data={chartData}
legendConfig={{ position: legendPosition }}
+ layoutChildren={layoutChildren}
groupByPerQuery={groupByPerQuery}
canPinTooltip
timezone={timezone}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/panel.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/panel.module.scss
index 79d799adc0..28c530ed33 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/panel.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/panel.module.scss
@@ -7,3 +7,7 @@
height: 100%;
position: relative;
}
+
+.chartManagerContainer {
+ padding: 36px 0;
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/interactions.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/interactions.ts
index 2b10150f48..6984126f24 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/interactions.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/interactions.ts
@@ -22,6 +22,9 @@ export type PanelClickEvent =
type DragSelect = (start: number, end: number) => void;
+/** Close the standalone View modal — fired by the chart's graph-manager Save/Cancel. */
+type CloseStandaloneView = () => void;
+
/**
* Per-kind interaction props — each kind exposes only the gestures it supports.
* Keyed by `PanelKind`; `PanelRendererProps<K>` indexes this, so a missing kind
@@ -31,10 +34,12 @@ export type PanelInteractionMap = Record<PanelKind, object> & {
'signoz/TimeSeriesPanel': {
onClick?: (event: ChartClickEvent) => void;
onDragSelect?: DragSelect;
+ onCloseStandaloneView?: CloseStandaloneView;
};
'signoz/BarChartPanel': {
onClick?: (event: ChartClickEvent) => void;
onDragSelect?: DragSelect;
+ onCloseStandaloneView?: CloseStandaloneView;
};
'signoz/HistogramPanel': { onClick?: (event: ChartClickEvent) => void };
'signoz/TablePanel': { onClick?: (event: TableClickEvent) => void };
@@ -50,4 +55,5 @@ export type PanelInteractionMap = Record<PanelKind, object> & {
export interface AnyPanelInteractionProps {
onClick?: (event: PanelClickEvent) => void;
onDragSelect?: DragSelect;
+ onCloseStandaloneView?: CloseStandaloneView;
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind.ts
index e415594d72..dcb7e7d674 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind.ts
@@ -17,3 +17,15 @@ export const PANEL_KIND_TO_PANEL_TYPE: Record<PanelKind, PANEL_TYPES> = {
'signoz/HistogramPanel': PANEL_TYPES.HISTOGRAM,
'signoz/ListPanel': PANEL_TYPES.LIST,
};
+
+/**
+ * Reverse of {@link PANEL_KIND_TO_PANEL_TYPE} — the mapping is a bijection, so every
+ * panel kind round-trips. Partial because `PANEL_TYPES` also has types with no V2 kind
+ * (e.g. trace/empty); a lookup on those returns `undefined`.
+ */
+export const PANEL_TYPE_TO_PANEL_KIND: Partial<Record<PANEL_TYPES, PanelKind>> =
+ Object.fromEntries(
+ (Object.entries(PANEL_KIND_TO_PANEL_TYPE) as [PanelKind, PANEL_TYPES][]).map(
+ ([kind, type]) => [type, kind],
+ ),
+ );
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/__tests__/buildViewPanelSpec.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/__tests__/buildViewPanelSpec.test.ts
new file mode 100644
index 0000000000..e85035aa60
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/__tests__/buildViewPanelSpec.test.ts
@@ -0,0 +1,73 @@
+import type { DashboardtypesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { getSwitchedPluginSpec } from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec';
+import { PANEL_TYPE_TO_PANEL_KIND } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import { toPerses } from 'pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters';
+import type { Query } from 'types/api/queryBuilder/queryBuilderData';
+
+import { buildViewPanelSpec } from '../buildViewPanelSpec';
+
+// The query conversion + kind-switch spec builder are tested in their own suites; here we
+// isolate buildViewPanelSpec's branching (same kind vs. kind switch).
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters',
+ () => ({ toPerses: jest.fn(() => [{ kind: 'mock-query' }]) }),
+);
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec',
+ () => ({ getSwitchedPluginSpec: jest.fn(() => ({ switched: true })) }),
+);
+
+const query = {} as Query;
+
+function specOfKind(kind: string): DashboardtypesPanelSpecDTO {
+ return {
+ plugin: { kind, spec: { formatting: {} } },
+ queries: [],
+ display: { name: 'panel' },
+ } as unknown as DashboardtypesPanelSpecDTO;
+}
+
+describe('PANEL_TYPE_TO_PANEL_KIND', () => {
+ it('is the inverse of the kind→type map', () => {
+ expect(PANEL_TYPE_TO_PANEL_KIND[PANEL_TYPES.VALUE]).toBe(
+ 'signoz/NumberPanel',
+ );
+ expect(PANEL_TYPE_TO_PANEL_KIND[PANEL_TYPES.TABLE]).toBe('signoz/TablePanel');
+ expect(PANEL_TYPE_TO_PANEL_KIND[PANEL_TYPES.TIME_SERIES]).toBe(
+ 'signoz/TimeSeriesPanel',
+ );
+ });
+});
+
+describe('buildViewPanelSpec', () => {
+ beforeEach(() => jest.clearAllMocks());
+
+ it('keeps the kind and only swaps the queries when the target type matches', () => {
+ const spec = specOfKind('signoz/TimeSeriesPanel');
+ const result = buildViewPanelSpec({
+ spec,
+ query,
+ panelType: PANEL_TYPES.TIME_SERIES,
+ });
+
+ expect(result.plugin.kind).toBe('signoz/TimeSeriesPanel');
+ expect(result.plugin.spec).toBe(spec.plugin.spec);
+ expect(result.queries).toStrictEqual([{ kind: 'mock-query' }]);
+ expect(toPerses).toHaveBeenCalledWith(query, PANEL_TYPES.TIME_SERIES);
+ expect(getSwitchedPluginSpec).not.toHaveBeenCalled();
+ });
+
+ it('switches the kind (Value → Table) and rebuilds the plugin spec', () => {
+ const result = buildViewPanelSpec({
+ spec: specOfKind('signoz/NumberPanel'),
+ query,
+ panelType: PANEL_TYPES.TABLE,
+ });
+
+ expect(result.plugin.kind).toBe('signoz/TablePanel');
+ expect(result.plugin.spec).toStrictEqual({ switched: true });
+ expect(getSwitchedPluginSpec).toHaveBeenCalled();
+ expect(toPerses).toHaveBeenCalledWith(query, PANEL_TYPES.TABLE);
+ });
+});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/buildViewPanelSpec.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/buildViewPanelSpec.ts
new file mode 100644
index 0000000000..0d19e9301c
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/buildViewPanelSpec.ts
@@ -0,0 +1,52 @@
+import type {
+ DashboardtypesPanelPluginDTO,
+ DashboardtypesPanelSpecDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import type { PANEL_TYPES } from 'constants/queryBuilder';
+import { getSwitchedPluginSpec } from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/getSwitchedPluginSpec';
+import {
+ PANEL_TYPE_TO_PANEL_KIND,
+ type PanelKind,
+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import { toPerses } from 'pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters';
+import type { Query } from 'types/api/queryBuilder/queryBuilderData';
+
+import { getBuilderQueries } from '../getBuilderQueries';
+
+/**
+ * Bakes a V1 query + target panel type into a View-modal spec (drilldown seed + URL re-hydration).
+ * When `panelType` maps to a different kind than the panel's (e.g. a breakout turns Value → Table),
+ * the kind is switched via the editor's `getSwitchedPluginSpec` so it opens with populated config.
+ */
+export function buildViewPanelSpec({
+ spec,
+ query,
+ panelType,
+}: {
+ spec: DashboardtypesPanelSpecDTO;
+ query: Query;
+ panelType: PANEL_TYPES;
+}): DashboardtypesPanelSpecDTO {
+ const queries = toPerses(query, panelType);
+ const currentKind = spec.plugin.kind as PanelKind;
+ const newKind = PANEL_TYPE_TO_PANEL_KIND[panelType] ?? currentKind;
+
+ if (newKind === currentKind) {
+ return { ...spec, queries };
+ }
+
+ // The plugin cast mirrors the editor's type-switch — a dynamically chosen kind can't be
+ // correlated with its spec statically.
+ const signal = getBuilderQueries(spec.queries)[0]
+ ?.signal as TelemetrytypesSignalDTO;
+ return {
+ ...spec,
+ plugin: {
+ ...spec.plugin,
+ kind: newKind,
+ spec: getSwitchedPluginSpec(spec, newKind, signal),
+ } as DashboardtypesPanelPluginDTO,
+ queries,
+ };
+}
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 3f212ced8d..a61ff12adb 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
@@ -14,6 +14,19 @@ jest.mock(
}),
);
+const mockOpenView = jest.fn();
+jest.mock('../../hooks/useViewPanel', () => ({
+ useViewPanel: (): {
+ openView: jest.Mock;
+ closeView: jest.Mock;
+ expandedPanelId: string | null;
+ } => ({
+ openView: mockOpenView,
+ closeView: jest.fn(),
+ expandedPanelId: null,
+ }),
+}));
+
const mockMovePanel = jest.fn();
jest.mock('../../hooks/useMovePanelToSection', () => ({
useMovePanelToSection: (): jest.Mock => mockMovePanel,
@@ -264,18 +277,13 @@ describe('usePanelActionItems', () => {
});
});
- it('not-yet-implemented actions (view) fire the placeholder alert with the feature name', () => {
- const alertSpy = jest.spyOn(window, 'alert').mockImplementation(() => {});
+ it('view opens the View modal for the panel', () => {
const { result } = renderHook(() => usePanelActionItems(baseArgs));
-
const view = result.current.items.find(
(i) => 'key' in i && i.key === 'view-panel',
);
(view as { onClick: () => void }).onClick();
-
- expect(alertSpy).toHaveBeenCalledTimes(1);
- expect(alertSpy).toHaveBeenCalledWith('View option clicked');
- alertSpy.mockRestore();
+ expect(mockOpenView).toHaveBeenCalledWith('panel-1');
});
it('create-alert seeds an alert from this panel', () => {
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/usePanelActionItems.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/usePanelActionItems.tsx
index c3c6e6e624..f6fd266067 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/usePanelActionItems.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelActionsMenu/usePanelActionItems.tsx
@@ -30,6 +30,7 @@ import {
type MovePanelArgs,
useMovePanelToSection,
} from '../hooks/useMovePanelToSection';
+import { useViewPanel } from '../hooks/useViewPanel';
import { PANEL_ACTION_META } from './panelActionMeta';
// Stable fallback so renders without layout context don't churn the mutation
@@ -146,6 +147,7 @@ export function usePanelActionItems({
const isEditable = useDashboardStore((s) => s.isEditable);
const openPanelEditor = useOpenPanelEditor();
const createAlert = useCreateAlertFromPanel();
+ const { openView } = useViewPanel();
// Mutations are store-backed (dashboardId/refetch) — the layout tree only
// supplies data (`sections`), so no callbacks are threaded through it.
@@ -178,7 +180,7 @@ export function usePanelActionItems({
key: 'view-panel',
label: 'View',
icon: <Fullscreen size={14} />,
- onClick: (): void => notImplementedYet('View'),
+ onClick: (): void => openView(panelId),
});
}
if (isEditable && canEditWidget && panelCapabilities.edit) {
@@ -263,6 +265,7 @@ export function usePanelActionItems({
panelActions,
sections,
panelId,
+ openView,
openPanelEditor,
createAlert,
movePanel,
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
index a0e09b6d62..3c86be8ab9 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
@@ -35,6 +35,8 @@ interface PanelBodyProps {
searchTerm?: string;
/** Server-side paging handles — only consumed by raw/list renderers. */
pagination?: PanelPagination;
+ /** Close the standalone View modal — only consumed by the time-series/bar graph manager. */
+ onCloseStandaloneView?: () => void;
}
/**
@@ -55,6 +57,7 @@ function PanelBody({
panelMode = PanelMode.DASHBOARD_VIEW,
searchTerm,
pagination,
+ onCloseStandaloneView,
}: PanelBodyProps): JSX.Element {
// A retained response (keepPreviousData) counts as data only if its type matches the current
// request — else a prior panel kind's response (time_series → raw) flashes NoData on switch.
@@ -121,6 +124,7 @@ function PanelBody({
dashboardPreference={dashboardPreference}
searchTerm={searchTerm}
pagination={pagination}
+ onCloseStandaloneView={onCloseStandaloneView}
/>
</div>
);
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.module.scss b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.module.scss
index d61540cf1e..f08da9b838 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.module.scss
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.module.scss
@@ -1,9 +1,17 @@
// Expanded state: a compact input that fits the header row.
.input {
- width: 180px;
+ width: min(100%, 320px);
+ height: 24px;
}
.clear {
--button-height: 18px;
+ --button-width: 18px;
--button-padding: 0;
}
+
+.searchTrigger {
+ --button-width: 24px;
+ --button-height: 24px;
+ --button-padding: 4px;
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.tsx
index be58353ff5..29e63e80b3 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelHeader/PanelHeaderSearch.tsx
@@ -43,6 +43,7 @@ function PanelHeaderSearch({
color="secondary"
size="icon"
onClick={(): void => setExpanded(true)}
+ className={styles.searchTrigger}
data-testid="panel-header-search-trigger"
aria-label="Search"
>
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
new file mode 100644
index 0000000000..4ed457b6a9
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.module.scss
@@ -0,0 +1,63 @@
+@use '../../../../../../styles/scrollbar' as *;
+
+.modal {
+ :global(.ant-modal-body) {
+ padding: 0px;
+ }
+}
+
+// Truncate a long panel name so the header stays on one line; the wrapping tooltip
+// then surfaces the full name on hover.
+.title {
+ display: inline-block;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ vertical-align: bottom;
+}
+
+// Tall, fixed-height column so the renderer's resize observer measures real
+// dimensions — the chart self-sizes to fill whatever space it's given.
+.content {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ height: 78vh;
+ overflow: auto;
+ padding: 12px;
+
+ @include custom-scrollbar;
+}
+
+.queryBuilder {
+ flex: 0 0 auto;
+ overflow: auto;
+ display: flex;
+ flex-direction: column;
+}
+
+.toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 8px;
+ flex: 0 0 auto;
+}
+
+.toolbarTime {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.body {
+ display: flex;
+ flex-direction: column;
+ flex: 1 1 auto;
+ min-height: 480px;
+}
+
+.panelTypeSelector {
+ width: 240px;
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx
new file mode 100644
index 0000000000..e528c20f33
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModal.tsx
@@ -0,0 +1,52 @@
+import { TooltipSimple } from '@signozhq/ui/tooltip';
+import { Typography } from '@signozhq/ui/typography';
+import { Modal } from 'antd';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+
+import ViewPanelModalContent from './ViewPanelModalContent';
+import styles from './ViewPanelModal.module.scss';
+
+interface ViewPanelModalProps {
+ /**
+ * The expanded panel and its id. Absent while the modal is closed — a single
+ * host instance lives at the layout level and only carries a panel when open.
+ */
+ panel?: DashboardtypesPanelDTO;
+ panelId?: string;
+ open: boolean;
+ onClose: () => void;
+}
+
+function ViewPanelModal({
+ panel,
+ panelId,
+ open,
+ onClose,
+}: ViewPanelModalProps): JSX.Element {
+ const name = panel?.spec.display.name ?? '';
+
+ return (
+ <Modal
+ 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>
+ }
+ >
+ {open && panel && panelId && (
+ <ViewPanelModalContent panel={panel} panelId={panelId} onClose={onClose} />
+ )}
+ </Modal>
+ );
+}
+
+export default ViewPanelModal;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx
new file mode 100644
index 0000000000..6949085852
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalContent.tsx
@@ -0,0 +1,125 @@
+import { useMemo } from 'react';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+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';
+import { useOpenPanelEditor } from 'pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor';
+
+import { usePanelInteractions } from '../hooks/usePanelInteractions';
+import ViewPanelModalHeader from './ViewPanelModalHeader';
+import { useViewPanelMode } from './useViewPanelMode';
+import { useViewPanelTimeWindow } from './useViewPanelTimeWindow';
+import styles from './ViewPanelModal.module.scss';
+
+interface ViewPanelModalContentProps {
+ panel: DashboardtypesPanelDTO;
+ panelId: string;
+ /** Close the modal — wired to the graph manager's Save/Cancel. */
+ onClose: () => void;
+}
+
+/**
+ * Body of the View modal: a compact drilldown editor. It renders an editable draft of
+ * the panel (preview) over a per-view time window plus the shared query builder, so the
+ * user can tweak + Stage & Run without touching the dashboard. Edits are temporary.
+ */
+function ViewPanelModalContent({
+ panel,
+ panelId,
+ onClose,
+}: ViewPanelModalContentProps): JSX.Element | null {
+ const {
+ timeOverride,
+ selectedInterval,
+ onTimeChange,
+ refreshWindow,
+ onDragSelect,
+ } = useViewPanelTimeWindow();
+
+ const {
+ draft,
+ panelDefinition,
+ signal,
+ queryType,
+ query,
+ runQuery,
+ onChangePanelKind,
+ resetQuery,
+ buildSaveSpec,
+ } = useViewPanelMode({ panel, panelId, time: timeOverride });
+ const { data, isFetching, error, refetch, cancelQuery, pagination } = query;
+
+ // Drag-to-zoom stays inside the modal; opt the chart out of the dashboard's
+ // cursor-sync group so a drag here can't replay onto the grid panels.
+ const { dashboardPreference } = usePanelInteractions();
+ const isolatedPreference = useMemo<DashboardPreference>(
+ () => ({ ...dashboardPreference, syncMode: DashboardCursorSync.None }),
+ [dashboardPreference],
+ );
+ const openPanelEditor = useOpenPanelEditor();
+
+ // The View action only appears for registered kinds, so this is defensive.
+ if (!panelDefinition) {
+ return null;
+ }
+
+ return (
+ <div className={styles.content} data-testid="view-panel-modal-content">
+ <ViewPanelModalHeader
+ selectedInterval={selectedInterval}
+ startMs={timeOverride.startMs}
+ endMs={timeOverride.endMs}
+ onTimeChange={onTimeChange}
+ isFetching={isFetching}
+ onRefresh={(): void => {
+ // Relative windows re-anchor to now (new key → refetch); a fixed
+ // custom window just re-runs the same query.
+ if (selectedInterval === 'custom') {
+ refetch();
+ } else {
+ refreshWindow();
+ }
+ }}
+ onSwitchToEdit={(): void =>
+ // Carry the drilldown edits so the editor opens on them, not the saved panel.
+ openPanelEditor(panelId, { editSpec: buildSaveSpec(draft.spec) })
+ }
+ panelKind={draft.spec.plugin.kind}
+ queryType={queryType}
+ signal={signal}
+ onChangePanelKind={onChangePanelKind}
+ onResetQuery={resetQuery}
+ />
+ <div className={styles.queryBuilder}>
+ <PanelEditorQueryBuilder
+ panelKind={draft.spec.plugin.kind}
+ signal={signal}
+ isLoadingQueries={isFetching}
+ onStageRunQuery={runQuery}
+ onCancelQuery={cancelQuery}
+ />
+ </div>
+ <div className={styles.body}>
+ <PreviewPane
+ panelId={panelId}
+ panel={draft}
+ panelDefinition={panelDefinition}
+ data={data}
+ isFetching={isFetching}
+ error={error}
+ refetch={refetch}
+ onDragSelect={onDragSelect}
+ pagination={pagination}
+ panelMode={PanelMode.STANDALONE_VIEW}
+ dashboardPreference={isolatedPreference}
+ onCloseStandaloneView={onClose}
+ hideHeader
+ />
+ </div>
+ </div>
+ );
+}
+
+export default ViewPanelModalContent;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx
new file mode 100644
index 0000000000..5deefec1cf
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx
@@ -0,0 +1,123 @@
+import { PenLine, RotateCw } from '@signozhq/icons';
+import { Button } from '@signozhq/ui/button';
+import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
+import cx from 'classnames';
+import DateTimeSelectionV2 from 'container/TopNav/DateTimeSelectionV2';
+import type {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/types';
+import { usePanelTypeSelectItems } from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/usePanelTypeSelectItems';
+import ConfigSelect from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSelect/ConfigSelect';
+import type { PanelKind } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import type { EQueryType } from 'types/common/dashboard';
+
+import styles from './ViewPanelModal.module.scss';
+
+interface ViewPanelModalHeaderProps {
+ selectedInterval: Time | CustomTimeType;
+ /** Current window bounds (epoch ms) — seed the picker's modal display. */
+ startMs: number;
+ endMs: number;
+ onTimeChange: (
+ interval: Time | CustomTimeType,
+ range?: [number, number],
+ ) => void;
+ /** Any query in flight — spins the refresh icon and disables it. */
+ isFetching: boolean;
+ onRefresh: () => void;
+ onSwitchToEdit: () => void;
+ /** Draft's current kind (selected value of the panel-type selector). */
+ panelKind: PanelKind;
+ /**
+ * The active query-builder tab (Query Builder / PromQL / ClickHouse). The type
+ * selector greys out kinds that can't be authored in it — e.g. List is
+ * Query-Builder-only, so PromQL/ClickHouse disable it.
+ */
+ queryType: EQueryType;
+ /** Current builder datasource — greys out kinds that don't support it (e.g. List needs logs/traces, not metrics). */
+ signal: TelemetrytypesSignalDTO;
+ onChangePanelKind: (kind: PanelKind) => void;
+ /** Restore the saved query + kind (drilldown reset). */
+ onResetQuery: () => void;
+}
+
+/**
+ * Toolbar for the View modal: reset the drilldown, open the full editor, switch the
+ * visualization kind, pick a per-view time window (isolated from the dashboard), and
+ * refresh. Mirrors V1's FullView header controls.
+ */
+function ViewPanelModalHeader({
+ selectedInterval,
+ startMs,
+ endMs,
+ onTimeChange,
+ isFetching,
+ onRefresh,
+ onSwitchToEdit,
+ panelKind,
+ queryType,
+ signal,
+ onChangePanelKind,
+ onResetQuery,
+}: ViewPanelModalHeaderProps): JSX.Element {
+ // Same capabilities-guarded options as the editor's PanelTypeSwitcher, so the two
+ // selectors disable the same kinds (e.g. List under PromQL, metrics-only kinds).
+ const panelTypeItems = usePanelTypeSelectItems({ queryType, signal });
+
+ return (
+ <div className={styles.toolbar}>
+ <div className={styles.panelTypeSelector}>
+ <ConfigSelect<PanelKind>
+ testId="view-panel-type-selector"
+ value={panelKind}
+ items={panelTypeItems}
+ onChange={onChangePanelKind}
+ />
+ </div>
+ <Button
+ variant="outlined"
+ color="secondary"
+ prefix={<PenLine />}
+ onClick={onSwitchToEdit}
+ data-testid="view-panel-switch-to-edit"
+ >
+ Switch to Edit Mode
+ </Button>
+ <Button
+ variant="link"
+ color="primary"
+ onClick={onResetQuery}
+ data-testid="view-panel-reset-query"
+ >
+ Reset Query
+ </Button>
+ <div className={styles.toolbarTime}>
+ <DateTimeSelectionV2
+ showAutoRefresh={false}
+ showRefreshText={false}
+ hideShareModal
+ isModalTimeSelection
+ disableUrlSync
+ onTimeChange={onTimeChange}
+ modalSelectedInterval={selectedInterval as Time}
+ modalInitialStartTime={startMs}
+ modalInitialEndTime={endMs}
+ />
+ <Button
+ size="icon"
+ variant="solid"
+ color="primary"
+ onClick={onRefresh}
+ disabled={isFetching}
+ aria-label="Refresh"
+ data-testid="view-panel-refresh"
+ >
+ <RotateCw className={cx({ 'animate-spin': isFetching })} />
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+export default ViewPanelModalHeader;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts
new file mode 100644
index 0000000000..a99360e7ab
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelMode.ts
@@ -0,0 +1,139 @@
+import { useCallback, useMemo } from 'react';
+import type {
+ DashboardtypesPanelDTO,
+ DashboardtypesPanelSpecDTO,
+ TelemetrytypesSignalDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import { QueryParams } from 'constants/query';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+import useUrlQuery from 'hooks/useUrlQuery';
+import { usePanelEditSession } from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/hooks/usePanelEditSession';
+import type { RenderablePanelDefinition } from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelDefinition';
+import {
+ PANEL_KIND_TO_PANEL_TYPE,
+ type PanelKind,
+} from 'pages/DashboardPageV2/DashboardContainer/Panels/types/panelKind';
+import { resolveSignal } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/getBuilderQueries';
+import { buildViewPanelSpec } from 'pages/DashboardPageV2/DashboardContainer/Panels/utils/drilldown/buildViewPanelSpec';
+import { fromPerses } from 'pages/DashboardPageV2/DashboardContainer/queryV5/persesQueryAdapters';
+import {
+ type PanelQueryTimeOverride,
+ type UsePanelQueryResult,
+} from 'pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery';
+import type { EQueryType } from 'types/common/dashboard';
+
+interface UseViewPanelModeArgs {
+ panel: DashboardtypesPanelDTO;
+ panelId: string;
+ /** Per-view time window (epoch ms); isolates the preview from the dashboard. */
+ time: PanelQueryTimeOverride;
+}
+
+export interface UseViewPanelModeReturn {
+ /** Local editable copy of the panel — the preview renders this, not the saved panel. */
+ draft: DashboardtypesPanelDTO;
+ /** Resolved renderer for the draft's current kind (registry always resolves a kind). */
+ panelDefinition: RenderablePanelDefinition;
+ /**
+ * Builder datasource driving the query builder and the panel-type selector's
+ * disabled rule. Resolved from the query, falling back to the kind's default
+ * signal, so it's always defined.
+ */
+ signal: TelemetrytypesSignalDTO;
+ /** Active query type (selected builder tab) — drives the panel-type selector's disabled rule. */
+ queryType: EQueryType;
+ /** Query result for the draft over the per-view window. */
+ query: UsePanelQueryResult;
+ /** Stage & run the live builder query into the draft (drilldown; not persisted). */
+ runQuery: () => void;
+ /** Switch the draft's visualization kind (temporary; reversible per session). */
+ onChangePanelKind: (kind: PanelKind) => void;
+ /** Restore the query the view opened with, discarding in-modal edits. */
+ resetQuery: () => void;
+ /** Bake the live (possibly un-run) query into a spec — used to hand edits to the full editor. */
+ buildSaveSpec: (
+ spec: DashboardtypesPanelSpecDTO,
+ ) => DashboardtypesPanelSpecDTO;
+}
+
+/**
+ * The View modal's compact drilldown editor on the shared `usePanelEditSession`. Edits are
+ * temporary — they live in the builder/URL + draft, never the dashboard (V1 parity).
+ */
+export function useViewPanelMode({
+ panel,
+ panelId,
+ time,
+}: UseViewPanelModeArgs): UseViewPanelModeReturn {
+ const { currentQuery, redirectWithQueryBuilderData } = useQueryBuilder();
+
+ // Seed the draft from the URL (`compositeQuery` + `graphType`) when present, else the saved
+ // panel — mount-only, so a refresh re-seeds from the URL and in-modal edits survive (V1 parity).
+ const urlQuery = useGetCompositeQueryParam();
+ const urlGraphType = useUrlQuery().get(
+ QueryParams.graphType,
+ ) as PANEL_TYPES | null;
+ const initialPanel = useMemo<DashboardtypesPanelDTO>(
+ () =>
+ urlQuery
+ ? {
+ ...panel,
+ spec: buildViewPanelSpec({
+ spec: panel.spec,
+ query: urlQuery,
+ panelType:
+ urlGraphType ?? PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind],
+ }),
+ }
+ : panel,
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only seed from the URL
+ [],
+ );
+
+ const {
+ draft,
+ panelDefinition,
+ defaultSignal,
+ query,
+ runQuery,
+ onChangePanelKind,
+ buildSaveSpec,
+ reset,
+ } = usePanelEditSession({ panel: initialPanel, panelId, time });
+
+ // The query the view opened with, captured once — the Reset target.
+ const savedQuery = useMemo(
+ () =>
+ fromPerses(
+ panel.spec.queries,
+ PANEL_KIND_TO_PANEL_TYPE[panel.spec.plugin.kind],
+ ),
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only snapshot
+ [],
+ );
+
+ const resetQuery = useCallback((): void => {
+ reset();
+ redirectWithQueryBuilderData(savedQuery);
+ }, [reset, redirectWithQueryBuilderData, savedQuery]);
+
+ // Current builder datasource — resolved the same way as the full editor's
+ // ConfigPane so the two selectors stay in sync, then defaulted to the kind's first
+ // signal (PromQL/ClickHouse carry none) so the query builder always has one.
+ const signal =
+ resolveSignal(draft.spec.queries, defaultSignal) ?? defaultSignal;
+
+ return {
+ draft,
+ panelDefinition,
+ signal,
+ queryType: currentQuery.queryType,
+ query,
+ runQuery,
+ onChangePanelKind,
+ resetQuery,
+ buildSaveSpec,
+ };
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelTimeWindow.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelTimeWindow.ts
new file mode 100644
index 0000000000..2b9e6c9e3c
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/useViewPanelTimeWindow.ts
@@ -0,0 +1,108 @@
+import { useCallback, useMemo, useState } from 'react';
+// eslint-disable-next-line no-restricted-imports -- global time still lives in redux
+import { useSelector } from 'react-redux';
+import type {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/types';
+import GetMinMax from 'lib/getMinMax';
+import type { PanelQueryTimeOverride } from 'pages/DashboardPageV2/DashboardContainer/hooks/usePanelQuery';
+import { AppState } from 'store/reducers';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+const NS_PER_MS = 1e6;
+
+export interface ViewPanelTimeWindow {
+ /** Absolute window (epoch ms) to pass to usePanelQuery as a time override. */
+ timeOverride: PanelQueryTimeOverride;
+ /** Interval shown in the picker — a relative `Time` or `'custom'`. */
+ selectedInterval: Time | CustomTimeType;
+ /** Apply a selection from DateTimeSelectionV2 (modal mode). */
+ onTimeChange: (
+ interval: Time | CustomTimeType,
+ range?: [number, number],
+ ) => void;
+ /** Re-anchor a relative window to "now" (manual refresh); no-op for custom. */
+ refreshWindow: () => void;
+ /** Drag-to-zoom on a time chart → set a custom window locally (not the dashboard's). */
+ onDragSelect: (start: number, end: number) => void;
+}
+
+/**
+ * Per-view time window for the panel View modal, isolated from the dashboard's
+ * global time (V1 parity: the modal's time selector doesn't move the grid). Seeded
+ * once from the current global window, then owned locally. Relative intervals
+ * resolve to an absolute ms window via the same `GetMinMax` the app-wide picker uses.
+ */
+export function useViewPanelTimeWindow(): ViewPanelTimeWindow {
+ const { selectedTime, minTime, maxTime } = useSelector<
+ AppState,
+ GlobalReducer
+ >((state) => state.globalTime);
+
+ const [selectedInterval, setSelectedInterval] = useState<
+ Time | CustomTimeType
+ >(selectedTime as Time);
+ const [timeOverride, setTimeOverride] = useState<PanelQueryTimeOverride>(
+ () => ({
+ startMs: Math.floor(minTime / NS_PER_MS),
+ endMs: Math.floor(maxTime / NS_PER_MS),
+ }),
+ );
+
+ const onTimeChange = useCallback(
+ (interval: Time | CustomTimeType, range?: [number, number]): void => {
+ setSelectedInterval(interval);
+ // Absolute range comes through directly (already epoch ms).
+ if (interval === 'custom' && range) {
+ setTimeOverride({
+ startMs: Math.floor(range[0]),
+ endMs: Math.floor(range[1]),
+ });
+ return;
+ }
+ // GetMinMax returns nanoseconds — convert to the ms window we work in.
+ const { minTime: startNs, maxTime: endNs } = GetMinMax(interval);
+ setTimeOverride({
+ startMs: Math.floor(startNs / NS_PER_MS),
+ endMs: Math.floor(endNs / NS_PER_MS),
+ });
+ },
+ [],
+ );
+
+ const refreshWindow = useCallback((): void => {
+ // A custom window is fixed; only relative intervals re-anchor to now.
+ if (selectedInterval === 'custom') {
+ return;
+ }
+ const { minTime: startNs, maxTime: endNs } = GetMinMax(selectedInterval);
+ setTimeOverride({
+ startMs: Math.floor(startNs / NS_PER_MS),
+ endMs: Math.floor(endNs / NS_PER_MS),
+ });
+ }, [selectedInterval]);
+
+ const onDragSelect = useCallback((start: number, end: number): void => {
+ // Drag values are already epoch ms (same as the global custom range).
+ const startMs = Math.floor(start);
+ const endMs = Math.floor(end);
+ // Ignore a click / zero-width or inverted selection.
+ if (startMs >= endMs) {
+ return;
+ }
+ setSelectedInterval('custom');
+ setTimeOverride({ startMs, endMs });
+ }, []);
+
+ return useMemo(
+ () => ({
+ timeOverride,
+ selectedInterval,
+ onTimeChange,
+ refreshWindow,
+ onDragSelect,
+ }),
+ [timeOverride, selectedInterval, onTimeChange, refreshWindow, onDragSelect],
+ );
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/ViewPanelModal.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/ViewPanelModal.test.tsx
new file mode 100644
index 0000000000..e41b35d849
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/ViewPanelModal.test.tsx
@@ -0,0 +1,177 @@
+import { TooltipProvider } from '@signozhq/ui/tooltip';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import type { ReactElement } from 'react';
+import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+import ViewPanelModal from '../ViewPanelModal/ViewPanelModal';
+
+// The preview reuses the edit page's PreviewPane (chart + header + heavy render
+// path); stub it (capturing props) so this suite asserts the modal shell + what it
+// threads down, not the preview internals (PreviewPane/PanelHeader own those).
+const mockPreviewPaneRender = jest.fn();
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/PanelEditor/PreviewPane/PreviewPane',
+ () =>
+ function MockPreviewPane(props: Record<string, unknown>): ReactElement {
+ mockPreviewPaneRender(props);
+ return <div data-testid="preview-pane" />;
+ },
+);
+
+// Isolate from the draft/query-builder plumbing (its own suite covers it).
+jest.mock('../ViewPanelModal/useViewPanelMode', () => ({
+ useViewPanelMode: (args: {
+ panel: { spec: { plugin: { kind: string } } };
+ }): unknown => {
+ const { kind } = args.panel.spec.plugin;
+ return {
+ draft: args.panel,
+ panelDefinition: {
+ kind,
+ actions: { search: kind === 'signoz/ListPanel' },
+ Renderer: (): null => null,
+ },
+ query: {
+ data: { response: undefined, requestPayload: undefined, legendMap: {} },
+ isLoading: false,
+ isFetching: false,
+ error: null,
+ refetch: jest.fn(),
+ cancelQuery: jest.fn(),
+ pagination: undefined,
+ },
+ runQuery: jest.fn(),
+ onChangePanelKind: jest.fn(),
+ resetQuery: jest.fn(),
+ signal: 'logs',
+ buildSaveSpec: (spec: unknown): unknown => spec,
+ };
+ },
+}));
+
+// The View modal reuses the edit page's query builder, which reads the global
+// QueryBuilder context and pulls in the ClickHouse/PromQL editors; stub it here.
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder',
+ () =>
+ function MockPanelEditorQueryBuilder(): ReactElement {
+ return <div data-testid="panel-editor-v2-query-builder" />;
+ },
+);
+
+jest.mock('../hooks/usePanelInteractions', () => ({
+ usePanelInteractions: (): unknown => ({
+ onDragSelect: jest.fn(),
+ dashboardPreference: { syncMode: 0 },
+ }),
+}));
+
+// The header mounts DateTimeSelectionV2 (redux + router + heavy deps); stub it so
+// this suite asserts the modal body, not the toolbar internals.
+jest.mock(
+ '../ViewPanelModal/ViewPanelModalHeader',
+ () =>
+ function MockViewPanelModalHeader(): ReactElement {
+ return <div data-testid="view-panel-header" />;
+ },
+);
+
+jest.mock('../ViewPanelModal/useViewPanelTimeWindow', () => ({
+ useViewPanelTimeWindow: (): unknown => ({
+ timeOverride: { startMs: 0, endMs: 0 },
+ selectedInterval: '5m',
+ onTimeChange: jest.fn(),
+ refreshWindow: jest.fn(),
+ onDragSelect: jest.fn(),
+ }),
+}));
+
+const mockOpenEditor = jest.fn();
+jest.mock(
+ 'pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor',
+ () => ({
+ useOpenPanelEditor: (): jest.Mock => mockOpenEditor,
+ }),
+);
+
+const renderWithProvider = (ui: ReactElement): ReturnType<typeof render> =>
+ render(<TooltipProvider>{ui}</TooltipProvider>);
+
+function makePanel(kind: string, name = 'My panel'): DashboardtypesPanelDTO {
+ return {
+ kind: 'Panel',
+ spec: {
+ display: { name },
+ plugin: { kind, spec: {} },
+ queries: [],
+ },
+ } as unknown as DashboardtypesPanelDTO;
+}
+
+describe('ViewPanelModal', () => {
+ it('renders nothing until opened', () => {
+ renderWithProvider(
+ <ViewPanelModal
+ panel={makePanel('signoz/TimeSeriesPanel')}
+ panelId="p1"
+ open={false}
+ onClose={jest.fn()}
+ />,
+ );
+ expect(
+ screen.queryByTestId('view-panel-modal-content'),
+ ).not.toBeInTheDocument();
+ });
+
+ it('renders the header, query builder, and preview when open', () => {
+ renderWithProvider(
+ <ViewPanelModal
+ panel={makePanel('signoz/TimeSeriesPanel', 'CPU usage')}
+ panelId="p1"
+ open
+ onClose={jest.fn()}
+ />,
+ );
+ expect(screen.getByTestId('view-panel-modal-content')).toBeInTheDocument();
+ expect(screen.getByTestId('view-panel-header')).toBeInTheDocument();
+ expect(
+ screen.getByTestId('panel-editor-v2-query-builder'),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId('preview-pane')).toBeInTheDocument();
+ });
+
+ it('invokes onClose when the modal is dismissed', async () => {
+ const user = userEvent.setup();
+ const onClose = jest.fn();
+ renderWithProvider(
+ <ViewPanelModal
+ panel={makePanel('signoz/TimeSeriesPanel')}
+ panelId="p1"
+ open
+ onClose={onClose}
+ />,
+ );
+ await user.click(screen.getByLabelText('Close'));
+ expect(onClose).toHaveBeenCalled();
+ });
+
+ // Charts share one global cursor-sync key and uPlot replays drag across the
+ // group; the modal must opt out so a drag here can't move the dashboard's time.
+ it('opts the chart out of the dashboard cursor-sync group', () => {
+ mockPreviewPaneRender.mockClear();
+ renderWithProvider(
+ <ViewPanelModal
+ panel={makePanel('signoz/TimeSeriesPanel')}
+ panelId="p1"
+ open
+ onClose={jest.fn()}
+ />,
+ );
+ const props = mockPreviewPaneRender.mock.calls.at(-1)?.[0] as {
+ dashboardPreference?: { syncMode?: unknown };
+ };
+ expect(props.dashboardPreference?.syncMode).toBe(DashboardCursorSync.None);
+ });
+});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useViewPanelTimeWindow.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useViewPanelTimeWindow.test.ts
new file mode 100644
index 0000000000..2ffe707d87
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/__tests__/useViewPanelTimeWindow.test.ts
@@ -0,0 +1,93 @@
+import { act, renderHook } from '@testing-library/react';
+import GetMinMax from 'lib/getMinMax';
+
+import { useViewPanelTimeWindow } from '../ViewPanelModal/useViewPanelTimeWindow';
+
+const NS_PER_MS = 1e6;
+
+// Global time is stored in nanoseconds; the hook must surface milliseconds.
+const mockState = {
+ globalTime: {
+ selectedTime: '6h',
+ minTime: 6_000_000 * NS_PER_MS,
+ maxTime: 7_000_000 * NS_PER_MS,
+ },
+};
+
+jest.mock('react-redux', () => ({
+ useSelector: (selector: (s: unknown) => unknown): unknown =>
+ selector(mockState),
+}));
+
+jest.mock('lib/getMinMax', () => ({
+ __esModule: true,
+ default: jest.fn(),
+}));
+
+const mockGetMinMax = GetMinMax as unknown as jest.Mock;
+
+describe('useViewPanelTimeWindow', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('seeds the window from global time, converting ns → ms', () => {
+ const { result } = renderHook(() => useViewPanelTimeWindow());
+
+ expect(result.current.timeOverride).toStrictEqual({
+ startMs: mockState.globalTime.minTime / NS_PER_MS,
+ endMs: mockState.globalTime.maxTime / NS_PER_MS,
+ });
+ expect(result.current.selectedInterval).toBe('6h');
+ });
+
+ it('converts GetMinMax (ns) to ms on a relative selection', () => {
+ mockGetMinMax.mockReturnValue({
+ minTime: 1_700_000_000_000 * NS_PER_MS,
+ maxTime: 1_700_000_300_000 * NS_PER_MS,
+ });
+ const { result } = renderHook(() => useViewPanelTimeWindow());
+
+ act(() => result.current.onTimeChange('5m'));
+
+ expect(result.current.selectedInterval).toBe('5m');
+ expect(result.current.timeOverride).toStrictEqual({
+ startMs: 1_700_000_000_000,
+ endMs: 1_700_000_300_000,
+ });
+ });
+
+ it('uses an absolute custom range as-is (already ms)', () => {
+ const { result } = renderHook(() => useViewPanelTimeWindow());
+
+ act(() => result.current.onTimeChange('custom', [111, 222]));
+
+ expect(mockGetMinMax).not.toHaveBeenCalled();
+ expect(result.current.timeOverride).toStrictEqual({
+ startMs: 111,
+ endMs: 222,
+ });
+ });
+
+ it('sets a custom window from a drag selection (modal-local, ms)', () => {
+ const { result } = renderHook(() => useViewPanelTimeWindow());
+
+ act(() => result.current.onDragSelect(1000, 5000));
+
+ expect(result.current.selectedInterval).toBe('custom');
+ expect(result.current.timeOverride).toStrictEqual({
+ startMs: 1000,
+ endMs: 5000,
+ });
+ });
+
+ it('ignores a zero-width or inverted drag selection', () => {
+ const { result } = renderHook(() => useViewPanelTimeWindow());
+ const initial = result.current.timeOverride;
+
+ act(() => result.current.onDragSelect(5000, 5000));
+ act(() => result.current.onDragSelect(9000, 1000));
+
+ expect(result.current.timeOverride).toStrictEqual(initial);
+ });
+});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useViewPanel.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useViewPanel.ts
new file mode 100644
index 0000000000..4b0db35d2e
--- /dev/null
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/hooks/useViewPanel.ts
@@ -0,0 +1,54 @@
+import { useCallback } from 'react';
+import { useLocation } from 'react-router-dom';
+import { QueryParams } from 'constants/query';
+import { useSafeNavigate } from 'hooks/useSafeNavigate';
+import useUrlQuery from 'hooks/useUrlQuery';
+
+export interface UseViewPanelApi {
+ /** Panel id currently expanded in the View modal; null when none is open. */
+ expandedPanelId: string | null;
+ /** Open the View modal on the saved panel (clears any leftover in-modal query/kind). */
+ openView: (panelId: string) => void;
+ /** Close the View modal by clearing the URL param. */
+ closeView: () => void;
+}
+
+/**
+ * Drives the panel View modal off the `expandedWidgetId` URL param (V1 parity):
+ * the open state is shareable, survives refresh, and the browser back-button
+ * closes it. Reuses V1's param key so a deep-linked V1 URL maps cleanly.
+ */
+export function useViewPanel(): UseViewPanelApi {
+ const { safeNavigate } = useSafeNavigate();
+ const { pathname } = useLocation();
+ const urlQuery = useUrlQuery();
+
+ const expandedPanelId = urlQuery.get(QueryParams.expandedWidgetId);
+
+ const openView = useCallback(
+ (panelId: string): void => {
+ // Copy before mutating: useUrlQuery returns a memoized instance.
+ const next = new URLSearchParams(urlQuery);
+ next.set(QueryParams.expandedWidgetId, panelId);
+ // Drop any leftover in-modal query/kind so a plain View opens on the saved
+ // panel, not a stale URL query the modal would otherwise hydrate from.
+ next.delete(QueryParams.compositeQuery);
+ next.delete(QueryParams.graphType);
+ safeNavigate(`${pathname}?${next.toString()}`);
+ },
+ [pathname, safeNavigate, urlQuery],
+ );
+
+ const closeView = useCallback((): void => {
+ const next = new URLSearchParams(urlQuery);
+ next.delete(QueryParams.expandedWidgetId);
+ // Drop the drilldown editor's URL state so it doesn't leak to the dashboard
+ // (the in-modal query builder writes compositeQuery, V1 parity).
+ next.delete(QueryParams.compositeQuery);
+ next.delete(QueryParams.graphType);
+ const search = next.toString();
+ safeNavigate(search ? `${pathname}?${search}` : pathname);
+ }, [pathname, safeNavigate, urlQuery]);
+
+ return { expandedPanelId, openView, closeView };
+}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/index.tsx
index 9f13ab133a..24e85113fc 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/index.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/index.tsx
@@ -8,6 +8,8 @@ import type {
import { useDashboardStore } from '../store/useDashboardStore';
import { layoutsToSections } from '../utils';
import DashboardEmptyState from './DashboardEmptyState/DashboardEmptyState';
+import { useViewPanel } from './Panel/hooks/useViewPanel';
+import ViewPanelModal from './Panel/ViewPanelModal/ViewPanelModal';
import Section from './Section/Section/Section';
import SectionList from './Section/SectionList';
import styles from './PanelsAndSectionsLayout.module.scss';
@@ -26,6 +28,12 @@ function PanelsAndSectionsLayout({
}: PanelsAndSectionsLayoutProps): JSX.Element {
const isEditable = useDashboardStore((s) => s.isEditable);
+ // Single View-modal host for the whole dashboard, driven by the URL
+ // (`expandedWidgetId`). One mounted modal beats one-per-panel: no N location
+ // subscriptions, and the expanded panel is looked up by id from the map.
+ const { expandedPanelId, closeView } = useViewPanel();
+ const expandedPanel = expandedPanelId ? panels[expandedPanelId] : undefined;
+
const sections = useMemo(
() => layoutsToSections(layouts, panels),
[layouts, panels],
@@ -56,7 +64,17 @@ function PanelsAndSectionsLayout({
));
};
- return <div className={styles.body}>{renderContent()}</div>;
+ return (
+ <div className={styles.body}>
+ {renderContent()}
+ <ViewPanelModal
+ open={!!expandedPanel}
+ panel={expandedPanel}
+ panelId={expandedPanelId ?? undefined}
+ onClose={closeView}
+ />
+ </div>
+ );
}
export default PanelsAndSectionsLayout;
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor.ts
index 1e591d9618..d62657d5e8 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useOpenPanelEditor.ts
@@ -3,21 +3,28 @@ import { generatePath } from 'react-router-dom';
import ROUTES from 'constants/routes';
import { useSafeNavigate } from 'hooks/useSafeNavigate';
+import type { PanelEditorHandoffState } from '../PanelEditor/panelEditorHandoff';
import { useDashboardStore } from '../store/useDashboardStore';
/**
* Returns a callback that opens the V2 panel editor by navigating to its full-page route
* (`/dashboard/:dashboardId/panel/:panelId`). The dashboard id comes from the store, so any
- * caller can open the editor with just the panel id.
+ * caller can open the editor with just the panel id. The optional `handoffState` is passed as
+ * router location state — the View modal uses it to hand its drilldown-edited spec off to the
+ * editor (view → edit) so the editor opens on those edits rather than the saved panel.
*/
-export function useOpenPanelEditor(): (panelId: string) => void {
+export function useOpenPanelEditor(): (
+ panelId: string,
+ handoffState?: PanelEditorHandoffState,
+) => void {
const { safeNavigate } = useSafeNavigate();
const dashboardId = useDashboardStore((s) => s.dashboardId);
return useCallback(
- (panelId: string): void => {
+ (panelId: string, handoffState?: PanelEditorHandoffState): void => {
safeNavigate(
generatePath(ROUTES.DASHBOARD_PANEL_EDITOR, { dashboardId, panelId }),
+ handoffState ? { state: handoffState } : undefined,
);
},
[safeNavigate, dashboardId],
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/index.tsx
index bfdbb97f3e..45ad257cc0 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/index.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/index.tsx
@@ -22,9 +22,13 @@ function DashboardContainer({
dashboard,
refetch,
}: DashboardContainerProps): JSX.Element {
+ const spec = dashboard.spec;
+ const image = dashboard.image || Base64Icons[0];
+ const name = spec.display.name;
+
useEffect(() => {
- document.title = dashboard.name;
- }, [dashboard.name]);
+ document.title = name;
+ }, [name]);
const fullScreenHandle = useFullScreenHandle();
@@ -55,10 +59,6 @@ function DashboardContainer({
// the store, so each panel's query substitutes the bar's selected values.
useResolvedVariables(dashboard);
- const spec = dashboard.spec;
- const image = dashboard.image || Base64Icons[0];
- const name = spec.display.name;
-
return (
<FullScreen handle={fullScreenHandle}>
<div className={styles.container}>
diff --git a/frontend/src/pages/DashboardPageV2/PanelEditorPage/PanelEditorPage.tsx b/frontend/src/pages/DashboardPageV2/PanelEditorPage/PanelEditorPage.tsx
index 813887ca3d..1fc16bf5b6 100644
--- a/frontend/src/pages/DashboardPageV2/PanelEditorPage/PanelEditorPage.tsx
+++ b/frontend/src/pages/DashboardPageV2/PanelEditorPage/PanelEditorPage.tsx
@@ -16,6 +16,7 @@ import { getPanelDefinition } from '../DashboardContainer/Panels/registry';
import { buildPluginSpec } from '../DashboardContainer/Panels/utils/buildPluginSpec';
import { buildDefaultQueries } from '../DashboardContainer/Panels/utils/buildDefaultQueries';
import PanelEditorContainer from '../DashboardContainer/PanelEditor';
+import type { PanelEditorHandoffState } from '../DashboardContainer/PanelEditor/panelEditorHandoff';
import {
parseNewPanelKind,
parseNewPanelLayoutIndex,
@@ -32,9 +33,13 @@ function PanelEditorPage(): JSX.Element {
dashboardId: string;
panelId: string;
}>();
- const { search } = useLocation();
+ const { search, state } = useLocation();
const { safeNavigate } = useSafeNavigate();
+ // Edits handed off from the View modal's drilldown — open the editor on these
+ // instead of the saved panel. Lost on refresh/new-tab, which falls back to saved.
+ const handoffSpec = (state as PanelEditorHandoffState | null)?.editSpec;
+
const { data, isLoading, isError, error } = useGetDashboardV2({
id: dashboardId,
});
@@ -44,17 +49,20 @@ function PanelEditorPage(): JSX.Element {
// kind rather than looking one up. Persisted (with a real id) only on save.
const newKind = parseNewPanelKind(panelId, search);
const existingPanel = dashboard?.spec.panels[panelId];
- const panel = useMemo(
- () =>
- newKind
- ? createDefaultPanel(
- newKind,
- buildPluginSpec(getPanelDefinition(newKind).sections),
- buildDefaultQueries(newKind),
- )
- : existingPanel,
- [newKind, existingPanel],
- );
+ const panel = useMemo(() => {
+ if (newKind) {
+ return createDefaultPanel(
+ newKind,
+ buildPluginSpec(getPanelDefinition(newKind).sections),
+ buildDefaultQueries(newKind),
+ );
+ }
+ if (!existingPanel) {
+ return undefined;
+ }
+ // Open on the modal's drilldown edits when handed off; else the saved panel.
+ return handoffSpec ? { ...existingPanel, spec: handoffSpec } : existingPanel;
+ }, [newKind, existingPanel, handoffSpec]);
// Target section for a newly-created panel (set by the "Add panel" trigger).
const layoutIndex = parseNewPanelLayoutIndex(search);