2020-06-03 09:56:07 +08:00
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { Button ,Spin } from "antd";
|
|
|
|
|
import { truncateCommitId } from '../common/util';
|
2020-11-10 16:42:32 +08:00
|
|
|
import { getImageUrl } from 'educoder';
|
|
|
|
|
import Files from '../Merge/Files';
|
2020-06-03 09:56:07 +08:00
|
|
|
|
2021-09-24 11:27:32 +08:00
|
|
|
import Tree from "./img/tree.png";
|
2020-06-03 09:56:07 +08:00
|
|
|
import User from "../Component/User";
|
|
|
|
|
|
|
|
|
|
import axios from "axios";
|
2020-05-29 17:00:42 +08:00
|
|
|
|
|
|
|
|
const Infos = styled.div`
|
2021-09-24 11:27:32 +08:00
|
|
|
border: 1px solid #FAFCFF;
|
2020-11-10 16:42:32 +08:00
|
|
|
margin-bottom:15px;
|
2020-06-03 09:56:07 +08:00
|
|
|
& .commitinfos {
|
|
|
|
|
background-color: #f1f8ff;
|
2021-09-24 11:27:32 +08:00
|
|
|
border: 1px solid rgba(42, 97, 255, 0.23);
|
|
|
|
|
border-radius: 3px 3px 0px 0px;
|
|
|
|
|
padding: 10px 8px 10px 16px;
|
|
|
|
|
& .f-wrap-between{
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
& .task-hide{
|
|
|
|
|
width: 65rem;
|
|
|
|
|
overflow:hidden;
|
|
|
|
|
white-space:normal;
|
|
|
|
|
word-break:break-all;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: #333333;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
}
|
2020-05-29 17:00:42 +08:00
|
|
|
}
|
2020-06-03 09:56:07 +08:00
|
|
|
& > .f-wrap-between {
|
2021-09-24 11:27:32 +08:00
|
|
|
padding: 14px 8px 14px 16px;
|
|
|
|
|
border-radius: 3px 3px 0px 0px;
|
|
|
|
|
border: 1px solid #D0D0D0;
|
|
|
|
|
.df{
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2020-05-29 17:00:42 +08:00
|
|
|
}
|
|
|
|
|
`;
|
2021-09-24 11:27:32 +08:00
|
|
|
//提交详情页
|
2020-11-10 16:42:32 +08:00
|
|
|
export default ({ match , history }) => {
|
2020-07-07 09:25:56 +08:00
|
|
|
const [data, setData] = useState({undefined});
|
2020-06-03 09:56:07 +08:00
|
|
|
const [commit, setCommit] = useState(undefined);
|
|
|
|
|
const [parents, setParents] = useState(undefined);
|
|
|
|
|
const [committer, setCommitter] = useState(undefined);
|
|
|
|
|
const [isSpin, setIsSpin] = useState(true);
|
2020-05-29 17:00:42 +08:00
|
|
|
|
2021-09-24 11:27:32 +08:00
|
|
|
const { sha , projectsId, owner, branchName } = match.params;
|
2020-06-03 09:56:07 +08:00
|
|
|
useEffect(() => {
|
2020-11-10 16:42:32 +08:00
|
|
|
if (projectsId && owner && sha) {
|
|
|
|
|
const url = `/${owner}/${projectsId}/commits/${sha}.json`;
|
2020-06-03 09:56:07 +08:00
|
|
|
axios
|
|
|
|
|
.get(url)
|
|
|
|
|
.then(result => {
|
|
|
|
|
if (result) {
|
|
|
|
|
setData(result.data);
|
|
|
|
|
setCommit(result.data.commit);
|
|
|
|
|
setParents(result.data.parents);
|
|
|
|
|
setCommitter(result.data.committer || (result.data.commit && result.data.commit.committer));
|
|
|
|
|
setIsSpin(false);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-11-10 16:42:32 +08:00
|
|
|
}, [projectsId , owner, sha]);
|
2021-09-24 11:27:32 +08:00
|
|
|
|
2020-06-03 09:56:07 +08:00
|
|
|
return (
|
2021-05-26 15:25:21 +08:00
|
|
|
<div className="main" style={{padding:"0px",border:"none"}}>
|
2020-06-03 09:56:07 +08:00
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
<Infos>
|
|
|
|
|
<div className="commitinfos">
|
2020-11-10 16:42:32 +08:00
|
|
|
<div className="f-wrap-between">
|
2021-09-24 11:27:32 +08:00
|
|
|
<div>
|
2020-11-10 16:42:32 +08:00
|
|
|
{commit && commit.message &&
|
2021-09-24 11:27:32 +08:00
|
|
|
<pre className="task-hide">{commit.message}</pre>
|
2020-11-10 16:42:32 +08:00
|
|
|
}
|
2021-09-24 11:27:32 +08:00
|
|
|
<i className="iconfont icon-fenzhi2 font-18"></i>{branchName}
|
|
|
|
|
</div>
|
2021-09-24 14:29:57 +08:00
|
|
|
<Button type="primary" onClick={()=>{history.push(`/${owner}/${projectsId}/tree/${truncateCommitId(sha)}`)}} className="btnblue" style={{height:"36px"}}>浏览文件</Button>
|
2020-11-10 16:42:32 +08:00
|
|
|
</div>
|
2020-06-03 09:56:07 +08:00
|
|
|
</div>
|
|
|
|
|
<div className="f-wrap-between" style={{ alignItems: "center" }}>
|
|
|
|
|
<ul className="df">
|
|
|
|
|
<User
|
2021-04-19 18:19:21 +08:00
|
|
|
url={(committer && getImageUrl(`/${committer.image_url}`))|| "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3025493530,1989042357&fm=26&gp=0.jpg"}
|
2020-06-03 09:56:07 +08:00
|
|
|
name={committer && committer.name}
|
|
|
|
|
/>
|
2021-09-24 11:27:32 +08:00
|
|
|
{commit && commit.time_from_now && <li className="ml4">提交于{commit.time_from_now}</li>}
|
2020-06-03 09:56:07 +08:00
|
|
|
</ul>
|
|
|
|
|
<li className="df">
|
|
|
|
|
{
|
|
|
|
|
parents && parents.length > 0 && parents.map((item,key)=>{
|
|
|
|
|
return(
|
2021-09-24 11:27:32 +08:00
|
|
|
<div className="ml40 f-wrap-alignCenter">
|
|
|
|
|
<label className="mr8">父节点</label>
|
|
|
|
|
<img src={Tree} alt="sha" width={"16px"} className="mr4"/>
|
|
|
|
|
<span>{truncateCommitId(item.sha)}</span>
|
|
|
|
|
</div>
|
2020-06-03 09:56:07 +08:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-09-24 11:27:32 +08:00
|
|
|
<div className="ml40 f-wrap-alignCenter">
|
|
|
|
|
<label className="mr8">当前节点</label>
|
|
|
|
|
<img src={Tree} alt="sha" width={"16px"} className="mr4"/>
|
|
|
|
|
<span>{truncateCommitId(sha)}</span>
|
|
|
|
|
</div>
|
2020-06-03 09:56:07 +08:00
|
|
|
</li>
|
|
|
|
|
</div>
|
|
|
|
|
</Infos>
|
2020-11-10 16:42:32 +08:00
|
|
|
<Files
|
|
|
|
|
history={history}
|
|
|
|
|
data={data}
|
|
|
|
|
owner={owner}
|
|
|
|
|
projectsId={projectsId}
|
|
|
|
|
/>
|
2020-06-03 09:56:07 +08:00
|
|
|
</Spin>
|
2020-05-29 17:00:42 +08:00
|
|
|
</div>
|
2020-06-03 09:56:07 +08:00
|
|
|
);
|
|
|
|
|
};
|