代码库:最新提交信息整改

This commit is contained in:
caishi 2020-06-03 14:42:13 +08:00
parent 4920fed97f
commit f45f205b93
9 changed files with 113 additions and 86 deletions

View File

@ -220,8 +220,6 @@ class App extends Component {
render() {
let { mygetHelmetapi } = this.state;
// console.log("appappapp");
// console.log(mygetHelmetapi);
return (
<Provider store={store}>
<ConfigProvider locale={zhCN}>

View File

@ -100,7 +100,7 @@ export function initAxiosInterceptors(props) {
// TODO 读取到package.json中的配置
var proxy = "http://localhost:3000"
// proxy = "https://pre-newweb.educoder.net"
// var proxy = "https://testforgeplus.trustie.net/"
proxy = "https://testforgeplus.trustie.net/"
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制

View File

@ -15,44 +15,49 @@ class SelectBranch extends Component{
}
}
componentDidMount() {
this.getTagList();
document.body.addEventListener('click', e => {
let v= this.state.visible;
let other = e.target && (e.target.matches('#m-btn') || e.target.matches("#navUl-btn") || e.target.matches("#input-btn")|| e.target.matches("#ul-btn"));
let classF = e.target.className === "navs" || e.target.className === "navs active";
if(e.target && e.target.matches("#down-btn")){
if(e.target.className && e.target.className.animVal!=undefined) return;
let s = e.target && e.target.className && e.target.className.indexOf('showtag')> -1;
let classF =e.target && e.target.className && e.target.className.indexOf("downobject") > -1 || e.target.className==="ant-input OptionsInput";
if(e.target && e.target.className === "ant-dropdown-trigger" || s){
this.setState({
visible:!v,
value:undefined
})
return;
}else if (other || classF) {
}else if (classF) {
return;
} else{
this.setState({
visible:false,
value:undefined
})
}
}
});
}
componentDidUpdate=(prevProps)=>{
if(this.props.repo_id && prevProps.repo_id != this.props.repo_id){
if(this.props.repo_id && this.props.repo_id!=prevProps.repo_id){
this.getTagList();
}
}
getTagList=()=>{
const { repo_id } = this.props;
const url = `/repositories/${repo_id}/tags.json`;
axios.get(url).then((result)=>{
if(result){
this.setState({
tags:result.data
})
}
}).catch(error=>{
console.log(error);
})
if(repo_id){
const url = `/repositories/${repo_id}/tags.json`;
axios.get(url).then((result)=>{
if(result){
this.setState({
tags:result.data
})
}
}).catch(error=>{
console.log(error);
})
}
}
InputClick=(e)=>{
@ -93,18 +98,18 @@ class SelectBranch extends Component{
const { branchs , branch } = this.props;
let array = branchs;
if(search === "tag"){
if(search === "tag" && tags.length>0){
array = tags;
}
let branchsFilter = value ? (array && array.length>0 && array.filter(item=>item.name.indexOf(value)>-1)) : array;
const menu = (
<div className="branchOptions" id="m-btn" onClick={this.stopPropagations}>
<div className="padding10 bor-bottom-greyE">
<div className="downobject padding10 bor-bottom-greyE">
<Input placeholder="请输入分支或标签名称搜索" autocomplete="off" id="input-btn" value={value} className="OptionsInput" onChange={this.changeValue} onClick={this.InputClick}/>
<ul className="navUl" id="navUl-btn">
<li className={search ==="branch"?"navs active":"navs"} onClick={()=>this.changeSearch("branch")}><i className="iconfont icon-fenzhi1 font-14 mr3"></i></li>
<li className={search ==="tag"?"navs active":"navs"} onClick={()=>this.changeSearch("tag")}><i className="iconfont icon-biaoqian3 font-14 mr3"></i></li>
<li className={search ==="branch"?"downobject active":"downobject"} onClick={()=>this.changeSearch("branch")}><i className="iconfont icon-fenzhi1 font-14 mr3"></i></li>
<li className={search ==="tag"?"downobject active":"downobject"} onClick={()=>this.changeSearch("tag")}><i className="iconfont icon-biaoqian3 font-14 mr3"></i></li>
</ul>
</div>
<ul className="OptionsUl" id="ul-btn">
@ -128,7 +133,7 @@ class SelectBranch extends Component{
{branch}
</a>
</span>
<Icon type="down" />
<i className="showtag iconfont icon-xiajiantou font-14 color-grey-9" />
</span>
</Dropdown>
</div>

View File

@ -61,9 +61,6 @@ class CoderRootCommit extends Component{
// 切换分支 search:tag为根据标签搜索
changeBranch=(value)=>{
const { branchList } = this.props;
// let branchLastCommit = branchList && branchList.filter(item=>item.name === value)[0];
const { page , limit } = this.state;
this.setState({
isSpin:true,

View File

@ -36,9 +36,12 @@ class CoderRootDirectory extends Component{
branchList:undefined,
fileDetail:undefined,
branchLastCommit:undefined,
lastCommitAuthor:undefined,
rootList:undefined,
readOnly: true
readOnly: true,
zip_url:undefined,
tar_url:undefined
}
}
changeAddress=(address)=>{
@ -101,16 +104,22 @@ class CoderRootDirectory extends Component{
}
}).then((result)=>{
if(result){
if(result && result.data && result.data.length > 0){
this.setState({
filePath:undefined,
fileDetail:undefined,
isSpin: false
})
this.renderData(result.data);
let last_commit = result.data && result.data.last_commit;
let entries = result.data && result.data.entries;
this.setState({
filePath:undefined,
fileDetail:undefined,
isSpin: false,
branchLastCommit:last_commit && last_commit.commit,
lastCommitAuthor:last_commit && (last_commit.author || (last_commit.commit && last_commit.commit.author)),
zip_url:result.data.zip_url,
tar_url:result.data.tar_url
})
if(entries && entries.length > 0){
this.renderData(entries);
}
this.setState({
rootList:result.data,
rootList:entries,
subFileType:true
})
}
@ -169,11 +178,12 @@ class CoderRootDirectory extends Component{
ref:ref || branch
}
}).then((result)=>{
if(result && result.data && result.data.length > 0){
let entries = result.data && result.data.entries
if(entries && entries.length > 0){
// 当前返回的子目录只有一条数据,且这条数据返回的是文件类型
if(result.data.length === 1 && result.data[0].type === "file"){
if(entries.length === 1 && entries[0].type === "file"){
this.setState({
fileDetail:result.data,
fileDetail:entries,
rootList:undefined,
isSpin:false,
subFileType:false
@ -181,10 +191,12 @@ class CoderRootDirectory extends Component{
}else{
this.setState({
fileDetail:undefined,
rootList:result.data,
isSpin:false
rootList:entries,
isSpin:false,
branchLastCommit:result.data.last_commit && result.data.last_commit.commit,
lastCommitAuthor:result.data.last_commit && (result.data.last_commit.author || (result.data.last_commit.commit && result.data.last_commit.commit.author))
})
this.renderData(result.data)
this.renderData(entries);
}
}
}).catch((error)=>{
@ -251,29 +263,24 @@ class CoderRootDirectory extends Component{
// 选择分支
changeBranch=(value)=>{
const { branchList } = this.props;
// let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0];
// if(branchLastCommit){
this.setState({
branch:value,
isSpin: true
})
let { search } = this.props.history.location;
if(search && search.indexOf("?url=")>-1){
let url =search.split("?url=")[1];
this.setState({
branch:value,
// branchLastCommit,
isSpin: true
filePath:url
})
let { search } = this.props.history.location;
if(search && search.indexOf("?url=")>-1){
let url =search.split("?url=")[1];
this.setState({
filePath:url
})
this.getFileDetail(url, value);
}else{
this.getProjectRoot( value );
}
// }
this.getFileDetail(url, value);
}else{
this.getProjectRoot( value );
}
}
render(){
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state;
const { branchLastCommit , isManager , isDeveloper , projectDetail } = this.props;
const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state;
const { isManager , isDeveloper , projectDetail } = this.props;
const { projectsId } = this.props.match.params;
const columns = [
@ -302,23 +309,26 @@ class CoderRootDirectory extends Component{
}
];
const title = () =>{
if(branchLastCommit && branchLastCommit.last_commit){
if(branchLastCommit){
return(
<div className="f-wrap-alignCenter">
{
branchLastCommit.author ?
lastCommitAuthor ?
<React.Fragment>
<Link to={`/users/${branchLastCommit.author.login}/projects`} className="show-user-link">
<img src={getImageUrl(`images/${branchLastCommit.author.image_url}`)} className="radius mr10" width="32" height="32" alt=""/>
<span className="mr15">{branchLastCommit.author.login}</span>
</Link>
{
lastCommitAuthor.login ?
<Link to={`/users/${lastCommitAuthor.login}/projects`} className="show-user-link">
<img src={getImageUrl(`images/${lastCommitAuthor.image_url}`)} className="radius mr10" width="32" height="32" alt=""/>
<span className="mr15">{lastCommitAuthor.name}</span>
</Link>:
<span className="mr15">{lastCommitAuthor.name}</span>
}
</React.Fragment>
:""
}
<span className="color-blue flex-1 hide-1">{branchLastCommit.last_commit.message}</span>
<span>{branchLastCommit.last_commit.time_from_now}</span>
<span className="commitKey">{truncateCommitId(branchLastCommit.last_commit.id)}</span>
<span className="color-blue flex-1 hide-1">{branchLastCommit.message}</span>
<span>{branchLastCommit.time_from_now}</span>
<span className="commitKey">{truncateCommitId(branchLastCommit.sha)}</span>
</div>
)
}else{
@ -326,16 +336,12 @@ class CoderRootDirectory extends Component{
}
}
const downloadUrl = ()=>{
if(branchLastCommit && branchLastCommit.zip_url){
return(
<Menu>
<Menu.Item><a href={branchLastCommit.zip_url}>ZIP</a></Menu.Item>
<Menu.Item><a href={branchLastCommit.tar_url}>TAR.GZ</a></Menu.Item>
</Menu>
)
}
}
const downloadUrl = ()=>(
<Menu>
{zip_url && <Menu.Item><a href={zip_url}>ZIP</a></Menu.Item> }
{tar_url && <Menu.Item><a href={tar_url}>TAR.GZ</a></Menu.Item> }
</Menu>
)
const urlRoot = filePath === undefined ? '':`/${filePath}`;
let array = filePath && filePath.split("/");

View File

@ -136,7 +136,6 @@ class Detail extends Component {
author: undefined,
branchs: undefined,
branchList: undefined,
branchLastCommit: undefined,
}
}
@ -279,7 +278,6 @@ class Detail extends Component {
this.setState({
branchList: result.data,
branchs,
branchLastCommit: result.data[0],
})
}
}).catch((error) => { })
@ -576,6 +574,11 @@ class Detail extends Component {
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
<Route path="/projects/:projectsId"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
<Route path="/projects/:projectsId/watch_users"
render={
(props) => (<WatchUsers {...this.props} {...props} {...this.state} {...common}/>)

View File

@ -1,6 +1,6 @@
import React, { Component } from "react";
import { Link } from "react-router-dom";
import { Avatar, Tag, Button, Pagination, Spin, Dropdown, Menu } from "antd";
import { Avatar, Tag, Button } from "antd";
import FocusButton from "../UsersList/focus_button";
import axios from "axios";
@ -22,6 +22,10 @@ const InfosIndex = Loadable({
loader: () => import("./InfosUser"),
loading: Loading,
});
const Organize = Loadable({
loader: () => import("./Team"),
loading: Loading,
});
class Infos extends Component {
constructor(props) {
@ -170,6 +174,12 @@ class Infos extends Component {
</div>
<div className="list-right">
<Switch {...this.props}>
<Route
path="/users/:username/organize"
render={(props) => {
return <Organize {...this.props} {...this.state} />;
}}
></Route>
<Route
path="/users/:username/projects"
render={(props) => {

8
src/forge/users/Team.jsx Normal file
View File

@ -0,0 +1,8 @@
import React from 'react';
export default (()=>{
return(
<div>cccc</div>
)
})

View File

@ -940,7 +940,7 @@ class NewHeader extends Component {
{
mygetHelmetapi2 && mygetHelmetapi2.new_course && mygetHelmetapi2.new_course.my_organ &&
<li><a href={`${mygetHelmetapi2.new_course.my_organ}`} target="_blank">我的组织</a></li>
<li><a href={`/users/${this.props.current_user.login}/organize`} target="_blank">我的组织</a></li>
}
<li className="bor-top-greyE">
<a onClick={() => this.educoderloginysl()}>退出</a>