dev_aliyun2
杨树明 5 years ago committed by harry
parent 4a6ff31898
commit 147e450d77

@ -20,8 +20,6 @@ import TPMShixunDiscussContainer from './TPMShixunDiscussContainer';
import TPMRepositoryComponent from './TPMRepositoryComponent'; import TPMRepositoryComponent from './TPMRepositoryComponent';
import TPMRepositoryComponentdetails from './TPMRepositoryComponentdetails';
import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits';
import TPMsettings from './TPMsettings/TPMsettings'; import TPMsettings from './TPMsettings/TPMsettings';

@ -76,7 +76,8 @@ class TPMRepositoryComponent extends Component {
console.log(error) console.log(error)
}); });
} }
fetchCode = (newPathArray) => { fetchCode = (newPathArray) =>{
const path = newPathArray.join('/') const path = newPathArray.join('/')
// https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json
@ -137,7 +138,6 @@ class TPMRepositoryComponent extends Component {
} }
// listItem 如果是num则是通过面包屑点击过来的取pathArray的子集 // listItem 如果是num则是通过面包屑点击过来的取pathArray的子集
fetchRepo = (listItem) => { fetchRepo = (listItem) => {
// if(listItem === "main"||listItem){ // if(listItem === "main"||listItem){
// this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/repository`) // this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/repository`)
// return; // return;
@ -174,6 +174,7 @@ class TPMRepositoryComponent extends Component {
listItemtypes:false listItemtypes:false
}) })
} }
// https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json
this.setState({ repositoryLoading: true, pathArray: newPathArray }) this.setState({ repositoryLoading: true, pathArray: newPathArray })
this.props.setpathArray(newPathArray) this.props.setpathArray(newPathArray)
@ -216,14 +217,14 @@ class TPMRepositoryComponent extends Component {
...response.data, ...response.data,
repositoryLoading: false repositoryLoading: false
}); });
this.props.history this.props.history
.replace(`/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}` + .replace(`/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}` +
(newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : ''))
} }
// 初始化时repo接口完毕后需要看是否需要fetchCode // 初始化时repo接口完毕后需要看是否需要fetchCode
if (fileInPathArray) { if (fileInPathArray&&!type) {
// //
this.fetchCode(newPathArray) this.fetchCode(newPathArray)
} }
@ -235,12 +236,11 @@ class TPMRepositoryComponent extends Component {
}); });
} }
oncodechanner=()=>{ oncodechanner=(sum)=>{
this.fetchRepo(0) this.fetchRepo(sum)
} }
render() { render() {
const { listItemtypes } = this.state; const { listItemtypes } = this.state;
return ( return (
<React.Fragment> <React.Fragment>
{ listItemtypes===false? <TPMRepository { listItemtypes===false? <TPMRepository
@ -261,7 +261,7 @@ class TPMRepositoryComponent extends Component {
fetchRepo={this.fetchRepo} fetchRepo={this.fetchRepo}
saveCode={this.saveCode} saveCode={this.saveCode}
nameTypeMap={this.nameTypeMap} nameTypeMap={this.nameTypeMap}
oncodechanner={this.oncodechanner} oncodechanner={(sum)=>this.oncodechanner(sum)}
></RepositoryCodeEditor> ></RepositoryCodeEditor>
</div> </div>
</div> </div>

@ -40,8 +40,11 @@ class Repository extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if(prevProps!=this.props){ if(prevProps!=this.props){
this.setState({ this.setState({
trees:this.props.trees trees:this.props.trees,
ischecke:false,
ischeckevalue:""
}) })
} }
} }
onRepoFileClick = (item) => { onRepoFileClick = (item) => {
@ -61,7 +64,10 @@ class Repository extends Component {
} }
onSelectDirectoryTree=(selectedKeys, info)=>{ onSelectDirectoryTree=(selectedKeys, info)=>{
this.setState({
ischecke:false,
ischeckevalue:""
})
this.onRepoFileClick(info.node.props.item) this.onRepoFileClick(info.node.props.item)
} }
@ -73,7 +79,7 @@ class Repository extends Component {
return return
}else{ }else{
confirm({ confirm({
title: '确认需要删除该文件?', title: '确认需要删除该文件?',
okText: '确定', okText: '确定',
cancelText: '取消', cancelText: '取消',
onOk() { onOk() {
@ -109,12 +115,18 @@ class Repository extends Component {
} }
}) })
} }
let pathtype=path;
if(path===undefined||path===""){ if(path===undefined||path===""){
path=newfilspath path=newfilspath
}else{ }else{
path=path+"/"+newfilspath path=path+"/"+newfilspath
} }
let gototype;
if(pathtype){
gototype=1
}else{
gototype=2
}
const url = `/shixuns//${shixunId}/delete_git_file.json`; const url = `/shixuns//${shixunId}/delete_git_file.json`;
@ -126,11 +138,23 @@ class Repository extends Component {
.then((response) => { .then((response) => {
if(response.data.status == 0) { if(response.data.status == 0) {
this.props.showNotification("删除成功") this.props.showNotification("删除成功")
if(gototype===1){
if(this.state.trees.length>1){
this.state.trees.map((item,key)=>{ this.state.trees.map((item,key)=>{
if(item.name===newfilspath){ if(item.name===newfilspath){
this.state.trees.splice(key,1) this.state.trees.splice(key,1)
} }
}) })
}else{
this.props.fetchRepo(this.props.pathArray.length-1)
}
}else{
this.state.trees.map((item,key)=>{
if(item.name===newfilspath){
this.state.trees.splice(key,1)
}
})
}
this.setState({ this.setState({
ischecke:false, ischecke:false,
ischeckevalue:"" ischeckevalue:""
@ -138,10 +162,7 @@ class Repository extends Component {
} }
}) })
.catch(function (error) { .catch(function (error) {
this.setState({ console.log(error)
ischecke:false,
ischeckevalue:""
})
}); });
} }
onCheck = (checkedKeys, info) => { onCheck = (checkedKeys, info) => {
@ -191,7 +212,6 @@ class Repository extends Component {
{...this.props} {...this.props}
Repositoryflag={Repositoryflag} Repositoryflag={Repositoryflag}
hideNewFolder={()=>this.hideNewFolder()} hideNewFolder={()=>this.hideNewFolder()}
setfilepath={(path)=>this.setfilepath(path)}
/>:""} />:""}
{ repositoryLoading ? <div style={{ minHeight: '500px'}}></div> : { repositoryLoading ? <div style={{ minHeight: '500px'}}></div> :
<div className="mb10" id="collaborators_list_info"> <div className="mb10" id="collaborators_list_info">
@ -393,7 +413,7 @@ class Repository extends Component {
> >
{ trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => { { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => {
return ( return (
<TreeNode disableCheckbox={this.state.ischeckevalue===item.name?false:this.state.ischecke?true:item.type==='tree'?true:false} item={item} title={`${item.name}`} key={item.type==='tree'?"0-0":`0-0-${index}`} icon={item.type==='tree'?<i className="iconfont icon-xingzhuangjiehebeifen color-blue font-12" />:<i className="iconfont icon-xingzhuangjiehe color-blue font-12"/>} id={`file${index}`} key={index}> <TreeNode disableCheckbox={this.state.ischeckevalue===item.name?false:this.state.ischecke?true:false} item={item} title={`${item.name}`} key={item.type==='tree'?"0-0":`0-0-${index}`} icon={item.type==='tree'?<i className="iconfont icon-xingzhuangjiehebeifen color-blue font-12" />:<i className="iconfont icon-xingzhuangjiehe color-blue font-12"/>} id={`file${index}`} key={index}>
<div className={"fr"}>x</div> <div className={"fr"}>x</div>
</TreeNode> </TreeNode>
)})} )})}

@ -252,7 +252,7 @@ class RepositoryAddFile extends Component {
}], }],
})( })(
<span> <span>
<span> </span><span><Input value={this.state.path} placeholder="文件名称或文件路径" className=" fl" style={{ width: 200 }} size="large" onInput={(e)=>this.setinput(e)}/></span><span className={" ml10 fl"}>提示:输入 / 可以将文件创建到新文件夹下</span> <span> </span><span><Input value={this.state.path} placeholder="文件名称或文件路径" className="fl" style={{ width: 200 }} size="large" onInput={(e)=>this.setinput(e)}/></span><span className={" ml10 fl"}>提示:输入 / 可以将文件创建到新文件夹下</span>
</span> </span>
)} )}
</Form.Item> </Form.Item>
@ -289,7 +289,9 @@ class RepositoryAddFile extends Component {
</div> </div>
</Form> </Form>
</div> </div>
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`} onSubmits={() => this.handleSubmit()}/> <Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}${this.state.path===""?"":"/master/shixun_show/"+this.state.path}`} onSubmits={() => this.handleSubmit()}/>
{/*<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`} onSubmits={() => this.handleSubmit()}/>*/}
</div> </div>
) )
} }

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

@ -91,7 +91,8 @@ class RepositoryCodeEditor extends Component {
// }, 2000) // }, 2000)
} }
} }
componentDidMount() { componentDidMount(){
let cmOptions = createCMOptions(this.props.mirror_name) let cmOptions = createCMOptions(this.props.mirror_name)
const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0] const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0]
, cmOptions); , cmOptions);
@ -119,12 +120,13 @@ class RepositoryCodeEditor extends Component {
).then((response) => { ).then((response) => {
if (response.data.content) { if (response.data.content) {
message.success('保存成功'); message.success('保存成功');
this.setCohetepaperbool(this.props.pathArray.length===0?0:this.props.pathArray.length-1)
this.setState({ codeSaving: false }) this.setState({ codeSaving: false })
} }
}) })
} }
setCohetepaperbool=()=>{ setCohetepaperbool=(sum)=>{
this.props.oncodechanner() this.props.oncodechanner(sum)
} }
render() { render() {
const { fileContent, shixunId, saveCode } = this.props; const { fileContent, shixunId, saveCode } = this.props;
@ -184,7 +186,7 @@ class RepositoryCodeEditor extends Component {
<Bottomsubmit <Bottomsubmit
Cohetepaperbool={true} Cohetepaperbool={true}
{...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`} {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`}
setCohetepaperbool={() => this.setCohetepaperbool()} setCohetepaperbool={() => this.setCohetepaperbool(this.props.pathArray.length===0?0:this.props.pathArray.length-1)}
onSubmits={() => this.saveCode(this.extend_editor.getValue())}/> onSubmits={() => this.saveCode(this.extend_editor.getValue())}/>
</React.Fragment> </React.Fragment>

@ -234,8 +234,10 @@ class Repositoryfile extends Component{
}).then((result)=>{ }).then((result)=>{
if(result){ if(result){
if(result.data.status===0){ if(result.data.status===0){
this.props.fetchRepo(this.props.pathArray.length)
this.props.showNotification("新建成功") this.props.showNotification("新建成功")
this.props.hideNewFolder(); this.props.hideNewFolder();
} }
} }
}).catch((error)=>{ }).catch((error)=>{
@ -276,7 +278,6 @@ class Repositoryfile extends Component{
</style> </style>
<div className="newupload_conbox clearfix"> <div className="newupload_conbox clearfix">
<ul id="directory_file"> <ul id="directory_file">
{console.log(main)}
{ {
main.length===0?"":main.map((item,key)=>{ main.length===0?"":main.map((item,key)=>{
return( return(

Loading…
Cancel
Save