Skip to content

Commit c7f8f71

Browse files
committed
feat: add support to expand all log accordians
1 parent 5697f74 commit c7f8f71

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

src/Assets/Icon/ic-collapse-all.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-expand-all.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Shared/Components/CICDHistory/LogsRenderer.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
path:nth-child(1) {
2424
fill: none !important;
2525
}
26-
26+
2727
path:nth-child(2) {
2828
fill: var(--N400);
2929
}
@@ -56,6 +56,10 @@
5656

5757
&__filters-border-bottom {
5858
border-bottom: 1px solid #2c3354;
59+
60+
& > :not(:first-child) {
61+
border-left: 1px solid #2C3354;
62+
}
5963
}
6064
}
6165
}

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import AnsiUp from 'ansi_up'
2020
import DOMPurify from 'dompurify'
2121
import { ANSI_UP_REGEX, ComponentSizeType } from '@Shared/constants'
2222
import { escapeRegExp } from '@Shared/Helpers'
23+
import { ReactComponent as ICExpandAll } from '@Icons/ic-expand-all.svg'
24+
import { ReactComponent as ICCollapseAll } from '@Icons/ic-collapse-all.svg'
2325
import {
2426
Progressing,
2527
Host,
@@ -182,10 +184,16 @@ export const LogsRenderer = ({
182184
triggerDetails.podStatus && triggerDetails.podStatus !== POD_STATUS.PENDING && logsURL,
183185
)
184186
const [stageList, setStageList] = useState<StageDetailType[]>([])
187+
const [openAllStages, setOpenAllStages] = useState(false)
185188
// State for logs list in case no stages are available
186189
const [logsList, setLogsList] = useState<string[]>([])
187190
const { searchKey, handleSearch } = useUrlFilters()
188191

192+
const handleSetStageList = (list: StageDetailType[]) => {
193+
setOpenAllStages(list.every((item) => item.isOpen))
194+
setStageList(list)
195+
}
196+
189197
const areStagesAvailable =
190198
(window._env_.FEATURE_STEP_WISE_LOGS_ENABLE && streamDataList[0]?.startsWith(LOGS_STAGE_IDENTIFIER)) || false
191199

@@ -374,27 +382,36 @@ export const LogsRenderer = ({
374382
}
375383

376384
const newStageList = getStageListFromStreamData()
377-
setStageList(newStageList)
385+
handleSetStageList(newStageList)
378386
// NOTE: Not adding searchKey as dependency since on mount we would already have searchKey
379387
// And for other cases we would use handleSearchEnter
380388
}, [streamDataList, areEventsProgressing])
381389

382390
const handleSearchEnter = (searchText: string) => {
383391
handleSearch(searchText)
384392
const newStageList = getStageListFromStreamData(searchText)
385-
setStageList(newStageList)
393+
handleSetStageList(newStageList)
386394
}
387395

388396
const handleStageClose = (index: number) => {
389397
const newLogs = structuredClone(stageList)
390398
newLogs[index].isOpen = false
391-
setStageList(newLogs)
399+
handleSetStageList(newLogs)
392400
}
393401

394402
const handleStageOpen = (index: number) => {
395403
const newLogs = structuredClone(stageList)
396404
newLogs[index].isOpen = true
397-
setStageList(newLogs)
405+
handleSetStageList(newLogs)
406+
}
407+
408+
const handleToggleOpenAllStages = () => {
409+
handleSetStageList(
410+
stageList.map((stage) => ({
411+
...stage,
412+
isOpen: !openAllStages,
413+
})),
414+
)
398415
}
399416

400417
const renderLogs = () => {
@@ -428,6 +445,18 @@ export const LogsRenderer = ({
428445
initialSearchText={searchKey}
429446
size={ComponentSizeType.large}
430447
/>
448+
<button
449+
type="button"
450+
className="dc__unset-button-styles px-10 flex dc__bg-n0--opacity-0_2"
451+
onClick={handleToggleOpenAllStages}
452+
aria-label="Expand all stages"
453+
>
454+
{openAllStages ? (
455+
<ICExpandAll className="icon-dim-16 dc__no-shrink dc__transition--transform scn-0" />
456+
) : (
457+
<ICCollapseAll className="icon-dim-16 dc__no-shrink dc__transition--transform scn-0" />
458+
)}
459+
</button>
431460
</div>
432461
</div>
433462

0 commit comments

Comments
 (0)