fix: list panel not querying selected columns (#5452)

Added log and traces columns to query for list panels
  Closes #5064

Co-authored-by: Vikrant Gupta <vikrant.thomso@gmail.com>
This commit is contained in:
B Kevin Anderson 2024-07-17 00:49:00 -06:00 committed by GitHub
parent 43e73e06fe
commit 77eba9a558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import { memo, useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { UpdateTimeInterval } from 'store/actions'; import { UpdateTimeInterval } from 'store/actions';
import { AppState } from 'store/reducers'; import { AppState } from 'store/reducers';
import { DataSource } from 'types/common/queryBuilder';
import { GlobalReducer } from 'types/reducer/globalTime'; import { GlobalReducer } from 'types/reducer/globalTime';
import { getGraphType } from 'utils/getGraphType'; import { getGraphType } from 'utils/getGraphType';
import { getSortedSeriesData } from 'utils/getSortedSeriesData'; import { getSortedSeriesData } from 'utils/getSortedSeriesData';
@ -113,6 +114,7 @@ function GridCardGraph({
}; };
} }
updatedQuery.builder.queryData[0].pageSize = 10; updatedQuery.builder.queryData[0].pageSize = 10;
const initialDataSource = updatedQuery.builder.queryData[0].dataSource;
return { return {
query: updatedQuery, query: updatedQuery,
graphType: PANEL_TYPES.LIST, graphType: PANEL_TYPES.LIST,
@ -123,6 +125,10 @@ function GridCardGraph({
offset: 0, offset: 0,
limit: updatedQuery.builder.queryData[0].limit || 0, limit: updatedQuery.builder.queryData[0].limit || 0,
}, },
selectColumns:
initialDataSource === DataSource.LOGS
? widget.selectedLogFields
: widget.selectedTracesFields,
}, },
fillGaps: widget.fillSpans, fillGaps: widget.fillSpans,
}; };

View File

@ -559,6 +559,29 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onSaveDashboard]); }, [onSaveDashboard]);
useEffect(() => {
if (selectedGraph === PANEL_TYPES.LIST) {
const initialDataSource = currentQuery.builder.queryData[0].dataSource;
if (initialDataSource === DataSource.LOGS) {
setRequestData((prev) => ({
...prev,
tableParams: {
...prev.tableParams,
selectColumns: selectedLogFields,
},
}));
} else if (initialDataSource === DataSource.TRACES) {
setRequestData((prev) => ({
...prev,
tableParams: {
...prev.tableParams,
selectColumns: selectedTracesFields,
},
}));
}
}
}, [selectedLogFields, selectedTracesFields, currentQuery, selectedGraph]);
return ( return (
<Container> <Container>
<div className="edit-header"> <div className="edit-header">

View File

@ -43,6 +43,7 @@ function TracesTableComponent({
setRequestData((prev) => ({ setRequestData((prev) => ({
...prev, ...prev,
tableParams: { tableParams: {
...prev.tableParams,
pagination, pagination,
}, },
})); }));