From e9fef026a64e2fa377b831d33070864f9420d6ba Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 5 Nov 2020 11:31:26 +0800 Subject: [PATCH] pr --- src/forge/Main/CoderRootCommit.js | 2 +- src/forge/Merge/Commits.jsx | 51 ++++++++++++ src/forge/Merge/Files.jsx | 71 ++++++++++++++++ src/forge/Merge/MessageCount.js | 59 ++++++++++++-- src/forge/Merge/NewMerge.js | 20 +++-- src/forge/Merge/merge.css | 129 ++++++++++++++++++++++++++++++ src/forge/Merge/merge_footer.js | 37 ++++----- 7 files changed, 335 insertions(+), 34 deletions(-) create mode 100644 src/forge/Merge/Commits.jsx create mode 100644 src/forge/Merge/Files.jsx diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 916af5b2..8655fbfc 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -1,7 +1,7 @@ import React , { Component } from 'react'; import { Spin , Pagination } from 'antd'; import { getImageUrl } from 'educoder'; -import { truncateCommitId } from '../common/util' +import { truncateCommitId } from '../common/util'; import SelectBranch from '../Branch/Select'; import Nodata from '../Nodata'; diff --git a/src/forge/Merge/Commits.jsx b/src/forge/Merge/Commits.jsx new file mode 100644 index 00000000..513aa384 --- /dev/null +++ b/src/forge/Merge/Commits.jsx @@ -0,0 +1,51 @@ +import React , { useEffect , useState } from 'react'; +import axios from 'axios'; +import { AlignCenter , FlexAJ } from '../Component/layout'; +import User from '../Component/User'; +import { truncateCommitId } from '../common/util'; +import { getImageUrl } from 'educoder'; +import {Link} from 'react-router-dom'; + +function Commits(props){ + const [ commits , setCommits ] = useState(undefined); + + const { projectsId , owner , mergeId } = props.match.params; + + useEffect(()=>{ + if(projectsId && owner && mergeId){ + const url = `/${owner}/${projectsId}/pulls/${mergeId}/commits.json`; + axios.get(url).then(result=>{ + if(result){ + setCommits(result.data.commits); + } + }).catch(error=>{}) + } + },[projectsId,owner,mergeId]); + return( +
+ { + commits && commits.length>0 && commits.map((item,key)=>{ + return( +
+

{item.created_at}

+
+ + + {truncateCommitId(`${item.sha}`)} +

{item.message}

+
+ {/* 浏览代码 */} + + :提交于{item.time_from_now} + +
+ +
+
+ ) + }) + } +
+ ) +} +export default Commits; \ No newline at end of file diff --git a/src/forge/Merge/Files.jsx b/src/forge/Merge/Files.jsx new file mode 100644 index 00000000..dc274594 --- /dev/null +++ b/src/forge/Merge/Files.jsx @@ -0,0 +1,71 @@ +import React ,{useEffect,useState} from 'react'; +import { AlignCenter , FlexAJ } from '../Component/layout'; + +import axios from 'axios'; +function Files(props){ + const [ data , setData ] = useState(undefined); + const [ files , setFiles ] = useState(undefined); + const { projectsId , owner , mergeId } = props.match.params; + + useEffect(()=>{ + if(projectsId && owner && mergeId){ + const url = `/${owner}/${projectsId}/pulls/${mergeId}/files.json`; + axios.get(url).then(result=>{ + if(result){ + setData(result.data); + setFiles(result.data.files); + } + }).catch(error=>{}) + } + },[projectsId,owner,mergeId]); + + return( +
+ + + + 共有 {data && data.files_count} 个文件被更改,包括 + {data && data.total_addition && {data && data.total_addition} 次插入 } + { data && data.total_deletion ? `和${ {data && data.total_deletion} 次删除}`:""} + + + { + files && files.length>0 && +
+ { + files.map((item,key)=>{ + return( +
+ + + + {item.name} + + + +{item.addition} + -{item.deletion} + + +
+ { + item.sections && item.sections.length >= 1 && item.sections[0].lines && + item.sections[0].lines.map((item,key)=>{ + return( +
+ {item.rightIdx && item.rightIdx !=="0" ? item.rightIdx :"" } +

{item.content}

+
+ ) + }) + } +
+
+ ) + }) + } +
+ } +
+ ) +} +export default Files; \ No newline at end of file diff --git a/src/forge/Merge/MessageCount.js b/src/forge/Merge/MessageCount.js index c7052fe7..b9b5ef38 100644 --- a/src/forge/Merge/MessageCount.js +++ b/src/forge/Merge/MessageCount.js @@ -1,6 +1,7 @@ import React, { Component } from "react"; +import { Tabs } from 'antd'; import { Link } from "react-router-dom"; - +import { AlignCenter } from '../Component/layout'; import axios from "axios"; import { getImageUrl } from "educoder"; import { @@ -39,6 +40,8 @@ class MessageCount extends Component { SpinMerge: false, edit_spin: false, pr_status: undefined, + + copyVisible:false, }; } @@ -47,7 +50,18 @@ class MessageCount extends Component { SpinFlag: true, }); this.getDetail(); + + // this.clickBody(); }; + clickBody=()=>{ + document.body.addEventListener('click', e => { + let name = e.target.className; + if(name.indexOf("notHide")>-1 || name.indexOf("ant-tabs-tab")>-1 || name==="ant-tabs-nav-scroll"){return;} + this.setState({ + copyVisible:false + }) + }) + } getDetail = () => { const { projectsId, mergeId, owner } = this.props.match.params; @@ -198,6 +212,33 @@ class MessageCount extends Component { return ; }; + setCopyVisible=(e)=>{ + e.stopPropagation(); + this.setState({ + copyVisible:true + }) + } + + copyItem =()=>{ + return( +
+ + HTTPS}>{this.returnCopyUrl("https://gitee.com/44886/polhttp.git")} + SSH}>{this.returnCopyUrl("https://gitee.com/44886/polssh.git")} + +
+ ) + } + + returnCopyUrl=(url)=>{ + return( +
+ + +
+ ) + } + render() { const { projectsId, mergeId , owner } = this.props.match.params; @@ -208,6 +249,7 @@ class MessageCount extends Component { isSpin, ismesrge, SpinFlag, + copyVisible } = this.state; const { current_user, projectDetail } = this.props; const menu = ( @@ -352,13 +394,20 @@ class MessageCount extends Component {
-
+
+ {/* + this.setCopyVisible(e)}> + 复制 + + 下载为 + */} {current_user && projectDetail && pr_status !== 2 && projectDetail.permission !=="Reporter" && (
-
+
{ this.setState({isSpin: true}) const { owner } = this.props.match.params; @@ -120,9 +120,7 @@ class NewMerge extends Component { }; selectProjectName = (value) => { - console.log("value",value) - const { project_id, projects_names,id } = this.state; - const { owner } = this.props.match.params; + const { projects_names,id } = this.state; let arr = projects_names && projects_names.filter(item=>item.id===value); let identifier = arr && arr[0].project_id; let login = arr && arr[0].project_user_login; @@ -138,7 +136,6 @@ class NewMerge extends Component { }) this.props.history.push(`/projects/${login}/${identifier}/pulls/new`); this.newMergelist(login,identifier); - }; //判断2分支是否可以合并 @@ -146,7 +143,7 @@ class NewMerge extends Component { ischeckmerge = () => { this.setState({ isSpin: true }); const { projectsId , owner } = this.props.match.params; - const { pull, merge, project_id, merge_head, id } = this.state; + const { pull, merge , merge_head, id } = this.state; const url = `/${owner}/${projectsId}/pulls/check_can_merge.json`; axios.post(url, { head: pull, @@ -196,7 +193,6 @@ class NewMerge extends Component { merge_head, projects_names, } = this.state; - const { projectsId } = this.props.match.params; const renderBrances = (list, type) => { if (list && list.length > 0) { return list.map((item, key) => { @@ -296,6 +292,14 @@ class NewMerge extends Component { )}
+ +
+ +
); } diff --git a/src/forge/Merge/merge.css b/src/forge/Merge/merge.css index f66d1025..72c4e093 100644 --- a/src/forge/Merge/merge.css +++ b/src/forge/Merge/merge.css @@ -58,4 +58,133 @@ form .ant-cascader-picker, form .ant-select { } .w240{ width: 240px; +} + +.custom-commit-tabs .ant-tabs-nav .ant-tabs-tab{ + padding:14px 0px!important; +} +.custom-commit-tabs .ant-tabs-bar{ + border-bottom: none; +} +.custom-commit-tabs .ant-tabs-nav .ant-tabs-tab-active .tabNum{ + background-color: #EBF4FE; +} +.custom-commit-tabs .ant-tabs-ink-bar{ + width: 34px!important; +} +.tabNum{ + display: inline-block; + margin-left:8px ; + border-radius: 10px; + height: 18px; + line-height: 18px; + background-color: #eee; + padding:0px 9px; + font-size: 12px; +} + +/* 复制-下载为,组合按钮 */ +.composeButton{ + display: flex; + border:1px solid #5091FF; + border-radius: 5px; + height: 34px; + line-height: 34px; +} +.composeButton > span{ + display: block; + padding:0px 18px; + color: #5091FF; + display: flex; + align-items: center; + border-radius: 5px; + cursor: pointer; +} +.composeButton > span:hover{ + background-color: #F1F8FF; +} +.composeButton > span:first-child{ + border-radius: 5px 0px 0px 5px; + border-right: 1px solid #5091FF; +} +.ant-btn{ + border-radius: 5px; +} + +/* 绿色按钮-type="green" */ +.ant-btn.ant-btn-green{ + border:1px solid #28BD6C; + color: #28BD6C; +} +.copyTab{ + min-width: 370px; + padding:0px 18px 22px 18px; + box-shadow: 0px 2px 10px rgba(0,0,0,0.2); + background-color: #fff; +} +.copyTab .ant-tabs-tab{ + padding:12px 0px!important; +} + +/* pr--提交tab页面 */ +.prCommits{ + border:1px solid #ddd; + border-top: none; +} +.prCommits:first-child{ + border-top: 1px solid #ddd; +} +.prCommits .prCreate{ + height: 50px; + line-height: 50px; + padding:0px 25px; + background-color:#fafafa; + color:#333; + font-size: 16px; + border-bottom: 1px solid #ddd; +} +.prCommits .prInfo{ + padding:20px 25px; +} +/* pr-文件修改信息页面 */ +.files{ + border:1px solid #ddd; + margin-top: 15px; + border-radius: 2px; +} +.filesInfo{ + padding:10px 15px; + /* cursor: pointer; */ + background-color: #fafafa; +} +.filesContent{ + border-top: 1px solid #ddd; +} +.linesContent{ + display: flex; + height: 30px; + line-height: 30px; + align-items: center; + color: #333; +} +.linesContent > span{ + padding: 0px 8px 0px 15px; + min-width: 8%; + text-align: right; + display: block; + border-right: 1px solid #ddd; + margin-right: 8px; + color: #888; +} +.linesContent.translate{ + background-color:#F1F8FF; +} +.linesContent.translate > span{ + border-right: 1px solid transparent; +} +.linesContent.reduce{ + background-color:rgba(247, 48, 48, 0.15);; +} +.linesContent.add{ + background: rgba(48, 232, 132, 0.15); } \ No newline at end of file diff --git a/src/forge/Merge/merge_footer.js b/src/forge/Merge/merge_footer.js index 63627977..89dc4e86 100644 --- a/src/forge/Merge/merge_footer.js +++ b/src/forge/Merge/merge_footer.js @@ -2,16 +2,13 @@ import React, { Component } from "react"; import { Tabs, Empty } from "antd"; import "../Order/order.css"; import "./merge.css"; -import CodesCommit from "../Main/CoderRootCommit"; +import Commits from "./Commits"; import Comments from "../comments/comments"; +import Files from "./Files"; const { TabPane } = Tabs; class MergeFooter extends Component { - constructor(props) { - super(props); - this.state = {}; - } render() { const { footer_type, order_id } = this.props; @@ -20,25 +17,25 @@ class MergeFooter extends Component { { footer_type === "show" && - 评论} key="1"> - - + 评论1} key="1"> + + } - - {/* 提交} key="2"> - - */} - {/* 文件} key="3"> - - */} + 提交111} key="2"> + + + 文件11} key="3"> + +
);