dev_new_shixunsrepository
杨树明 5 years ago
parent 68a8b44083
commit 0ae972209b

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

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

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

@ -252,7 +252,7 @@ class RepositoryAddFile extends Component {
}],
})(
<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>
)}
</Form.Item>
@ -289,7 +289,9 @@ class RepositoryAddFile extends Component {
</div>
</Form>
</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>
)
}

@ -301,8 +301,8 @@ 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={"确定"}/>
<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>
)

@ -103,6 +103,7 @@ class RepositoryCodeEditor extends Component {
}
}
componentDidMount(){
let cmOptions = createCMOptions(this.props.mirror_name)
const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0]
, cmOptions);
@ -130,12 +131,13 @@ class RepositoryCodeEditor extends Component {
).then((response) => {
if (response.data.content) {
message.success('保存成功');
this.setCohetepaperbool(this.props.pathArray.length===0?0:this.props.pathArray.length-1)
this.setState({ codeSaving: false })
}
})
}
setCohetepaperbool=()=>{
this.props.oncodechanner()
setCohetepaperbool=(sum)=>{
this.props.oncodechanner(sum)
}
render() {
const { fileContent, shixunId, saveCode } = this.props;
@ -195,7 +197,7 @@ class RepositoryCodeEditor extends Component {
<Bottomsubmit
Cohetepaperbool={true}
{...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())}/>
</React.Fragment>

@ -234,8 +234,10 @@ class Repositoryfile extends Component{
}).then((result)=>{
if(result){
if(result.data.status===0){
this.props.fetchRepo(this.props.pathArray.length)
this.props.showNotification("新建成功")
this.props.hideNewFolder();
}
}
}).catch((error)=>{
@ -276,7 +278,6 @@ 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