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.

chore: add sql migration for dashboards (#12249)

Naman Verma41c66f2634c0
diff --git a/cmd/metastore.go b/cmd/metastore.go
index 6fd145c0be..35a98aad89 100644
--- a/cmd/metastore.go
+++ b/cmd/metastore.go
@@ -8,6 +8,8 @@ import (
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/instrumentation"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
+ "github.com/SigNoz/signoz/pkg/modules/tag/impltag"
"github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/sqlmigration"
"github.com/SigNoz/signoz/pkg/sqlmigrator"
@@ -145,7 +147,7 @@ func newSyncMigrator(ctx context.Context, config signoz.Config, sqlstoreProvider
return nil, err
}
- sqlmigrations, err := sqlmigration.New(ctx, providerSettings, config.SQLMigration, signoz.NewSQLMigrationProviderFactories(sqlstore, sqlschema, telemetrystore, providerSettings))
+ sqlmigrations, err := sqlmigration.New(ctx, providerSettings, config.SQLMigration, signoz.NewSQLMigrationProviderFactories(sqlstore, sqlschema, telemetrystore, providerSettings, impldashboard.NewStore(sqlstore), impltag.NewModule(impltag.NewStore(sqlstore))))
if err != nil {
return nil, err
}
diff --git a/ee/query-service/app/api/featureFlags.go b/ee/query-service/app/api/featureFlags.go
index 969ceff9a0..7eaba405d7 100644
--- a/ee/query-service/app/api/featureFlags.go
+++ b/ee/query-service/app/api/featureFlags.go
@@ -89,15 +89,6 @@ func (ah *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) {
Route: "",
})
- useDashboardV2 := ah.Signoz.Flagger.BooleanOrEmpty(ctx, flagger.FeatureUseDashboardV2, evalCtx)
- featureSet = append(featureSet, &licensetypes.Feature{
- Name: valuer.NewString(flagger.FeatureUseDashboardV2.String()),
- Active: useDashboardV2,
- Usage: 0,
- UsageLimit: -1,
- Route: "",
- })
-
aiObservability := ah.Signoz.Flagger.BooleanOrEmpty(ctx, flagger.FeatureEnableAIObservability, evalCtx)
featureSet = append(featureSet, &licensetypes.Feature{
Name: valuer.NewString(flagger.FeatureEnableAIObservability.String()),
diff --git a/frontend/src/constants/features.ts b/frontend/src/constants/features.ts
index b1fd3543f9..cf1a3069a8 100644
--- a/frontend/src/constants/features.ts
+++ b/frontend/src/constants/features.ts
@@ -10,7 +10,6 @@ export enum FeatureKeys {
DOT_METRICS_ENABLED = 'dot_metrics_enabled',
USE_JSON_BODY = 'use_json_body',
USE_FINE_GRAINED_AUTHZ = 'use_fine_grained_authz',
- USE_DASHBOARD_V2 = 'use_dashboard_v2',
USE_INFRA_MONITORING_V2 = 'use_infra_monitoring_v2',
ENABLE_AI_OBSERVABILITY = 'enable_ai_observability',
ENABLE_METRICS_REDUCTION = 'enable_metrics_reduction',
diff --git a/frontend/src/container/ExplorerOptions/__tests__/ExplorerOptionWrapper.test.tsx b/frontend/src/container/ExplorerOptions/__tests__/ExplorerOptionWrapper.test.tsx
index d8b9826cc4..fe6d759753 100644
--- a/frontend/src/container/ExplorerOptions/__tests__/ExplorerOptionWrapper.test.tsx
+++ b/frontend/src/container/ExplorerOptions/__tests__/ExplorerOptionWrapper.test.tsx
@@ -1,5 +1,4 @@
import { useHistory } from 'react-router-dom';
-import { FeatureKeys } from 'constants/features';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { MOCK_QUERY } from 'container/QueryTable/Drilldown/__tests__/mockTableData';
import { ExportDashboard } from 'hooks/dashboard/useExportDashboards';
@@ -12,7 +11,6 @@ import {
userEvent,
waitFor,
} from 'tests/test-utils';
-import { Dashboard } from 'types/api/dashboard/getAll';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';
import { generateExportToDashboardLink } from 'utils/dashboard/generateExportToDashboardLink';
@@ -48,33 +46,16 @@ const mockUseHistory = jest.mocked(useHistory);
// Mock data
const TEST_QUERY_ID = 'test-query-id';
const TEST_DASHBOARD_ID = 'test-dashboard-id';
-const TEST_DASHBOARD_TITLE = 'Test Dashboard';
-const TEST_DASHBOARD_DESCRIPTION = 'Test Description';
-const TEST_TIMESTAMP = '2023-01-01T00:00:00Z';
const TEST_DASHBOARD_TITLE_2 = 'Test Dashboard for Export';
const NEW_DASHBOARD_ID = 'new-dashboard-id';
-// The export dialog is flag-aware (`use_dashboard_v2`): V1 talks to the legacy
-// dashboards API, V2 to the generated Perses-spec endpoints. The tests below run
-// against both contracts, so each path gets its own endpoints + response shapes.
-const V1_DASHBOARDS_ENDPOINT = '*/api/v1/dashboards';
+// The export dialog talks to the generated Perses-spec dashboard endpoints.
const V2_LIST_ENDPOINT = '*/api/v2/users/me/dashboards';
const V2_CREATE_ENDPOINT = '*/api/v2/dashboards';
-// V2 "create new dashboard" names the dashboard from the `new_dashboard_title`
-// i18n key; the test-utils react-i18next mock returns the key verbatim.
-const NEW_V2_DASHBOARD_TITLE = 'new_dashboard_title';
-
-const featureFlagsWithDashboardV2 = [
- ...defaultFeatureFlags,
- {
- name: FeatureKeys.USE_DASHBOARD_V2,
- active: true,
- usage: 0,
- usage_limit: -1,
- route: '',
- },
-];
+// "Create new dashboard" names the dashboard from the `new_dashboard_title` i18n
+// key; the test-utils react-i18next mock returns the key verbatim.
+const NEW_DASHBOARD_TITLE = 'new_dashboard_title';
// Use the existing mock query from the codebase
const mockQuery: Query = {
@@ -82,21 +63,6 @@ const mockQuery: Query = {
id: TEST_QUERY_ID, // Override with our test ID
} as Query;
-const createMockDashboard = (id: string = TEST_DASHBOARD_ID): Dashboard => ({
- id,
- data: {
- title: TEST_DASHBOARD_TITLE,
- description: TEST_DASHBOARD_DESCRIPTION,
- tags: [],
- layout: [],
- variables: {},
- },
- createdAt: TEST_TIMESTAMP,
- updatedAt: TEST_TIMESTAMP,
- createdBy: 'test-user',
- updatedBy: 'test-user',
-});
-
const ADD_TO_DASHBOARD_BUTTON_NAME = /add to dashboard/i;
interface PickerDashboard {
@@ -104,92 +70,40 @@ interface PickerDashboard {
title: string;
}
-/**
- * Describes one dashboard-API contract (V1 or V2) the export dialog can run
- * against: the feature flags that select it, plus helpers that register the
- * matching MSW handlers so the same test body exercises either path.
- */
-interface ExportVariant {
- name: string;
- featureFlags: typeof defaultFeatureFlags;
- /** Register the "list dashboards" endpoint the picker reads. */
- mockDashboardList: (dashboards: PickerDashboard[]) => void;
- /**
- * Register the "create dashboard" endpoint the "New dashboard" button hits.
- * Returns the title `onExport` should receive for the created dashboard.
- */
- mockCreateDashboard: (id: string) => { expectedTitle: string };
-}
-
-const v1Variant: ExportVariant = {
- name: 'V1',
- featureFlags: defaultFeatureFlags,
- mockDashboardList: (dashboards): void => {
- server.use(
- rest.get(V1_DASHBOARDS_ENDPOINT, (_req, res, ctx) =>
- res(
- ctx.status(200),
- ctx.json({
- data: dashboards.map(({ id, title }) => {
- const dashboard = createMockDashboard(id);
- dashboard.data.title = title;
- return dashboard;
- }),
- }),
- ),
+/** Register the "list dashboards" endpoint the picker reads. */
+function mockDashboardList(dashboards: PickerDashboard[]): void {
+ server.use(
+ rest.get(V2_LIST_ENDPOINT, (_req, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ status: 'success',
+ data: {
+ dashboards: dashboards.map(({ id, title }) => ({
+ id,
+ name: title,
+ spec: { display: { name: title } },
+ })),
+ reservedKeywords: [],
+ },
+ }),
),
- );
- },
- mockCreateDashboard: (id): { expectedTitle: string } => {
- const dashboard = createMockDashboard(id);
- server.use(
- rest.post(V1_DASHBOARDS_ENDPOINT, (_req, res, ctx) =>
- res(ctx.status(200), ctx.json({ data: dashboard })),
- ),
- );
- return { expectedTitle: dashboard.data.title ?? '' };
- },
-};
-
-const v2Variant: ExportVariant = {
- name: 'V2',
- featureFlags: featureFlagsWithDashboardV2,
- mockDashboardList: (dashboards): void => {
- server.use(
- rest.get(V2_LIST_ENDPOINT, (_req, res, ctx) =>
- res(
- ctx.status(200),
- ctx.json({
- status: 'success',
- data: {
- dashboards: dashboards.map(({ id, title }) => ({
- id,
- name: title,
- spec: { display: { name: title } },
- })),
- reservedKeywords: [],
- },
- }),
- ),
- ),
- );
- },
- mockCreateDashboard: (id): { expectedTitle: string } => {
- server.use(
- rest.post(V2_CREATE_ENDPOINT, (_req, res, ctx) =>
- res(ctx.status(201), ctx.json({ status: 'success', data: { id } })),
- ),
- );
- return { expectedTitle: NEW_V2_DASHBOARD_TITLE };
- },
-};
+ ),
+ );
+}
-const exportVariants: ExportVariant[] = [v1Variant, v2Variant];
+/** Register the "create dashboard" endpoint the "New dashboard" button hits. */
+function mockCreateDashboard(id: string): void {
+ server.use(
+ rest.post(V2_CREATE_ENDPOINT, (_req, res, ctx) =>
+ res(ctx.status(201), ctx.json({ status: 'success', data: { id } })),
+ ),
+ );
+}
// Helper function to render component with props
const renderExplorerOptionWrapper = (
overrides = {},
- featureFlags: typeof defaultFeatureFlags = defaultFeatureFlags,
): ReturnType<typeof render> => {
const props = {
disabled: false,
@@ -221,7 +135,7 @@ const renderExplorerOptionWrapper = (
signalSource={props.signalSource}
/>,
undefined,
- { appContextOverrides: { featureFlags } },
+ { appContextOverrides: { featureFlags: defaultFeatureFlags } },
);
};
@@ -264,222 +178,218 @@ describe('ExplorerOptionWrapper', () => {
expect(params.has('compositeQuery')).toBe(true);
});
- describe.each(exportVariants)(
- 'onExport functionality [$name dashboards]',
- ({ featureFlags, mockDashboardList, mockCreateDashboard }) => {
- it('should call onExport when New Dashboard button is clicked in export modal', async () => {
- const user = userEvent.setup({ pointerEventsCheck: 0 });
- const testOnExport = jest.fn() as jest.MockedFunction<
- (
- dashboard: ExportDashboard | null,
- isNewDashboard?: boolean,
- queryToExport?: Query,
- ) => void
- >;
-
- // Mock the dashboard creation API for the active contract.
- const { expectedTitle } = mockCreateDashboard(NEW_DASHBOARD_ID);
-
- renderExplorerOptionWrapper({ onExport: testOnExport }, featureFlags);
-
- // Find and click the "Add to Dashboard" button
- const addToDashboardButton = screen.getByRole('button', {
- name: ADD_TO_DASHBOARD_BUTTON_NAME,
- });
- await user.click(addToDashboardButton);
+ describe('onExport functionality', () => {
+ it('should call onExport when New Dashboard button is clicked in export modal', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ const testOnExport = jest.fn() as jest.MockedFunction<
+ (
+ dashboard: ExportDashboard | null,
+ isNewDashboard?: boolean,
+ queryToExport?: Query,
+ ) => void
+ >;
- // Wait for the export modal to appear
- await waitFor(() => {
- expect(screen.getByRole('dialog')).toBeInTheDocument();
- });
+ mockCreateDashboard(NEW_DASHBOARD_ID);
- // Click the "New dashboard" button
- const newDashboardButton = screen.getByTestId('export-panel-new-dashboard');
- await user.click(newDashboardButton);
+ renderExplorerOptionWrapper({ onExport: testOnExport });
- // Wait for the API call to complete and onExport to be called
- await waitFor(() => {
- expect(testOnExport).toHaveBeenCalledWith(
- { id: NEW_DASHBOARD_ID, title: expectedTitle },
- true,
- );
- });
+ // Find and click the "Add to Dashboard" button
+ const addToDashboardButton = screen.getByRole('button', {
+ name: ADD_TO_DASHBOARD_BUTTON_NAME,
});
+ await user.click(addToDashboardButton);
- it('should call onExport when selecting existing dashboard and clicking Export button', async () => {
- const user = userEvent.setup({ pointerEventsCheck: 0 });
- const testOnExport = jest.fn() as jest.MockedFunction<
- (
- dashboard: ExportDashboard | null,
- isNewDashboard?: boolean,
- queryToExport?: Query,
- ) => void
- >;
-
- // Mock existing dashboards with unique titles
- const dashboards: PickerDashboard[] = [
- { id: 'dashboard-1', title: 'Dashboard 1' },
- { id: 'dashboard-2', title: 'Dashboard 2' },
- ];
- mockDashboardList(dashboards);
-
- renderExplorerOptionWrapper({ onExport: testOnExport }, featureFlags);
-
- // Find and click the "Add to Dashboard" button
- const addToDashboardButton = screen.getByRole('button', {
- name: ADD_TO_DASHBOARD_BUTTON_NAME,
- });
- await user.click(addToDashboardButton);
+ // Wait for the export modal to appear
+ await waitFor(() => {
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
+ });
- // Wait for the export modal to appear
- await waitFor(() => {
- expect(screen.getByRole('dialog')).toBeInTheDocument();
- });
+ // Click the "New dashboard" button
+ const newDashboardButton = screen.getByTestId('export-panel-new-dashboard');
+ await user.click(newDashboardButton);
- // Wait for the dashboard select to render AND finish loading. antd
- // disables the Select while the list request is in flight, and a click
- // on a disabled combobox is a no-op — so sync on the ready (enabled)
- // state before clicking.
- const modal = screen.getByRole('dialog');
- await waitFor(() => {
- const combobox = modal.querySelector('[role="combobox"]');
- expect(combobox).toBeTruthy();
- expect(combobox).not.toBeDisabled();
- });
+ // Wait for the API call to complete and onExport to be called
+ await waitFor(() => {
+ expect(testOnExport).toHaveBeenCalledWith(
+ { id: NEW_DASHBOARD_ID, title: NEW_DASHBOARD_TITLE },
+ true,
+ );
+ });
+ });
- const dashboardSelect = modal.querySelector(
- '[role="combobox"]',
- ) as HTMLElement;
- expect(dashboardSelect).toBeInTheDocument();
- await user.click(dashboardSelect);
+ it('should call onExport when selecting existing dashboard and clicking Export button', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ const testOnExport = jest.fn() as jest.MockedFunction<
+ (
+ dashboard: ExportDashboard | null,
+ isNewDashboard?: boolean,
+ queryToExport?: Query,
+ ) => void
+ >;
+
+ // Mock existing dashboards with unique titles
+ const dashboards: PickerDashboard[] = [
+ { id: 'dashboard-1', title: 'Dashboard 1' },
+ { id: 'dashboard-2', title: 'Dashboard 2' },
+ ];
+ mockDashboardList(dashboards);
+
+ renderExplorerOptionWrapper({ onExport: testOnExport });
+
+ // Find and click the "Add to Dashboard" button
+ const addToDashboardButton = screen.getByRole('button', {
+ name: ADD_TO_DASHBOARD_BUTTON_NAME,
+ });
+ await user.click(addToDashboardButton);
- // Wait for the dropdown options to appear and select the first dashboard
- await waitFor(() => {
- expect(screen.getByText(dashboards[0].title)).toBeInTheDocument();
- });
+ // Wait for the export modal to appear
+ await waitFor(() => {
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
+ });
- // Click on the first dashboard option
- const dashboardOption = screen.getByText(dashboards[0].title);
- await user.click(dashboardOption);
+ // Wait for the dashboard select to render AND finish loading. antd
+ // disables the Select while the list request is in flight, and a click
+ // on a disabled combobox is a no-op — so sync on the ready (enabled)
+ // state before clicking.
+ const modal = screen.getByRole('dialog');
+ await waitFor(() => {
+ const combobox = modal.querySelector('[role="combobox"]');
+ expect(combobox).toBeTruthy();
+ expect(combobox).not.toBeDisabled();
+ });
- // Wait for the selection to be made and the export button to be enabled
- await waitFor(() => {
- expect(screen.getByTestId('export-panel-export')).not.toBeDisabled();
- });
+ const dashboardSelect = modal.querySelector(
+ '[role="combobox"]',
+ ) as HTMLElement;
+ expect(dashboardSelect).toBeInTheDocument();
+ await user.click(dashboardSelect);
- // Click the export button
- const exportButton = screen.getByTestId('export-panel-export');
- await user.click(exportButton);
+ // Wait for the dropdown options to appear and select the first dashboard
+ await waitFor(() => {
+ expect(screen.getByText(dashboards[0].title)).toBeInTheDocument();
+ });
- // Wait for onExport to be called with the selected dashboard
- await waitFor(() => {
- expect(testOnExport).toHaveBeenCalledWith(
- { id: dashboards[0].id, title: dashboards[0].title },
- false,
- );
- });
+ // Click on the first dashboard option
+ const dashboardOption = screen.getByText(dashboards[0].title);
+ await user.click(dashboardOption);
+
+ // Wait for the selection to be made and the export button to be enabled
+ await waitFor(() => {
+ expect(screen.getByTestId('export-panel-export')).not.toBeDisabled();
});
- it('should test actual handleExport function with generateExportToDashboardLink and verify useUpdateDashboard is NOT called', async () => {
- const user = userEvent.setup({ pointerEventsCheck: 0 });
-
- // Mock the safeNavigate function
- const mockSafeNavigate = jest.fn();
-
- // Get the mock mutate function to track calls
- const mockMutate = mockUseUpdateDashboard().mutate as jest.MockedFunction<
- (...args: unknown[]) => void
- >;
-
- const panelTypeParam = PANEL_TYPES.TIME_SERIES;
- const widgetId = v4();
- const query = mockQuery;
-
- // Create a real handleExport function similar to LogsExplorerViews
- // This should NOT call useUpdateDashboard (as per PR #8029)
- const handleExport = (dashboard: ExportDashboard | null): void => {
- if (!dashboard) {
- return;
- }
-
- // Call the actual generateExportToDashboardLink function (not mocked)
- const dashboardEditView = generateExportToDashboardLink({
- query,
- panelType: panelTypeParam,
- dashboardId: dashboard.id,
- widgetId,
- });
-
- // Simulate navigation
- mockSafeNavigate(dashboardEditView);
- };
-
- // Mock existing dashboards
- const dashboards: PickerDashboard[] = [
- { id: TEST_DASHBOARD_ID, title: TEST_DASHBOARD_TITLE_2 },
- ];
- mockDashboardList(dashboards);
-
- renderExplorerOptionWrapper({ onExport: handleExport }, featureFlags);
-
- // Find and click the "Add to Dashboard" button
- const addToDashboardButton = screen.getByRole('button', {
- name: ADD_TO_DASHBOARD_BUTTON_NAME,
- });
- await user.click(addToDashboardButton);
+ // Click the export button
+ const exportButton = screen.getByTestId('export-panel-export');
+ await user.click(exportButton);
- // Wait for the export modal to appear
- await waitFor(() => {
- expect(screen.getByRole('dialog')).toBeInTheDocument();
- });
+ // Wait for onExport to be called with the selected dashboard
+ await waitFor(() => {
+ expect(testOnExport).toHaveBeenCalledWith(
+ { id: dashboards[0].id, title: dashboards[0].title },
+ false,
+ );
+ });
+ });
- // Wait for the dashboard select to render AND finish loading (see note above).
- const modal = screen.getByRole('dialog');
- await waitFor(() => {
- const combobox = modal.querySelector('[role="combobox"]');
- expect(combobox).toBeTruthy();
- expect(combobox).not.toBeDisabled();
+ it('should test actual handleExport function with generateExportToDashboardLink and verify useUpdateDashboard is NOT called', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+
+ // Mock the safeNavigate function
+ const mockSafeNavigate = jest.fn();
+
+ // Get the mock mutate function to track calls
+ const mockMutate = mockUseUpdateDashboard().mutate as jest.MockedFunction<
+ (...args: unknown[]) => void
+ >;
+
+ const panelTypeParam = PANEL_TYPES.TIME_SERIES;
+ const widgetId = v4();
+ const query = mockQuery;
+
+ // Create a real handleExport function similar to LogsExplorerViews
+ // This should NOT call useUpdateDashboard (as per PR #8029)
+ const handleExport = (dashboard: ExportDashboard | null): void => {
+ if (!dashboard) {
+ return;
+ }
+
+ // Call the actual generateExportToDashboardLink function (not mocked)
+ const dashboardEditView = generateExportToDashboardLink({
+ query,
+ panelType: panelTypeParam,
+ dashboardId: dashboard.id,
+ widgetId,
});
- const dashboardSelect = modal.querySelector(
- '[role="combobox"]',
- ) as HTMLElement;
- expect(dashboardSelect).toBeInTheDocument();
- await user.click(dashboardSelect);
+ // Simulate navigation
+ mockSafeNavigate(dashboardEditView);
+ };
- // Wait for the dropdown options to appear and select the dashboard
- await waitFor(() => {
- expect(screen.getByText(dashboards[0].title)).toBeInTheDocument();
- });
+ // Mock existing dashboards
+ const dashboards: PickerDashboard[] = [
+ { id: TEST_DASHBOARD_ID, title: TEST_DASHBOARD_TITLE_2 },
+ ];
+ mockDashboardList(dashboards);
- // Click on the dashboard option
- const dashboardOption = screen.getByText(dashboards[0].title);
- await user.click(dashboardOption);
+ renderExplorerOptionWrapper({ onExport: handleExport });
- // Wait for the selection to be made and the export button to be enabled
- await waitFor(() => {
- expect(screen.getByTestId('export-panel-export')).not.toBeDisabled();
- });
+ // Find and click the "Add to Dashboard" button
+ const addToDashboardButton = screen.getByRole('button', {
+ name: ADD_TO_DASHBOARD_BUTTON_NAME,
+ });
+ await user.click(addToDashboardButton);
- // Click the export button
- const exportButton = screen.getByTestId('export-panel-export');
- await user.click(exportButton);
-
- // Wait for the handleExport function to be called and navigation to occur
- await waitFor(() => {
- expect(mockSafeNavigate).toHaveBeenCalledTimes(1);
- expect(mockSafeNavigate).toHaveBeenCalledWith(
- `/dashboard/${TEST_DASHBOARD_ID}/new?graphType=${panelTypeParam}&widgetId=${widgetId}&compositeQuery=${encodeURIComponent(
- JSON.stringify(query),
- )}`,
- );
- });
+ // Wait for the export modal to appear
+ await waitFor(() => {
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
+ });
- // Assert that useUpdateDashboard was NOT called (as per PR #8029)
- expect(mockMutate).not.toHaveBeenCalled();
+ // Wait for the dashboard select to render AND finish loading (see note above).
+ const modal = screen.getByRole('dialog');
+ await waitFor(() => {
+ const combobox = modal.querySelector('[role="combobox"]');
+ expect(combobox).toBeTruthy();
+ expect(combobox).not.toBeDisabled();
});
- },
- );
+
+ const dashboardSelect = modal.querySelector(
+ '[role="combobox"]',
+ ) as HTMLElement;
+ expect(dashboardSelect).toBeInTheDocument();
+ await user.click(dashboardSelect);
+
+ // Wait for the dropdown options to appear and select the dashboard
+ await waitFor(() => {
+ expect(screen.getByText(dashboards[0].title)).toBeInTheDocument();
+ });
+
+ // Click on the dashboard option
+ const dashboardOption = screen.getByText(dashboards[0].title);
+ await user.click(dashboardOption);
+
+ // Wait for the selection to be made and the export button to be enabled
+ await waitFor(() => {
+ expect(screen.getByTestId('export-panel-export')).not.toBeDisabled();
+ });
+
+ // Click the export button
+ const exportButton = screen.getByTestId('export-panel-export');
+ await user.click(exportButton);
+
+ // Wait for the handleExport function to be called and navigation to occur
+ await waitFor(() => {
+ expect(mockSafeNavigate).toHaveBeenCalledTimes(1);
+ expect(mockSafeNavigate).toHaveBeenCalledWith(
+ `/dashboard/${TEST_DASHBOARD_ID}/new?graphType=${panelTypeParam}&widgetId=${widgetId}&compositeQuery=${encodeURIComponent(
+ JSON.stringify(query),
+ )}`,
+ );
+ });
+
+ // Assert that useUpdateDashboard was NOT called (as per PR #8029)
+ expect(mockMutate).not.toHaveBeenCalled();
+ });
+ });
it('should not show export buttons when component is disabled', () => {
const testOnExport = jest.fn() as jest.MockedFunction<
diff --git a/frontend/src/container/Home/Dashboards/Dashboards.tsx b/frontend/src/container/Home/Dashboards/Dashboards.tsx
index ab103f9a86..8d89537f7d 100644
--- a/frontend/src/container/Home/Dashboards/Dashboards.tsx
+++ b/frontend/src/container/Home/Dashboards/Dashboards.tsx
@@ -9,8 +9,6 @@ import {
DashboardtypesListSortDTO,
} from 'api/generated/services/sigNoz.schemas';
import ROUTES from 'constants/routes';
-import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { ArrowRight, ArrowUpRight, Plus } from '@signozhq/icons';
import Card from 'periscope/components/Card/Card';
@@ -22,7 +20,7 @@ import dialsUrl from '@/assets/Icons/dials.svg';
import { getItemIcon } from '../constants';
-// The five most-recent dashboards, normalised across the v1 and v2 list APIs.
+// The five most-recent dashboards from the V2 list API.
interface RecentDashboard {
id: string;
title: string;
@@ -38,52 +36,27 @@ export default function Dashboards({
}): JSX.Element {
const { safeNavigate } = useSafeNavigate();
const { user } = useAppContext();
- const isDashboardV2 = useIsDashboardV2();
- // Fetch the recent dashboards from whichever API the `use_dashboard_v2` flag
- // selects; the inactive one stays disabled so it never fires.
const {
- data: v1List,
- isLoading: v1Loading,
- isError: v1Error,
- } = useGetAllDashboard({ enabled: !isDashboardV2 });
-
- const {
- data: v2List,
- isLoading: v2Loading,
- isError: v2Error,
- } = useListDashboardsForUserV2(
- {
- sort: DashboardtypesListSortDTO.updated_at,
- order: DashboardtypesListOrderDTO.desc,
- limit: 5,
- offset: 0,
- },
- { query: { enabled: isDashboardV2 } },
- );
-
- const isDashboardListLoading = isDashboardV2 ? v2Loading : v1Loading;
- const isDashboardListError = isDashboardV2 ? v2Error : v1Error;
-
- const sortedDashboards = useMemo<RecentDashboard[]>(() => {
- if (isDashboardV2) {
- return (v2List?.data?.dashboards ?? []).map((d) => ({
+ data: dashboardsList,
+ isLoading: isDashboardListLoading,
+ isError: isDashboardListError,
+ } = useListDashboardsForUserV2({
+ sort: DashboardtypesListSortDTO.updated_at,
+ order: DashboardtypesListOrderDTO.desc,
+ limit: 5,
+ offset: 0,
+ });
+
+ const sortedDashboards = useMemo<RecentDashboard[]>(
+ () =>
+ (dashboardsList?.data?.dashboards ?? []).map((d) => ({
id: d.id,
title: d.spec?.display?.name ?? d.name,
tags: (d.tags ?? []).map((t) => (t.value ? `${t.key}:${t.value}` : t.key)),
- }));
- }
- return [...(v1List?.data ?? [])]
- .sort(
- (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),
- )
- .slice(0, 5)
- .map((d) => ({
- id: d.id,
- title: d.data.title,
- tags: d.data.tags ?? [],
- }));
- }, [isDashboardV2, v1List, v2List]);
+ })),
+ [dashboardsList],
+ );
useEffect(() => {
if (sortedDashboards.length > 0 && !loadingUserPreferences) {
diff --git a/frontend/src/hooks/dashboard/__test__/useCreateExportDashboard.test.tsx b/frontend/src/hooks/dashboard/__test__/useCreateExportDashboard.test.tsx
index ba30965bbf..9efe732812 100644
--- a/frontend/src/hooks/dashboard/__test__/useCreateExportDashboard.test.tsx
+++ b/frontend/src/hooks/dashboard/__test__/useCreateExportDashboard.test.tsx
@@ -2,15 +2,9 @@ import { ReactNode } from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { act, renderHook, waitFor } from '@testing-library/react';
import { createDashboardV2 } from 'api/generated/services/dashboard';
-import createDashboardV1 from 'api/v1/dashboards/create';
-import { ENTITY_VERSION_V5 } from 'constants/app';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
-import { Dashboard } from 'types/api/dashboard/getAll';
import { useCreateExportDashboard } from '../useCreateExportDashboard';
-jest.mock('hooks/useIsDashboardV2');
-jest.mock('api/v1/dashboards/create');
jest.mock('api/generated/services/dashboard', () => ({
createDashboardV2: jest.fn(),
}));
@@ -20,10 +14,6 @@ jest.mock('providers/ErrorModalProvider', () => ({
}),
}));
-const mockUseIsDashboardV2 = useIsDashboardV2 as jest.MockedFunction<
- typeof useIsDashboardV2
->;
-const mockCreateV1 = createDashboardV1 as jest.Mock;
const mockCreateV2 = createDashboardV2 as jest.Mock;
function wrapper({ children }: { children: ReactNode }): JSX.Element {
@@ -40,35 +30,7 @@ beforeEach(() => {
});
describe('useCreateExportDashboard', () => {
- it('creates via the V1 endpoint and returns the created dashboard when the flag is off', async () => {
- mockUseIsDashboardV2.mockReturnValue(false);
- const v1Dashboard = {
- id: 'v1-new',
- data: { title: TITLE },
- } as unknown as Dashboard;
- mockCreateV1.mockResolvedValue({ httpStatusCode: 200, data: v1Dashboard });
- const onCreated = jest.fn();
-
- const { result } = renderHook(
- () => useCreateExportDashboard({ title: TITLE, onCreated }),
- { wrapper },
- );
-
- act(() => result.current.create());
-
- await waitFor(() =>
- expect(onCreated).toHaveBeenCalledWith({ id: 'v1-new', title: TITLE }),
- );
- expect(mockCreateV1).toHaveBeenCalledWith({
- title: TITLE,
- uploadedGrafana: false,
- version: ENTITY_VERSION_V5,
- });
- expect(mockCreateV2).not.toHaveBeenCalled();
- });
-
- it('creates via the V2 Perses endpoint and normalizes the response when the flag is on', async () => {
- mockUseIsDashboardV2.mockReturnValue(true);
+ it('creates via the V2 Perses endpoint and normalizes the response', async () => {
mockCreateV2.mockResolvedValue({ data: { id: 'v2-new' } });
const onCreated = jest.fn();
@@ -88,6 +50,5 @@ describe('useCreateExportDashboard', () => {
spec: expect.objectContaining({ display: { name: TITLE } }),
}),
);
- expect(mockCreateV1).not.toHaveBeenCalled();
});
});
diff --git a/frontend/src/hooks/dashboard/__test__/useExportDashboards.test.ts b/frontend/src/hooks/dashboard/__test__/useExportDashboards.test.ts
index d92c6d258d..b65df419e3 100644
--- a/frontend/src/hooks/dashboard/__test__/useExportDashboards.test.ts
+++ b/frontend/src/hooks/dashboard/__test__/useExportDashboards.test.ts
@@ -1,44 +1,18 @@
import { renderHook } from '@testing-library/react';
import { useListDashboardsForUserV2 } from 'api/generated/services/dashboard';
-import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
-import { Dashboard } from 'types/api/dashboard/getAll';
import { useExportDashboards } from '../useExportDashboards';
-jest.mock('hooks/useIsDashboardV2');
-jest.mock('hooks/dashboard/useGetAllDashboard');
jest.mock('api/generated/services/dashboard', () => ({
useListDashboardsForUserV2: jest.fn(),
}));
-const mockUseIsDashboardV2 = useIsDashboardV2 as jest.MockedFunction<
- typeof useIsDashboardV2
->;
-const mockUseGetAllDashboard = useGetAllDashboard as jest.Mock;
const mockUseListV2 = useListDashboardsForUserV2 as jest.Mock;
-const v1Refetch = jest.fn();
const v2Refetch = jest.fn();
-const v1Dashboard = {
- id: 'v1-1',
- data: { title: 'V1 Dashboard' },
-} as unknown as Dashboard;
-
-const v1Other = {
- id: 'v1-2',
- data: { title: 'Other board' },
-} as unknown as Dashboard;
-
beforeEach(() => {
jest.clearAllMocks();
- mockUseGetAllDashboard.mockReturnValue({
- data: { data: [v1Dashboard, v1Other] },
- isLoading: false,
- isFetching: false,
- refetch: v1Refetch,
- });
mockUseListV2.mockReturnValue({
data: {
data: {
@@ -58,54 +32,21 @@ beforeEach(() => {
});
describe('useExportDashboards', () => {
- it('returns the V1 list and disables the V2 query when the flag is off', () => {
- mockUseIsDashboardV2.mockReturnValue(false);
-
- const { result } = renderHook(() => useExportDashboards());
-
- expect(result.current.dashboards).toStrictEqual([
- { id: 'v1-1', title: 'V1 Dashboard' },
- { id: 'v1-2', title: 'Other board' },
- ]);
- expect(mockUseGetAllDashboard).toHaveBeenCalledWith({ enabled: true });
- expect(mockUseListV2).toHaveBeenCalledWith(
- expect.anything(),
- expect.objectContaining({
- query: { enabled: false, keepPreviousData: true },
- }),
- );
- });
-
- it('filters the V1 list in memory by title (case-insensitive)', () => {
- mockUseIsDashboardV2.mockReturnValue(false);
-
- const { result } = renderHook(() => useExportDashboards('v1 dash'));
-
- expect(result.current.dashboards).toStrictEqual([
- { id: 'v1-1', title: 'V1 Dashboard' },
- ]);
- });
-
- it('returns the V2 list normalized to the export shape when the flag is on', () => {
- mockUseIsDashboardV2.mockReturnValue(true);
-
+ it('returns the V2 list normalized to the export shape', () => {
const { result } = renderHook(() => useExportDashboards());
expect(result.current.dashboards).toStrictEqual([
{ id: 'v2-1', title: 'V2 Dashboard' },
]);
- expect(mockUseGetAllDashboard).toHaveBeenCalledWith({ enabled: false });
expect(mockUseListV2).toHaveBeenCalledWith(
expect.objectContaining({ query: undefined }),
expect.objectContaining({
- query: { enabled: true, keepPreviousData: true },
+ query: { keepPreviousData: true },
}),
);
});
it('passes the search term as a name-contains filter clause to the V2 query param', () => {
- mockUseIsDashboardV2.mockReturnValue(true);
-
renderHook(() => useExportDashboards('payments'));
expect(mockUseListV2).toHaveBeenCalledWith(
@@ -114,12 +55,10 @@ describe('useExportDashboards', () => {
);
});
- it('refetches the active source', () => {
- mockUseIsDashboardV2.mockReturnValue(true);
+ it('refetches the V2 source', () => {
const { result } = renderHook(() => useExportDashboards());
result.current.refetch();
expect(v2Refetch).toHaveBeenCalledTimes(1);
- expect(v1Refetch).not.toHaveBeenCalled();
});
});
diff --git a/frontend/src/hooks/dashboard/__test__/useGetExportToDashboardLink.test.ts b/frontend/src/hooks/dashboard/__test__/useGetExportToDashboardLink.test.ts
index b4bdcc0f3d..c1ec45cf60 100644
--- a/frontend/src/hooks/dashboard/__test__/useGetExportToDashboardLink.test.ts
+++ b/frontend/src/hooks/dashboard/__test__/useGetExportToDashboardLink.test.ts
@@ -1,15 +1,9 @@
import { renderHook } from '@testing-library/react';
import { PANEL_TYPES } from 'constants/queryBuilder';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import type { Query } from 'types/api/queryBuilder/queryBuilderData';
import { useGetExportToDashboardLink } from '../useGetExportToDashboardLink';
-jest.mock('hooks/useIsDashboardV2');
-const mockUseIsDashboardV2 = useIsDashboardV2 as jest.MockedFunction<
- typeof useIsDashboardV2
->;
-
const query = { id: 'q1', queryType: 'builder' } as unknown as Query;
const params = {
dashboardId: 'dash-1',
@@ -19,21 +13,7 @@ const params = {
};
describe('useGetExportToDashboardLink', () => {
- it('builds a V1 new-widget link when the dashboard-v2 flag is off', () => {
- mockUseIsDashboardV2.mockReturnValue(false);
-
- const { result } = renderHook(() => useGetExportToDashboardLink());
- const link = result.current(params);
-
- expect(link?.startsWith('/dashboard/dash-1/new?')).toBe(true);
- expect(link).toContain('graphType=');
- expect(link).toContain('widgetId=w1');
- expect(link).toContain('compositeQuery=');
- });
-
- it('builds a V2 panel/new link (ignoring widgetId) when the flag is on', () => {
- mockUseIsDashboardV2.mockReturnValue(true);
-
+ it('builds a V2 panel/new link (ignoring widgetId)', () => {
const { result } = renderHook(() => useGetExportToDashboardLink());
const link = result.current(params);
diff --git a/frontend/src/hooks/dashboard/useCreateExportDashboard.ts b/frontend/src/hooks/dashboard/useCreateExportDashboard.ts
index f135247889..ab9911f5f6 100644
--- a/frontend/src/hooks/dashboard/useCreateExportDashboard.ts
+++ b/frontend/src/hooks/dashboard/useCreateExportDashboard.ts
@@ -1,9 +1,6 @@
import { useCallback } from 'react';
import { useMutation } from 'react-query';
import { createDashboardV2 } from 'api/generated/services/dashboard';
-import createDashboardV1 from 'api/v1/dashboards/create';
-import { ENTITY_VERSION_V5 } from 'constants/app';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import { useErrorModal } from 'providers/ErrorModalProvider';
import APIError from 'types/api/error';
@@ -20,14 +17,13 @@ interface UseCreateExportDashboardResult {
}
/**
- * Flag-aware "create a new dashboard to export into". V2 uses the Perses-spec
- * `createDashboardV2`; V1 uses the legacy create. Both normalize to an `ExportDashboard`.
+ * "Create a new dashboard to export into". Uses the Perses-spec `createDashboardV2`
+ * and normalizes to an `ExportDashboard`.
*/
export function useCreateExportDashboard({
title,
onCreated,
}: UseCreateExportDashboardParams): UseCreateExportDashboardResult {
- const isDashboardV2 = useIsDashboardV2();
const { showErrorModal } = useErrorModal();
const onError = useCallback(
@@ -35,16 +31,7 @@ export function useCreateExportDashboard({
[showErrorModal],
);
- const v1 = useMutation(createDashboardV1, {
- onSuccess: (data) => {
- if (data.data) {
- onCreated({ id: data.data.id, title: data.data.data.title ?? '' });
- }
- },
- onError,
- });
-
- const v2 = useMutation(
+ const createDashboardMutation = useMutation(
() =>
createDashboardV2({
schemaVersion: 'v6',
@@ -66,15 +53,11 @@ export function useCreateExportDashboard({
);
const create = useCallback((): void => {
- if (isDashboardV2) {
- v2.mutate();
- } else {
- v1.mutate({ title, uploadedGrafana: false, version: ENTITY_VERSION_V5 });
- }
- }, [isDashboardV2, v1, v2, title]);
+ createDashboardMutation.mutate();
+ }, [createDashboardMutation]);
return {
create,
- isLoading: isDashboardV2 ? v2.isLoading : v1.isLoading,
+ isLoading: createDashboardMutation.isLoading,
};
}
diff --git a/frontend/src/hooks/dashboard/useExportDashboards.ts b/frontend/src/hooks/dashboard/useExportDashboards.ts
index 813c99aeb3..a68db906dc 100644
--- a/frontend/src/hooks/dashboard/useExportDashboards.ts
+++ b/frontend/src/hooks/dashboard/useExportDashboards.ts
@@ -1,15 +1,12 @@
import { useCallback, useMemo } from 'react';
import { useListDashboardsForUserV2 } from 'api/generated/services/dashboard';
import { DashboardtypesListedDashboardForUserV2DTO } from 'api/generated/services/sigNoz.schemas';
-import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
import useDebounce from 'hooks/useDebounce';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
-import { Dashboard } from 'types/api/dashboard/getAll';
const V2_LIST_LIMIT = 1000;
const SEARCH_DEBOUNCE_MS = 300;
-/** Neutral id+title the picker uses in place of the V1/V2 dashboard entity. */
+/** Neutral id+title the picker uses in place of the dashboard entity. */
export interface ExportDashboard {
id: string;
title: string;
@@ -24,29 +21,12 @@ export interface UseExportDashboardsResult {
refetch: () => void;
}
-function fromV2(
+function toExportDashboard(
item: DashboardtypesListedDashboardForUserV2DTO,
): ExportDashboard {
return { id: item.id, title: item.spec.display?.name || item.name };
}
-function fromV1(dashboard: Dashboard): ExportDashboard {
- return { id: dashboard.id, title: dashboard.data.title ?? '' };
-}
-
-function filterByTitle(
- dashboards: ExportDashboard[],
- search: string,
-): ExportDashboard[] {
- const term = search.trim().toLowerCase();
- if (!term) {
- return dashboards;
- }
- return dashboards.filter((dashboard) =>
- dashboard.title.toLowerCase().includes(term),
- );
-}
-
// The V2 list `query` is a filter DSL (`key OP value`), not free text — wrap a typed term
// as a name-contains clause (single quotes escaped).
function toNameQuery(search: string): string | undefined {
@@ -54,37 +34,28 @@ function toNameQuery(search: string): string | undefined {
return term ? `name CONTAINS '${term.replace(/'/g, "\\'")}'` : undefined;
}
-/** Flag-aware picker source: V2 searches server-side (debounced), V1 filters in memory. */
+/** Picker source: searches the V2 dashboard list server-side (debounced). */
export function useExportDashboards(search = ''): UseExportDashboardsResult {
- const isDashboardV2 = useIsDashboardV2();
const debouncedSearch = useDebounce(search, SEARCH_DEBOUNCE_MS);
- const v1 = useGetAllDashboard({ enabled: !isDashboardV2 });
- const v2 = useListDashboardsForUserV2(
+ const listQuery = useListDashboardsForUserV2(
{ limit: V2_LIST_LIMIT, query: toNameQuery(debouncedSearch) },
- { query: { enabled: isDashboardV2, keepPreviousData: true } },
+ { query: { keepPreviousData: true } },
);
const dashboards = useMemo<ExportDashboard[]>(
- () =>
- isDashboardV2
- ? (v2.data?.data?.dashboards ?? []).map(fromV2)
- : filterByTitle((v1.data?.data ?? []).map(fromV1), search),
- [isDashboardV2, v1.data, v2.data, search],
+ () => (listQuery.data?.data?.dashboards ?? []).map(toExportDashboard),
+ [listQuery.data],
);
const refetch = useCallback((): void => {
- if (isDashboardV2) {
- void v2.refetch();
- } else {
- void v1.refetch();
- }
- }, [isDashboardV2, v1, v2]);
+ void listQuery.refetch();
+ }, [listQuery]);
return {
dashboards,
- isLoading: isDashboardV2 ? v2.isLoading : v1.isLoading,
- isFetching: isDashboardV2 ? v2.isFetching : v1.isFetching,
+ isLoading: listQuery.isLoading,
+ isFetching: listQuery.isFetching,
refetch,
};
}
diff --git a/frontend/src/hooks/dashboard/useGetExportToDashboardLink.ts b/frontend/src/hooks/dashboard/useGetExportToDashboardLink.ts
index 0dfcd4ea80..3d4a1aaaf5 100644
--- a/frontend/src/hooks/dashboard/useGetExportToDashboardLink.ts
+++ b/frontend/src/hooks/dashboard/useGetExportToDashboardLink.ts
@@ -1,9 +1,7 @@
import { useCallback } from 'react';
import type { PANEL_TYPES } from 'constants/queryBuilder';
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import { buildExportPanelLink } from 'pages/DashboardPageV2/DashboardContainer/PanelEditor/newPanelRoute';
import type { Query } from 'types/api/queryBuilder/queryBuilderData';
-import { generateExportToDashboardLink } from 'utils/dashboard/generateExportToDashboardLink';
interface ExportToDashboardLinkParams {
dashboardId: string;
@@ -13,25 +11,15 @@ interface ExportToDashboardLinkParams {
}
/**
- * Flag-aware "Add to Dashboard" link builder for the explorers. V2 targets the panel
- * editor; V1 uses the legacy new-widget link. `null` (V2 only) when the panel type has no
- * V2 kind, so callers skip navigation.
+ * "Add to Dashboard" link builder for the explorers. Targets the V2 panel editor;
+ * `null` when the panel type has no V2 kind, so callers skip navigation.
*/
export function useGetExportToDashboardLink(): (
params: ExportToDashboardLinkParams,
) => string | null {
- const isDashboardV2 = useIsDashboardV2();
-
return useCallback(
- ({ dashboardId, panelType, query, widgetId }: ExportToDashboardLinkParams) =>
- isDashboardV2
- ? buildExportPanelLink({ dashboardId, panelType, query })
- : generateExportToDashboardLink({
- query,
- panelType,
- dashboardId,
- widgetId,
- }),
- [isDashboardV2],
+ ({ dashboardId, panelType, query }: ExportToDashboardLinkParams) =>
+ buildExportPanelLink({ dashboardId, panelType, query }),
+ [],
);
}
diff --git a/frontend/src/hooks/useIsDashboardV2.ts b/frontend/src/hooks/useIsDashboardV2.ts
deleted file mode 100644
index 70c4150ee5..0000000000
--- a/frontend/src/hooks/useIsDashboardV2.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { FeatureKeys } from 'constants/features';
-import { useAppContext } from 'providers/App/App';
-
-export function useIsDashboardV2(): boolean {
- const { featureFlags } = useAppContext();
- return Boolean(
- featureFlags?.find((flag) => flag.name === FeatureKeys.USE_DASHBOARD_V2)
- ?.active,
- );
-}
diff --git a/frontend/src/pages/DashboardPage/index.tsx b/frontend/src/pages/DashboardPage/index.tsx
index 0bb878dd9b..091933fac0 100644
--- a/frontend/src/pages/DashboardPage/index.tsx
+++ b/frontend/src/pages/DashboardPage/index.tsx
@@ -1,15 +1,7 @@
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import DashboardPageV2 from 'pages/DashboardPageV2';
-import DashboardPage from './DashboardPage';
-
-// Serves the V2 dashboard detail page when the `use_dashboard_v2` flag is active;
-// otherwise the existing V1 page. Lets V2 dark-ship behind the flag without
-// changing route definitions.
function DashboardPageEntry(): JSX.Element {
- const isDashboardV2 = useIsDashboardV2();
-
- return isDashboardV2 ? <DashboardPageV2 /> : <DashboardPage />;
+ return <DashboardPageV2 />;
}
export default DashboardPageEntry;
diff --git a/frontend/src/pages/DashboardsListPage/index.tsx b/frontend/src/pages/DashboardsListPage/index.tsx
index 700b67bd7c..61bb156b1f 100644
--- a/frontend/src/pages/DashboardsListPage/index.tsx
+++ b/frontend/src/pages/DashboardsListPage/index.tsx
@@ -1,15 +1,7 @@
-import { useIsDashboardV2 } from 'hooks/useIsDashboardV2';
import DashboardsListPageV2 from 'pages/DashboardsListPageV2';
-import DashboardsListPage from './DashboardsListPage';
-
-// Serves the V2 dashboards list when the `use_dashboard_v2` flag is active;
-// otherwise the existing V1 list. Lets V2 dark-ship behind the flag without
-// changing route definitions.
function DashboardsListPageEntry(): JSX.Element {
- const isDashboardV2 = useIsDashboardV2();
-
- return isDashboardV2 ? <DashboardsListPageV2 /> : <DashboardsListPage />;
+ return <DashboardsListPageV2 />;
}
export default DashboardsListPageEntry;
diff --git a/pkg/flagger/registry.go b/pkg/flagger/registry.go
index f25c03f9f0..c97b41c8ba 100644
--- a/pkg/flagger/registry.go
+++ b/pkg/flagger/registry.go
@@ -11,7 +11,6 @@ var (
FeatureUseMeterReporter = featuretypes.MustNewName("use_meter_reporter")
FeatureUseJSONBody = featuretypes.MustNewName("use_json_body")
FeatureUseFineGrainedAuthz = featuretypes.MustNewName("use_fine_grained_authz")
- FeatureUseDashboardV2 = featuretypes.MustNewName("use_dashboard_v2")
FeatureEnableAIObservability = featuretypes.MustNewName("enable_ai_observability")
FeatureEnableMetricsReduction = featuretypes.MustNewName("enable_metrics_reduction")
FeatureUseInfraMonitoringV2 = featuretypes.MustNewName("use_infra_monitoring_v2")
@@ -83,14 +82,6 @@ func MustNewRegistry() featuretypes.Registry {
DefaultVariant: featuretypes.MustNewName("disabled"),
Variants: featuretypes.NewBooleanVariants(),
},
- &featuretypes.Feature{
- Name: FeatureUseDashboardV2,
- Kind: featuretypes.KindBoolean,
- Stage: featuretypes.StageExperimental,
- Description: "Controls whether dashboard v2 is enabled",
- DefaultVariant: featuretypes.MustNewName("disabled"),
- Variants: featuretypes.NewBooleanVariants(),
- },
&featuretypes.Feature{
Name: FeatureEnableAIObservability,
Kind: featuretypes.KindBoolean,
diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go
index 1b256ea262..f8712f1621 100644
--- a/pkg/query-service/app/http_handler.go
+++ b/pkg/query-service/app/http_handler.go
@@ -1605,15 +1605,6 @@ func (aH *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) {
Route: "",
})
- useDashboardV2 := aH.Signoz.Flagger.BooleanOrEmpty(r.Context(), flagger.FeatureUseDashboardV2, evalCtx)
- featureSet = append(featureSet, &licensetypes.Feature{
- Name: valuer.NewString(flagger.FeatureUseDashboardV2.String()),
- Active: useDashboardV2,
- Usage: 0,
- UsageLimit: -1,
- Route: "",
- })
-
aiObservability := aH.Signoz.Flagger.BooleanOrEmpty(r.Context(), flagger.FeatureEnableAIObservability, evalCtx)
featureSet = append(featureSet, &licensetypes.Feature{
Name: valuer.NewString(flagger.FeatureEnableAIObservability.String()),
diff --git a/pkg/signoz/provider.go b/pkg/signoz/provider.go
index 653acb6bc5..dcffa9f4f3 100644
--- a/pkg/signoz/provider.go
+++ b/pkg/signoz/provider.go
@@ -37,6 +37,7 @@ import (
"github.com/SigNoz/signoz/pkg/modules/promote/implpromote"
"github.com/SigNoz/signoz/pkg/modules/serviceaccount"
"github.com/SigNoz/signoz/pkg/modules/session/implsession"
+ "github.com/SigNoz/signoz/pkg/modules/tag"
"github.com/SigNoz/signoz/pkg/modules/user"
"github.com/SigNoz/signoz/pkg/modules/user/impluser"
"github.com/SigNoz/signoz/pkg/pprof"
@@ -66,6 +67,7 @@ import (
"github.com/SigNoz/signoz/pkg/tokenizer/opaquetokenizer"
"github.com/SigNoz/signoz/pkg/tokenizer/tokenizerstore/sqltokenizerstore"
"github.com/SigNoz/signoz/pkg/types/alertmanagertypes"
+ "github.com/SigNoz/signoz/pkg/types/dashboardtypes"
"github.com/SigNoz/signoz/pkg/types/featuretypes"
"github.com/SigNoz/signoz/pkg/version"
"github.com/SigNoz/signoz/pkg/web"
@@ -118,6 +120,8 @@ func NewSQLMigrationProviderFactories(
sqlschema sqlschema.SQLSchema,
telemetryStore telemetrystore.TelemetryStore,
providerSettings factory.ProviderSettings,
+ dashboardStore dashboardtypes.Store,
+ tagModule tag.Module,
) factory.NamedMap[factory.ProviderFactory[sqlmigration.SQLMigration, sqlmigration.Config]] {
return factory.MustNewNamedMap(
sqlmigration.NewAddDataMigrationsFactory(),
@@ -222,6 +226,7 @@ func NewSQLMigrationProviderFactories(
sqlmigration.NewAddTagUniqueIndexFactory(sqlstore, sqlschema),
sqlmigration.NewAddTelemetryTuplesFactory(sqlstore),
sqlmigration.NewAddTagRelationRankFactory(sqlstore, sqlschema),
+ sqlmigration.NewMigrateDashboardsV1ToV2Factory(sqlstore, sqlschema, dashboardStore, tagModule),
)
}
diff --git a/pkg/signoz/provider_test.go b/pkg/signoz/provider_test.go
index c7bccb7fd7..fc7f6c3457 100644
--- a/pkg/signoz/provider_test.go
+++ b/pkg/signoz/provider_test.go
@@ -12,7 +12,9 @@ import (
"github.com/SigNoz/signoz/pkg/flagger"
"github.com/SigNoz/signoz/pkg/global"
"github.com/SigNoz/signoz/pkg/instrumentation/instrumentationtest"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/organization/implorganization"
+ "github.com/SigNoz/signoz/pkg/modules/tag/impltag"
"github.com/SigNoz/signoz/pkg/modules/user/impluser"
"github.com/SigNoz/signoz/pkg/sqlschema"
"github.com/SigNoz/signoz/pkg/sqlschema/sqlschematest"
@@ -48,11 +50,14 @@ func TestNewProviderFactories(t *testing.T) {
})
assert.NotPanics(t, func() {
+ store := sqlstoretest.New(sqlstore.Config{Provider: "sqlite"}, sqlmock.QueryMatcherEqual)
NewSQLMigrationProviderFactories(
- sqlstoretest.New(sqlstore.Config{Provider: "sqlite"}, sqlmock.QueryMatcherEqual),
+ store,
sqlschematest.New(map[string]*sqlschema.Table{}, map[string][]*sqlschema.UniqueConstraint{}, map[string]sqlschema.Index{}),
telemetrystoretest.New(telemetrystore.Config{Provider: "clickhouse"}, sqlmock.QueryMatcherEqual),
instrumentationtest.New().ToProviderSettings(),
+ impldashboard.NewStore(store),
+ impltag.NewModule(impltag.NewStore(store)),
)
})
diff --git a/pkg/signoz/signoz.go b/pkg/signoz/signoz.go
index e6db688cba..91983889c9 100644
--- a/pkg/signoz/signoz.go
+++ b/pkg/signoz/signoz.go
@@ -27,6 +27,7 @@ import (
"github.com/SigNoz/signoz/pkg/modules/authdomain/implauthdomain"
"github.com/SigNoz/signoz/pkg/modules/cloudintegration"
"github.com/SigNoz/signoz/pkg/modules/dashboard"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/metricreductionrule"
"github.com/SigNoz/signoz/pkg/modules/organization"
"github.com/SigNoz/signoz/pkg/modules/organization/implorganization"
@@ -276,12 +277,20 @@ func New(
return nil, err
}
+ // Initialize tag module — shared across modules that link entities to tags
+ // (currently dashboard; future: alerts, RBAC). Built once here and injected
+ // where needed.
+ tagModule := impltag.NewModule(impltag.NewStore(sqlstore))
+
+ // Dashboard store, injected into the migrations that reshape stored dashboards.
+ dashboardStore := impldashboard.NewStore(sqlstore)
+
// Run migrations on the sqlstore
sqlmigrations, err := sqlmigration.New(
ctx,
providerSettings,
config.SQLMigration,
- NewSQLMigrationProviderFactories(sqlstore, sqlschema, telemetrystore, providerSettings),
+ NewSQLMigrationProviderFactories(sqlstore, sqlschema, telemetrystore, providerSettings, dashboardStore, tagModule),
)
if err != nil {
return nil, err
@@ -338,11 +347,6 @@ func New(
// Initialize query parser (needed for dashboard module)
queryParser := queryparser.New(providerSettings)
- // Initialize tag module — shared across modules that link entities to tags
- // (currently dashboard; future: alerts, RBAC). Built once here and injected
- // where needed.
- tagModule := impltag.NewModule(impltag.NewStore(sqlstore))
-
// Initialize dashboard module
dashboard := dashboardModuleCallback(sqlstore, providerSettings, analytics, orgGetter, queryParser, querier, licensing, tagModule)
diff --git a/pkg/sqlmigration/103_migrate_dashboards_v1_to_v2.go b/pkg/sqlmigration/103_migrate_dashboards_v1_to_v2.go
new file mode 100644
index 0000000000..fa10eb2563
--- /dev/null
+++ b/pkg/sqlmigration/103_migrate_dashboards_v1_to_v2.go
@@ -0,0 +1,153 @@
+package sqlmigration
+
+import (
+ "context"
+ "log/slog"
+
+ "github.com/SigNoz/signoz/pkg/factory"
+ "github.com/SigNoz/signoz/pkg/modules/tag"
+ "github.com/SigNoz/signoz/pkg/sqlschema"
+ "github.com/SigNoz/signoz/pkg/sqlstore"
+ "github.com/SigNoz/signoz/pkg/transition"
+ "github.com/SigNoz/signoz/pkg/types"
+ "github.com/SigNoz/signoz/pkg/types/coretypes"
+ "github.com/SigNoz/signoz/pkg/types/dashboardtypes"
+ "github.com/SigNoz/signoz/pkg/types/tagtypes"
+ "github.com/SigNoz/signoz/pkg/valuer"
+ "github.com/uptrace/bun"
+ "github.com/uptrace/bun/migrate"
+)
+
+type migrateDashboardsV1ToV2 struct {
+ sqlstore sqlstore.SQLStore
+ sqlschema sqlschema.SQLSchema
+ dashboardStore dashboardtypes.Store
+ tagModule tag.Module
+ settings factory.ProviderSettings
+}
+
+func NewMigrateDashboardsV1ToV2Factory(sqlstore sqlstore.SQLStore, sqlschema sqlschema.SQLSchema, dashboardStore dashboardtypes.Store, tagModule tag.Module) factory.ProviderFactory[SQLMigration, Config] {
+ return factory.NewProviderFactory(
+ factory.MustNewName("migrate_dashboards_v1_to_v2"),
+ func(ctx context.Context, ps factory.ProviderSettings, c Config) (SQLMigration, error) {
+ return &migrateDashboardsV1ToV2{sqlstore: sqlstore, sqlschema: sqlschema, dashboardStore: dashboardStore, tagModule: tagModule, settings: ps}, nil
+ },
+ )
+}
+
+func (migration *migrateDashboardsV1ToV2) Register(migrations *migrate.Migrations) error {
+ return migrations.Register(migration.Up, migration.Down)
+}
+
+// Up converts every v1 dashboard in every org to the v2 schema in place. Each
+// dashboard runs the v4→v5 query migration, is converted to v2, has its stored
+// data overwritten, and its tags synced. Dashboards already in v2 are skipped, and
+// dashboards whose data can't be converted are logged and left on v1 rather than
+// aborting the run, so one irrecoverably malformed dashboard can't wedge startup.
+//
+// Every write — data, tags, names, and the unique index — happens in a single
+// transaction, so any error other than a per-dashboard conversion failure leaves
+// every dashboard on v1 instead of a half-converted mix. The tag sync's own
+// RunInTx joins this transaction rather than opening a second one.
+func (migration *migrateDashboardsV1ToV2) Up(ctx context.Context, _ *bun.DB) error {
+ return migration.sqlstore.RunInTxCtx(ctx, nil, func(ctx context.Context) error {
+ var orgIDs []string
+ if err := migration.sqlstore.BunDBCtx(ctx).NewSelect().Model((*types.Organization)(nil)).Column("id").Scan(ctx, &orgIDs); err != nil {
+ return err
+ }
+
+ for _, id := range orgIDs {
+ orgID, err := valuer.NewUUID(id)
+ if err != nil {
+ return err
+ }
+ if err := migration.convertOrg(ctx, orgID); err != nil {
+ return err
+ }
+ }
+
+ // Every dashboard now has a name (migrated, or backfilled from the v1 title), so a
+ // v2 dashboard's (org_id, name) can be made unique.
+ sqls := migration.sqlschema.Operator().CreateIndex(&sqlschema.UniqueIndex{
+ TableName: "dashboard",
+ ColumnNames: []sqlschema.ColumnName{"org_id", "name"},
+ })
+ for _, sql := range sqls {
+ if _, err := migration.sqlstore.BunDBCtx(ctx).ExecContext(ctx, string(sql)); err != nil {
+ return err
+ }
+ }
+
+ return nil
+ })
+}
+
+// convertOrg converts every v1 dashboard in the org, skipping v2 dashboards and
+// recording (not propagating) dashboards whose data won't convert. Runs inside the
+// caller's transaction, so every failure that did touch the database propagates —
+// swallowing one would leave writes the caller can no longer undo selectively.
+func (migration *migrateDashboardsV1ToV2) convertOrg(ctx context.Context, orgID valuer.UUID) error {
+ storables, err := migration.dashboardStore.List(ctx, orgID)
+ if err != nil {
+ return err
+ }
+
+ logger := migration.settings.Logger
+ // The v1→v2 conversion assumes v5-shaped widget queries, so run the v4→v5
+ // migration first (in place) — same pass the create path runs.
+ v5 := transition.NewDashboardMigrateV5(logger, nil, nil)
+
+ var migrated, skipped, failed int
+ for _, storable := range storables {
+ if storable.IsV2() {
+ skipped++
+ continue
+ }
+
+ v5.Migrate(ctx, storable.Data)
+
+ v2, err := storable.ConvertV1ToV2()
+ if err != nil {
+ failed++
+ logger.WarnContext(ctx, "failed to convert dashboard from v1 to v2", slog.String("org_id", orgID.String()), slog.String("dashboard_id", storable.ID.String()), slog.Any("error", err))
+ // Backfill the name column from the v1 title even though the data couldn't
+ // migrate, so the dashboard stays findable by name. Only when it's unset, so a
+ // retry doesn't regenerate a different (randomly-suffixed) name.
+ if storable.Name == "" {
+ if err := migration.dashboardStore.UpdateName(ctx, orgID, storable.ID, storable.V1Name()); err != nil {
+ return err
+ }
+ }
+ continue
+ }
+
+ if err := migration.writeV2Dashboard(ctx, orgID, v2); err != nil {
+ return err
+ }
+ migrated++
+ }
+
+ logger.InfoContext(ctx, "converted dashboards from v1 to v2", slog.String("org_id", orgID.String()), slog.Int("total", len(storables)), slog.Int("migrated", migrated), slog.Int("skipped", skipped), slog.Int("failed", failed))
+ return nil
+}
+
+// writeV2Dashboard syncs a converted dashboard's tags and overwrites its stored
+// data with the v2 shape.
+func (migration *migrateDashboardsV1ToV2) writeV2Dashboard(ctx context.Context, orgID valuer.UUID, v2 *dashboardtypes.DashboardV2) error {
+ resolvedTags, err := migration.tagModule.SyncTags(ctx, orgID, coretypes.KindDashboard, v2.ID, tagtypes.NewPostableTagsFromTags(v2.Tags))
+ if err != nil {
+ return err
+ }
+ v2.Tags = resolvedTags
+
+ v2Storable, err := v2.ToStorableDashboard()
+ if err != nil {
+ return err
+ }
+
+ return migration.dashboardStore.Update(ctx, orgID, v2Storable)
+}
+
+func (migration *migrateDashboardsV1ToV2) Down(context.Context, *bun.DB) error {
+ return nil
+}