Skip to content

Commit 8c72b07

Browse files
committed
fix: move computation of logs calculation from index to name+timestamp
1 parent 29e25e2 commit 8c72b07

File tree

7 files changed

+175
-161
lines changed

7 files changed

+175
-161
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.7",
3+
"version": "0.1.7-beta-6",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 125 additions & 158 deletions
Large diffs are not rendered by default.

src/Shared/Components/CICDHistory/constants.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ export const LOGS_RETRY_COUNT = 3
7878
export const DEPLOYMENT_STATUS_QUERY_PARAM = 'deployment-status'
7979

8080
export const MANIFEST_STATUS_HEADERS = ['KIND', 'NAME', 'SYNC STATUS', 'MESSAGE']
81+
82+
export const LOGS_STAGE_IDENTIFIER = 'STAGE_INFO'

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,23 @@ export interface TriggerHistoryFilterCriteriaProps {
672672
showCurrentReleaseDeployments: boolean
673673
}
674674

675+
export enum StageStatusType {
676+
SUCCESS = 'Success',
677+
FAILURE = 'Failure',
678+
}
679+
680+
export interface StageInfoDTO {
681+
stage: string
682+
startTime: string
683+
endTime?: string
684+
status: StageStatusType
685+
}
686+
687+
export interface StageDetailType extends Pick<StageInfoDTO, 'stage' | 'startTime' | 'endTime' | 'status'> {
688+
logs: string[]
689+
isOpen: boolean
690+
}
691+
675692
export type TriggerHistoryFilterCriteriaType = `${string}|${string}|${string}`[]
676693
export const terminalStatus = new Set(['error', 'healthy', 'succeeded', 'cancelled', 'failed', 'aborted'])
677694
export const statusSet = new Set(['starting', 'running', 'pending'])

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
DeploymentHistoryResultObject,
2020
DeploymentHistory,
2121
TriggerHistoryFilterCriteriaType,
22+
StageStatusType,
2223
} from './types'
2324
import { ResourceKindType } from '../../types'
2425
import { ReactComponent as Close } from '../../../Assets/Icon/ic-close.svg'
@@ -28,6 +29,8 @@ import { ReactComponent as Error } from '../../../Assets/Icon/ic-error-exclamati
2829
import { ReactComponent as Timer } from '../../../Assets/Icon/ic-timer.svg'
2930
import { ReactComponent as Disconnect } from '../../../Assets/Icon/ic-disconnected.svg'
3031
import { ReactComponent as TimeOut } from '../../../Assets/Icon/ic-timeout-red.svg'
32+
import { ReactComponent as ICCheck } from '../../../Assets/Icon/ic-check.svg'
33+
import { ReactComponent as ICInProgress } from '../../../Assets/Icon/ic-in-progress.svg'
3134

3235
export const getTriggerHistoryFilterCriteria = ({
3336
appId,
@@ -123,3 +126,14 @@ export const renderIcon = (iconState: string): JSX.Element => {
123126
return <Timer className="icon-dim-20 timer-icon" />
124127
}
125128
}
129+
130+
export const getStageStatusIcon = (status: StageStatusType): JSX.Element => {
131+
switch (status) {
132+
case StageStatusType.SUCCESS:
133+
return <ICCheck className="dc__no-shrink icon-dim-16 scg-5" />
134+
case StageStatusType.FAILURE:
135+
return <Close className="dc__no-shrink icon-dim-16 fcr-5" />
136+
default:
137+
return <ICInProgress className="dc__no-shrink icon-dim-16 ic-in-progress-orange" />
138+
}
139+
}

src/Shared/Helpers.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/* eslint-disable no-param-reassign */
1818
import { useEffect, useRef, useState, ReactElement } from 'react'
1919
import Tippy from '@tippyjs/react'
20+
import moment from 'moment'
2021
import { handleUTCTime, mapByKey, MaterialInfo, shallowEqual, SortingOrder } from '../Common'
2122
import {
2223
AggregationKeys,
@@ -707,3 +708,16 @@ export const decode = (data, isEncoded: boolean = false) =>
707708
agg[curr.key] = curr.value
708709
return agg
709710
}, {})
711+
712+
export const getTimeDifference = (startTime: string, endTime: string): string => {
713+
const seconds = moment(endTime).diff(moment(startTime), 'seconds')
714+
const minutes = moment(endTime).diff(moment(startTime), 'minutes') % 60
715+
const hours = moment(endTime).diff(moment(startTime), 'hours', true).toFixed(2)
716+
if (seconds < 60) {
717+
return `${seconds}s`
718+
}
719+
if (minutes < 60) {
720+
return `${minutes}m ${seconds % 60}s`
721+
}
722+
return `${hours}h ${minutes % 60}m ${seconds % 60}s`
723+
}

0 commit comments

Comments
 (0)