Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(dashboard-v2): add (not replace) description when it is empty (#11983)

Ashwin Bhatkal6251616d9d06
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/index.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/index.tsx
index a578d210c2..17caddbf06 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/index.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/DashboardSettings/Overview/index.tsx
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
+import { DashboardtypesPatchOpDTO } from 'api/generated/services/sigNoz.schemas';
import type {
DashboardtypesGettableDashboardV2DTO,
DashboardtypesJSONPatchOperationDTO,
@@ -54,20 +55,32 @@ function Overview({ dashboard }: OverviewProps): JSX.Element {
const buildPatch = useCallback((): DashboardtypesJSONPatchOperationDTO[] => {
const ops: DashboardtypesJSONPatchOperationDTO[] = [];
+ const op = (
+ operation: DashboardtypesJSONPatchOperationDTO['op'],
+ path: string,
+ value: unknown,
+ ): DashboardtypesJSONPatchOperationDTO => ({ op: operation, path, value });
const replace = (
path: string,
value: unknown,
- ): DashboardtypesJSONPatchOperationDTO => ({
- op: 'replace' as DashboardtypesJSONPatchOperationDTO['op'],
- path,
- value,
- });
+ ): DashboardtypesJSONPatchOperationDTO =>
+ op(DashboardtypesPatchOpDTO.replace, path, value);
if (updatedTitle !== title && updatedTitle !== '') {
ops.push(replace('/spec/display/name', updatedTitle));
}
if (updatedDescription !== description) {
- ops.push(replace('/spec/display/description', updatedDescription));
+ // `replace` fails when the description doesn't exist yet, so add it when
+ // the current one is empty (`add` creates or replaces the member).
+ ops.push(
+ op(
+ description
+ ? DashboardtypesPatchOpDTO.replace
+ : DashboardtypesPatchOpDTO.add,
+ '/spec/display/description',
+ updatedDescription,
+ ),
+ );
}
if (updatedImage !== image) {
ops.push(replace('/image', updatedImage));