mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-31 09:12:08 +08:00
fix: handle the old variables by name instead of id (#4890)
This commit is contained in:
parent
731eacbbca
commit
38d2833931
@ -72,6 +72,7 @@ function DashboardVariableSelection(): JSX.Element | null {
|
|||||||
id: string,
|
id: string,
|
||||||
value: IDashboardVariable['selectedValue'],
|
value: IDashboardVariable['selectedValue'],
|
||||||
allSelected: boolean,
|
allSelected: boolean,
|
||||||
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||||
): void => {
|
): void => {
|
||||||
if (id) {
|
if (id) {
|
||||||
updateLocalStorageDashboardVariables(name, value, allSelected);
|
updateLocalStorageDashboardVariables(name, value, allSelected);
|
||||||
@ -79,17 +80,29 @@ function DashboardVariableSelection(): JSX.Element | null {
|
|||||||
if (selectedDashboard) {
|
if (selectedDashboard) {
|
||||||
setSelectedDashboard((prev) => {
|
setSelectedDashboard((prev) => {
|
||||||
if (prev) {
|
if (prev) {
|
||||||
|
const oldVariables = prev?.data.variables;
|
||||||
|
// this is added to handle case where we have two different
|
||||||
|
// schemas for variable response
|
||||||
|
if (oldVariables[id]) {
|
||||||
|
oldVariables[id] = {
|
||||||
|
...oldVariables[id],
|
||||||
|
selectedValue: value,
|
||||||
|
allSelected,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (oldVariables[name]) {
|
||||||
|
oldVariables[name] = {
|
||||||
|
...oldVariables[name],
|
||||||
|
selectedValue: value,
|
||||||
|
allSelected,
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
data: {
|
data: {
|
||||||
...prev?.data,
|
...prev?.data,
|
||||||
variables: {
|
variables: {
|
||||||
...prev?.data.variables,
|
...oldVariables,
|
||||||
[id]: {
|
|
||||||
...prev.data.variables[id],
|
|
||||||
selectedValue: value,
|
|
||||||
allSelected,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user