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 {