Merge pull request '通知管理' (#195) from durian/forgeplus-react:feature_notification_v2_noticeSettings into pre_develop_dev
This commit is contained in:
commit
2f90ccab3c
|
@ -734,7 +734,9 @@ a.color-grey-ccc:hover{
|
|||
border: 1px solid rgba(42, 97, 255, 0.23);
|
||||
border-radius: 4px;
|
||||
margin-left: 16px;
|
||||
align-items: center;
|
||||
& .treecopy{
|
||||
margin-top: 20px;
|
||||
}
|
||||
& .markdown-body table{
|
||||
background: #FAFCFF;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ function Index(props){
|
|||
{notice_url && <ul className="securityUl ul-border-buttom">
|
||||
<li>消息通知</li>
|
||||
<li className={(pathname.indexOf("/settings/notice")>-1 && pathname.indexOf("/settings/notice/config") == -1) || pathname.indexOf("/settings/notice/privateLetter")>-1 ?"active":""}><Link to={"/settings/notice"}><i className="iconfont icon-wodetongzhi"></i><span className="text-shodow-bold">我的通知</span></Link></li>
|
||||
{/* <li className={pathname.indexOf("/settings/notice/config")>-1 ?"active":""}><Link to={'/settings/notice/config'}><i className="iconfont icon-tongzhiguanli"></i><span className="text-shodow-bold">通知管理</span></Link></li> */}
|
||||
<li className={pathname.indexOf("/settings/notice/config")>-1 ?"active":""}><Link to={'/settings/notice/config'}><i className="iconfont icon-tongzhiguanli"></i><span className="text-shodow-bold">通知管理</span></Link></li>
|
||||
</ul>}
|
||||
<ul className="securityUl">
|
||||
<li>安全设置</li>
|
||||
|
@ -73,18 +73,24 @@ function Index(props){
|
|||
<LongWidth>
|
||||
<Gap>
|
||||
<Switch>
|
||||
<Route
|
||||
path="/settings/notice"
|
||||
render={(p) => (
|
||||
<MyNoticeIndex {...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/settings/notice/config"
|
||||
render={(p) => (
|
||||
<NoticeManager {...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/settings/notice/privateLetter"
|
||||
render={(p)=>(
|
||||
<PrivateLetter{...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/settings/notice"
|
||||
render={(p) => (
|
||||
<MyNoticeIndex {...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/settings/SSH/new"
|
||||
render={(p) => (
|
||||
|
@ -103,12 +109,6 @@ function Index(props){
|
|||
<SSHIndex {...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/settings/notice/privateLetter"
|
||||
render={(p)=>(
|
||||
<PrivateLetter{...props} {...p}/>
|
||||
)}
|
||||
></Route>
|
||||
</Switch>
|
||||
</Gap>
|
||||
</LongWidth>
|
||||
|
|
|
@ -1,9 +1,52 @@
|
|||
import { Button, Checkbox } from "antd";
|
||||
import React from "react";
|
||||
|
||||
import { Checkbox } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import axios from 'axios';
|
||||
import './Index.scss';
|
||||
|
||||
function NoticeManager(props){
|
||||
const {current_user} = props;
|
||||
|
||||
const [settingTypes, setSettingTypes] = useState();
|
||||
const [userNotification, setUserNotification] = useState();
|
||||
const [userEmail, setUserEmail] = useState();
|
||||
|
||||
function onChange(type,e,setting){
|
||||
let notification_body = userNotification;
|
||||
let email_body = userEmail;
|
||||
if(type){//站内信
|
||||
notification_body[setting] = e.target.checked;
|
||||
}else{//邮件
|
||||
email_body[setting] = e.target.checked;
|
||||
}
|
||||
axios.post(`/users/${current_user.login}/template_message_settings/update_setting.json`,{
|
||||
setting:{
|
||||
notification_body:notification_body,
|
||||
email_body:email_body
|
||||
}
|
||||
}).then(response=>{
|
||||
if(response && response.status === 0){
|
||||
getUserSettings();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getUserSettings(){
|
||||
axios.get(`/users/${current_user.login}/template_message_settings.json`).then((response)=>{
|
||||
if(response && response.status === 200 ){
|
||||
setUserEmail(response.data.email_body);
|
||||
setUserNotification(response.data.notification_body);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
axios.get("/template_message_settings.json").then(response => {
|
||||
if (response && response.status === 200) {
|
||||
setSettingTypes(response.data.setting_types);
|
||||
}
|
||||
})
|
||||
getUserSettings();
|
||||
},[])
|
||||
|
||||
return(
|
||||
<div className="notice01">
|
||||
|
@ -12,87 +55,23 @@ function NoticeManager(props){
|
|||
</div>
|
||||
<div>
|
||||
<span className="notice-manager-tip">您可以通过通知管理来选择接受通知的方式</span>
|
||||
<div className="manager-cont-top">
|
||||
我创建或负责的
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">易修状态变更</div>
|
||||
<Checkbox defaultChecked='true' disabled>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">易修截止日期到达最后一天</div>
|
||||
<Checkbox defaultChecked='true' disabled>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">合并请求状态变更</div>
|
||||
<Checkbox defaultChecked='true' disabled>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">易修有新的评论</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">合并请求有新的评论</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
|
||||
<div className="manager-cont-top">
|
||||
我管理的仓库
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">被关注</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">被点赞</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">被复刻</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">有新的里程碑</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
|
||||
<div className="manager-cont-top">
|
||||
我关注的仓库
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">被删除</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">被转移</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">有新的易修</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">有新的合并请求</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont-title">有新的版本发布</div>
|
||||
<Checkbox defaultChecked='true'>站内信</Checkbox>
|
||||
<Checkbox >邮件</Checkbox>
|
||||
</div>
|
||||
{settingTypes && userNotification && userEmail && settingTypes.map((item,key)=>{
|
||||
return(
|
||||
item.type_name && <div key={key}>
|
||||
<div className="manager-cont-top">{item.type_name}</div>
|
||||
{item.settings.map((i, k) => {
|
||||
const setting = item.type.substring(item.type.indexOf("::")+2)+"::"+i.key;
|
||||
return (
|
||||
<div className="manager-cont" key={k}>
|
||||
<div className="manager-cont-title">{i.name}</div>
|
||||
<Checkbox disabled = {i.notification_disabled} defaultChecked={userNotification[setting]} onChange={(e)=>{onChange(true,e,setting)}}>站内信</Checkbox>
|
||||
<Checkbox disabled = {i.email_disabled} defaultChecked={userEmail[setting]} onChange={(e)=>{onChange(false,e,setting)}}>邮件</Checkbox>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -11,7 +11,6 @@ export default Form.create()(
|
|||
const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form;
|
||||
// const { username } = props && props.match && props.match.params;
|
||||
const { resetUserInfo , current_user } = props;
|
||||
console.log(props);
|
||||
|
||||
useEffect(()=>{
|
||||
if(current_user && current_user.login){
|
||||
|
|
Loading…
Reference in New Issue