From ff1aa828e548fdb3991ebe26839978dd55c8c8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 28 Feb 2020 14:42:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMIndex.js | 222 +++++++++--------- .../src/modules/tpm/TPMRepositoryComponent.js | 16 +- .../modules/tpm/TPMsettings/TPMsettings.js | 1 + .../react/src/modules/tpm/component/TPMNav.js | 8 +- .../tpm/shixunchild/Repository/Repository.js | 1 + .../Repository/RepositoryAddFile.js | 43 +++- .../RepositoryAddFileupload_file.js | 22 +- .../shixunchild/Repository/Repositoryfile.js | 79 ++++++- 8 files changed, 254 insertions(+), 138 deletions(-) diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 145db7090..3d9966c32 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -144,22 +144,24 @@ const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.j , 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json'] const cacheInterceptorUrlMap = {} class TPMIndex extends Component { - constructor(props) { - super(props) - this.state = { - loadingContent: false, - power: false, - shixunsDetails: {}, - shixunId: undefined, - star_info: [0, 0, 0, 0, 0, 0], - star_infos: [0, 0, 0, 0, 0, 0], - identity: undefined, - TPMRightSectionData: undefined, - PropaedeuticsList: undefined, - tpmindexjupyterbool: false, - is_jupyter: false, - selectedKeys: "", - openknows: false + constructor(props) { + super(props) + this.state = { + loadingContent: false, + power: false, + shixunsDetails: {}, + shixunId: undefined, + star_info: [0, 0, 0, 0, 0, 0], + star_infos: [0, 0, 0, 0, 0, 0], + identity:undefined, + TPMRightSectionData:undefined, + PropaedeuticsList: undefined, + tpmindexjupyterbool:false, + is_jupyter:false, + selectedKeys:"", + openknows:false, + newathArray:[] + } } } @@ -379,23 +381,28 @@ class TPMIndex extends Component { this.props.history.replace(`/shixuns/${id}/settings`); } } - render() { - - let url = window.location.href; - let flag = false; - // url.indexOf("add_file")>-1; - - return ( -
- {/*头部*/} - { - !flag && - - } + setpathArray=(list)=>{ + this.setState({ + newathArray:list + }) + } + render() { + + let url = window.location.href; + let flag =false; + // url.indexOf("add_file")>-1; + + return ( +
+ {/*头部*/} + { + !flag && + + }

新建文件
@@ -195,15 +208,33 @@ class RepositoryAddFile extends Component { )} -
- {getFieldDecorator('path')( + +
+ + {getFieldDecorator('path', { + rules: [{ + required: true, message: '请输入提交信息', + },{ + whitespace: true, message: '请勿输入空格' + }], + })( - 提示:输入 / 可以将文件创建到新文件夹下 + 提示:输入 / 可以将文件创建到新文件夹下 )} +
-
-
+ + +
diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js index a06e9956d..82bdc12d4 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js @@ -25,11 +25,27 @@ class RepositoryAddFileupload_files extends Component { } componentDidMount(){ + if(this.props.newathArray){ + if(this.props.newathArray.length>0){ + let newfilspath=""; + let list=this.props.newathArray; + list.map((item,key)=>{ + if(key===0){ + newfilspath=item; + }else{ + newfilspath=newfilspath+'/'+item; + } + }) + this.setState({ + filspath:newfilspath + }) + } + } + } handleChange = (info) => { - console.log(info) if (info.file.status === 'done'||info.file.status === "uploading") { @@ -178,7 +194,7 @@ class RepositoryAddFileupload_files extends Component { this.props.showNotification("上传文件请先填写提交信息") return false } - console.log(file) + this.props.showNotification("上传成功") }, }; @@ -285,7 +301,9 @@ class RepositoryAddFileupload_files extends Component {
+ {/**/} +
) } diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js index b0b8360d0..1653cbaaf 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js @@ -23,7 +23,64 @@ class Repositoryfile extends Component{ } componentDidMount() { - this.goblakepath("") + + let pathArrays; + if(this.props.pathArray){ + pathArrays=this.props.pathArray; + }else{ + pathArrays=this.props.newathArray; + } + + let path=''; + let ary=[]; + if(pathArrays){ + if(pathArrays.length>0){ + pathArrays.map((item,key)=>{ + if(key===0){ + path=item; + ary.push({val:"根目录",path:""},{val:"/"+item,path:path}); + }else{ + path=path+'/'+item; + ary.push({val:"/"+item,path:path}); + } + }) + } + } + + this.getdata(path,ary) + + } + + getdata(path,ary){ + + let matchpath =this.props.match.path; + let id = this.props.match.params.shixunId; + + let url =""; + if( matchpath.indexOf("repository")>-1){ + url ="/shixuns/"+id+"/repository.json"; + } + if(matchpath.indexOf("secret_repository")>-1){ + url ="/shixuns/"+id+"/secret_repository.json"; + } + + axios.post(url,{ + path: path + }).then((response) => { + if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + + }else { + this.setState({ + trees: response.data.trees, + path: path, + main: ary, + // selectpath:selectpath + }) + } + }).catch((error) => { + console.log(error) + }); + } goblakepath=(path,key)=>{ @@ -127,6 +184,7 @@ class Repositoryfile extends Component{ if(matchpath.indexOf("secret_repository")>-1){ flag =true; } + if(this.props.selectupfils===true){ this.props.selectupfilspath(path); this.props.showNotification("选择文件目录成功") @@ -147,16 +205,18 @@ class Repositoryfile extends Component{ let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`; this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - let types=false; - trees.map((item,key)=>{ - if(item.type==="tree"){ - if(item.name===values.name){ - types=true - return + if(trees){ + trees.map((item,key)=>{ + if(item.type==="tree"){ + if(item.name===values.name){ + types=true + return + } } - } - }) + }) + } + if(types===true){ this.props.showNotification("请勿新建相同名字的文件夹") @@ -216,6 +276,7 @@ class Repositoryfile extends Component{
    + {console.log(main)} { main.length===0?"":main.map((item,key)=>{ return(