Skip to content

Commit 1e4afd6

Browse files
committed
refactor: update WorkerStatus component to use isTimeStringAvailable helper for improved timeout logic
1 parent 38cdf91 commit 1e4afd6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Shared/Components/CICDHistory/WorkerStatus.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NavLink } from 'react-router-dom'
44
import moment from 'moment'
55
import { ReactComponent as ICLines } from '@Icons/ic-lines.svg'
66
import { ReactComponent as ICWarningY5 } from '@Icons/ic-warning-y5.svg'
7-
import { ZERO_TIME_STRING } from '@Common/Constants'
7+
import { isTimeStringAvailable } from '@Shared/Helpers'
88
import { ShowMoreText } from '../ShowMoreText'
99
import { FAILED_WORKFLOW_STAGE_STATUS_MAP, TIMEOUT_VALUE, WORKFLOW_STAGE_STATUS_TO_TEXT_MAP } from './constants'
1010
import { getWorkerPodBaseUrl } from './utils'
@@ -27,10 +27,12 @@ const WorkerStatus = memo(
2727
if (!message && !podStatus) {
2828
return null
2929
}
30-
// check if finishedOn time is timed out or not
31-
const isTimedOut = moment(finishedOn).isBefore(moment().subtract(TIMEOUT_VALUE, 'hours'))
32-
// finishedOn is 0001-01-01T00:00:00Z when the worker is still running
33-
const showLink = workerPodName && (finishedOn === ZERO_TIME_STRING || !isTimedOut)
30+
31+
// Logic is workerPodName should be available and, if finishedOn is available, it should be less than timeout value
32+
const showLink =
33+
workerPodName &&
34+
(!isTimeStringAvailable(finishedOn) ||
35+
!moment(finishedOn).isBefore(moment().subtract(TIMEOUT_VALUE, 'hours')))
3436

3537
const getViewWorker = () =>
3638
showLink ? (

0 commit comments

Comments
 (0)