dev_new_shixunsrepository
杨树明 5 years ago
parent 43530f6431
commit b68fd0a48a

@ -54,8 +54,9 @@
.colorFF6601{ .colorFF6601{
color:#FF6601 color:#FF6601
} }
.padding040pxRepository{ .padding040pxRepository{
padding: 40px 40px 0px 40px; padding: 40px 20px 0px 20px;
} }
.color888{ .color888{

@ -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>

@ -90,7 +90,7 @@ class RepositoryAddFileupload_files extends Component {
}}) }})
.then((response) => { .then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.props.showNotification("删除成功")
} }
}) })
.catch(function (error) { .catch(function (error) {

@ -5,6 +5,7 @@ import axios from 'axios';
import { trace_collapse, WordsBtn } from 'educoder' import { trace_collapse, WordsBtn } from 'educoder'
import { message, Input } from 'antd'; import { message, Input } from 'antd';
import Repositoryfile from "./Repositoryfile";
const $ = window.$; const $ = window.$;
@ -15,37 +16,54 @@ class RepositoryCombinePath extends Component {
super(props) super(props)
this.state = { this.state = {
value: this.props.secret_dir_path || '', value: this.props.secret_dir_path || '',
newvalue:'',
isEdit: false, isEdit: false,
} }
} }
onSave = () => { onSave = (value) => {
const { shixunId, pathArray } = this.props; const { shixunId, pathArray } = this.props;
const url = `/shixuns/${shixunId}/set_secret_dir.json` const url = `/shixuns/${shixunId}/set_secret_dir.json`
this.setState({ codeSaving: true })
axios.post(url, { axios.post(url, {
secret_dir_path: this.state.value secret_dir_path:value
} }
).then((response) => { ).then((response) => {
if (response.data) { if (response.data) {
message.success('保存成功'); this.setState({
this.setState({isEdit: false}) newvalue:value
})
// message.success('保存成功');
} }
}) })
} }
onChange = (e) => { // onChange = (e) => {
const { value } = e.target; // const { value } = e.target;
this.setState({ value }) // 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() { render() {
const { fileContent, match, saveCode } = this.props; const { fileContent, match, saveCode } = this.props;
const { isEdit, value } = this.state; const { newvalue, value } = this.state;
return ( return (
<div className="combinePathEditRow"> <div className="combinePathEditRow">
@ -61,11 +79,22 @@ class RepositoryCombinePath extends Component {
margin-left: 24px; margin-left: 24px;
} }
`}</style> `}</style>
{this.state.visibles===true?<Repositoryfile
titles={"选择文件目录"}
evaluationvisible={this.state.visibles}
hideNewFolder={this.hideNewFolder}
{...this.state}
{...this.props}
RepositoryCombinePath={true}
selectupfilspath={(value)=>this.onSave(value)}
/>:""}
<div className={"mt2"}>合并版本库路径</div>
<div className={"df"}> <div className={"df"}>
<span className={"mt2"}> {!isEdit?"源路径:":"目标路径:"}</span><span><Input disabled={!isEdit} value={value} onChange={this.onChange}></Input></span> {/*<span className={"mt2"}> {!isEdit?"源路径:":"目标路径:"}</span><span><Input disabled={!isEdit} value={value} onChange={this.onChange}></Input></span>*/}
{!isEdit && <WordsBtn className="wordsBtn" onClick={this.onEdit} style="blue">修改</WordsBtn>} <span className={"mt3"}> <span>源路径</span><span>{value}</span></span> <span><i className={"iconfont icon-youjiang color-grey-8 ml20"}></i></span>
{isEdit && <WordsBtn className="wordsBtn" onClick={this.onSave} style="blue">保存</WordsBtn>} <span className={"mt4 ml20"}> <span>目标路径</span><span>{newvalue}</span></span>
<WordsBtn className="wordsBtn mt4" onClick={this.Selectfiledirectory} style="blue">选择文件目录</WordsBtn>
{/*{isEdit && <WordsBtn className="wordsBtn" onClick={this.onSave} style="blue">保存</WordsBtn>}*/}
</div> </div>
</div> </div>

@ -128,16 +128,31 @@ class Repositoryfile extends Component{
flag =true; flag =true;
} }
if(this.props.selectupfils===true){ if(this.props.selectupfils===true){
this.props.selectupfilspath(path); this.props.selectupfilspath(path);
this.props.showNotification("选择文件目录成功") this.props.showNotification("选择文件目录成功")
this.props.hideNewFolder(); 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{ }else{
let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`; let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`;
this.props.form.validateFieldsAndScroll((err, values) => { this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) { if (!err) {
console.log('Received values of form: ', values); let paths;
let paths=path+"/"+values.name; if(path===""){
paths=values.name;
}else{
paths=path+"/"+values.name;
}
axios.post(url,{ axios.post(url,{
path: paths, path: paths,
secret_repository:flag===false?undefined:flag, secret_repository:flag===false?undefined:flag,
@ -154,8 +169,7 @@ class Repositoryfile extends Component{
} }
}); });
} }
}
};
render(){ render(){
const {getFieldDecorator} = this.props.form; const {getFieldDecorator} = this.props.form;

Loading…
Cancel
Save