From b68fd0a48a1ccff9465066572bd1ed3f1c9b4f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 7 Jan 2020 17:37:37 +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 --- .../tpm/shixunchild/Repository/Repository.css | 3 +- .../tpm/shixunchild/Repository/Repository.js | 132 +++++++++++++++++- .../RepositoryAddFileupload_file.js | 2 +- .../Repository/RepositoryCombinePath.js | 65 ++++++--- .../shixunchild/Repository/Repositoryfile.js | 24 +++- 5 files changed, 194 insertions(+), 32 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.css b/public/react/src/modules/tpm/shixunchild/Repository/Repository.css index a8aeeb8b3..15955a159 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.css +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.css @@ -54,8 +54,9 @@ .colorFF6601{ color:#FF6601 } + .padding040pxRepository{ - padding: 40px 40px 0px 40px; + padding: 40px 20px 0px 20px; } .color888{ diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js index 72e9a52ad..960f88966 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js @@ -1,12 +1,14 @@ import React, { Component } from 'react'; import {getImageUrl} from "educoder"; import RepositoryDirectories from './RepositoryDirectories'; -import { Button ,Tree,Icon} from "antd"; +import { Button ,Tree,Icon,Modal} from "antd"; +import axios from 'axios'; import {Link} from 'react-router-dom'; import RepositoryCombinePath from './RepositoryCombinePath'; import RepositoryNoneData from './RepositoryNoneData'; import Repositoryfile from './Repositoryfile'; import './Repository.css'; +const { confirm } = Modal; const $ = window.$; const { TreeNode, DirectoryTree } = Tree; // 点击按钮复制功能 @@ -24,13 +26,24 @@ class Repository extends Component { super(props); this.state={ evaluationvisible:false, + ischecke:false, + ischeckevalue:"", + trees:undefined } } componentDidMount() { - + this.setState({ + trees:this.props.trees + }) + } + componentDidUpdate(prevProps, prevState) { + if(prevProps!=this.props){ + this.setState({ + trees:this.props.trees + }) + } } - onRepoFileClick = (item) => { this.props.fetchRepo(item) } @@ -50,8 +63,107 @@ class Repository extends Component { onSelectDirectoryTree=(selectedKeys, info)=>{ this.onRepoFileClick(info.node.props.item) } + + showDeleteConfirm =()=>{ + + let that=this; + if(this.state.ischeckevalue===""){ + this.props.showNotification("请选择要删除的文件") + return + }else{ + confirm({ + title: '确认需要要删除该文件?', + okText: '确定', + cancelText: '取消', + onOk() { + that.onAttachmentRemove() + } + }); + } + + } + onAttachmentRemove=()=>{ + + let shixunId = this.props.match.params.shixunId; + let matchpath =this.props.match.path; + let Repositoryflag =undefined; + + if( matchpath.indexOf("repository")>-1){ + Repositoryflag =undefined; + } + if(matchpath.indexOf("secret_repository")>-1){ + Repositoryflag =true; + } + + let newfilspath=this.state.ischeckevalue; + + let path=""; + + if(this.props.pathArray.length>0){ + this.props.pathArray.map((item,key)=>{ + if(key===0){ + path=item + }else{ + path=path+"/"+item + } + }) + } + + if(path===undefined||path===""){ + path=newfilspath + }else{ + path=path+"/"+newfilspath + } + + const url = `/shixuns//${shixunId}/delete_git_file.json`; + + axios.delete(url, { data: { + path:path, + message:"删除"+newfilspath, + secret_repository:Repositoryflag + }}) + .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) + } + }) + this.setState({ + ischecke:false, + ischeckevalue:"" + }) + } + }) + .catch(function (error) { + this.setState({ + ischecke:false, + ischeckevalue:"" + }) + }); + } + onCheck = (checkedKeys, info) => { + + if(checkedKeys.length===0){ + + this.setState({ + ischecke:false, + ischeckevalue:"" + }) + } + + if(info.node.props.title&&checkedKeys.length!=0){ + + this.setState({ + ischecke:true, + ischeckevalue:info.node.props.title + }) + } + }; render() { - let { match, author, git_url, lastest_commit,repositoryLoading, commits,trees,pathArray , TPMRightSectionData } = this.props; + let { match, author, git_url, lastest_commit,repositoryLoading, commits,pathArray , TPMRightSectionData } = this.props; + let{trees}= this.state; let matchpath =this.props.match.path; let Repositoryflag =""; @@ -231,7 +343,9 @@ class Repository extends Component {
{/* 当前目录位置 */} - +
+ +
{/*
*/} {/* { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => {*/} @@ -250,10 +364,14 @@ class Repository extends Component { {/* })}*/} {/*
*/} - + { this.props.current_user && (this.props.current_user.admin ==true || (TPMRightSectionData && TPMRightSectionData.creator && TPMRightSectionData.creator.login == this.props.current_user.login)) ? + :""} +
+ { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => { return ( - :} id={`file${index}`} key={index}> + :} id={`file${index}`} key={index}> +
x
)})}
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 9c4ae4509..ba8a80ba9 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js @@ -90,7 +90,7 @@ class RepositoryAddFileupload_files extends Component { }}) .then((response) => { if (response.data.status == 0) { - + this.props.showNotification("删除成功") } }) .catch(function (error) { diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCombinePath.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCombinePath.js index 932c6a94f..b32685736 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCombinePath.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCombinePath.js @@ -5,6 +5,7 @@ import axios from 'axios'; import { trace_collapse, WordsBtn } from 'educoder' import { message, Input } from 'antd'; +import Repositoryfile from "./Repositoryfile"; const $ = window.$; @@ -15,37 +16,54 @@ class RepositoryCombinePath extends Component { super(props) this.state = { value: this.props.secret_dir_path || '', + newvalue:'', isEdit: false, } } - onSave = () => { + onSave = (value) => { const { shixunId, pathArray } = this.props; const url = `/shixuns/${shixunId}/set_secret_dir.json` - - this.setState({ codeSaving: true }) + axios.post(url, { - secret_dir_path: this.state.value + secret_dir_path:value } ).then((response) => { if (response.data) { - message.success('保存成功'); - this.setState({isEdit: false}) + this.setState({ + newvalue:value + }) + // message.success('保存成功'); + } }) } - onChange = (e) => { - const { value } = e.target; - this.setState({ value }) + // onChange = (e) => { + // const { value } = e.target; + // this.setState({ value }) + // } + // onEdit = () => { + // this.setState({isEdit: true}, () => { + // window.$('.combinePathEditRow input')[0].focus() + // }); + // } + + Selectfiledirectory=()=>{ + this.setState({ + visibles:true + }) } - onEdit = () => { - this.setState({isEdit: true}, () => { - window.$('.combinePathEditRow input')[0].focus() - }); + + + hideNewFolder=()=>{ + this.setState({ + visibles:false + }) } + render() { const { fileContent, match, saveCode } = this.props; - const { isEdit, value } = this.state; + const { newvalue, value } = this.state; return (
@@ -61,11 +79,22 @@ class RepositoryCombinePath extends Component { margin-left: 24px; } `} - + {this.state.visibles===true?this.onSave(value)} + />:""} +
合并版本库路径:
- {!isEdit?"源路径:":"目标路径:"} - {!isEdit && 修改} - {isEdit && 保存} + {/* {!isEdit?"源路径:":"目标路径:"}*/} + 源路径:{value} + 目标路径:{newvalue} + 选择文件目录 + {/*{isEdit && 保存}*/}
diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js index bc58d6cc0..7336fcd9e 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js @@ -128,16 +128,31 @@ class Repositoryfile extends Component{ flag =true; } if(this.props.selectupfils===true){ - this.props.selectupfilspath(path); this.props.showNotification("选择文件目录成功") this.props.hideNewFolder(); + }else if(this.props.RepositoryCombinePath===true){ + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + if(path===""){ + this.props.selectupfilspath(values.name); + }else{ + this.props.selectupfilspath(path+"/"+values.name); + } + this.props.showNotification("保存成功") + this.props.hideNewFolder(); + } + }); }else{ let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`; this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - console.log('Received values of form: ', values); - let paths=path+"/"+values.name; + let paths; + if(path===""){ + paths=values.name; + }else{ + paths=path+"/"+values.name; + } axios.post(url,{ path: paths, secret_repository:flag===false?undefined:flag, @@ -154,8 +169,7 @@ class Repositoryfile extends Component{ } }); } - - }; + } render(){ const {getFieldDecorator} = this.props.form;