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 variable getting deleted on edit instances (#1561)

Pranshu Chittorac43dabdb0b8a
diff --git a/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/VariableItem.tsx b/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/VariableItem.tsx
index 31d443abff..f8a08f2677 100644
--- a/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/VariableItem.tsx
+++ b/frontend/src/container/NewDashboard/DashboardSettings/Variables/VariableItem/VariableItem.tsx
@@ -33,7 +33,7 @@ const { Option } = Select;
interface VariableItemProps {
variableData: IDashboardVariable;
onCancel: () => void;
- onSave: (name: string, arg0: IDashboardVariable) => void;
+ onSave: (name: string, arg0: IDashboardVariable, arg1: string) => void;
validateName: (arg0: string) => boolean;
variableViewMode: TVariableViewMode;
}
@@ -118,8 +118,11 @@ function VariableItem({
modificationUUID: v4(),
};
onSave(
- (variableViewMode === 'EDIT' ? variableData.name : variableName) as string,
+ variableName,
newVariableData,
+ (variableViewMode === 'EDIT' && variableName !== variableData.name
+ ? variableData.name
+ : '') as string,
);
onCancel();
};
@@ -162,7 +165,9 @@ function VariableItem({
value={variableName}
onChange={(e): void => {
setVariableName(e.target.value);
- setErrorName(!validateName(e.target.value));
+ setErrorName(
+ !validateName(e.target.value) && e.target.value !== variableData.name,
+ );
}}
/>
<div>
diff --git a/frontend/src/container/NewDashboard/DashboardSettings/Variables/index.tsx b/frontend/src/container/NewDashboard/DashboardSettings/Variables/index.tsx
index f070752ac4..02f2d3e9ae 100644
--- a/frontend/src/container/NewDashboard/DashboardSettings/Variables/index.tsx
+++ b/frontend/src/container/NewDashboard/DashboardSettings/Variables/index.tsx
@@ -62,13 +62,19 @@ function VariablesSetting({
const onVariableSaveHandler = (
name: string,
variableData: IDashboardVariable,
+ oldName: string,
): void => {
if (!variableData.name) {
return;
}
+
const newVariables = { ...variables };
- newVariables[variableData.name] = variableData;
- if (variableViewMode === 'EDIT') delete newVariables[name];
+ newVariables[name] = variableData;
+
+ if (oldName) {
+ delete newVariables[oldName];
+ }
+
updateDashboardVariables(newVariables);
onDoneVariableViewMode();
};