From 77b2e89e3163e86637076398ad8b8031f224a2db Mon Sep 17 00:00:00 2001 From: Juntao Wang Date: Fri, 3 May 2024 11:37:41 -0400 Subject: [PATCH] Remove step status icon on pipeline run log containers --- frontend/src/concepts/k8s/pods/utils.ts | 39 +------------------ .../pipelineRun/runLogs/LogsTab.tsx | 30 ++------------ .../pipelineRun/runLogs/usePodStepsStates.ts | 23 ----------- frontend/src/types.ts | 8 ---- 4 files changed, 5 insertions(+), 95 deletions(-) delete mode 100644 frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/usePodStepsStates.ts diff --git a/frontend/src/concepts/k8s/pods/utils.ts b/frontend/src/concepts/k8s/pods/utils.ts index 923bd2fb0b..73963f5a4a 100644 --- a/frontend/src/concepts/k8s/pods/utils.ts +++ b/frontend/src/concepts/k8s/pods/utils.ts @@ -1,5 +1,5 @@ import { PodKind } from '~/k8sTypes'; -import { PodContainer, PodContainerStatuses, PodStepState, PodStepStateType } from '~/types'; +import { PodContainer, PodContainerStatuses } from '~/types'; import { getPodContainerLogText } from '~/api'; import { downloadString } from '~/utilities/string'; @@ -54,40 +54,3 @@ ${logsIndividualStep}`, const combinedLogs = allStepLogs.join('\n'); downloadString(`${pod.metadata.name}-${completed ? 'full' : currentTimeStamp}.log`, combinedLogs); }; - -export const getPodStepsStates = async ( - podContainerStatuses: PodContainerStatuses, - namespace: string, - podName: string | undefined, -): Promise => { - const stepsStatesPromises = podContainerStatuses.reduce[]>( - (accumulator, podContainerStatus) => { - if (podContainerStatus && podName) { - const stepsStatePromise = getPodContainerLogText( - namespace, - podName, - podContainerStatus.name, - ) - .then((logsIndividualStep) => ({ - stepName: podContainerStatus.name || '', - state: - podContainerStatus.state?.running || podContainerStatus.state?.waiting - ? PodStepStateType.loading - : logsIndividualStep.toLowerCase().includes('error') - ? PodStepStateType.error - : podContainerStatus.state?.terminated - ? PodStepStateType.success - : PodStepStateType.loading, - })) - .catch(() => ({ - stepName: podContainerStatus.name || '', - state: PodStepStateType.error, - })); - accumulator.push(stepsStatePromise); - } - return accumulator; - }, - [], - ); - return Promise.all(stepsStatesPromises); -}; diff --git a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/LogsTab.tsx b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/LogsTab.tsx index 13bd5267f5..6b12489b23 100644 --- a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/LogsTab.tsx +++ b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/LogsTab.tsx @@ -3,7 +3,6 @@ import { Button, Checkbox, DropdownList, - Icon, Spinner, Stack, StackItem, @@ -20,10 +19,8 @@ import { PlayIcon } from '@patternfly/react-icons/dist/esm/icons/play-icon'; import { DownloadIcon } from '@patternfly/react-icons/dist/esm/icons/download-icon'; import { LogViewer, LogViewerSearch } from '@patternfly/react-log-viewer'; import { - CheckCircleIcon, CompressIcon, EllipsisVIcon, - ExclamationCircleIcon, ExpandIcon, OutlinedWindowRestoreIcon, } from '@patternfly/react-icons'; @@ -34,10 +31,8 @@ import usePodContainerLogState from '~/concepts/pipelines/content/pipelinesDetai import LogsTabStatus from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/LogsTabStatus'; import { LOG_TAIL_LINES } from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/const'; import { downloadAllStepLogs, downloadCurrentStepLog } from '~/concepts/k8s/pods/utils'; -import usePodStepsStates from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/usePodStepsStates'; import { usePipelinesAPI } from '~/concepts/pipelines/context'; import DownloadDropdown from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/DownloadDropdown'; -import { PodStepStateType } from '~/types'; import useDebounceCallback from '~/utilities/useDebounceCallback'; import { PipelineTask } from '~/concepts/pipelines/topology'; import { ExecutionStateKF } from '~/concepts/pipelines/kfTypes'; @@ -83,7 +78,6 @@ const LogsTabForPodName: React.FC<{ podName: string; isFailedPod: boolean }> = ( (podContainerStatus) => podContainerStatus?.name === podContainer.name, ), ); - const podStepStates = usePodStepsStates(sortedContainerStatuses, podName); const [downloading, setDownloading] = React.useState(false); const [downloadError, setDownloadError] = React.useState(); const logViewerRef = React.useRef<{ scrollToBottom: () => void }>(); @@ -244,26 +238,10 @@ const LogsTabForPodName: React.FC<{ podName: string; isFailedPod: boolean }> = ( ({ - key: podStepState.stepName, - label: podStepState.stepName, - dropdownLabel: ( - <> - {podStepState.stepName} - {podStepState.state === PodStepStateType.loading ? ( - - ) : podStepState.state === PodStepStateType.error ? ( - - - - ) : ( - - - - )} - - ), + isDisabled={sortedContainerStatuses.length <= 1} + options={sortedContainerStatuses.map((containerStatus) => ({ + key: containerStatus?.name || '', + label: containerStatus?.name || '', }))} value={containerName} placeholder="Select container..." diff --git a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/usePodStepsStates.ts b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/usePodStepsStates.ts deleted file mode 100644 index c467704b82..0000000000 --- a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/usePodStepsStates.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as React from 'react'; -import { PodContainerStatuses, PodStepState } from '~/types'; -import { usePipelinesAPI } from '~/concepts/pipelines/context'; -import { useDeepCompareMemoize } from '~/utilities/useDeepCompareMemoize'; -import { getPodStepsStates } from '~/concepts/k8s/pods/utils'; - -const usePodStepsStates = ( - sortedpodContainerStatuses: PodContainerStatuses, - podName: string, -): PodStepState[] => { - const { namespace } = usePipelinesAPI(); - const podContainerStatuses = useDeepCompareMemoize(sortedpodContainerStatuses); - const [allpodStepsState, setAllPodStepsState] = React.useState([]); - - React.useEffect(() => { - getPodStepsStates(podContainerStatuses, namespace, podName).then((result) => { - setAllPodStepsState(result); - }); - }, [podContainerStatuses, namespace, podName]); - return allpodStepsState; -}; - -export default usePodStepsStates; diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 68e9efd459..c47a5c88f2 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -331,14 +331,6 @@ export type PodContainer = { securityContext?: unknown; }; -export type PodStepState = { stepName: string; state: PodStepStateType }; - -export enum PodStepStateType { - success = 'Success', - error = 'Error', - loading = 'Loading', -} - export type PodContainerStatus = { name?: string; ready: boolean;