@ -1,6 +1,6 @@
import React , { PureComponent } from 'react' ;
import React , { PureComponent } from 'react' ;
import { FormattedMessage , formatMessage } from 'umi/locale' ;
import { FormattedMessage , formatMessage } from 'umi/locale' ;
import { Spin , Tag , Menu , Icon , Avatar , Tooltip } from 'antd' ;
import { Spin , Tag , Menu , Icon , Avatar , Tooltip , message } from 'antd' ;
import moment from 'moment' ;
import moment from 'moment' ;
import groupBy from 'lodash/groupBy' ;
import groupBy from 'lodash/groupBy' ;
import NoticeIcon from '../NoticeIcon' ;
import NoticeIcon from '../NoticeIcon' ;
@ -63,30 +63,13 @@ export default class GlobalHeaderRight extends PureComponent {
} ) ;
} ) ;
} ;
} ;
fetchMoreNotices = tabProps => {
const { list , name } = tabProps ;
const { dispatch , notices = [ ] } = this . props ;
const lastItemId = notices [ notices . length - 1 ] . id ;
dispatch ( {
type : 'global/fetchMoreNotices' ,
payload : {
lastItemId ,
type : name ,
offset : list . length ,
} ,
} ) ;
} ;
render ( ) {
render ( ) {
const {
const {
currentUser ,
currentUser ,
fetchingMoreNotices ,
fetchingNotices ,
fetchingNotices ,
loadedAllNotices ,
onNoticeVisibleChange ,
onNoticeVisibleChange ,
onMenuClick ,
onMenuClick ,
onNoticeClear ,
onNoticeClear ,
skeletonCount ,
theme ,
theme ,
} = this . props ;
} = this . props ;
const menu = (
const menu = (
@ -110,11 +93,6 @@ export default class GlobalHeaderRight extends PureComponent {
< / M e n u . I t e m >
< / M e n u . I t e m >
< / M e n u >
< / M e n u >
) ;
) ;
const loadMoreProps = {
skeletonCount ,
loadedAll : loadedAllNotices ,
loading : fetchingMoreNotices ,
} ;
const noticeData = this . getNoticeData ( ) ;
const noticeData = this . getNoticeData ( ) ;
const unreadMsg = this . getUnreadData ( noticeData ) ;
const unreadMsg = this . getUnreadData ( noticeData ) ;
let className = styles . right ;
let className = styles . right ;
@ -155,44 +133,43 @@ export default class GlobalHeaderRight extends PureComponent {
console . log ( item , tabProps ) ; // eslint-disable-line
console . log ( item , tabProps ) ; // eslint-disable-line
this . changeReadState ( item , tabProps ) ;
this . changeReadState ( item , tabProps ) ;
} }
} }
loading = { fetchingNotices }
locale = { {
locale = { {
emptyText : formatMessage ( { id : 'component.noticeIcon.empty' } ) ,
emptyText : formatMessage ( { id : 'component.noticeIcon.empty' } ) ,
clear : formatMessage ( { id : 'component.noticeIcon.clear' } ) ,
clear : formatMessage ( { id : 'component.noticeIcon.clear' } ) ,
loadedAll : formatMessage ( { id : 'component.noticeIcon.loaded' } ) ,
viewMore : formatMessage ( { id : 'component.noticeIcon.view-more' } ) ,
loadMore : formatMessage ( { id : 'component.noticeIcon.loading-more' } ) ,
notification : formatMessage ( { id : 'component.globalHeader.notification' } ) ,
message : formatMessage ( { id : 'component.globalHeader.message' } ) ,
event : formatMessage ( { id : 'component.globalHeader.event' } ) ,
} }
} }
onClear = { onNoticeClear }
onClear = { onNoticeClear }
onLoadMore = { this . fetchMoreNotices }
onPopupVisibleChange = { onNoticeVisibleChange }
onPopupVisibleChange = { onNoticeVisibleChange }
loading = { fetchingNotices }
onViewMore = { ( ) => message . info ( 'Click on view more' ) }
clearClose
clearClose
>
>
< NoticeIcon . Tab
< NoticeIcon . Tab
count = { unreadMsg . notification }
count = { unreadMsg . notification }
list = { noticeData . notification }
list = { noticeData . notification }
title = { formatMessage ( { id : 'component.globalHeader.notification' } ) }
title = "notification"
name = "notification"
emptyText = { formatMessage ( { id : 'component.globalHeader.notification.empty' } ) }
emptyText = { formatMessage ( { id : 'component.globalHeader.notification.empty' } ) }
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg"
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg"
{ ... loadMoreProps }
showViewMore
/ >
/ >
< NoticeIcon . Tab
< NoticeIcon . Tab
count = { unreadMsg . message }
count = { unreadMsg . message }
list = { noticeData . message }
list = { noticeData . message }
title = { formatMessage ( { id : 'component.globalHeader.message' } ) }
title = "message"
name = "message"
emptyText = { formatMessage ( { id : 'component.globalHeader.message.empty' } ) }
emptyText = { formatMessage ( { id : 'component.globalHeader.message.empty' } ) }
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg"
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg"
{ ... loadMoreProps }
showViewMore
/ >
/ >
< NoticeIcon . Tab
< NoticeIcon . Tab
count = { unreadMsg . event }
count = { unreadMsg . event }
list = { noticeData . event }
list = { noticeData . event }
title = { formatMessage ( { id : 'component.globalHeader.event' } ) }
title = "event"
name = "event"
emptyText = { formatMessage ( { id : 'component.globalHeader.event.empty' } ) }
emptyText = { formatMessage ( { id : 'component.globalHeader.event.empty' } ) }
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/HsIsxMZiWKrNUavQUXqx.svg"
emptyImage = "https://gw.alipayobjects.com/zos/rmsportal/HsIsxMZiWKrNUavQUXqx.svg"
{ ... loadMoreProps }
showViewMore
/ >
/ >
< / N o t i c e I c o n >
< / N o t i c e I c o n >
{ currentUser . name ? (
{ currentUser . name ? (