Merge branch 'newVersion_forge' of http://gitea.trustie.net/jasder/forgeplus-react into newVersion_forge

This commit is contained in:
caishi 2020-06-29 16:32:44 +08:00
commit 9b042c0113
8 changed files with 47 additions and 49 deletions

View File

@ -10,6 +10,7 @@ import RootTable from './RootTable';
import CoderRootFileDetail from './CoderRootFileDetail';
import { truncateCommitId } from '../common/util';
import RenderHtml from '../../components/render-html';
import Top from './DetailTop';
import axios from "axios";
/**
@ -42,7 +43,11 @@ class CoderRootDirectory extends Component {
readOnly: true,
zip_url:undefined,
tar_url:undefined,
chooseType:undefined
chooseType:undefined,
tags_count:undefined,
commits_count:undefined,
branches_count:undefined
}
}
changeAddress = (address) => {
@ -122,6 +127,9 @@ class CoderRootDirectory extends Component {
(last_commit.commit && last_commit.commit.author)),
zip_url: result.data.zip_url,
tar_url: result.data.tar_url,
tags_count: result.data.tags_count,
branches_count: result.data.branches_count,
commits_count: result.data.commits_count
});
if (entries && entries.length > 0) {
this.renderData(entries);
@ -440,14 +448,15 @@ class CoderRootDirectory extends Component {
let array = filePath && filePath.split("/");
return (
<Spin spinning={isSpin}>
<Top {...this.props} {...this.state}/>
<div className="main">
<div className="f-wrap-between mb20">
<div className="f-wrap-alignCenter">
<SelectBranch
repo_id={projectDetail && projectDetail.repo_id}
projectsId={projectsId}
<SelectBranch
repo_id={projectDetail && projectDetail.repo_id}
projectsId={projectsId}
branch={branch}
changeBranch={this.changeBranch}
changeBranch={this.changeBranch}
></SelectBranch>
{filePath && (

View File

@ -3,7 +3,6 @@ import { Route , Switch } from 'react-router-dom';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import Top from './DetailTop';
const CoderRootDirectory = Loadable({
@ -40,11 +39,9 @@ const Diff = Loadable({
})
class CoderRootIndex extends Component{
render(){
return(
<div>
<Top {...this.props} {...this.state}/>
<Switch {...this.props}>
<Route path="/projects/:projectsId/coders/commit"
render={
@ -68,7 +65,7 @@ class CoderRootIndex extends Component{
(props) => (<CoderRootVersionUpdate {...this.props} {...props} {...this.state} />)
}
></Route>
<Route path="/projects/:projectsId/coders/version"
render={
(props) => (<CoderRootVersion {...this.props} {...props} {...this.state} />)
@ -99,4 +96,4 @@ class CoderRootIndex extends Component{
)
}
}
export default CoderRootIndex;
export default CoderRootIndex;

View File

@ -145,19 +145,31 @@ class Detail extends Component {
author: undefined,
branchs: undefined,
branchList: undefined,
project: null
}
}
componentDidMount = () => {
this.getProject();
this.getDetail();
}
componentDidUpdate = (prevState) => {
if ((prevState.match.params.projectsId !== this.props.match.params.projectsId)) {
this.getProject();
this.getDetail();
}
}
getProject = () => {
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/simple.json`;
axios.get(url).then((result) => {
this.setState({
project: result.data
})
})
}
getDetail = () => {
const { projectsId } = this.props.match.params;
@ -186,7 +198,7 @@ class Detail extends Component {
// 关注和取消关注
focusFunc = (flag) => {
const { project_id } = this.state;
axios({
method: flag? 'delete' : 'post',
url: `/watchers/${flag? 'unfollow' : 'follow'}.json`,
@ -262,25 +274,7 @@ class Detail extends Component {
console.log(error);
})
}
// 获取分支列表
getBranch = (id) => {
const url = `/projects/${id}/branches.json`;
axios.get(url).then((result) => {
if (result && result.data.length > 0) {
const branchs = [];
result.data.map((item, key) => {
branchs.push({
index: key,
name: item.name
})
})
this.setState({
branchList: result.data,
branchs,
})
}
}).catch((error) => { })
}
// 同步镜像
synchronismMirror=()=>{
@ -292,6 +286,7 @@ class Detail extends Component {
axios.post(url).then(result=>{
if(result && result.data && result.data.status === 0){
this.props.showNotification("镜像同步成功!");
this.getProject();
this.getDetail();
}else{
this.props.showNotification("镜像同步失败!");
@ -299,14 +294,14 @@ class Detail extends Component {
isSpin:false
})
}
}).catch(error=>{
console.log(error);
})
}
render() {
const { projectDetail, watchers_count, praises_count, forked_count, isSpin, isManager, watched, praised } = this.state;
const { projectDetail, watchers_count, praises_count, forked_count, isSpin, isManager, watched, praised, project } = this.state;
const url = this.props.history.location.pathname;
const urlArr = url.split("/");
const urlFlag = (urlArr.length === 3);
@ -337,19 +332,18 @@ class Detail extends Component {
}
return (
<div>
<Spin spinning={isSpin}>
<div className="detailHeader-wrapper">
<div className="normal">
<div className="f-wrap-between mb15" style={{ position: "relative" }}>
<p className="font-18 color-white df flex-1 lineH2 mt15" style={{ alignItems: "center" }}>
{projectDetail && projectDetail.author &&
<Link to={`/users/${projectDetail.author.login}`} className="show-user-link color-white">
{projectDetail.author.name}
{project && project.author &&
<Link to={`/users/${project.author.login}`} className="show-user-link color-white">
{project.author.name}
</Link>
}
<span className="ml5 mr5">/</span>
<span className="hide-1 flex-1 df">
<Link to={`/projects/${projectsId}/coders`} className="color-white font-22">{projectDetail && projectDetail.name}</Link>
<Link to={`/projects/${projectsId}/coders`} className="color-white font-22">{project && project.name}</Link>
{
projectDetail && projectDetail.forked_from_project_id && projectDetail.fork_info ?
<Tooltip placement={'right'} title={text}>
@ -404,7 +398,6 @@ class Detail extends Component {
<li className={(url.indexOf("coders") > -1 || urlFlag) ? "active" : ""}>
<Link to={{ pathname: `/projects/${projectsId}/coders`, state }}>
<img alt="" src={img_1} width="18" />代码库
{ projectDetail && projectDetail.commits_count ? <span>{projectDetail.commits_count}</span>:""}
</Link>
</li>
<li className={(url.indexOf("orders") > -1 && !(url.indexOf("Milepost") > 0 || url.indexOf("meilpost") > 0 || url.indexOf("tags") > 0)) ? "active" : ""}>
@ -546,7 +539,7 @@ class Detail extends Component {
<Route path="/projects/:projectsId/merge/new"
render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common}/>)
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork= {true}/>)
}
></Route>
@ -604,7 +597,6 @@ class Detail extends Component {
}
></Route>
</Switch>
</Spin>
</div>
)
}

View File

@ -3,22 +3,22 @@ import { Link } from 'react-router-dom';
class DetailTop extends Component {
render() {
const { projectDetail } = this.props;
const { projectDetail, tags_count, commits_count, branches_count } = this.props;
const { projectsId } = this.props.match.params;
const { pathname } = this.props.location;
return (
<p className="branch-wrapper">
<Link to={`/projects/${projectsId}/coders/commit`} className={pathname.indexOf("/coders/commit") > 0 ? "active" : ""}>
<i className="iconfont icon-tijiaojilu font-20 mr3 font-bd"></i>
<span>{projectDetail && projectDetail.commits_count}</span>
<span>{commits_count}</span>
</Link>
<Link to={`/projects/${projectsId}/coders/branch`} className={pathname.indexOf("/coders/branch") > 0 ? "active" : ""}>
<i className="iconfont icon-fenzhi1 font-18 mr3"></i>
<span>{projectDetail && projectDetail.branches_count}</span>
<span>{branches_count}</span>
</Link>
<Link to={`/projects/${projectsId}/coders/tag`} className={pathname.indexOf("/coders/tag") > 0 ? "active" : ""}>
<i className="iconfont icon-biaoqian3 font-18 mr3"></i>
<span>{projectDetail && projectDetail.issue_tags_count}</span>
<span>{tags_count}</span>
</Link>
<Link to={`/projects/${projectsId}/coders/version`} className={pathname.indexOf("/coders/version") > 0 ? "active" : ""}>
<i className="iconfont icon-fahangban font-18 mr3"></i>

View File

@ -84,7 +84,7 @@ class CommonUsers extends Component {
</React.Fragment>
);
return (
<div className="background-g pbt15">
<div className="pbt15">
<div className="main background-f minH-670">
<div className="plr-20 user-list-items">
<div className="font-18 pb-10 border-b-line">{type_title}</div>

View File

@ -120,7 +120,7 @@ class ForkUsers extends Component {
}
};
return (
<div className="background-g pbt15">
<div className="pbt15">
<div className="main background-f minH-670">
<div className="plr-20 user-list-items">
<div className="font-18 pb-10 border-b-line">Fork列表</div>

View File

@ -2,9 +2,9 @@
background: #fff;
}
.newMain{background: transparent!important;}
.background-g {
/* .background-g {
background: #fafafa;
}
} */
.pt-15 {
padding-top: 15px;
}

View File

@ -96,7 +96,7 @@ body>.-task-title {
}
.newContainer {
background: #fafafa !important;
background: #EAEBEC !important;
}
.ant-modal-title {