dev_new_shixunsrepository
杨树明 5 years ago
parent e7bd084bf5
commit e00ee61a17

@ -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 {
<Route path="/shixuns/:shixunId/repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter} setpathArray={(value)=>this.setpathArray(value)}
/>)
}></Route>
@ -588,7 +594,7 @@ class TPMIndex extends Component {
<Route path="/shixuns/:shixunId/settings" render={
(props) => (<TPMsettings {...this.props} {...this.state} {...props} />)
(props) => (<TPMsettings {...this.props} {...this.state} {...props} getcomponentdidmount={()=>this.getcomponentdidmount()} />)
}></Route>
{/*实训项目条目塞选*/}

@ -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 (
<React.Fragment>
{ listItemtypes===false? <TPMRepository

@ -54,6 +54,7 @@ export default class TPMsettings extends Component {
}
});
this.props.getcomponentdidmount()
//
// if(key==="3"&&this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === true){
// window.location.href =`/shixuns/${this.props.match.params.shixunId}/challenges`;

@ -42,15 +42,15 @@ class TPMNav extends Component {
{ this.props.identity >4||this.props.identity===undefined ?"":
(this.props.is_jupyter===false?
<Link to={`/shixuns/${shixunId}/repository`}
className={`${match.url.indexOf('/repository') != -1 ? 'active' : ''} fl mr40`}>版本库</Link>
<a href={`/shixuns/${shixunId}/repository`}
className={`${match.url.indexOf('/repository') != -1 ? 'active' : ''} fl mr40`}>版本库</a>
:"")
}
{this.props.identity >4||this.props.identity===undefined ?"": secret_repository && <Link to={`/shixuns/${shixunId}/secret_repository`}
className={`${match.url.indexOf('secret_repository') != -1 ? 'active' : ''} fl mr40`}>私密版本库</Link>}
{this.props.identity >4||this.props.identity===undefined ?"": secret_repository && <a href={`/shixuns/${shixunId}/secret_repository`}
className={`${match.url.indexOf('secret_repository') != -1 ? 'active' : ''} fl mr40`}>私密版本库</a>}
<Link to={`/shixuns/${shixunId}/collaborators`}
className={`${match.url.indexOf('collaborators') != -1 ? 'active' : ''} fl mr40`}>合作者</Link>

@ -189,6 +189,7 @@ class Repository extends Component {
{this.state.evaluationvisible===true?<Repositoryfile
{...this.state}
{...this.props}
Repositoryflag={Repositoryflag}
hideNewFolder={()=>this.hideNewFolder()}
setfilepath={(path)=>this.setfilepath(path)}
/>:""}

@ -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 {
{/* </Breadcrumb>*/}
{/*</p>*/}
<Form onSubmit={this.handleSubmit} className="formStyle">
<style>
{
`
.padding20-30{
padding:20px 30px 5px 30px;
}
.formStyle .ant-form-item{
margin-bottom:0px !important;
height:60px;
}
`
}
</style>
<div className="edu-back-white padding20-30">
<p className="ant-form-item-label">
<div className={"font-20 color-black"}>新建文件</div>
@ -195,15 +208,33 @@ class RepositoryAddFile extends Component {
<Input placeholder="必填描述主要修改内容相当于Git Commit message的Header" size="large" className="winput-300-35 fl "/>
)}
</Form.Item>
<div className={"mt20"}>
{getFieldDecorator('path')(
<div className={"mt50"}>
<Form.Item>
{getFieldDecorator('path', {
rules: [{
required: true, message: '请输入提交信息',
},{
whitespace: true, message: '请勿输入空格'
}],
})(
<span>
<span> </span><span><Input placeholder="文件名称或文件路径" className=" fl" style={{ width: 200 }} size="large"/></span><span className={"mt10 ml10 fl"}>提示:输入 / 可以将文件创建到新文件夹下</span>
<span> </span><span><Input placeholder="文件名称或文件路径" className=" fl" style={{ width: 200 }} size="large"/></span><span className={" ml10 fl"}>提示:输入 / 可以将文件创建到新文件夹下</span>
</span>
)}
</Form.Item>
</div>
</div>
<div className="edu-back-white padding30">
<style>
{
`
.padding30{
padding:0px 30px 30px 30px;
}
`
}
</style>
<div className="mt10 mb25 repoCMWrapper filecode">
<textarea className="" id="codemirror-file-edit" style={{display:'none'}} name="content"></textarea>

@ -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 {
</div>
</Form>
</div>
{/*<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}${this.state.filspath===""?"":"/master/shixun_show/"+this.state.filspath}`} bottomvalue={"确定"}/>*/}
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`} bottomvalue={"确定"}/>
</div>
)
}

@ -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{
</style>
<div className="newupload_conbox clearfix">
<ul id="directory_file">
{console.log(main)}
{
main.length===0?"":main.map((item,key)=>{
return(

Loading…
Cancel
Save