Skip to content

Commit

Permalink
fix: list panel not querying selected columns (#5452)
Browse files Browse the repository at this point in the history
Added log and traces columns to query for list panels
  Closes #5064

Co-authored-by: Vikrant Gupta <[email protected]>
  • Loading branch information
bka9 and vikrantgupta25 authored Jul 17, 2024
1 parent 43e73e0 commit 77eba9a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/src/container/GridCardLayout/GridCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { memo, useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { UpdateTimeInterval } from 'store/actions';
import { AppState } from 'store/reducers';
import { DataSource } from 'types/common/queryBuilder';
import { GlobalReducer } from 'types/reducer/globalTime';
import { getGraphType } from 'utils/getGraphType';
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
Expand Down Expand Up @@ -113,6 +114,7 @@ function GridCardGraph({
};
}
updatedQuery.builder.queryData[0].pageSize = 10;
const initialDataSource = updatedQuery.builder.queryData[0].dataSource;
return {
query: updatedQuery,
graphType: PANEL_TYPES.LIST,
Expand All @@ -123,6 +125,10 @@ function GridCardGraph({
offset: 0,
limit: updatedQuery.builder.queryData[0].limit || 0,
},
selectColumns:
initialDataSource === DataSource.LOGS
? widget.selectedLogFields
: widget.selectedTracesFields,
},
fillGaps: widget.fillSpans,
};
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/container/NewWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,29 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [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 (
<Container>
<div className="edit-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function TracesTableComponent({
setRequestData((prev) => ({
...prev,
tableParams: {
...prev.tableParams,
pagination,
},
}));
Expand Down

0 comments on commit 77eba9a

Please sign in to comment.