Prechádzať zdrojové kódy

Filters v2 , pagination issue during the newest first and oldest first.

Mgrdich 2 rokov pred
rodič
commit
eb873783c7

+ 1 - 4
kafka-ui-react-app/src/components/Topics/Topic/MessagesV2/Messages.tsx

@@ -41,10 +41,7 @@ const Messages = () => {
   // Pagination is disabled in live mode, also we don't want to show the button
   // if we are fetching the messages or if we are at the end of the topic
   const isPaginationDisabled =
-    isTailing ||
-    ['newest', 'oldest'].includes(mode) || // TODO: remove after BE is fixed
-    isFetching ||
-    !searchParams.get('seekTo');
+    isTailing || isFetching || !searchParams.get('seekTo');
 
   const isNextPageButtonDisabled =
     isPaginationDisabled ||

+ 3 - 2
kafka-ui-react-app/src/components/Topics/Topic/MessagesV2/utils/handleNextPageClick.ts

@@ -30,15 +30,16 @@ export default (
 
     switch (mode) {
       case 'fromOffset':
-      case 'oldest':
         // First message in the reversed array is the message with max offset.
         // Replace offset in seekTo query param with the max offset for
         // each partition from displayed messages array.
         return { partition, offset: Math.max(message.offset, offset) };
       case 'toOffset':
-      case 'newest':
         // First message in the reversed array is the message with min offset.
         return { partition, offset: Math.min(message.offset, offset) };
+      case 'oldest':
+      case 'newest':
+        return { partition, offset: message.offset };
       case 'sinceTime':
         // First message in the reversed array is the message with max timestamp.
         return {

+ 6 - 0
kafka-ui-react-app/src/lib/hooks/api/topicMessages.tsx

@@ -93,6 +93,12 @@ export const useTopicMessages = ({
           break;
       }
 
+      // 0 case is null
+      if (searchParams.get('page')) {
+        // if the pagination is working then seekType is offset
+        requestParams.set('seekType', SeekType.OFFSET);
+      }
+
       await fetchEventSource(`${url}?${requestParams.toString()}`, {
         method: 'GET',
         signal: abortController.signal,