parent
dfa9f07018
commit
736574c2ba
@ -0,0 +1,108 @@
|
||||
import React , { Component } from "react";
|
||||
import SelectBranch from '../Branch/SelectBranch';
|
||||
import { getImageUrl } from 'educoder';
|
||||
|
||||
import {Link} from 'react-router-dom';
|
||||
|
||||
import RootTable from './RootTable';
|
||||
import './list.css';
|
||||
import axios from 'axios';
|
||||
|
||||
class CoderRootFileDetail extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
branch:undefined,
|
||||
subRootData:undefined
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
const { branch } = this.props.match.params;
|
||||
this.getFileDetail(branch);
|
||||
}
|
||||
|
||||
componentDidUpdate=(prevProps)=>{
|
||||
}
|
||||
|
||||
getFileDetail=(branch)=>{
|
||||
const { current_user } = this.props;
|
||||
const { fileurl , projectsId } = this.props.match.params;
|
||||
const url =`/${current_user.login}/${projectsId}/sub_entries.json`;
|
||||
|
||||
axios.get(url,{
|
||||
params:{
|
||||
filepath:fileurl,
|
||||
ref:branch
|
||||
}
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
subRootData:result.data
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
changeBranch=(value)=>{
|
||||
|
||||
}
|
||||
|
||||
|
||||
render(){
|
||||
const { branch , projectsId , fileurl } = this.props.match.params;
|
||||
const { branchLastCommit , http_url } = this.props;
|
||||
|
||||
const { subRootData } = this.state;
|
||||
const columns =[
|
||||
{
|
||||
dataIndex: 'name',
|
||||
width:"100%",
|
||||
render: (text,item) => (
|
||||
<Link to={`/projects/${projectsId}/${item.path}`}>
|
||||
<i className={ item.type === "file" ? "iconfont icon-zuoye font-15 color-blue mr5":"iconfont icon-wenjian font-15 color-blue mr5"}></i>{text}
|
||||
</Link>
|
||||
),
|
||||
}
|
||||
];
|
||||
|
||||
const title = () =>{
|
||||
if(branchLastCommit && branchLastCommit.last_commit){
|
||||
return(
|
||||
<div className="f-wrap-alignCenter">
|
||||
{
|
||||
branchLastCommit.author ?
|
||||
<React.Fragment>
|
||||
<img src={getImageUrl(`images/${branchLastCommit.author.image_url}`)} alt=""/>
|
||||
<span className="mr15">{branchLastCommit.author.login}</span>
|
||||
</React.Fragment>
|
||||
:""
|
||||
}
|
||||
<Link to={``} className="commitKey">{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>
|
||||
)
|
||||
}else{
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return(
|
||||
<div>
|
||||
<div className="f-wrap-alignCenter mt20">
|
||||
<SelectBranch branch={branch} changeBranch={this.changeBranch} {...this.props} {...this.state}></SelectBranch>
|
||||
<span className="flex-1 ml20 font-16">
|
||||
<Link to={``} className="color-blue">iSulad</Link>
|
||||
<span className="color-grey-6 subFileName">{fileurl}</span>
|
||||
</span>
|
||||
</div>
|
||||
<RootTable columns = {columns} data={subRootData} title={() => title()}></RootTable>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default CoderRootFileDetail;
|
@ -0,0 +1,19 @@
|
||||
import React , { Component } from 'react';
|
||||
import { Table } from 'antd';
|
||||
class RootTable extends Component{
|
||||
render(){
|
||||
const { columns , data , title }=this.props;
|
||||
return(
|
||||
<Table
|
||||
className="mt20 wrap-commit-table"
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
showHeader={false}
|
||||
size="small"
|
||||
pagination={false}
|
||||
title={() => title()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default RootTable;
|
@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
export default combineReducers({
|
||||
|
||||
})
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* @Description: 指定容器并绑定 reducers
|
||||
* @Author: tangjiang
|
||||
* @Date: 2019-11-13 20:13:21
|
||||
* @Last Modified by: tangjiang
|
||||
* @Last Modified time: 2019-11-14 19:20:44
|
||||
*/
|
||||
|
||||
import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import rootReducer from '../reducers';
|
||||
|
||||
const configureStore = () => createStore(
|
||||
rootReducer,
|
||||
applyMiddleware(thunk)
|
||||
);
|
||||
|
||||
export default configureStore;
|
Loading…
Reference in new issue