mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 03:02:03 +08:00
fix: dashboard variable getting deleted on edit instances (#1561)
This commit is contained in:
parent
eaadc3bb95
commit
c43dabdb0b
@ -33,7 +33,7 @@ const { Option } = Select;
|
|||||||
interface VariableItemProps {
|
interface VariableItemProps {
|
||||||
variableData: IDashboardVariable;
|
variableData: IDashboardVariable;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
onSave: (name: string, arg0: IDashboardVariable) => void;
|
onSave: (name: string, arg0: IDashboardVariable, arg1: string) => void;
|
||||||
validateName: (arg0: string) => boolean;
|
validateName: (arg0: string) => boolean;
|
||||||
variableViewMode: TVariableViewMode;
|
variableViewMode: TVariableViewMode;
|
||||||
}
|
}
|
||||||
@ -118,8 +118,11 @@ function VariableItem({
|
|||||||
modificationUUID: v4(),
|
modificationUUID: v4(),
|
||||||
};
|
};
|
||||||
onSave(
|
onSave(
|
||||||
(variableViewMode === 'EDIT' ? variableData.name : variableName) as string,
|
variableName,
|
||||||
newVariableData,
|
newVariableData,
|
||||||
|
(variableViewMode === 'EDIT' && variableName !== variableData.name
|
||||||
|
? variableData.name
|
||||||
|
: '') as string,
|
||||||
);
|
);
|
||||||
onCancel();
|
onCancel();
|
||||||
};
|
};
|
||||||
@ -162,7 +165,9 @@ function VariableItem({
|
|||||||
value={variableName}
|
value={variableName}
|
||||||
onChange={(e): void => {
|
onChange={(e): void => {
|
||||||
setVariableName(e.target.value);
|
setVariableName(e.target.value);
|
||||||
setErrorName(!validateName(e.target.value));
|
setErrorName(
|
||||||
|
!validateName(e.target.value) && e.target.value !== variableData.name,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
|
@ -62,13 +62,19 @@ function VariablesSetting({
|
|||||||
const onVariableSaveHandler = (
|
const onVariableSaveHandler = (
|
||||||
name: string,
|
name: string,
|
||||||
variableData: IDashboardVariable,
|
variableData: IDashboardVariable,
|
||||||
|
oldName: string,
|
||||||
): void => {
|
): void => {
|
||||||
if (!variableData.name) {
|
if (!variableData.name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newVariables = { ...variables };
|
const newVariables = { ...variables };
|
||||||
newVariables[variableData.name] = variableData;
|
newVariables[name] = variableData;
|
||||||
if (variableViewMode === 'EDIT') delete newVariables[name];
|
|
||||||
|
if (oldName) {
|
||||||
|
delete newVariables[oldName];
|
||||||
|
}
|
||||||
|
|
||||||
updateDashboardVariables(newVariables);
|
updateDashboardVariables(newVariables);
|
||||||
onDoneVariableViewMode();
|
onDoneVariableViewMode();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user