Skip to content

Commit 20e1aaf

Browse files
authored
[klogs] Fix Page Parameter (#579)
When a query in the klogs plugin was adjusted, the page parameter still had the old value of the selected page, which could result in an empty result table. To fix this the page parameter is now always reset to 1 when a query or the time range is adjusted.
1 parent 93b9c77 commit 20e1aaf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

app/packages/klogs/src/components/LogsPage.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,15 @@ const LogsToolbar: FunctionComponent<{
248248
...times,
249249
order: additionalFields[1].value === 'ascending' ? 'ascending' : 'descending',
250250
orderBy: additionalFields[0].value,
251+
page: 1,
251252
query: query,
252253
});
253254
}
254255
};
255256

256257
const handleSubmit = () => {
257258
addStateHistoryItem('kobs-klogs-queryhistory', query);
258-
setOptions({ ...options, query: query });
259+
setOptions({ ...options, page: 1, query: query });
259260
};
260261

261262
useEffect(() => {
@@ -388,22 +389,22 @@ const LogsPage: FunctionComponent<IPluginPageProps> = ({ instance }) => {
388389
* `setTimes` changes the users selected time range to the provided `times`.
389390
*/
390391
const setTimes = (times: ITimes) => {
391-
setOptions({ ...options, ...times });
392+
setOptions({ ...options, ...times, page: 1 });
392393
};
393394

394395
/**
395396
* `addFilter` adds the given filter as string to the query, so that it can be used to filter down an existing query.
396397
*/
397398
const addFilter = (filter: string) => {
398-
setOptions({ ...options, query: `${options.query} ${filter}` });
399+
setOptions({ ...options, page: 1, query: `${options.query} ${filter}` });
399400
};
400401

401402
/**
402403
* `changeOrder` changes the order parameters for a query, to the provided `order` and `orderBy` values.
403404
*/
404405
const changeOrder = (orderBy: string): void => {
405406
const isAscending = options.orderBy === orderBy && options.order === 'ascending';
406-
setOptions({ ...options, order: isAscending ? 'descending' : 'ascending', orderBy: orderBy });
407+
setOptions({ ...options, order: isAscending ? 'descending' : 'ascending', orderBy: orderBy, page: 1 });
407408
};
408409

409410
return (

0 commit comments

Comments
 (0)