Skip to content

Commit 11d8483

Browse files
committed
feat: add target platforms support in LogStageAccordion and LogsRenderer components
1 parent 39fd834 commit 11d8483

File tree

4 files changed

+63
-24
lines changed

4 files changed

+63
-24
lines changed

src/Shared/Components/CICDHistory/LogStageAccordion.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import { RefCallback } from 'react'
12
import DOMPurify from 'dompurify'
23
import { getTimeDifference } from '@Shared/Helpers'
3-
import { RefCallback } from 'react'
4+
import { Tooltip } from '@Common/Tooltip'
5+
import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
6+
import { ReactComponent as ICStack } from '@Icons/ic-stack.svg'
47
import { LogStageAccordionProps } from './types'
58
import { getLogSearchIndex, getStageStatusIcon } from './utils'
6-
import { ReactComponent as ICCaretDown } from '../../../Assets/Icon/ic-caret-down.svg'
9+
import { TargetPlatformListTooltip } from '../TargetPlatforms'
710

811
const LogsItemContainer = ({ children }: { children: React.ReactNode }) => (
912
<div className="display-grid dc__column-gap-10 dc__align-start logs-renderer__log-item">{children}</div>
@@ -22,6 +25,7 @@ const LogStageAccordion = ({
2225
isLoading,
2326
fullScreenView,
2427
searchIndex,
28+
targetPlatforms,
2529
}: LogStageAccordionProps) => {
2630
const handleAccordionToggle = () => {
2731
if (isOpen) {
@@ -79,7 +83,28 @@ const LogStageAccordion = ({
7983
</div>
8084
</div>
8185

82-
{!!endTime && <span className="text__white fs-13 fw-4 lh-20">{getFormattedTimeDifference()}</span>}
86+
<div className="flexbox dc__gap-8">
87+
{!!targetPlatforms?.length && (
88+
<>
89+
<Tooltip
90+
content={<TargetPlatformListTooltip targetPlatforms={targetPlatforms} />}
91+
alwaysShowTippyOnHover
92+
>
93+
<div className="flexbox dc__gap-4 dc__align-items-center">
94+
<ICStack className="scn-0 dc__no-shrink icon-stroke__white icon-dim-12" />
95+
<span className="text__white fs-13 fw-4 lh-20">
96+
{targetPlatforms.length}&nbsp;target platform
97+
{targetPlatforms.length > 1 ? 's' : ''}
98+
</span>
99+
</div>
100+
</Tooltip>
101+
102+
<div className="dc__bullet--white dc__bullet" />
103+
</>
104+
)}
105+
106+
{!!endTime && <span className="text__white fs-13 fw-4 lh-20">{getFormattedTimeDifference()}</span>}
107+
</div>
83108
</button>
84109

85110
{isOpen && (

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
1919
import AnsiUp from 'ansi_up'
2020
import DOMPurify from 'dompurify'
2121
import { ANSI_UP_REGEX, ComponentSizeType } from '@Shared/constants'
22-
import { escapeRegExp } from '@Shared/Helpers'
22+
import { escapeRegExp, sanitizeTargetPlatforms } from '@Shared/Helpers'
2323
import { ReactComponent as ICExpandAll } from '@Icons/ic-expand-all.svg'
2424
import { ReactComponent as ICCollapseAll } from '@Icons/ic-collapse-all.svg'
2525
import { ReactComponent as ICArrow } from '@Icons/ic-caret-down.svg'
@@ -311,7 +311,7 @@ const LogsRenderer = ({ triggerDetails, isBlobStorageConfigured, parentType, ful
311311
const newStageList = streamDataList.reduce((acc, streamItem: string, index) => {
312312
if (streamItem.startsWith(LOGS_STAGE_IDENTIFIER)) {
313313
try {
314-
const { stage, startTime, endTime, status }: StageInfoDTO = JSON.parse(
314+
const { stage, startTime, endTime, status, metadata }: StageInfoDTO = JSON.parse(
315315
streamItem.split(LOGS_STAGE_STREAM_SEPARATOR)[1],
316316
)
317317
const existingStage = acc.find((item) => item.stage === stage && item.startTime === startTime)
@@ -345,6 +345,7 @@ const LogsRenderer = ({ triggerDetails, isBlobStorageConfigured, parentType, ful
345345
!!targetSearchKey,
346346
),
347347
status: derivedStatus,
348+
targetPlatforms: sanitizeTargetPlatforms(metadata?.targetPlatforms),
348349
logs: [],
349350
})
350351
}
@@ -557,23 +558,26 @@ const LogsRenderer = ({ triggerDetails, isBlobStorageConfigured, parentType, ful
557558
</div>
558559

559560
<div className="flexbox-col px-12 dc__gap-4">
560-
{stageList.map(({ stage, isOpen, logs, endTime, startTime, status }, index) => (
561-
<LogStageAccordion
562-
key={`${stage}-${startTime}-log-stage-accordion`}
563-
stage={stage}
564-
isOpen={isOpen}
565-
logs={logs}
566-
endTime={endTime}
567-
startTime={startTime}
568-
status={status}
569-
handleStageClose={handleStageClose}
570-
handleStageOpen={handleStageOpen}
571-
stageIndex={index}
572-
isLoading={index === stageList.length - 1 && areEventsProgressing}
573-
fullScreenView={fullScreenView}
574-
searchIndex={searchResults[currentSearchIndex]}
575-
/>
576-
))}
561+
{stageList.map(
562+
({ stage, isOpen, logs, endTime, startTime, status, targetPlatforms }, index) => (
563+
<LogStageAccordion
564+
key={`${stage}-${startTime}-log-stage-accordion`}
565+
stage={stage}
566+
isOpen={isOpen}
567+
logs={logs}
568+
endTime={endTime}
569+
startTime={startTime}
570+
targetPlatforms={targetPlatforms}
571+
status={status}
572+
handleStageClose={handleStageClose}
573+
handleStageOpen={handleStageOpen}
574+
stageIndex={index}
575+
isLoading={index === stageList.length - 1 && areEventsProgressing}
576+
fullScreenView={fullScreenView}
577+
searchIndex={searchResults[currentSearchIndex]}
578+
/>
579+
),
580+
)}
577581
</div>
578582
</div>
579583
)

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ import {
3030
SortingOrder,
3131
} from '../../../Common'
3232
import { DeploymentStageType } from '../../constants'
33-
import { AggregationKeys, GitTriggers, Node, NodeType, ResourceKindType, ResourceVersionType } from '../../types'
33+
import {
34+
AggregationKeys,
35+
GitTriggers,
36+
Node,
37+
NodeType,
38+
ResourceKindType,
39+
ResourceVersionType,
40+
TargetPlatformsDTO,
41+
} from '../../types'
3442
import { TERMINAL_STATUS_MAP } from './constants'
3543

3644
export enum HistoryComponentType {
@@ -747,11 +755,13 @@ export interface StageInfoDTO {
747755
startTime: string
748756
endTime?: string
749757
status?: StageStatusType
758+
metadata: Partial<Pick<TargetPlatformsDTO, 'targetPlatforms'>>
750759
}
751760

752761
export interface StageDetailType extends Pick<StageInfoDTO, 'stage' | 'startTime' | 'endTime' | 'status'> {
753762
logs: string[]
754763
isOpen: boolean
764+
targetPlatforms?: StageInfoDTO['metadata']['targetPlatforms']
755765
}
756766

757767
export interface LogStageAccordionProps extends StageDetailType, Pick<LogsRendererType, 'fullScreenView'> {

src/Shared/Components/ImageCard/ImageCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ImageCard = ({
3030
materialInfoRootClassName = '',
3131
}: ImageCardProps) => (
3232
<div className={`material-history material-history--cd image-tag-parent-card ${rootClassName || ''}`}>
33-
<div className="p-12 bg__primary br-4 flexbox-col dc__gap-12">
33+
<div className="p-12 bg__primary br-4 flexbox-col">
3434
<div className="dc__content-space flexbox dc__align-start">
3535
<div className="flexbox-col dc__content-start dc__align-start">
3636
<SequentialCDCardTitle {...sequentialCDCardTitleProps} />

0 commit comments

Comments
 (0)