|
|
@ -1,12 +1,14 @@
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import {getImageUrl} from "educoder";
|
|
|
|
import {getImageUrl} from "educoder";
|
|
|
|
import RepositoryDirectories from './RepositoryDirectories';
|
|
|
|
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 {Link} from 'react-router-dom';
|
|
|
|
import RepositoryCombinePath from './RepositoryCombinePath';
|
|
|
|
import RepositoryCombinePath from './RepositoryCombinePath';
|
|
|
|
import RepositoryNoneData from './RepositoryNoneData';
|
|
|
|
import RepositoryNoneData from './RepositoryNoneData';
|
|
|
|
import Repositoryfile from './Repositoryfile';
|
|
|
|
import Repositoryfile from './Repositoryfile';
|
|
|
|
import './Repository.css';
|
|
|
|
import './Repository.css';
|
|
|
|
|
|
|
|
const { confirm } = Modal;
|
|
|
|
const $ = window.$;
|
|
|
|
const $ = window.$;
|
|
|
|
const { TreeNode, DirectoryTree } = Tree;
|
|
|
|
const { TreeNode, DirectoryTree } = Tree;
|
|
|
|
// 点击按钮复制功能
|
|
|
|
// 点击按钮复制功能
|
|
|
@ -24,13 +26,24 @@ class Repository extends Component {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.state={
|
|
|
|
this.state={
|
|
|
|
evaluationvisible:false,
|
|
|
|
evaluationvisible:false,
|
|
|
|
|
|
|
|
ischecke:false,
|
|
|
|
|
|
|
|
ischeckevalue:"",
|
|
|
|
|
|
|
|
trees:undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
trees:this.props.trees
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
|
|
|
|
if(prevProps!=this.props){
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
trees:this.props.trees
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onRepoFileClick = (item) => {
|
|
|
|
onRepoFileClick = (item) => {
|
|
|
|
this.props.fetchRepo(item)
|
|
|
|
this.props.fetchRepo(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -50,8 +63,107 @@ class Repository extends Component {
|
|
|
|
onSelectDirectoryTree=(selectedKeys, info)=>{
|
|
|
|
onSelectDirectoryTree=(selectedKeys, info)=>{
|
|
|
|
this.onRepoFileClick(info.node.props.item)
|
|
|
|
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() {
|
|
|
|
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 matchpath =this.props.match.path;
|
|
|
|
let Repositoryflag ="";
|
|
|
|
let Repositoryflag ="";
|
|
|
|
|
|
|
|
|
|
|
@ -231,7 +343,9 @@ class Repository extends Component {
|
|
|
|
<div className="padding20" style={{minHeight: '372px'}}>
|
|
|
|
<div className="padding20" style={{minHeight: '372px'}}>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{/* 当前目录位置 */}
|
|
|
|
{/* 当前目录位置 */}
|
|
|
|
<RepositoryDirectories {...this.props}></RepositoryDirectories>
|
|
|
|
<div className={"mb10"}>
|
|
|
|
|
|
|
|
<RepositoryDirectories {...this.props}></RepositoryDirectories>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/*<div className="versionFileList">*/}
|
|
|
|
{/*<div className="versionFileList">*/}
|
|
|
|
{/* { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => {*/}
|
|
|
|
{/* { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => {*/}
|
|
|
@ -250,10 +364,14 @@ class Repository extends Component {
|
|
|
|
{/* })}*/}
|
|
|
|
{/* })}*/}
|
|
|
|
{/*</div>*/}
|
|
|
|
{/*</div>*/}
|
|
|
|
|
|
|
|
|
|
|
|
<DirectoryTree multiple defaultExpandAll onSelect={this.onSelectDirectoryTree}>
|
|
|
|
{ this.props.current_user && (this.props.current_user.admin ==true || (TPMRightSectionData && TPMRightSectionData.creator && TPMRightSectionData.creator.login == this.props.current_user.login)) ?
|
|
|
|
|
|
|
|
<Button size={"small"} className={"fr"} type="link" onClick={this.showDeleteConfirm}><Icon type="delete" /></Button>:""}
|
|
|
|
|
|
|
|
<div className={"both"}></div>
|
|
|
|
|
|
|
|
<DirectoryTree multiple defaultExpandAll checkable onSelect={this.onSelectDirectoryTree} onCheck={this.onCheck}>
|
|
|
|
{ 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 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: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}>
|
|
|
|
|
|
|
|
<div className={"fr"}>x</div>
|
|
|
|
</TreeNode>
|
|
|
|
</TreeNode>
|
|
|
|
)})}
|
|
|
|
)})}
|
|
|
|
</DirectoryTree>
|
|
|
|
</DirectoryTree>
|
|
|
|