@@ -21,6 +21,11 @@ import ProjectSpecification from '../../../components/ProjectSpecification/Proje
2121import { loadDashboardFeeds , createProjectTopic , loadFeedComments , addFeedComment } from '../../actions/projectTopics'
2222import spinnerWhileLoading from '../../../components/LoadingSpinner'
2323
24+ import { Helpers , scroller } from 'react-scroll'
25+
26+ /*eslint-disable new-cap */
27+ const ScrollableFeed = Helpers . Element ( Feed )
28+
2429const SYSTEM_USER = {
2530 firstName : CODER_BOT_USER_FNAME ,
2631 lastName : CODER_BOT_USER_LNAME ,
@@ -79,7 +84,7 @@ class FeedView extends React.Component {
7984 }
8085
8186 mapFeed ( feed , showAll = false , resetNewComment = false ) {
82- const { allMembers } = this . props
87+ const { allMembers, project } = this . props
8388 const item = _ . pick ( feed , [ 'id' , 'date' , 'read' , 'tag' , 'title' , 'totalPosts' , 'userId' , 'reference' , 'referenceId' , 'postIds' , 'isAddingComment' , 'isLoadingComments' , 'error' ] )
8489 // Github issue##623, allow comments on all posts (including system posts)
8590 item . allowComments = true
@@ -125,6 +130,9 @@ class FeedView extends React.Component {
125130 item . newComment = feedFromState ? feedFromState . newComment : ''
126131 }
127132 item . hasMoreComments = item . comments . length !== item . totalComments
133+ // adds permalink for the feed
134+ // item.permalink = `/projects/${project.id}/status/${item.id}`
135+ item . permalink = `/projects/${ project . id } #feed-${ item . id } `
128136 return item
129137 }
130138
@@ -146,6 +154,18 @@ class FeedView extends React.Component {
146154 const resetNewComment = prevFeed && prevFeed . isAddingComment && ! feed . isAddingComment && ! feed . error
147155 return this . mapFeed ( feed , this . state . showAll . indexOf ( feed . id ) > - 1 , resetNewComment )
148156 } ) . filter ( item => item )
157+ } , ( ) => {
158+ const scrollTo = window . location . hash ? window . location . hash . substring ( 1 ) : null
159+ // const scrollTo = _.get(props, 'params.statusId', null)
160+ if ( scrollTo ) {
161+ scroller . scrollTo ( scrollTo , {
162+ spy : true ,
163+ smooth : true ,
164+ offset : - 80 , // 60px for top bar and 20px for margin from nav bar
165+ duration : 500 ,
166+ activeClass : 'active'
167+ } )
168+ }
149169 } )
150170 }
151171
@@ -223,10 +243,12 @@ class FeedView extends React.Component {
223243 if ( ( item . spec || item . sendForReview ) && ! showDraftSpec ) {
224244 return null
225245 }
246+ const anchorId = 'feed-' + item . id
226247 return (
227248 < div className = "feed-action-card" key = { item . id } >
228- < Feed
249+ < ScrollableFeed
229250 { ...item }
251+ name = { anchorId }
230252 allowComments = { item . allowComments && ! ! currentMemberRole }
231253 currentUser = { currentUser }
232254 onNewCommentChange = { this . onNewCommentChange . bind ( this , item . id ) }
@@ -236,7 +258,7 @@ class FeedView extends React.Component {
236258 { item . sendForReview && < div className = "panel-buttons" >
237259 < button className = "tc-btn tc-btn-primary tc-btn-md" > Send for review</ button >
238260 </ div > }
239- </ Feed >
261+ </ ScrollableFeed >
240262 { item . spec && < ProjectSpecification project = { project } currentMemberRole = { currentMemberRole } /> }
241263 </ div >
242264 )
0 commit comments