ADD truncate commit id

This commit is contained in:
Jasder 2020-03-30 10:21:22 +08:00
parent 2b658e59fa
commit adde24ccaf
4 changed files with 17 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import React , { Component } from 'react';
import { Link } from "react-router-dom";
import { Dropdown , Menu , Icon , Tooltip } from 'antd';
import { truncateCommitId } from '../common/util';
import './list.css'
import { branch } from 'recompose';
@ -21,7 +22,7 @@ class CoderRootBranch extends Component {
if(branchList && branchList.length>0){
return(
<React.Fragment>
<ul className="branchUl">
{
@ -32,7 +33,7 @@ class CoderRootBranch extends Component {
<Link to={`/projects/${projectsId}/coders?branch=${item.name}`} className="color-blue font-15" style={{"maxWidth":"100px"}}>{item.name}</Link>
{/*<span className="color-blue font-15">{item.name}</span>*/}
<p className="f-wrap-alignCenter">
<span className="mr5 color-blue">{item.last_commit && item.last_commit.id}</span>
<span className="mr5 color-blue">{item.last_commit && truncateCommitId(item.last_commit.id)}</span>
{/*<Link to="javascript:void(0)" className="mr5 color-blue" >{item.last_commit && item.last_commit.id}</Link>*/}
<span className="color-grey-9 hide-1 messages leftPoint">{item.last_commit && item.last_commit.message}</span>
<span className="color-grey-6 leftPoint">最后更新于{item.last_commit && item.last_commit.time_from_now}</span>
@ -40,7 +41,7 @@ class CoderRootBranch extends Component {
</div>
<span>
<Link to={`/projects/${projectsId}/merge/new`} className="mr20 operationBtn">创建合并请求</Link>
<Dropdown overlay={menu(item.zip_url,item.tar_url)} trigger={['click']} placement="bottomRight" className="operationBtn">
<a className="ant-dropdown-link">
<Tooltip title={`下载分支${item.name}`}><Icon type="cloud-download" className="font-18"/></Tooltip>
@ -75,4 +76,4 @@ class CoderRootBranch extends Component {
}
export default CoderRootBranch;
export default CoderRootBranch;

View File

@ -1,6 +1,7 @@
import React , { Component } from 'react';
import { Table , Spin } from 'antd';
import { getImageUrl } from 'educoder';
import { truncateCommitId } from '../common/util'
import SelectBranch from '../Branch/SelectBranch';
import Top from './DetailTop';
@ -92,7 +93,7 @@ class CoderRootCommit extends Component{
title:"SHA",
dataIndex: 'sha',
render: (text) => (
<span className="commitKey">{text}</span>
<span className="commitKey">{truncateCommitId(text)}</span>
)
},{
title:"备注",
@ -124,7 +125,7 @@ class CoderRootCommit extends Component{
const Pagination =()=> {
if(dataCount > limit){
return(
return(
<div className="edu-txt-center pt30 mb30">
<Pagination simple defaultCurrent={page} total={dataCount} pageSize={limit} onChange={this.ChangePage}></Pagination>
</div>
@ -153,4 +154,4 @@ class CoderRootCommit extends Component{
)
}
}
export default CoderRootCommit;
export default CoderRootCommit;

View File

@ -11,6 +11,7 @@ import CloneAddress from '../Branch/CloneAddress';
import RootTable from './RootTable';
import CoderRootFileDetail from './CoderRootFileDetail';
import NullData from './NullData';
import { truncateCommitId } from '../common/util';
import axios from 'axios';
/**
@ -233,7 +234,7 @@ class CoderRootDirectory extends Component{
</React.Fragment>
:""
}
<Link to={``} className="commitKey">{branchLastCommit.last_commit.id}</Link>
<Link to={``} className="commitKey">{truncateCommitId(branchLastCommit.last_commit.id)}</Link>
<span className="color-blue flex-1 hide-1">{branchLastCommit.last_commit.message}</span>
<span>{branchLastCommit.last_commit.time_from_now}</span>
</div>

6
src/forge/common/util.js Normal file
View File

@ -0,0 +1,6 @@
export function truncateCommitId(str) {
if (str.length > 11) {
return str.substring(0, 10)
}
}