forked from Gitlink/forgeplus-react
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
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(
|
||
<div className="pb20">
|
||
{
|
||
commits && commits.length>0 && commits.map((item,key)=>{
|
||
return(
|
||
<div className="prCommits">
|
||
<p className="prCreate">{item.created_at}</p>
|
||
<div className="prInfo">
|
||
<FlexAJ>
|
||
<AlignCenter>
|
||
<span className="commitKey" style={{marginLeft:0}}>{truncateCommitId(`${item.sha}`)}</span>
|
||
<p className="ml15 font-16 color-grey-3">{item.message}</p>
|
||
</AlignCenter>
|
||
{/* <Link to={""} className="color-blue">浏览代码</Link> */}
|
||
<AlignCenter>
|
||
<User url={getImageUrl(`images/${item.committer && item.committer.image_url}`)} name={`${item.committer && item.committer.name}`}></User><span>:提交于{item.time_from_now}</span>
|
||
</AlignCenter>
|
||
</FlexAJ>
|
||
|
||
</div>
|
||
</div>
|
||
)
|
||
})
|
||
}
|
||
</div>
|
||
)
|
||
}
|
||
export default Commits; |