Compare commits

..

2 Commits

Author SHA1 Message Date
wjr b73120152e feat: remove useless testcase 2022-08-21 21:17:52 +08:00
wjr d0417effab feat: issue and jouranl support emoji 2022-08-21 21:07:39 +08:00
10 changed files with 5365 additions and 4920 deletions

9818
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -187,7 +187,7 @@
"eslintConfig": {
"extends": "react-app"
},
"proxy": "http://localhost:3001",
"proxy": "http://localhost:3000",
"port": "3007",
"devDependencies": {
"@babel/runtime": "7.0.0-beta.51",

View File

@ -23,7 +23,6 @@ import Nodata from '../Nodata';
import Invite from './sub/Invite';
import CheckProfile from '../Component/ProfileModal/Profile';
import RenderHtml from '../../components/render-html';
import Badge from "./sub/Badge";
/**
* projectDetail.type:0是托管项目1是镜像项目2是同步镜像项目(为2时不支持在线创建在线上传在线修改在线删除创建合并请求等功能)
*/
@ -81,12 +80,6 @@ function CoderDepot(props){
const distribution = details && details.type != 2 && (details.permission === "Admin" || details.permission === "Owner" || details.permission === "Manager");
const { bannerList } = props;
// test data
const badges = {badge:[{ "login": "many_stars", "image_url": "https://www.gitlink.org.cn/system/lets/letter_avatars/2/J/236_194_58/120.png", "description": "test description1"}, {"login": "many_stars", "image_url": "https://www.gitlink.org.cn/system/lets/letter_avatars/2/X/181_166_38/120.png", "description": "test description2"}], total_count: 3}
console.log(badges.badge)
console.log(badges.total_count)
useEffect(()=>{
if(bannerList && bannerList.length>0){
let a = bannerList.filter(i=>i.menu_name === "pulls");
@ -353,7 +346,6 @@ function CoderDepot(props){
const fileOperate = type === "dir" && projectDetail && projectDetail.type !== 2 && ((projectDetail.permission && projectDetail.permission !=="Reporter") || (current_user && current_user.admin));
return(
<WhiteBack>
<UpdateDescModal desc={desc} website={website} lesson_url={lesson_url} visible={openModal} onCancel={()=>setOpenModal(false)} onOk={okUpdate}/>
<Spin spinning={isSpin}>
@ -377,8 +369,7 @@ function CoderDepot(props){
</React.Fragment>
}
<div style={{minHeight:"500px"}}>
{
{
projectDetail &&
<Box className="Panels">
<LongWidth>
@ -559,19 +550,6 @@ function CoderDepot(props){
<Invite code={inviteCode}/>
</div>
}
{/*{*/}
{/* inviteCode &&*/}
{/* <div>*/}
{/* <Badge code={inviteCode}/>*/}
{/* </div>*/}
{/*}*/}
{/* 徽章 */}
{
badges && badges.total_count >0 &&
<Badge badges={badges} owner={owner} />
}
{
lesson_url &&
<div>

View File

@ -200,26 +200,6 @@
}
}
}
.attrBadge{
padding-top: 12px;
display: flex;
flex-wrap: wrap;
padding-bottom: 2px;
a{
margin: 0px 17px 10px 0px;
img{
border-radius: 50%;
width: 40px;
height: 40px;
}
&:nth-child(5n){
margin-right: 0px;
}
}
}
.progress{
display: flex;
border-radius: 2px;

View File

@ -1,103 +0,0 @@
import React, { useEffect, useState } from 'react';
import { AlignCenter , FlexAJ } from '/home/gitlink/forgeplus/public/react/forgeplus-react/src/forge/Component/layout';
import { Link } from 'react-router-dom';
import { Popover , Spin , Button } from 'antd';
import { getImageUrl } from 'educoder';
import '/home/gitlink/forgeplus/public/react/forgeplus-react/src/forge/Component/Component.scss';
// projectDetail && projectDetail.contributors && projectDetail.contributors.total_count >0 &&
// <Badge contributors={projectDetail.contributors} owner={owner} projectsId={projectsId} />?
function Badge({badges,owner}){
const [ list , setList ]= useState(undefined);
const [ total , setTotal ]= useState(0);
const [ menu , setMenu ] = useState("");
const [ login , setLogin ] = useState(undefined);
const [ badge , setBadge ] = useState(undefined);
useEffect(()=>{
if(badges && badges.total_count>0){
setTotal(badges.total_count);
setList(badges.badge);
}
},[badges])
useEffect(()=>{
setMenusFunc(badge);
},[badge])
function setMenusFunc(data){
if(data){
let ele = (
<AlignCenter>
<Link to={`/${data.login}`}><img src={data.image_url} alt="" className="radius" width="38px" height="38px"/></Link>
<div className="ml10">
<Link to={`/${data.login}`}>{data.name}</Link>
{ data.description && <span className="leftline">{data.description}</span> }
</div>
</AlignCenter>
)
setMenu(ele);
}
}
function setVisibleFunc(flag,l,index){
if(l !== badge){
setBadge(l);
}
var lx = list.concat();
lx.map(i=>i.visible =false);
if(flag){
lx[index].visible = flag;
}
lx.splice();
setList(lx);
}
// {
// "list": [
// {
// "login": "many_stars",
// "image_url": "User",
// "description": "test description"
// },
// {
// "login": "many_stars",
// "image_url": "User",
// "description": "test description"
// }
// ],
// "total_count": 2
// }
return(
<div className="halfs">
<Link to={`/${owner}/badge`} className="font-16 color-ooo hoverA">
<span>徽章</span>
{ badges && badges.total_count > 0 && <span className="infoCount">{badges.total_count}</span>}
</Link>
<div className="attrBadge" onMouseLeave={()=>setVisibleFunc(false)}>
{
total > 0 ?
list.map((item,key)=>{
return(
<Popover content={menu} visible={item.visible} overlayClassName="menuPanels" placement="top">
<Link key={key} to={`/${item.login}`}>
<img src={item.image_url} alt="" onMouseOver={()=>setVisibleFunc(true,item,key)}/>
</Link>
</Popover>
)
})
:""
}
</div>
</div>
)
}
//{getImageUrl(`/${item.image_url}`)}
export default Badge;

View File

@ -3,10 +3,11 @@ import { Link } from "react-router-dom";
import axios from "axios";
import { getImageUrl } from "educoder";
import { Form, Popconfirm, Tag, Spin } from "antd";
import { Form, Popconfirm, Tag, Spin, Popover, Icon, Button } from "antd";
import Attachments from "../Upload/attachment";
import RenderHtml from "../../components/render-html";
import Comments from "../comments/comments";
import update from 'immutability-helper'
import "./order.css";
class Detail extends Component {
@ -50,6 +51,8 @@ class Detail extends Component {
.get(url)
.then((result) => {
if (result) {
// todo 增加后台返回
result.data.emojiComment = {}
this.setState({
data: result.data,
isSpins: false
@ -190,7 +193,54 @@ class Detail extends Component {
render() {
const { projectsId, orderId, owner } = this.props.match.params;
const { current_user } = this.props
const { data, isSpins } = this.state;
const emojiList = ["😀", "😅"];
const update_emoji_comment = (emoji) => {
// 无emoji评论
if (!data.emojiComment || !data.emojiComment[emoji] || data.emojiComment[emoji].users.length == 0) {
var emojiComment = data.emojiComment ? data.emojiComment : {}
emojiComment[emoji] = {
"users": [owner],
"total": 1
}
this.setState({
data: update(data, { emojiComment: { $set: emojiComment } })
})
return
}
// 有emoji评论
var userList = data.emojiComment[emoji].users
var addNewUser = true
for (var i = 0; i < userList.length; i++) {
if (userList[i] == owner) {
userList.splice(i, 1);
addNewUser = false
break
}
}
if (addNewUser) {
userList.push(owner)
}
var emojiComment = data.emojiComment
emojiComment[emoji] = {
"users": userList,
"total": userList.length
}
this.setState({
data: update(data, { emojiComment: { $set: emojiComment } })
})
}
const emojiComment = (
emojiList.map((emoji) => {
return <Button type="link" className="detail_emoji_comment_menu_item"
onClick={(e) => update_emoji_comment(emoji)} key={emoji}>{emoji}</Button>
})
);
const get_color = (type) => {
if (type === "高") {
return "#e67e22";
@ -233,7 +283,7 @@ class Detail extends Component {
: "合并请求"}
</span>
<span className="font-16 fwb" style={{wordBreak:"break-all"}}>{data && data.subject}</span>
<span className="font-16 fwb" style={{ wordBreak: "break-all" }}>{data && data.subject}</span>
</span>
{data && data.priority && (
@ -279,8 +329,8 @@ class Detail extends Component {
</Link>
</span>
) : (
""
)}
""
)}
</div>
</div>
</div>
@ -289,8 +339,8 @@ class Detail extends Component {
{data && data.description && data.description.length > 0 ? (
this.commentCtx(data.description)
) : (
<span className="color-grey-9 ml3 mr3">暂无描述</span>
)}
<span className="color-grey-9 ml3 mr3">暂无描述</span>
)}
</div>
{data && data.attachments && data.attachments.length > 0 ? (
<Attachments
@ -298,8 +348,37 @@ class Detail extends Component {
showNotification={this.props.showNotification}
/>
) : (
""
)}
""
)}
<div className="detail_emoji_comment" >
<style>
{`
.ant-popover-inner-content {
padding: 2px 5px;
}
`}
</style>
{current_user && current_user.login ? (
<Popover content={emojiComment} trigger="click">
<Button shape="circle"><Icon type="smile" theme="outlined" /></Button>
</Popover>
) : ("")
}
{current_user && current_user.login && data && data.emojiComment ? (
Object.keys(data.emojiComment).map(key => {
const item = data.emojiComment[key]
if (item.users.length == 0) {
return
}
return <Popover className="detail_emoji_pop" content={item.users.join(",")} key={key}>
<Button className="detail_emoji_button" shape="round" onClick={(e) => update_emoji_comment(key)}>
{key}+{item.total}
</Button>
</Popover>
})
) : ("")
}
</div>
</div>
</div>
@ -329,8 +408,8 @@ class Detail extends Component {
{data.issue_tags[0].name}
</span>
) : (
"--"
)}
"--"
)}
</span>
</p>
<p className="grid-item-left pb15">

View File

@ -44,6 +44,24 @@
display: flex;
}
.detail_emoji_comment {
margin-top: 20px;
}
.detail_emoji_comment_menu {
padding: 5px;
}
.detail_emoji_comment_menu_item {
padding-left: 0px;
padding-right: 0px;
}
.detail_emoji_pop {
margin-left: 10px;
}
.detail_emoji_button {
padding-left: 5px;
padding-right: 5px;
}
.detail_right {
flex-grow: 1;
text-align: right;

View File

@ -5,14 +5,15 @@ import axios from "axios";
import Upload from "../Upload/Index";
import UploadImg from "../Images/upload.png";
import { getImageUrl } from "educoder";
import { List, Popconfirm, Pagination, Button, Tabs, Avatar } from "antd";
import { List, Popconfirm, Pagination, Button, Tabs, Popover, Icon } from "antd";
import Attachments from "../Upload/attachment";
import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor";
import RenderHtml from "../../components/render-html";
import ChildrenComments from "./children_comments";
import update from 'immutability-helper'
import "../Order/order.css";
const { TabPane } = Tabs;
class comments extends Component {
class comments extends Component {
constructor(props) {
super(props);
this.state = {
@ -94,7 +95,7 @@ class comments extends Component {
this.setState({
journal_spin: false
});
if(result && result.data.status !== 411){
if (result && result.data.status !== 411) {
this.props.showNotification(result.data.message);
}
})
@ -202,7 +203,7 @@ class comments extends Component {
</span>
<span>
{item.value && item.value.length > 0 ? (
item.detail === "标记"? (
item.detail === "标记" ? (
<span
className="issue-tag-show"
style={{ background: item.value[0].color }}
@ -272,12 +273,12 @@ class comments extends Component {
}
commentCtx = (v) => {
return <RenderHtml className="break_word_comments imageLayerParent" value={v} url={this.props.history.location}/>;
return <RenderHtml className="break_word_comments imageLayerParent" value={v} url={this.props.history.location} />;
};
Paginations = ()=>{
Paginations = () => {
const { page, limit, search_count } = this.state;
if(search_count > limit){
return(
if (search_count > limit) {
return (
<div className="pt30 mb50 edu-txt-center btp1">
<Pagination
simple
@ -308,6 +309,62 @@ class comments extends Component {
new_journal_id,
} = this.state;
const { current_user, only_show_content } = this.props;
const emojiList = ["😀", "😅"];
const update_emoji_comment = (item, emoji) => {
// 无emoji评论
if (!item.emojiComment || !item.emojiComment[emoji] || item.emojiComment[emoji].users.length == 0) {
const idx = journalsdata.issue_journals.findIndex(function (journal) {
return journal.id == item.id;
})
var emojiComment = item.emojiComment ? item.emojiComment : {}
emojiComment[emoji] = {
"users": [current_user.login],
"total": 1
}
var journal = journalsdata.issue_journals[idx]
journal.emojiComment = emojiComment
this.setState({
journalsdata: update(journalsdata, { issue_journals: { [idx]: { $set: journal } } })
})
return
}
// 有emoji评论
var userList = item.emojiComment[emoji].users
var addNewUser = true
for (var i = 0; i < userList.length; i++) {
if (userList[i] == current_user.login) {
userList.splice(i, 1);
addNewUser = false
break
}
}
if (addNewUser) {
userList.push(current_user.login)
}
const idx = journalsdata.issue_journals.findIndex(function (journal) {
return journal.id == item.id;
})
var emojiComment = item.emojiComment
emojiComment[emoji] = {
"users": userList,
"total": userList.length
}
var journal = journalsdata.issue_journals[idx]
journal.emojiComment = emojiComment
this.setState({
journalsdata: update(journalsdata, { issue_journals: { [idx]: { $set: journal } } })
})
};
const emojiComment = (item) => {
return emojiList.map((emoji) => {
return <Button type="link" className="detail_emoji_comment_menu_item"
onClick={(e) => update_emoji_comment(item, emoji)} key={emoji}>{emoji}</Button>
})
};
const new_comment = (is_reply, item_id) => {
return (
@ -315,7 +372,7 @@ class comments extends Component {
<Link
to={`/${current_user && current_user.login}`}
className="show-user-link mr10"
>
>1
<img
className="radius"
src={getImageUrl(
@ -416,11 +473,33 @@ class comments extends Component {
""
)}
<div className="grid-item mt5">
<span className="color-grey-8">{item.created_at}</span>
<div>
<span className="color-grey-8">{item.created_at}</span>
{current_user && current_user.login ? (
<Popover content={emojiComment(item)} trigger="click" className="ml10">
<Button shape="circle"><Icon type="smile" theme="outlined" /></Button>
</Popover>
) : ("")
}
{current_user && current_user.login && item.emojiComment ? (
Object.keys(item.emojiComment).map(key => {
const comments = item.emojiComment[key]
if (comments.users.length == 0) {
return
}
return <Popover className="detail_emoji_pop" content={comments.users.join(",")} key={key}>
<Button className="detail_emoji_button" shape="round" onClick={(e) => update_emoji_comment(item, key)}>
{key}+{comments.total}
</Button>
</Popover>
})
) : ("")
}
</div>
<span className="text-right">
{current_user &&
(current_user.admin ||
current_user.login === item.user_login) ? (
(current_user.admin ||
current_user.login === item.user_login) ? (
<Popconfirm
placement="bottom"
title={"确定要删除当前评论吗?"}

View File

@ -239,59 +239,4 @@ ul.ant-menu.menuStyle{
content:"";
}
}
}
.attrBadge{
padding-top: 12px;
display: flex;
flex-wrap: wrap;
padding-bottom: 2px;
a{
margin: 0px 17px 10px 0px;
img{
border-radius: 50%;
width: 40px;
height: 40px;
}
&:nth-child(5n){
margin-right: 0px;
}
}
}
.attrBadge{
padding-top: 12px;
display: flex;
flex-wrap: wrap;
padding-bottom: 2px;
a{
margin: 0px 17px 10px 0px;
img{
border-radius: 50%;
width: 40px;
height: 40px;
}
&:nth-child(5n){
margin-right: 0px;
}
}
}
.infoCount{
display: inline-block;
width: 24px;
text-align: center;
height: 24px;
line-height: 24px;
background-color:rgba(153, 153, 153, 0.13);;
color:#666;
border-radius: 12px;
margin-left: 6px;
font-size: 12px;
}
}

View File

@ -1,6 +1,6 @@
import React, { Component } from "react";
import { Link } from "react-router-dom";
import { Button, Spin , Menu, Popover } from "antd";
import { Button, Spin , Menu } from "antd";
import FocusButton from "../UsersList/focus_button";
import axios from "axios";
@ -13,10 +13,6 @@ import './Index.scss';
import Loadable from "react-loadable";
import Loading from "../../Loading";
import Badge from "../Main/sub/Badge";
//test data
const badges = {badge:[{ "login": "many_stars", "image_url": "https://testforgeplus.trustie.net//system/lets/letter_avatars/2/G/178_217_57/120.png", "description": "test description1"}, {"login": "many_stars", "image_url": "https://testforgeplus.trustie.net//images/avatars/User/36480?t=1686645429", "description": "test description2"}], total_count: 3}
const UpdateInfo = Loadable({
loader: () => import("./Material/Index"),
@ -74,7 +70,6 @@ class Infos extends Component {
};
}
renderPath=(pathname)=>{
const { username } = this.props.match.params;
if(pathname === `/${username}`){
@ -135,9 +130,7 @@ class Infos extends Component {
this.setState({
user: result.data,
isSpin: false,
undo_events:e,
//测试数据
badges : {badge:[1, 2, 3], total_count: 3}
undo_events:e
});
})
.catch((error) => {
@ -201,7 +194,7 @@ class Infos extends Component {
render() {
const { current_user } = this.props;
const { username } = this.props.match.params;
const { user, isSpin, route_type , undo_events , menuKey} = this.state;
const { user, isSpin, route_type , undo_events , menuKey } = this.state;
return (
<div className="newMain clearfix">
<Spin spinning={isSpin}>
@ -282,35 +275,7 @@ class Infos extends Component {
</div>
:""
}
</div>
{
badges && badges.total_count >0 &&
<Badge badges={badges} />
}
{/*{*/}
{/* badges && badges.total_count >0 &&*/}
{/* <div className="list-l-Menu text-center">*/}
{/* {*/}
{/* badges.total_count > 0 ? owner={owner} projectsId={projectsId} */}
{/* badges.badge.map((item,key)=>{*/}
{/* return(*/}
{/* <Popover content={menu} visible={item.visible} overlayClassName="menuPanels" placement="top">*/}
{/* <div>*/}
{/* <span>{item}</span>*/}
{/* <img src={getImageUrl(`/${item.image_url}`)} />*/}
{/* </div>*/}
{/* </Popover>*/}
{/* )*/}
{/* })*/}
{/* :""*/}
{/* }*/}
{/* </div>*/}
{/*}*/}
</div>
</div>
<div className="list-right">