import React from 'react' ; import { NavLink } from 'react-router-dom' ; const BugLinkTitle = ( { bugId , title } ) => ( < NavLink to = { `/dashboard/bugs/${ bugId }` } > # { bugId } < small > ( { title } ) < /small> < /NavLink>); const Commented = ( { byUser , onBug } ) => { return ( < > < NavLink to = { `/profiles/${ byUser ?. username }` } > @ { byUser ?. username } < /NavLink> < span > commented on < /span> < BugLinkTitle bugId = { onBug ?. bugId } title = { onBug ?. title } / > < />); } ; const Referenced = ( { byUser , fromBug , references } ) => { const referenceSlice = references ?. slice ( 0 , 2 ) ; const remaining = references ?. length - referenceSlice ?. length ; const refs = referenceSlice ?. map ( ( ref , index ) => ( < > { references . length === 2 && index > 0 && ' & ' } < BugLinkTitle bugId = { ref . bugId } title = { ref . title } key = { ref . id } / > < />)); return ( < > < span > { refs } { remaining > 0 && < span > & { remaining } more bugs < /span>} & nbsp ; referenced in & nbsp ; < /span> < BugLinkTitle bugId = { fromBug ?. bugId } title = { fromBug ?. title } / > & nbsp ; by { ' ' } < NavLink to = { `/profiles/${ byUser ?. username }` } > @ { byUser ?. username } < /NavLink> < />); } ; const NewBug = ( { byUser , onBug } ) => ( < > < NavLink to = { `/profiles/${ byUser ?. username }` } > @ { byUser ?. username } < /NavLink> < span > created a new bug < /span> < BugLinkTitle bugId = { onBug ?. bugId } title = { onBug ?. title } / > < />); const BugStatus = ( { byUser , onBug , bug_status } ) => ( < > < BugLinkTitle bugId = { onBug ?. bugId } title = { onBug ?. title } / > < span > { bug_status } by < /span> < NavLink to = { `/profiles/${ byUser ?. username }` } > @ { byUser ?. username } < /NavLink> < />); const Mentioned = ( { byUser , onBug , mentions } ) => { return ( < > < NavLink to = { `/profiles/${ byUser ?. username }` } > @ { byUser ?. username } { ' ' } < /NavLink> < span > mentioned { mentions . map ( ( username , index ) => { return ( < > { mentions . length > 2 && index > mentions . length - 2 && '&' } < NavLink to = { `/profiles/${ username }` } > @ { username } < /NavLink> < />); } ) } < /span> < span > at < BugLinkTitle bugId = { onBug ?. bugId } title = { onBug ?. title } / > < /span> < />); } ; const notification_switch = { COMMENTED : Commented , REFERENCED : Referenced , NEW_BUG : NewBug , BUG_STATUS : BugStatus , MENTIONED : Mentioned } ; export default notification_switch ;