@@ -14,7 +14,7 @@ import TimelineContent, {
14
14
timelineContentClasses ,
15
15
} from "@mui/lab/TimelineContent" ;
16
16
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" ;
18
18
import { IconProps } from "../../../icons/type" ;
19
19
import icons from "../../../icons" ;
20
20
import { IssuesContext } from "../IssuesContext" ;
@@ -38,6 +38,12 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
38
38
39
39
const SHOW_MORE_THRESHOLD = 3 ;
40
40
41
+ const firstNUpdatesInTimeline = subsequentUpdates . slice (
42
+ 0 ,
43
+ SHOW_MORE_THRESHOLD
44
+ ) ;
45
+ const restOfUpdatesInTimeline = subsequentUpdates . slice ( SHOW_MORE_THRESHOLD ) ;
46
+
41
47
return (
42
48
< Timeline
43
49
position = "left"
@@ -50,7 +56,7 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
50
56
paddingLeft : 0 ,
51
57
} }
52
58
>
53
- { subsequentUpdates . slice ( 0 , SHOW_MORE_THRESHOLD ) . map ( ( update , index ) => {
59
+ { firstNUpdatesInTimeline . map ( ( update , index ) => {
54
60
const isSuccess = highlightFirstInTimeLineApproved && index === 0 ;
55
61
return (
56
62
< TimelineItem key = { update . id } >
@@ -97,13 +103,19 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
97
103
} ,
98
104
] }
99
105
/>
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 >
107
119
</ TimelineSeparator >
108
120
< TimelineContent >
109
121
< ETCaption3 color = { Palette . neutral . main } >
@@ -113,9 +125,9 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
113
125
</ TimelineItem >
114
126
) ;
115
127
} ) }
116
- < When condition = { subsequentUpdates . length > SHOW_MORE_THRESHOLD } >
128
+ < When condition = { restOfUpdatesInTimeline . length > 0 } >
117
129
< Collapse in = { expand } >
118
- { subsequentUpdates . slice ( SHOW_MORE_THRESHOLD ) . map ( ( update ) => (
130
+ { restOfUpdatesInTimeline . map ( ( update , index ) => (
119
131
< TimelineItem key = { update . id } >
120
132
< TimelineOppositeContent >
121
133
< ETPreviewText color = { Palette . neutral . main } >
@@ -124,7 +136,11 @@ const IssueHistory = ({ issue }: { issue: WorkIssue }) => {
124
136
</ TimelineOppositeContent >
125
137
< TimelineSeparator >
126
138
< TimelineDot />
127
- < TimelineConnector />
139
+ < Unless
140
+ condition = { index === restOfUpdatesInTimeline . length - 1 }
141
+ >
142
+ < TimelineConnector />
143
+ </ Unless >
128
144
</ TimelineSeparator >
129
145
< TimelineContent >
130
146
< ETCaption3 color = { Palette . neutral . main } >
0 commit comments