Skip to content

Commit 0008ef0

Browse files
committed
chore: Add LogStageAccordion component for displaying logs in CICDHistory
1 parent 8c72b07 commit 0008ef0

File tree

4 files changed

+248
-99
lines changed

4 files changed

+248
-99
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { ZERO_TIME_STRING } from '@Common/Constants'
2+
import { getTimeDifference } from '@Shared/Helpers'
3+
import { LogStageAccordionProps } from './types'
4+
import { getStageStatusIcon } from './utils'
5+
import { ReactComponent as ICCaretDown } from '../../../Assets/Icon/ic-caret-down.svg'
6+
7+
const LogStageAccordion = ({
8+
stage,
9+
isOpen,
10+
logs,
11+
endTime,
12+
startTime,
13+
status,
14+
handleStageClose,
15+
handleStageOpen,
16+
accordionIndex,
17+
}: LogStageAccordionProps) => {
18+
const handleAccordionToggle = () => {
19+
if (isOpen) {
20+
handleStageClose(accordionIndex)
21+
} else {
22+
handleStageOpen(accordionIndex)
23+
}
24+
}
25+
26+
return (
27+
<div className="flexbox-col dc__gap-8">
28+
<button
29+
className="flexbox dc__transparent dc__content-space py-6 px-8 br-4 dc__align-items-center dc__select-text logs-renderer__stage-accordion-hover"
30+
style={{
31+
backgroundColor: isOpen ? '#2C3354' : '#0C1021',
32+
}}
33+
type="button"
34+
role="tab"
35+
onClick={handleAccordionToggle}
36+
>
37+
<div className="flexbox dc__gap-8 dc__transparent dc__align-items-center">
38+
<ICCaretDown
39+
className={`icon-dim-16 dc__no-shrink dc__transition--transform ${!isOpen ? 'dc__flip-n90 dc__opacity-0_5' : ''}`}
40+
/>
41+
42+
<div className="flexbox dc__gap-12 dc__align-items-center">
43+
{getStageStatusIcon(status)}
44+
45+
<h3 className="m-0 cn-0 fs-13 fw-6 lh-20 dc__word-break">{stage}</h3>
46+
</div>
47+
</div>
48+
49+
{endTime !== ZERO_TIME_STRING && (
50+
<span className="cn-0 fs-13 fw-4 lh-20">{getTimeDifference(startTime, endTime)}</span>
51+
)}
52+
</button>
53+
54+
{isOpen &&
55+
logs.map((log: string, logsIndex: number) => (
56+
<div
57+
className="flex top left pl-24 dc__gap-10 lh-24 pb-10"
58+
// eslint-disable-next-line react/no-array-index-key
59+
key={`logs-${stage}-${startTime}-${logsIndex}`}
60+
>
61+
<span className="cn-4 col-2">{logsIndex + 1}</span>
62+
<p
63+
className="mono fs-14 mb-0-imp cn-0 dc__word-break"
64+
// eslint-disable-next-line react/no-danger
65+
dangerouslySetInnerHTML={{
66+
__html: log,
67+
}}
68+
/>
69+
</div>
70+
))}
71+
</div>
72+
)
73+
}
74+
75+
export default LogStageAccordion

src/Shared/Components/CICDHistory/LogsRenderer.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@
1212
color: var(--N500);
1313
}
1414
}
15+
16+
&:hover {
17+
border: none !important;
18+
background: transparent;
19+
}
1520
}
1621

1722
.search-bar:focus-within {
1823
border: none !important;
1924
}
2025
}
2126

27+
// TODO: Sync with product to replace this placeholder
28+
&__stage-accordion-hover {
29+
&:hover {
30+
background-color: #2C3354 !important;
31+
}
32+
}
33+
2234
&__filters-border-bottom {
2335
border-bottom: 1px solid #2C3354;
2436
}

0 commit comments

Comments
 (0)