diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 392808197..392242393 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -160,7 +160,8 @@ class TPMIndex extends Component { tpmindexjupyterbool:false, is_jupyter:false, selectedKeys:"", - openknows:false + openknows:false, + newathArray:[] } } @@ -390,6 +391,11 @@ class TPMIndex extends Component { }else if(e.key==="9"){ this.props.history.replace(`/shixuns/${id}/settings`); } + } + setpathArray=(list)=>{ + this.setState({ + newathArray:list + }) } render() { @@ -539,24 +545,24 @@ class TPMIndex extends Component { ( (this.setpathArray(value)} />) }> ( (this.setpathArray(value)} />) }> ( (this.setpathArray(value)} />) }> ( (this.setpathArray(value)} />) }> @@ -588,7 +594,7 @@ class TPMIndex extends Component { () + (props) => (this.getcomponentdidmount()} />) }> {/*实训项目条目塞选*/} diff --git a/public/react/src/modules/tpm/TPMRepositoryComponent.js b/public/react/src/modules/tpm/TPMRepositoryComponent.js index e1806f524..aa5a35185 100644 --- a/public/react/src/modules/tpm/TPMRepositoryComponent.js +++ b/public/react/src/modules/tpm/TPMRepositoryComponent.js @@ -32,6 +32,7 @@ class TPMRepositoryComponent extends Component { pathArray: pathArray, isContentWidth100: this._isFileInPathArray(pathArray) } + this.props.setpathArray(pathArray) } componentDidUpdate(prevProps, prevState) { if (this.props.secret_repository_tab != prevProps.secret_repository_tab) { @@ -106,6 +107,7 @@ class TPMRepositoryComponent extends Component { }) this.setState({ repositoryLoading: true, pathArray: newPathArray }) + this.props.setpathArray(newPathArray) this.setState({ fileContent: response.data.content, repositoryLoading: false @@ -113,7 +115,7 @@ class TPMRepositoryComponent extends Component { if(response.data.content){ this.props.history - .replace(`/shixuns/${id}/repository` + + .replace(`/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}` + (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) // this.props.history.replace(`${this.props.match.url}/master/shixun_show/${newPathArray.join('/')}`) } @@ -174,6 +176,7 @@ class TPMRepositoryComponent extends Component { } // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json this.setState({ repositoryLoading: true, pathArray: newPathArray }) + this.props.setpathArray(newPathArray) let urlNewPathArray = newPathArray; let fileInPathArray = false; if (newPathArray.length) { @@ -215,7 +218,7 @@ class TPMRepositoryComponent extends Component { }); this.props.history - .replace(`/shixuns/${id}/repository` + + .replace(`/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}` + (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) } @@ -237,16 +240,7 @@ class TPMRepositoryComponent extends Component { } render() { const { listItemtypes } = this.state; - let matchpath =this.props.match.path; - let flag =false; - // if(matchpath==="/shixuns/:shixunId/repository"){ - // flag =true; - // }else if(matchpath==="/shixuns/:shixunId/secret_repository"){ - // flag =true; - // } - - // 需要重构 return ( { listItemtypes===false? 4||this.props.identity===undefined ?"": (this.props.is_jupyter===false? - 版本库 + 版本库 :"") } - {this.props.identity >4||this.props.identity===undefined ?"": secret_repository && 私密版本库} + {this.props.identity >4||this.props.identity===undefined ?"": secret_repository && 私密版本库} 合作者 diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js index fc1e0ee70..8233af78a 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js @@ -189,6 +189,7 @@ class Repository extends Component { {this.state.evaluationvisible===true?this.hideNewFolder()} setfilepath={(path)=>this.setfilepath(path)} />:""} diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js index 5ac18c2b4..af7fe1275 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js @@ -88,7 +88,7 @@ class RepositoryAddFile extends Component { window.editor_tempCodeMirror = extend_editor; this.extend_editor = extend_editor; } - + checkPath= (rule, value, callback) =>{ if(!value){ callback('文件名不能为空'); @@ -179,6 +179,19 @@ class RepositoryAddFile extends Component { {/* */} {/*

*/}
+

新建文件
@@ -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(