SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(dashboard): honour "open in new tab" on v2 context links (#12836)
Abhi kumarf9294367b116
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/__tests__/drilldown.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/__tests__/drilldown.test.tsindex 967bed7fc2..a9b408fc1d 100644--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/__tests__/drilldown.test.ts+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/__tests__/drilldown.test.ts@@ -426,6 +426,30 @@ describe('resolvePanelContextLinks', () => {expect(resolved[0].url).toBe('https://wiki/{{_service.name}}');});++ it('carries targetBlank through, defaulting to true when unset', () => {+ const resolved = resolvePanelContextLinks(+ [+ { name: 'Same tab', url: 'https://wiki/a', targetBlank: false },+ { name: 'New tab', url: 'https://wiki/b', targetBlank: true },+ { name: 'Unset', url: 'https://wiki/c' },+ {+ name: 'Literal',+ url: 'https://wiki/d',+ targetBlank: false,+ renderVariables: false,+ },+ ],+ {},+ );++ expect(resolved.map((link) => link.targetBlank)).toStrictEqual([+ false,+ true,+ true,+ false,+ ]);+ });});describe('stepClickTimeRange', () => {diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/resolvePanelContextLinks.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/resolvePanelContextLinks.tsindex c56a0a7cc1..b42b68406f 100644--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/resolvePanelContextLinks.ts+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/utils/drilldown/resolvePanelContextLinks.ts@@ -8,6 +8,8 @@ export interface ResolvedDrilldownLink {id: string;label: string;url: string;+ /** Opens in a new tab; links saved before the toggle existed default to true. */+ targetBlank: boolean;}/**@@ -26,14 +28,16 @@ export function resolvePanelContextLinks(return usable.map((link, index) => {const rawLabel = link.name || link.url || '';const rawUrl = link.url ?? '';+ const targetBlank = link.targetBlank ?? true;// Only an explicit `false` opts out; undefined defaults to substitution on.if (link.renderVariables === false) {- return { id: String(index), label: rawLabel, url: rawUrl };+ return { id: String(index), label: rawLabel, url: rawUrl, targetBlank };}return {id: String(index),label: resolveTexts({ texts: [rawLabel], processedVariables }).fullTexts[0],url: resolveContextLinkUrl(rawUrl, processedVariables),+ targetBlank,};});}diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/DrilldownMenu/DrilldownAggregateMenu.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/DrilldownMenu/DrilldownAggregateMenu.tsxindex 741a016877..5381cbf655 100644--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/DrilldownMenu/DrilldownAggregateMenu.tsx+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/DrilldownMenu/DrilldownAggregateMenu.tsx@@ -173,7 +173,7 @@ function DrilldownAggregateMenu({void logEvent(DashboardDetailEvents.DrilldownAction, {action: 'contextLink',});- openInNewTab(link.url);+ openInNewTab(link.url, !!link.targetBlank);onClose();}}>diff --git a/frontend/src/utils/navigation.ts b/frontend/src/utils/navigation.tsindex 23096f3a5a..45de0dd121 100644--- a/frontend/src/utils/navigation.ts+++ b/frontend/src/utils/navigation.ts@@ -1,5 +1,9 @@import { withBasePath } from 'utils/basePath';-export const openInNewTab = (path: string): void => {- window.open(withBasePath(path), '_blank');+export const openInNewTab = (path: string, newTab = true): void => {+ if (newTab) {+ window.open(withBasePath(path), '_blank');+ } else {+ window.location.assign(withBasePath(path));+ }};