mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Logs panel: Table UI - Guess string field types (#82397)
* Guess field type for string fields in logs table
This commit is contained in:
parent
705ab460a2
commit
4dcc59244a
@ -164,7 +164,7 @@ describe('LogsTable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render `tsNs`', async () => {
|
it('should not render `tsNs` column', async () => {
|
||||||
setup(undefined, getMockLokiFrame());
|
setup(undefined, getMockLokiFrame());
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
@ -174,6 +174,28 @@ describe('LogsTable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render numeric field aligned right', async () => {
|
||||||
|
setup(
|
||||||
|
{
|
||||||
|
columnsWithMeta: {
|
||||||
|
Time: { active: true, percentOfLinesWithLabel: 100, index: 0 },
|
||||||
|
line: { active: true, percentOfLinesWithLabel: 100, index: 1 },
|
||||||
|
tsNs: { active: true, percentOfLinesWithLabel: 100, index: 2 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
getMockLokiFrame()
|
||||||
|
);
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
const columns = screen.queryAllByRole('columnheader', { name: 'tsNs' });
|
||||||
|
expect(columns.length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
const cells = screen.queryAllByRole('cell');
|
||||||
|
|
||||||
|
expect(cells[cells.length - 1].style.textAlign).toBe('right');
|
||||||
|
});
|
||||||
|
|
||||||
it('should not render `labels`', async () => {
|
it('should not render `labels`', async () => {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
DataTransformerConfig,
|
DataTransformerConfig,
|
||||||
Field,
|
Field,
|
||||||
FieldType,
|
FieldType,
|
||||||
|
guessFieldTypeForField,
|
||||||
LogsSortOrder,
|
LogsSortOrder,
|
||||||
sortDataFrame,
|
sortDataFrame,
|
||||||
SplitOpen,
|
SplitOpen,
|
||||||
@ -86,6 +87,9 @@ export function LogsTable(props: Props) {
|
|||||||
// This sets the individual field value as filterable
|
// This sets the individual field value as filterable
|
||||||
filterable: isFieldFilterable(field, logsFrame?.bodyField.name ?? '', logsFrame?.timeField.name ?? ''),
|
filterable: isFieldFilterable(field, logsFrame?.bodyField.name ?? '', logsFrame?.timeField.name ?? ''),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If it's a string, then try to guess for a better type for numeric support in viz
|
||||||
|
field.type = field.type === FieldType.string ? guessFieldTypeForField(field) ?? FieldType.string : field.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return frameWithOverrides;
|
return frameWithOverrides;
|
||||||
|
Loading…
Reference in New Issue
Block a user