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 (
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;