Kaynağa Gözat

fix: hide load previous when no more logs

Soham Parekh 3 yıl önce
ebeveyn
işleme
edf8293372

+ 1 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/LogsSection.tsx

@@ -233,8 +233,7 @@ const LogsSection: React.FC<Props> = ({
             <>
             <>
               <LoadMoreButton
               <LoadMoreButton
                 active={
                 active={
-                  logs.length !== 0 &&
-                  (!selectedDate || paginationInfo.previousCursor !== null)
+                  logs.length !== 0 && paginationInfo.previousCursor !== null
                 }
                 }
                 role="button"
                 role="button"
                 onClick={onLoadPrevious}
                 onClick={onLoadPrevious}
@@ -468,7 +467,6 @@ const SearchRow = styled.div`
   background: #26292e;
   background: #26292e;
   border-radius: 5px;
   border-radius: 5px;
   border: 1px solid #aaaabb33;
   border: 1px solid #aaaabb33;
-  display: none;
 `;
 `;
 
 
 const SearchRowWrapper = styled(SearchRow)`
 const SearchRowWrapper = styled(SearchRow)`

+ 7 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/useAgentLogs.ts

@@ -173,9 +173,9 @@ export const useLogs = (
       onmessage: (evt: MessageEvent) => {
       onmessage: (evt: MessageEvent) => {
         // Nothing to do here
         // Nothing to do here
         if (!evt?.data || typeof evt.data !== "string") {
         if (!evt?.data || typeof evt.data !== "string") {
-          return
+          return;
         }
         }
-        
+
         const newLogs = parseLogs(
         const newLogs = parseLogs(
           evt?.data?.split("}\n").map((line: string) => line + "}")
           evt?.data?.split("}\n").map((line: string) => line + "}")
         );
         );
@@ -225,7 +225,11 @@ export const useLogs = (
 
 
         return {
         return {
           logs: newLogs,
           logs: newLogs,
-          previousCursor: res.data.backward_continue_time,
+          previousCursor:
+            // There are no more historical logs so don't set the previous cursor
+            newLogs.length < QUERY_LIMIT && direction == Direction.backward
+              ? null
+              : res.data.backward_continue_time,
           nextCursor: res.data.forward_continue_time,
           nextCursor: res.data.forward_continue_time,
         };
         };
       });
       });