Skip to content

Commit eebf67b

Browse files
committed
refactor: remove redundant check with handleUTCTime
1 parent 19a1af8 commit eebf67b

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
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.0.94-beta-3",
3+
"version": "0.0.94-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Helper.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import moment from 'moment'
2323
import { useLocation } from 'react-router-dom'
2424
import { toast } from 'react-toastify'
2525
import YAML from 'yaml'
26-
import { ERROR_EMPTY_SCREEN, SortingOrder, TOKEN_COOKIE_NAME, EXCLUDED_FALSY_VALUES, DISCORD_LINK, ZERO_TIME_STRING } from './Constants'
26+
import { ERROR_EMPTY_SCREEN, SortingOrder, EXCLUDED_FALSY_VALUES, DISCORD_LINK, ZERO_TIME_STRING } from './Constants'
2727
import { ServerErrors } from './ServerError'
2828
import { toastAccessDenied } from './ToastBody'
2929
import { AsyncOptions, AsyncState, UseSearchString } from './Types'
@@ -301,12 +301,10 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
301301
export function handleUTCTime(ts: string, isRelativeTime = false) {
302302
let timestamp = ''
303303
try {
304-
if (ts && ts.length) {
304+
if (ts && ts.length && ts !== ZERO_TIME_STRING) {
305305
const date = moment(ts)
306306
if (isRelativeTime) {
307-
if (ts !== ZERO_TIME_STRING) {
308-
timestamp = date.fromNow()
309-
}
307+
timestamp = date.fromNow()
310308
} else {
311309
timestamp = date.format(DATE_TIME_FORMAT_STRING)
312310
}

src/Shared/Services/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const getParsedCIMaterialInfo = (ciMaterialData: CIMaterialInfoDTO): CIMa
3030
commitURL: mat.url ? createGitCommitUrl(mat.url, hist.Commit) : '',
3131
commit: hist.Commit || '',
3232
author: hist.Author || '',
33-
date: hist.Date ? handleUTCTime(hist.Date, false) : '',
33+
date: handleUTCTime(hist.Date, false),
3434
message: hist.Message || '',
3535
changes: hist.Changes || [],
3636
showChanges: index === 0,
@@ -44,7 +44,7 @@ export const getParsedCIMaterialInfo = (ciMaterialData: CIMaterialInfoDTO): CIMa
4444
return {
4545
materials,
4646
triggeredByEmail: ciMaterialData?.triggeredByEmail || '',
47-
lastDeployedTime: ciMaterialData?.lastDeployedTime ? handleUTCTime(ciMaterialData.lastDeployedTime, false) : '',
47+
lastDeployedTime: handleUTCTime(ciMaterialData.lastDeployedTime, false),
4848
environmentName: ciMaterialData?.environmentName || '',
4949
environmentId: ciMaterialData?.environmentId || 0,
5050
appId: ciMaterialData?.appId,

0 commit comments

Comments
 (0)