Merge branch 'feature_notification' of https://git.trustie.net/tongChong/forgeplus-react into feature_notification_xiesi
This commit is contained in:
commit
9050c5ca2b
|
@ -280,7 +280,7 @@ class NewHeader extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { match ,hisroty ,showNotification} = this.props;
|
const { match ,resetUserInfo ,showNotification} = this.props;
|
||||||
let current_user = this.props.user;
|
let current_user = this.props.user;
|
||||||
let {
|
let {
|
||||||
AccountProfiletype,
|
AccountProfiletype,
|
||||||
|
@ -444,7 +444,7 @@ class NewHeader extends Component {
|
||||||
<Popover
|
<Popover
|
||||||
overlayClassName="notice-popover"
|
overlayClassName="notice-popover"
|
||||||
placement={`bottomRight`}
|
placement={`bottomRight`}
|
||||||
content={<NoticeContent current_user={current_user} showNotification={showNotification}/>}
|
content={<NoticeContent visible={visible} current_user={current_user} showNotification={showNotification} resetUserInfo={resetUserInfo}/>}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onVisibleChange={this.handleVisibleChange}
|
onVisibleChange={this.handleVisibleChange}
|
||||||
>
|
>
|
||||||
|
|
|
@ -3,13 +3,14 @@ import { Badge, Menu } from 'antd';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import AppPullRefresh from './AppPullRefresh';
|
import AppPullRefresh from './AppPullRefresh';
|
||||||
|
import { noticeSourceType } from '../common/static';
|
||||||
import './header.scss';
|
import './header.scss';
|
||||||
import '../SecuritySetting/notice/manager/Index.scss';
|
import '../SecuritySetting/notice/manager/Index.scss';
|
||||||
import '../SecuritySetting/Index.scss';
|
import '../SecuritySetting/Index.scss';
|
||||||
import '../SecuritySetting/notice/myNotice/Index.scss';
|
import '../SecuritySetting/notice/myNotice/Index.scss';
|
||||||
|
|
||||||
|
|
||||||
function NoticeContent({ showNotification, current_user: { login } }) {
|
function NoticeContent({ visible, showNotification, resetUserInfo, current_user: { login } }) {
|
||||||
const [initialize, setInitialize] = useState(true);
|
const [initialize, setInitialize] = useState(true);
|
||||||
const [noticeType, setNoticeType] = useState("notification");
|
const [noticeType, setNoticeType] = useState("notification");
|
||||||
const [letterUnreadCount, setLetterUnreadCount] = useState(0);//未读私信数量
|
const [letterUnreadCount, setLetterUnreadCount] = useState(0);//未读私信数量
|
||||||
|
@ -43,8 +44,8 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
params.type = "atme"
|
params.type = "atme"
|
||||||
}
|
}
|
||||||
getMessageList(params);
|
visible && getMessageList(params);
|
||||||
}, [reload]);
|
}, [reload, visible]);
|
||||||
|
|
||||||
|
|
||||||
function getMessageList(params) {
|
function getMessageList(params) {
|
||||||
|
@ -87,6 +88,7 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
if (data.status === 0) {
|
if (data.status === 0) {
|
||||||
setReload(Math.random());
|
setReload(Math.random());
|
||||||
|
resetUserInfo();
|
||||||
} else {
|
} else {
|
||||||
showNotification(data.message);
|
showNotification(data.message);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +115,7 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
if (data.status === 0) {
|
if (data.status === 0) {
|
||||||
changeReadMark(item);
|
changeReadMark(item);
|
||||||
|
resetUserInfo();
|
||||||
item.notification_url && window.open(item.notification_url);
|
item.notification_url && window.open(item.notification_url);
|
||||||
} else {
|
} else {
|
||||||
showNotification(data.message);
|
showNotification(data.message);
|
||||||
|
@ -126,11 +129,17 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
let index = noticeUnreadList.indexOf(item);
|
let index = noticeUnreadList.indexOf(item);
|
||||||
list[index].status = 2;
|
list[index].status = 2;
|
||||||
setNoticeUnreadList(list);
|
setNoticeUnreadList(list);
|
||||||
|
if (noticeUnreadCount > 0) {
|
||||||
|
setNoticeUnreadCount(noticeUnreadCount - 1);
|
||||||
|
}
|
||||||
} else if (item.type === "atme") {
|
} else if (item.type === "atme") {
|
||||||
let list = atUnreadList.slice();
|
let list = atUnreadList.slice();
|
||||||
let index = atUnreadList.indexOf(item);
|
let index = atUnreadList.indexOf(item);
|
||||||
list[index].status = 2;
|
list[index].status = 2;
|
||||||
setAtUnreadList(list);
|
setAtUnreadList(list);
|
||||||
|
if (atUnreadCount > 0) {
|
||||||
|
setAtUnreadCount(atUnreadCount - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +158,7 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
className='hoverNotice-body' // 外部添加className加以区分
|
className='hoverNotice-body' // 外部添加className加以区分
|
||||||
onPullRefresh={() => { setNoticePage(noticePage + 1); }} //触发加载ajax的function
|
onPullRefresh={() => { setNoticePage(noticePage + 1); }} //触发加载ajax的function
|
||||||
// type={2} // 传送加载组件的状态
|
// type={2} // 传送加载组件的状态
|
||||||
count={noticeUnreadCount} // 数据当前的总数量
|
count={noticeUnreadList.length} // 数据当前的总数量
|
||||||
pageSize={10} //
|
pageSize={10} //
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
@ -161,7 +170,7 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
<span style={{ visibility: item.status === 1 ? 'visible' : 'hidden' }}>
|
<span style={{ visibility: item.status === 1 ? 'visible' : 'hidden' }}>
|
||||||
<Badge color="#FA2020" />
|
<Badge color="#FA2020" />
|
||||||
</span>
|
</span>
|
||||||
<i className="iconfont icon-yixiuicon1"></i>
|
<i className={"iconfont "+noticeSourceType[item.source]}></i>
|
||||||
<div className="noticeCont-text">
|
<div className="noticeCont-text">
|
||||||
<span dangerouslySetInnerHTML={{ __html: contentStr ? contentStr : item.content.length >= 48 ? item.content.substr(0, 48) + "..." : item.content }}></span>
|
<span dangerouslySetInnerHTML={{ __html: contentStr ? contentStr : item.content.length >= 48 ? item.content.substr(0, 48) + "..." : item.content }}></span>
|
||||||
<span className="timeSpan">{item.time_ago}</span>
|
<span className="timeSpan">{item.time_ago}</span>
|
||||||
|
@ -179,7 +188,7 @@ function NoticeContent({ showNotification, current_user: { login } }) {
|
||||||
className='hoverNotice-body' // 外部添加className加以区分
|
className='hoverNotice-body' // 外部添加className加以区分
|
||||||
onPullRefresh={() => { setAtPage(atPage + 1); }} //触发加载ajax的function
|
onPullRefresh={() => { setAtPage(atPage + 1); }} //触发加载ajax的function
|
||||||
// type={1} // 传送加载组件的状态
|
// type={1} // 传送加载组件的状态
|
||||||
count={atUnreadCount} // 数据当前的总数量
|
count={atUnreadList.length} // 数据当前的总数量
|
||||||
pageSize={10} //
|
pageSize={10} //
|
||||||
>
|
>
|
||||||
{atUnreadList.map(item => {
|
{atUnreadList.map(item => {
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import axios from 'axios';
|
||||||
import { Badge, Button, Checkbox, Menu, Pagination } from 'antd';
|
import { Badge, Button, Checkbox, Menu, Pagination } from 'antd';
|
||||||
|
import DelModal from '../../../Component/ModalFun';
|
||||||
|
import NoneData from '../../../Nodata.js';
|
||||||
|
import { noticeSourceType } from '../../../common/static';
|
||||||
import './Index.scss';
|
import './Index.scss';
|
||||||
import '../manager/Index.scss'
|
import '../manager/Index.scss'
|
||||||
import DelModal from '../../../Wiki/components/ModalFun';
|
|
||||||
import axios from 'axios';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import NoneData from '../../../Nodata.js';
|
|
||||||
|
|
||||||
function MyNotice(props) {
|
function MyNotice(props) {
|
||||||
let current_user = props.current_user;
|
let current_user = props.current_user;
|
||||||
let pageSize = 20;
|
let pageSize = 20;
|
||||||
|
|
||||||
const [noticeType, setNoticeType] = useState("2");//消息类别tab栏选择
|
const [noticeType, setNoticeType] = useState("0");//消息类别tab栏选择
|
||||||
const [selectedNum, setSelectedNum] = useState(0);//@我批量删除选择消息条数
|
const [selectedNum, setSelectedNum] = useState(0);//@我批量删除选择消息条数
|
||||||
const [isBatchDelete, setIsBatchDelete] = useState(false);//@我是否批量删除
|
const [isBatchDelete, setIsBatchDelete] = useState(false);//@我是否批量删除
|
||||||
const [batchDeleteCheckedAll, setBatchDeleteCheckAll] = useState(false);//@我批量删除--全选
|
const [batchDeleteCheckedAll, setBatchDeleteCheckAll] = useState(false);//@我批量删除--全选
|
||||||
|
@ -23,45 +24,6 @@ function MyNotice(props) {
|
||||||
const [messTotalCount, setMessTotalCount] = useState();//消息总数
|
const [messTotalCount, setMessTotalCount] = useState();//消息总数
|
||||||
const [currentPage, setCurrentPage] = useState(1);//当前页数
|
const [currentPage, setCurrentPage] = useState(1);//当前页数
|
||||||
const [onlyUnread, setOnlyUnread] = useState();
|
const [onlyUnread, setOnlyUnread] = useState();
|
||||||
const noticeSourceType = {
|
|
||||||
// 易修
|
|
||||||
IssueAssigned:"icon-yixiuicon1", // 有新指派给我的易修
|
|
||||||
IssueAssignerExpire:"icon-yixiuicon1", // 我负责的易修截止日期到达最后一天
|
|
||||||
IssueAtme:"icon-yixiuicon1", // 在易修中@我
|
|
||||||
IssueChanged:"icon-yixiuicon1", // 我创建或负责的易修状态变更
|
|
||||||
IssueCreatorExpire:"icon-yixiuicon1", // 我创建的易修截止日期到达最后一天
|
|
||||||
IssueDelete:"icon-yixiuicon1", // 我创建或负责的易修删除
|
|
||||||
IssueDeleted:"icon-yixiuicon1", // 我创建或负责的易修删除
|
|
||||||
IssueJournal:"icon-yixiuicon1", // 我创建或负责的易修有新的评论
|
|
||||||
//平台通知
|
|
||||||
LoginIpTip:"icon-xitongtongzhiicon", //登录异常提示
|
|
||||||
//个人状态类通知
|
|
||||||
OrganizationJoined:"icon-xiaoxi2", // 账号被拉入组织
|
|
||||||
OrganizationLeft:"icon-xiaoxi2", // 账号被移出组织
|
|
||||||
rganizationRole:"icon-xiaoxi2", // 账号组织权限变更
|
|
||||||
ProjectJoined:"icon-xiaoxi2", // 账号被拉入项目
|
|
||||||
ProjectLeft:"icon-xiaoxi2", // 账号被移出项目
|
|
||||||
ProjectRole:"icon-xiaoxi2", // 账号仓库权限变更
|
|
||||||
//其他仓库通知
|
|
||||||
ProjectDelete:"icon-daimakuicon1", // 我关注的仓库被删除
|
|
||||||
ProjectFollowed:"icon-daimakuicon1", // 我管理的仓库被关注
|
|
||||||
ProjectForked:"icon-daimakuicon1", // 我管理的仓库被复刻
|
|
||||||
ProjectIssue:"icon-daimakuicon1", // 我管理/关注的仓库有新的易修
|
|
||||||
ProjectSettingChanged:"icon-daimakuicon1", // 我管理的仓库项目设置被更改
|
|
||||||
ProjectTransfer:"icon-daimakuicon1", // 我关注的仓库被转移
|
|
||||||
ProjectVersion:"icon-daimakuicon1", // 我关注的仓库有新的发行版
|
|
||||||
ProjectMemberJoined:"icon-daimakuicon1", // 我管理的仓库有成员加入
|
|
||||||
ProjectMemberLeft:"icon-daimakuicon1", // 我管理的仓库有成员移出
|
|
||||||
ProjectPraised:"icon-daimakuicon1", // 我管理的仓库被点赞
|
|
||||||
//合并请求类通知
|
|
||||||
ProjectPullRequest:"icon-hebingqingqiuicon", // 我管理/关注的仓库有新的合并请求
|
|
||||||
PullRequestAssigned:"icon-hebingqingqiuicon", // 有新指派给我的合并请求
|
|
||||||
PullRequestAtme:"icon-hebingqingqiuicon", // 在合并请求中@我
|
|
||||||
PullRequestChanged:"icon-hebingqingqiuicon", // 我创建或负责的合并请求状态变更
|
|
||||||
PullRequestJournal:"icon-hebingqingqiuicon", // 我创建或负责的合并请求有新的评论
|
|
||||||
//里程碑
|
|
||||||
ProjectMilestone:"icon-lichengbeiicon", // 我管理的仓库有新的里程碑
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// const params = {
|
// const params = {
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
export const noticeSourceType = {
|
||||||
|
// 易修
|
||||||
|
IssueAssigned:"icon-yixiuicon1", // 有新指派给我的易修
|
||||||
|
IssueAssignerExpire:"icon-yixiuicon1", // 我负责的易修截止日期到达最后一天
|
||||||
|
IssueAtme:"icon-yixiuicon1", // 在易修中@我
|
||||||
|
IssueChanged:"icon-yixiuicon1", // 我创建或负责的易修状态变更
|
||||||
|
IssueCreatorExpire:"icon-yixiuicon1", // 我创建的易修截止日期到达最后一天
|
||||||
|
IssueDelete:"icon-yixiuicon1", // 我创建或负责的易修删除
|
||||||
|
IssueDeleted:"icon-yixiuicon1", // 我创建或负责的易修删除
|
||||||
|
IssueJournal:"icon-yixiuicon1", // 我创建或负责的易修有新的评论
|
||||||
|
//平台通知
|
||||||
|
LoginIpTip:"icon-xitongtongzhiicon", //登录异常提示
|
||||||
|
//个人状态类通知
|
||||||
|
OrganizationJoined:"icon-xiaoxi2", // 账号被拉入组织
|
||||||
|
OrganizationLeft:"icon-xiaoxi2", // 账号被移出组织
|
||||||
|
rganizationRole:"icon-xiaoxi2", // 账号组织权限变更
|
||||||
|
ProjectJoined:"icon-xiaoxi2", // 账号被拉入项目
|
||||||
|
ProjectLeft:"icon-xiaoxi2", // 账号被移出项目
|
||||||
|
ProjectRole:"icon-xiaoxi2", // 账号仓库权限变更
|
||||||
|
//其他仓库通知
|
||||||
|
ProjectDelete:"icon-daimakuicon1", // 我关注的仓库被删除
|
||||||
|
ProjectFollowed:"icon-daimakuicon1", // 我管理的仓库被关注
|
||||||
|
ProjectForked:"icon-daimakuicon1", // 我管理的仓库被复刻
|
||||||
|
ProjectIssue:"icon-daimakuicon1", // 我管理/关注的仓库有新的易修
|
||||||
|
ProjectSettingChanged:"icon-daimakuicon1", // 我管理的仓库项目设置被更改
|
||||||
|
ProjectTransfer:"icon-daimakuicon1", // 我关注的仓库被转移
|
||||||
|
ProjectVersion:"icon-daimakuicon1", // 我关注的仓库有新的发行版
|
||||||
|
ProjectMemberJoined:"icon-daimakuicon1", // 我管理的仓库有成员加入
|
||||||
|
ProjectMemberLeft:"icon-daimakuicon1", // 我管理的仓库有成员移出
|
||||||
|
ProjectPraised:"icon-daimakuicon1", // 我管理的仓库被点赞
|
||||||
|
//合并请求类通知
|
||||||
|
ProjectPullRequest:"icon-hebingqingqiuicon", // 我管理/关注的仓库有新的合并请求
|
||||||
|
PullRequestAssigned:"icon-hebingqingqiuicon", // 有新指派给我的合并请求
|
||||||
|
PullRequestAtme:"icon-hebingqingqiuicon", // 在合并请求中@我
|
||||||
|
PullRequestChanged:"icon-hebingqingqiuicon", // 我创建或负责的合并请求状态变更
|
||||||
|
PullRequestJournal:"icon-hebingqingqiuicon", // 我创建或负责的合并请求有新的评论
|
||||||
|
//里程碑
|
||||||
|
ProjectMilestone:"icon-lichengbeiicon", // 我管理的仓库有新的里程碑
|
||||||
|
};
|
Loading…
Reference in New Issue