Skip to content

Commit 22b460b

Browse files
authored
Merge pull request #1480 from jadmsaadaot/TRACK-task#1295-B
Remove connector in issue history for last item in timeline
2 parents f957072 + 77d3ada commit 22b460b

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

epictrack-web/src/components/workPlan/issues/IssueAccordion/IssueHistory.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TimelineContent, {
1414
timelineContentClasses,
1515
} from "@mui/lab/TimelineContent";
1616
import { Button, Collapse, Grid, useTheme } from "@mui/material";
17-
import { Else, If, Then, When } from "react-if";
17+
import { Else, If, Then, When, Unless } from "react-if";
1818
import { IconProps } from "../../../icons/type";
1919
import icons from "../../../icons";
2020
import { IssuesContext } from "../IssuesContext";
@@ -38,6 +38,12 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
3838

3939
const SHOW_MORE_THRESHOLD = 3;
4040

41+
const firstNUpdatesInTimeline = subsequentUpdates.slice(
42+
0,
43+
SHOW_MORE_THRESHOLD
44+
);
45+
const restOfUpdatesInTimeline = subsequentUpdates.slice(SHOW_MORE_THRESHOLD);
46+
4147
return (
4248
<Timeline
4349
position="left"
@@ -50,7 +56,7 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
5056
paddingLeft: 0,
5157
}}
5258
>
53-
{subsequentUpdates.slice(0, SHOW_MORE_THRESHOLD).map((update, index) => {
59+
{firstNUpdatesInTimeline.map((update, index) => {
5460
const isSuccess = highlightFirstInTimeLineApproved && index === 0;
5561
return (
5662
<TimelineItem key={update.id}>
@@ -97,13 +103,19 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
97103
},
98104
]}
99105
/>
100-
<TimelineConnector
101-
sx={[
102-
isSuccess && {
103-
bgcolor: Palette.success.light,
104-
},
105-
]}
106-
/>
106+
<Unless
107+
condition={
108+
index === firstNUpdatesInTimeline.length - 1 && !expand
109+
}
110+
>
111+
<TimelineConnector
112+
sx={[
113+
isSuccess && {
114+
bgcolor: Palette.success.light,
115+
},
116+
]}
117+
/>
118+
</Unless>
107119
</TimelineSeparator>
108120
<TimelineContent>
109121
<ETCaption3 color={Palette.neutral.main}>
@@ -113,9 +125,9 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
113125
</TimelineItem>
114126
);
115127
})}
116-
<When condition={subsequentUpdates.length > SHOW_MORE_THRESHOLD}>
128+
<When condition={restOfUpdatesInTimeline.length > 0}>
117129
<Collapse in={expand}>
118-
{subsequentUpdates.slice(SHOW_MORE_THRESHOLD).map((update) => (
130+
{restOfUpdatesInTimeline.map((update, index) => (
119131
<TimelineItem key={update.id}>
120132
<TimelineOppositeContent>
121133
<ETPreviewText color={Palette.neutral.main}>
@@ -124,7 +136,11 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
124136
</TimelineOppositeContent>
125137
<TimelineSeparator>
126138
<TimelineDot />
127-
<TimelineConnector />
139+
<Unless
140+
condition={index === restOfUpdatesInTimeline.length - 1}
141+
>
142+
<TimelineConnector />
143+
</Unless>
128144
</TimelineSeparator>
129145
<TimelineContent>
130146
<ETCaption3 color={Palette.neutral.main}>

0 commit comments

Comments
 (0)