Transformations: Fix field named Time matching all time fields
The byName and byNames matchers fall back to matching any time field when the configured name is Time or time, so configs keep working after the dataplane rename. The fallback also kicked in when the frame already had a field with that name, so hiding `time` in Organize fields hid every time field and Filter by name could not drop the other ones. The fallback now only applies when no field in the frame has that name or display name.
This commit is contained in:
1 parent
00681578cc
commit
47a8d79948
2 files changed
+40
-2
No files matched your search
@@ -115,8 +115,16 @@ function fieldNameFallback(fields: Set<string>) {
|
||||
);
|
||||
};
|
||||
} else if (fields.has('Time') || fields.has('time')) {
|
||||
fallback = (field: Field, frame: DataFrame) => {
|
||||
return frame.meta?.typeVersion == null && field.type === FieldType.time;
|
||||
const timeNames = ['Time', 'time'].filter((name) => fields.has(name));
|
||||
fallback = (field: Field, frame: DataFrame, allFrames: DataFrame[]) => {
|
||||
return (
|
||||
frame.meta?.typeVersion == null &&
|
||||
field.type === FieldType.time &&
|
||||
// A field that already carries the name is matched directly, so other time fields must not be pulled in
|
||||
!frame.fields.some(
|
||||
(f) => timeNames.includes(f.name) || timeNames.includes(getFieldDisplayName(f, frame, allFrames))
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user