mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix error when changing operations with different parameters (#51779)
* copy defaultParams when changing an operation * add type and name comparison * removed name check
This commit is contained in:
parent
0a6eeaa636
commit
663f3fcd2a
@ -79,7 +79,16 @@ export const OperationHeader = React.memo<Props>(
|
||||
if (value.value) {
|
||||
// Operation should exist if it is selectable
|
||||
const newDef = queryModeller.getOperationDef(value.value.id)!;
|
||||
let changedOp = { ...operation, id: value.value.id };
|
||||
|
||||
// copy default params, and override with all current params
|
||||
const newParams = [...newDef.defaultParams];
|
||||
for (let i = 0; i < Math.min(operation.params.length, newParams.length); i++) {
|
||||
if (newDef.params[i].type === def.params[i].type) {
|
||||
newParams[i] = operation.params[i];
|
||||
}
|
||||
}
|
||||
|
||||
const changedOp = { ...operation, params: newParams, id: value.value.id };
|
||||
onChange(index, def.changeTypeHandler ? def.changeTypeHandler(changedOp, newDef) : changedOp);
|
||||
}
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user