diff --git a/src/forge/Merge/UpdateMerge.js b/src/forge/Merge/UpdateMerge.js
index d9167fa2a..8117f3877 100644
--- a/src/forge/Merge/UpdateMerge.js
+++ b/src/forge/Merge/UpdateMerge.js
@@ -4,7 +4,6 @@ import axios from "axios";
import "../Order/order.scss";
import "./merge.css";
import MergeForm from "./merge_form";
-import MergeFooter from "./merge_footer";
const Option = Select.Option;
class UpdateMerge extends Component {
constructor(props) {
diff --git a/src/forge/Merge/components/fileDrop.jsx b/src/forge/Merge/components/fileDrop.jsx
new file mode 100644
index 000000000..193cb8d63
--- /dev/null
+++ b/src/forge/Merge/components/fileDrop.jsx
@@ -0,0 +1,117 @@
+import React ,{useEffect,useState } from 'react';
+import { truncateCommitId } from '../../common/util';
+import { AlignCenter , FlexAJ } from '../../Component/layout';
+import { Tooltip , Progress , Spin } from 'antd';
+import "../Index.scss";
+import axios from 'axios';
+
+
+function FileDrop({prekey,item,projectsId,owner , history , mergeId,parentsSha}){
+ const [ copyfileTipTitle, setCopyfileTipTitle] = useState("复制文件路径");
+ const [ sections, setSections ] = useState(undefined);
+ const [ show, setShow ] = useState(true);
+ const [ isSpin, setIsSpin ] = useState(false);
+
+ useEffect(()=>{
+ if(prekey < 3 && item && item.filename){
+ showDown(item.filename);
+ }
+ },[prekey,item])
+
+ function copyFileName(fileName){
+ var copyCont = document.createElement('input');
+ copyCont.defaultValue = fileName;
+ document.body.appendChild(copyCont);
+ copyCont.select(); // 选择对象
+ document.execCommand("Copy"); // 执行浏览器复制命令
+ copyCont.className = 'copyCont';
+ copyCont.style.display='none';
+ setCopyfileTipTitle("复制成功");
+ }
+ function subStrContent(content){
+ return content ? " " + content.slice(1) :"";
+ }
+
+ function showDown(filename){
+ if(!sections){
+ setIsSpin(true);
+ const url = `/v1/${owner}/${projectsId}/${mergeId}/files.json`;
+ axios.get(url,{
+ params:{filepath:filename}
+ }).then(res=>{
+ if(res){
+ let files = res.data && res.data.files && res.data.files.length>0 && res.data.files[0];
+ setSections(files.sections);
+ setShow(true);
+ setIsSpin(false);
+ }
+ })
+ }else{
+ setShow(!show);
+ }
+ }
+ return(
+
+
+
+ setShow(!show)} style={{cursor:!item.is_bin && item.changes !== 0?"pointer":"default"}}>
+ {(!item.is_bin && item.changes !== 0) ?
:""}
+
+ { item.is_renamed && item.old_name}
+ { item.is_renamed && }
+ {item.filename}
+
+ setCopyfileTipTitle("复制文件路径")}
+ >
+ {e.stopPropagation();copyFileName(item.filename);}}>
+
+
+
+
0 ? ":":""} ${item.additions > 0 ? item.additions + "处添加" : ""}${item.additions > 0 && item.deletions > 0 ? "和" : ""}${item.deletions > 0 ? item.deletions + "处删除" : ""}`}>
+
+ {item.additions+item.deletions}处
+
+ {
+ !item.is_submodule &&
+
{history.push(`/${owner}/${projectsId}${item.is_deleted ? `/commits/${truncateCommitId(parentsSha)}`:`/tree/${truncateCommitId(item.sha)}/${item.filename}`}`)}}>查看文件
+ }
+
+
+ {
+ (!item.is_bin && item.changes !== 0) && show &&
+
+ {
+ (sections && sections.length > 0) ? sections.map((i,k)=>{
+ return(
+ i.lines && i.lines.length>0 && i.lines.map((item,keys)=>{
+ return(
+
+
+ {item.left_index && item.left_index !=="0" ? item.left_index :"" }
+ {item.right_index && item.right_index !=="0" ? item.right_index :"" }
+
+
+
{item.type===2 ? "+" : item.type===3 ? "-" :""}
+
+ {(item.type===3 || item.type===2) ? subStrContent(item.content) : item.content}
+
+
+
+ )
+ })
+ )
+ })
+ :
+
+ }
+
+ }
+
+
+ )
+}
+export default FileDrop;
\ No newline at end of file
diff --git a/src/forge/Merge/merge_footer.js b/src/forge/Merge/merge_footer.js
index 340d47b26..324876541 100644
--- a/src/forge/Merge/merge_footer.js
+++ b/src/forge/Merge/merge_footer.js
@@ -1,10 +1,12 @@
import React, { Component } from 'react';
-import { Tabs } from 'antd';
+import { Tabs , Spin } from 'antd';
import Commits from './Commits';
import Files from './Files';
+import { returnbar , turnbar } from 'educoder';
import '../Order/order.scss';
import './merge.css';
+import axios from 'axios';
const { TabPane } = Tabs;
@@ -13,9 +15,30 @@ class MergeFooter extends Component {
super(props);
this.state = {
activeKey: '1',
+ diff:undefined,
+ filesData: undefined,
+ page:1,
+ hasMore:true,
+ dropLoading:false,
+ limit:100
};
}
+ componentDidMount(){
+ this.getFilesInfo();
+ window.addEventListener("scroll",this.scrollListener);
+ return ()=>{window.removeEventListener("scroll",this.scrollListener);}
+ }
+
+ scrollListener=()=>{
+ let scrollHeight = document.documentElement.scrollHeight;
+ let clientHeight = document.documentElement.clientHeight;
+ let scrollTop = document.documentElement.scrollTop;
+ if(Math.ceil(scrollTop+clientHeight) >= scrollHeight-5){
+ this.getFilesInfo();
+ }
+ }
+
changeTab = (index) => {
this.setState({
activeKey: index,
@@ -27,11 +50,58 @@ class MergeFooter extends Component {
changeCommitFunc&& changeCommitFunc(page);
}
+ componentDidUpdate(prevProps) {
+ // 解决切换tab后浏览器回退不刷新的问题、点击tab后url变化但tab未切换的问题
+ const newPathname = this.props.location.pathname;
+ const prevPathname = prevProps.location.pathname;
+ if (newPathname !== prevPathname) {
+ this.getFilesInfo();
+ }
+ }
+
+ getFilesInfo=()=>{
+ const { hasMore , dropLoading , filesData , page , limit } = this.state;
+ if(!hasMore || dropLoading){
+ return;
+ }
+ this.setState({dropLoading:page>1})
+ const { branchParams = {} } = this.props;
+ const { mergeOwner, projectId } = branchParams;
+ let url = `/v1/${mergeOwner}/${projectId}/${this.getUrl()}/files.json`;
+ axios.get(url,{
+ params:{page,limit}
+ }).then(res=>{
+ if(res){
+ let datas = res.data;
+ let files = page === 1 ? datas.files : filesData.concat(datas.files);
+ this.setState({
+ diff:res.data ,
+ filesData: files,
+ hasMore:datas.files && datas.files.length === limit,
+ dropLoading:false,page:page+1
+ })
+ }
+ })
+ }
+
+ getUrl = ()=>{
+ const { branchParams = {} } = this.props;
+ const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId , pullIdentity } = branchParams;
+ let url = `compare`;
+ if (mergeOwner === pullOwner) {
+ url += `/${Base64.encode(returnbar(pullBranch))}...${Base64.encode(returnbar(mergeBranch))}`;
+ } else {
+ url += `/${Base64.encode(returnbar(mergeBranch))}...${pullOwner}/${pullIdentity || projectId}:${Base64.encode(returnbar(pullBranch))}`;
+ }
+ return url;
+ }
+
+
render() {
const { projectsId, owner } = this.props.match.params;
- const { comparesData = {} ,limit } = this.props;
- const { commits, diff, commits_count } = comparesData;
- const { activeKey } = this.state;
+ const { comparesData = {} ,limit ,branchParams } = this.props;
+ const { commits,commits_count } = comparesData;
+ const { activeKey , diff , filesData , dropLoading } = this.state;
return (commits && commits.length === 0) || !diff ? (
''
@@ -71,19 +141,24 @@ class MergeFooter extends Component {
tab={
文件
- {diff.files_count > 0 && (
- {diff.files_count}
+ {diff.file_nums > 0 && (
+ {diff.file_nums}
)}
}
key="3"
>
-
+
+
+ { dropLoading &&
文件加载中...
}
+
)}