Просмотр исходного кода

Merge branch 'belanger/agent-v3-integration' of https://github.com/porter-dev/porter into belanger/agent-v3-integration

Alexander Belanger 3 лет назад
Родитель
Сommit
f8a847b038

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChartWrapper.tsx

@@ -9,7 +9,7 @@ import {
   StorageType,
 } from "shared/types";
 import api from "shared/api";
-import { getQueryParam, pushFiltered } from "shared/routing";
+import { pushFiltered } from "shared/routing";
 import { ExpandedJobChartFC } from "./ExpandedJobChart";
 import ExpandedChart from "./ExpandedChart";
 import Loading from "components/Loading";

+ 3 - 6
dashboard/src/main/home/cluster-dashboard/expanded-chart/events/EventList.tsx

@@ -16,8 +16,6 @@ import time from "assets/time.svg";
 import { Context } from "shared/Context";
 import { InitLogData } from "../logs-section/LogsSection";
 
-const iconDict: any = {};
-
 type Props = {
   filters: any;
   setLogData?: (logData: InitLogData) => void;
@@ -27,7 +25,6 @@ const EventList: React.FC<Props> = ({ filters, setLogData }) => {
   const { currentProject, currentCluster } = useContext(Context);
   const [events, setEvents] = useState([]);
   const [expandedEvent, setExpandedEvent] = useState(null);
-  const [expandedEventDetails, setExpandedEventDetails] = useState(null);
   const [expandedIncidentEvents, setExpandedIncidentEvents] = useState(null);
   const [isLoading, setIsLoading] = useState(true);
 
@@ -75,9 +72,9 @@ const EventList: React.FC<Props> = ({ filters, setLogData }) => {
         }
       )
       .then((res) => {
-        let podName = res.data?.events[0]?.pod_name;
-        let timestamp = res.data?.events[0]?.last_seen;
-        let revision = res.data?.events[0]?.revision;
+        const podName = res.data?.events[0]?.pod_name;
+        const timestamp = res.data?.events[0]?.last_seen;
+        const revision = res.data?.events[0]?.revision;
 
         setLogData({
           podName,

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

@@ -21,11 +21,11 @@ import Loading from "components/Loading";
 import _ from "lodash";
 import { ChartType } from "shared/types";
 
-export type InitLogData = {
+export type InitLogData = Partial<{
   podName: string;
   timestamp: string;
   revision: string;
-};
+}>;
 
 type Props = {
   currentChart?: ChartType;
@@ -96,19 +96,19 @@ const LogsSection: React.FC<Props> = ({
   currentChart,
   isFullscreen,
   setIsFullscreen,
-  initData,
+  initData = {},
 }) => {
   const scrollToBottomRef = useRef<HTMLDivElement | undefined>(undefined);
   const { currentProject, currentCluster } = useContext(Context);
-  const [podFilter, setPodFilter] = useState(initData?.podName);
+  const [podFilter, setPodFilter] = useState(initData.podName);
   const [podFilterOpts, setPodFilterOpts] = useState<string[]>(
-    initData ? [initData?.podName] : null
+    _.compact([initData.podName])
   );
   const [scrollToBottomEnabled, setScrollToBottomEnabled] = useState(true);
   const [searchText, setSearchText] = useState("");
   const [enteredSearchText, setEnteredSearchText] = useState("");
   const [selectedDate, setSelectedDate] = useState<Date | undefined>(
-    initData ? dayjs(initData?.timestamp).toDate() : undefined
+    initData ? dayjs(initData.timestamp).toDate() : undefined
   );
 
   const { loading, logs, refresh, moveCursor, paginationInfo } = useLogs(
@@ -124,7 +124,7 @@ const LogsSection: React.FC<Props> = ({
       .getLogPodValues(
         "<TOKEN>",
         {
-          revision: currentChart.version.toString(),
+          revision: initData.revision ?? currentChart.version.toString(),
           match_prefix: currentChart.name,
         },
         {
@@ -136,7 +136,7 @@ const LogsSection: React.FC<Props> = ({
         setPodFilterOpts(_.uniq(res.data ?? []));
 
         // only set pod filter if the current pod is not found in the resulting data
-        if (!res.data?.contains(podFilter)) {
+        if (!res.data?.includes(podFilter)) {
           setPodFilter(res.data[0]);
         }
       });