通知管理模块

This commit is contained in:
谢思 2021-10-18 16:54:16 +08:00
parent 3e3e9f3681
commit a2c5c1ea6f
2 changed files with 59 additions and 97 deletions

View File

@ -63,7 +63,7 @@ function Index(props){
{notice_url && <ul className="securityUl ul-border-buttom"> {notice_url && <ul className="securityUl ul-border-buttom">
<li>消息通知</li> <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")>-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>}
<ul className="securityUl"> <ul className="securityUl">
<li>安全设置</li> <li>安全设置</li>
@ -73,18 +73,24 @@ function Index(props){
<LongWidth> <LongWidth>
<Gap> <Gap>
<Switch> <Switch>
<Route
path="/settings/notice"
render={(p) => (
<MyNoticeIndex {...props} {...p}/>
)}
></Route>
<Route <Route
path="/settings/notice/config" path="/settings/notice/config"
render={(p) => ( render={(p) => (
<NoticeManager {...props} {...p}/> <NoticeManager {...props} {...p}/>
)} )}
></Route> ></Route>
<Route
path="/settings/notice/privateLetter"
render={(p)=>(
<PrivateLetter{...props} {...p}/>
)}
></Route>
<Route
path="/settings/notice"
render={(p) => (
<MyNoticeIndex {...props} {...p}/>
)}
></Route>
<Route <Route
path="/settings/SSH/new" path="/settings/SSH/new"
render={(p) => ( render={(p) => (
@ -103,12 +109,6 @@ function Index(props){
<SSHIndex {...props} {...p}/> <SSHIndex {...props} {...p}/>
)} )}
></Route> ></Route>
<Route
path="/settings/notice/privateLetter"
render={(p)=>(
<PrivateLetter{...props} {...p}/>
)}
></Route>
</Switch> </Switch>
</Gap> </Gap>
</LongWidth> </LongWidth>

View File

@ -1,10 +1,36 @@
import { Button, Checkbox } from "antd"; import { Checkbox } from "antd";
import React from "react"; import React, { useEffect, useState } from "react";
import axios from 'axios';
import './Index.scss'; import './Index.scss';
function NoticeManager(props){ function NoticeManager(props){
const {current_user} = props;
const [settingTypes, setSettingTypes] = useState();
const [userNotification, setUserNotification] = useState();
const [userEmail, setUserEmail] = useState();
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();
},[])
console.log('settingTypes',settingTypes);
console.log('userNotification',userNotification,'userEmail',userEmail);
console.log(userNotification.ins)
return( return(
<div className="notice01"> <div className="notice01">
<div className="sshHead"> <div className="sshHead">
@ -12,87 +38,23 @@ function NoticeManager(props){
</div> </div>
<div> <div>
<span className="notice-manager-tip">您可以通过通知管理来选择接受通知的方式</span> <span className="notice-manager-tip">您可以通过通知管理来选择接受通知的方式</span>
<div className="manager-cont-top"> {settingTypes && settingTypes.map((item,key)=>{
我创建或负责的 return(
</div> item.type_name && <div>
<div className="manager-cont"> <div className="manager-cont-top">{item.type_name}</div>
<div className="manager-cont-title">易修状态变更</div> {item.settings.map((i, k) => {
<Checkbox defaultChecked='true' disabled>站内信</Checkbox> console.log(userNotification.get(item.type.substring(item.type.indexOf("::")+2)+"::"+i.key));
<Checkbox >邮件</Checkbox> return (
</div> <div className="manager-cont">
<div className="manager-cont"> <div className="manager-cont-title">{i.name}</div>
<div className="manager-cont-title">易修截止日期到达最后一天</div> <Checkbox defaultChecked='true' disabled = {i.notification_disabled}>站内信</Checkbox>
<Checkbox defaultChecked='true' disabled>站内信</Checkbox> <Checkbox disabled = {i.email_disabled}>邮件</Checkbox>
<Checkbox >邮件</Checkbox> </div>
</div> )
<div className="manager-cont"> })}
<div className="manager-cont-title">合并请求状态变更</div> </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>
</div> </div>
</div> </div>
) )