diff --git a/src/features/metadata/components/EnvBuilds.tsx b/src/features/metadata/components/EnvBuilds.tsx index 18953b68..da85edcc 100644 --- a/src/features/metadata/components/EnvBuilds.tsx +++ b/src/features/metadata/components/EnvBuilds.tsx @@ -45,7 +45,9 @@ export const EnvBuilds = ({ Status: {""} {currentBuild.status_info ? ( - <>{currentBuild.status} ({currentBuild.status_info}) + <> + {currentBuild.status} ({currentBuild.status_info}) + ) : ( <>{currentBuild.status} )} diff --git a/src/utils/helpers/buildMapper.ts b/src/utils/helpers/buildMapper.ts index 0bbb09dd..d93876aa 100644 --- a/src/utils/helpers/buildMapper.ts +++ b/src/utils/helpers/buildMapper.ts @@ -41,48 +41,50 @@ const dateToTimezone = (date: string) => { }; export const buildMapper = (data: Build[], currentBuildId: number) => { - return data.map(({ id, status, status_info, ended_on, scheduled_on }: Build) => { - let duration = 0; - if (ended_on && scheduled_on) { - const startTime = new Date(scheduled_on); - const endTime = new Date(ended_on); - duration = (endTime.valueOf() - startTime.valueOf()) / 60000; - duration = Math.round(duration); - } - if (id === currentBuildId) { - return { - id, - name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`, - status: isCompleted(status, duration), - status_info, - }; - } + return data.map( + ({ id, status, status_info, ended_on, scheduled_on }: Build) => { + let duration = 0; + if (ended_on && scheduled_on) { + const startTime = new Date(scheduled_on); + const endTime = new Date(ended_on); + duration = (endTime.valueOf() - startTime.valueOf()) / 60000; + duration = Math.round(duration); + } + if (id === currentBuildId) { + return { + id, + name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`, + status: isCompleted(status, duration), + status_info + }; + } - if (isBuilding(status)) { - return { - id, - name: `${dateToTimezone(scheduled_on)} - Building`, - status: "Building", - status_info, - }; - } + if (isBuilding(status)) { + return { + id, + name: `${dateToTimezone(scheduled_on)} - Building`, + status: "Building", + status_info + }; + } + + if (isQueued(status)) { + return { + id, + name: `${dateToTimezone(scheduled_on)} - Queued`, + status: "Building", + status_info + }; + } - if (isQueued(status)) { return { id, - name: `${dateToTimezone(scheduled_on)} - Queued`, - status: "Building", - status_info, + name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${ + STATUS_OPTIONS[status] + }`, + status: isCompleted(status, duration), + status_info }; } - - return { - id, - name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${ - STATUS_OPTIONS[status] - }`, - status: isCompleted(status, duration), - status_info, - }; - }); + ); };