mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 23:42:01 +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 {
|
||||
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>
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user