This commit is contained in:
caishi 2020-08-27 10:14:07 +08:00
parent 74d26a40d3
commit 33c3395221
1 changed files with 20 additions and 11 deletions

View File

@ -20,6 +20,16 @@ import axios from "axios";
* readMeContent:根目录下面的readme文件内容
*/
function getPathUrl(array,index){
if(array && array.length>0 && index){
let str = "";
for(let i=0;i<index;i++){
str += `/${array[i]}`;
}
return str.substr(1);
}
}
class CoderRootDirectory extends Component {
constructor(props) {
super(props);
@ -95,7 +105,7 @@ class CoderRootDirectory extends Component {
this.setState({
readOnly:true
})
this.props.history.push(`/projects/${owner}/${projectsId}`);
this.props.history.push(`/projects/${owner}/${projectsId}/coders`);
this.getProjectRoot(branch);
};
@ -132,7 +142,7 @@ class CoderRootDirectory extends Component {
ChangeFile = (arr, readOnly) => {
const { projectsId , owner } = this.props.match.params;
//点击直接跳转页面 加载一次路由
this.props.history.push(`/projects/${owner}/${projectsId}?url=${arr.path}`);
this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${arr.path}`);
this.setState({
readOnly: readOnly,
chooseType:"file"
@ -163,7 +173,7 @@ class CoderRootDirectory extends Component {
const { projectsId , owner } = this.props.match.params;
//点击直接跳转页面 加载一次路由
this.props.history.push(
`/projects/${owner}/${projectsId}?url=${str.substr(1)}`
`/projects/${owner}/${projectsId}/coders?url=${str.substr(1)}`
);
} else {
list.push({
@ -247,7 +257,7 @@ class CoderRootDirectory extends Component {
chooseType:type
})
const { projectsId, owner } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}?url=${path}`);
this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${path}`);
if(filename.substring(filename.length - 3) === ".md"){
this.setState({
md:true
@ -330,7 +340,7 @@ class CoderRootDirectory extends Component {
readOnly:true
})
const { projectsId , owner } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}?url=${url}`);
this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${url}`);
}
onEdit=(readOnly)=>{
@ -357,7 +367,6 @@ class CoderRootDirectory extends Component {
}
title = (branchLastCommit,lastCommitAuthor) => {
console.log(branchLastCommit)
if (branchLastCommit) {
return (
<div className="f-wrap-alignCenter">
@ -398,6 +407,7 @@ class CoderRootDirectory extends Component {
}
}
render(){
const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state;
const { isManager , isDeveloper , projectDetail } = this.props;
@ -458,15 +468,14 @@ class CoderRootDirectory extends Component {
>
{projectDetail && projectDetail.identifier}
</a>
{array &&
array.map((item, key) => {
{ array && array.map((item, key) => {
return (
<React.Fragment>
{
key === array.length-1 ?
<span className="color-grey-6 subFileName" key={key}>{item}</span>
:
<a onClick={()=>this.returnUlr(`${key === 0 ? `${item}` :`${array[key-1]}/${item}`}`)} className="color-blue subFileName">{item}</a>
<a onClick={()=>this.returnUlr(`${getPathUrl(array,key+1)}`)} className="color-blue subFileName">{item}</a>
}
</React.Fragment>
);
@ -478,13 +487,13 @@ class CoderRootDirectory extends Component {
{subFileType && (projectDetail && parseInt(projectDetail.type)) !== 2 && (isManager || isDeveloper) && (
<div>
<span>
<Link to={`/projects/${owner}/${projectsId}/${branch}/uploadfile${urlRoot}`} >
<Link to={`/projects/${owner}/${projectsId}/coders/${branch}/uploadfile${urlRoot}`} >
<span className="color-green mr30">上传文件</span>
</Link>
</span>
<span className="mr30">
<Link
to={`/projects/${owner}/${projectsId}/${branch}/newfile${urlRoot}`}
to={`/projects/${owner}/${projectsId}/coders/${branch}/newfile${urlRoot}`}
>
<span className="color-blue">新建文件</span>
</Link>