@@ -50,16 +50,12 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
5050 const { flow} = useContext ( FlowContext )
5151 const { id : orgID } = useSelector ( getOrg )
5252
53- const isDraft = version . id === 'draft'
54-
5553 const handleClick = ( ) => {
56- let route = `/orgs/${ orgID } /${ PROJECT_NAME_PLURAL . toLowerCase ( ) } /${ flow . id } `
57-
58- if ( ! isDraft ) {
59- route = `${ route } /versions/${ version . id } `
60- }
61-
62- history . push ( route )
54+ history . push (
55+ `/orgs/${ orgID } /${ PROJECT_NAME_PLURAL . toLowerCase ( ) } /${
56+ flow . id
57+ } /versions/${ version . id } `
58+ )
6359 }
6460
6561 const handleRevert = async ( ) => {
@@ -121,7 +117,7 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
121117
122118 return (
123119 < List . Item
124- selected = { ! isDraft && id === version . id }
120+ selected = { id === version . id }
125121 onClick = { handleClick }
126122 backgroundColor = { InfluxColors . Grey15 }
127123 className = "version-sidebar--listitem"
@@ -133,43 +129,36 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
133129 < h6 className = "published-date--text" >
134130 { new Date ( version . publishedAt ) . toLocaleString ( ) }
135131 </ h6 >
136- { isDraft && < h6 className = "current-version--text" > Current version</ h6 > }
137- { ! isDraft && (
138- < h6 className = "published-by--text" > { version . publishedBy } </ h6 >
139- ) }
132+ < h6 className = "published-by--text" > { version . publishedBy } </ h6 >
140133 </ FlexBox >
141- { isDraft === false && (
142- < >
143- < Icon
144- glyph = { IconFont . More }
145- ref = { triggerRef }
146- style = { { color : InfluxColors . White } }
147- />
148- < Popover
149- triggerRef = { triggerRef }
150- enableDefaultStyles = { false }
151- style = { { minWidth : 209 } }
152- showEvent = { PopoverInteraction . Click }
153- hideEvent = { PopoverInteraction . Click }
154- contents = { onHide => (
155- < List >
156- { menuItems . map ( item => (
157- < List . Item
158- key = { item . title }
159- onClick = { ( ) => {
160- item ?. onClick ( )
161- onHide ( )
162- } }
163- >
164- < Icon glyph = { item ?. icon } />
165- < span style = { { paddingLeft : '10px' } } > { item ?. title } </ span >
166- </ List . Item >
167- ) ) }
168- </ List >
169- ) }
170- />
171- </ >
172- ) }
134+ < Icon
135+ glyph = { IconFont . More }
136+ ref = { triggerRef }
137+ style = { { color : InfluxColors . White } }
138+ />
139+ < Popover
140+ triggerRef = { triggerRef }
141+ enableDefaultStyles = { false }
142+ style = { { minWidth : 209 } }
143+ showEvent = { PopoverInteraction . Click }
144+ hideEvent = { PopoverInteraction . Click }
145+ contents = { onHide => (
146+ < List >
147+ { menuItems . map ( item => (
148+ < List . Item
149+ key = { item . title }
150+ onClick = { ( ) => {
151+ item ?. onClick ( )
152+ onHide ( )
153+ } }
154+ >
155+ < Icon glyph = { item ?. icon } />
156+ < span style = { { paddingLeft : '10px' } } > { item ?. title } </ span >
157+ </ List . Item >
158+ ) ) }
159+ </ List >
160+ ) }
161+ />
173162 </ List . Item >
174163 )
175164}
@@ -188,6 +177,14 @@ export const VersionSidebar: FC = () => {
188177 )
189178 }
190179
180+ const hasDraft = versions [ 0 ] ?. id === 'draft'
181+
182+ const trimmedVersions = versions . slice ( )
183+
184+ if ( hasDraft ) {
185+ trimmedVersions . splice ( 0 , 1 )
186+ }
187+
191188 return (
192189 < div className = "version-sidebar" >
193190 < div className = "version-sidebar--buttons" >
@@ -206,8 +203,16 @@ export const VersionSidebar: FC = () => {
206203 thumbStartColor = "gray"
207204 >
208205 < div className = "version-sidebar--submenu-wrapper" >
206+ { hasDraft && (
207+ < Button
208+ icon = { IconFont . ArrowLeft_New }
209+ text = "Back to Current Version"
210+ onClick = { handleClose }
211+ className = "version-sidebar--back-btn"
212+ />
213+ ) }
209214 < List >
210- { versions . map ( version => (
215+ { trimmedVersions . map ( version => (
211216 < React . Fragment key = { version . id } >
212217 < VersionSidebarListItem version = { version } />
213218 < List . Divider style = { { margin : 0 } } />
0 commit comments