|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { Form , Upload , Input , Icon, message } from 'antd';
|
|
|
|
|
import { Form , Upload , Input , notification, message } from 'antd';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import { getUploadActionUrl } from 'educoder';
|
|
|
|
|
import { getupload_git_file } from 'educoder';
|
|
|
|
|
import Bottomsubmit from "../../../modals/Bottomsubmit";
|
|
|
|
|
import "./Repository.css"
|
|
|
|
|
const { Dragger } = Upload;
|
|
|
|
@ -10,6 +10,7 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state={
|
|
|
|
|
filspath:"",
|
|
|
|
|
message:undefined,
|
|
|
|
|
fileList: [
|
|
|
|
|
// {
|
|
|
|
|
// uid: '-1',
|
|
|
|
@ -45,27 +46,18 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
handleChange = (info) => {
|
|
|
|
|
console.log(info)
|
|
|
|
|
console.log(info.file)
|
|
|
|
|
|
|
|
|
|
const { status } = info.file;
|
|
|
|
|
if (status !== 'uploading') {
|
|
|
|
|
console.log(info.file, info.fileList);
|
|
|
|
|
}
|
|
|
|
|
if (status === 'done') {
|
|
|
|
|
message.success(`${info.file.name} file uploaded successfully.`);
|
|
|
|
|
} else if (status === 'error') {
|
|
|
|
|
message.error(`${info.file.name} file upload failed.`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// notification.open({
|
|
|
|
|
// message: '提示',
|
|
|
|
|
// description: result.data.messages,
|
|
|
|
|
// });
|
|
|
|
|
let fileList = [...info.fileList];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileList = fileList.slice(-2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileList = fileList.map(file => {
|
|
|
|
|
if (file.response) {
|
|
|
|
|
|
|
|
|
|
file.url = file.response.url;
|
|
|
|
|
}
|
|
|
|
|
return file;
|
|
|
|
@ -73,31 +65,109 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
|
|
|
|
|
this.setState({ fileList });
|
|
|
|
|
|
|
|
|
|
console.log(fileList)
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onAttachmentRemove=(info)=>{
|
|
|
|
|
let shixunId = this.props.match.params.shixunId;
|
|
|
|
|
let {message,filspath}=this.state;
|
|
|
|
|
if(message===""||message===undefined){
|
|
|
|
|
notification.open({
|
|
|
|
|
message: '提示',
|
|
|
|
|
description: '删除文件请先填写提交信息',
|
|
|
|
|
});
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let matchpath =this.props.match.path;
|
|
|
|
|
|
|
|
|
|
let Repositoryflag =false;
|
|
|
|
|
|
|
|
|
|
if( matchpath.indexOf("repository")>-1){
|
|
|
|
|
Repositoryflag =false;
|
|
|
|
|
}
|
|
|
|
|
if(matchpath.indexOf("secret_repository")>-1){
|
|
|
|
|
Repositoryflag =true;
|
|
|
|
|
}
|
|
|
|
|
const url = `/shixuns//${shixunId}/delete_git_file.json`;
|
|
|
|
|
axios.delete(url, { data: {
|
|
|
|
|
path:filspath+info.name,
|
|
|
|
|
message:message,
|
|
|
|
|
secret_repository:Repositoryflag
|
|
|
|
|
}})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.data.status == 0) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormInput=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
message:e.target.value
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
|
let { shixunId } = this.props.match.params;
|
|
|
|
|
// const props = {
|
|
|
|
|
// height:300,
|
|
|
|
|
// // name: 'file',
|
|
|
|
|
// multiple: true,
|
|
|
|
|
//
|
|
|
|
|
// action: `${getUploadActionUrl()}`,
|
|
|
|
|
// onChange: this.handleChange,
|
|
|
|
|
// onRemove: this.onAttachmentRemove,
|
|
|
|
|
// // beforeUpload: (file) => {
|
|
|
|
|
// // console.log('beforeUpload', file.name);
|
|
|
|
|
// // const isLt150M = file.size / 1024 / 1024 < 150;
|
|
|
|
|
// // if (!isLt150M) {
|
|
|
|
|
// // this.props.showNotification('文件大小必须小于150MB!');
|
|
|
|
|
// // }
|
|
|
|
|
// // return isLt150M;
|
|
|
|
|
// // },
|
|
|
|
|
// };
|
|
|
|
|
let matchpath =this.props.match.path;
|
|
|
|
|
|
|
|
|
|
let Repositoryflagtype =false;
|
|
|
|
|
let Repositoryflag ="";
|
|
|
|
|
|
|
|
|
|
if( matchpath.indexOf("repository")>-1){
|
|
|
|
|
Repositoryflag ="repository";
|
|
|
|
|
Repositoryflagtype =false;
|
|
|
|
|
}
|
|
|
|
|
if(matchpath.indexOf("secret_repository")>-1){
|
|
|
|
|
Repositoryflag ="secret_repository";
|
|
|
|
|
Repositoryflagtype =true;
|
|
|
|
|
}
|
|
|
|
|
const props = {
|
|
|
|
|
height:300,
|
|
|
|
|
name: 'file',
|
|
|
|
|
multiple: true,
|
|
|
|
|
fileList:this.state.fileList,
|
|
|
|
|
action: getUploadActionUrl(),
|
|
|
|
|
data:{
|
|
|
|
|
path:this.state.filspath,
|
|
|
|
|
message:this.state.message,
|
|
|
|
|
secret_repository:Repositoryflagtype
|
|
|
|
|
},
|
|
|
|
|
// fileList:this.state.fileList,
|
|
|
|
|
// showUploadList:false,
|
|
|
|
|
action: `${getupload_git_file(shixunId)}`,
|
|
|
|
|
onChange: this.handleChange,
|
|
|
|
|
onRemove: this.onAttachmentRemove,
|
|
|
|
|
// beforeUpload: (file) => {
|
|
|
|
|
// console.log('beforeUpload', file.name);
|
|
|
|
|
// const isLt150M = file.size / 1024 / 1024 < 150;
|
|
|
|
|
// if (!isLt150M) {
|
|
|
|
|
// this.props.showNotification('文件大小必须小于150MB!');
|
|
|
|
|
// }
|
|
|
|
|
// return isLt150M;
|
|
|
|
|
// },
|
|
|
|
|
beforeUpload: (file) => {
|
|
|
|
|
let {message}=this.state;
|
|
|
|
|
if(message===""||message===undefined){
|
|
|
|
|
notification.open({
|
|
|
|
|
message: '提示',
|
|
|
|
|
description: '上传文件请先填写提交信息',
|
|
|
|
|
});
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
|
|
|
|
<div className="educontent mt30">
|
|
|
|
@ -149,12 +219,12 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
|
|
|
|
|
{getFieldDecorator('message', {
|
|
|
|
|
rules: [{
|
|
|
|
|
required: true, message: '请输入名称',
|
|
|
|
|
required: true, message: '请输入提交信息',
|
|
|
|
|
},{
|
|
|
|
|
whitespace: true, message: '请勿输入空格'
|
|
|
|
|
}],
|
|
|
|
|
})(
|
|
|
|
|
<Input placeholder="必填,描述主要修改内容(相当于Git Commit message的Header)" className="winput-300-35 fl"/>
|
|
|
|
|
<Input placeholder="必填,描述主要修改内容(相当于Git Commit message的Header)" onInput={this.FormInput} className="winput-300-35 fl"/>
|
|
|
|
|
)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
@ -170,12 +240,12 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Dragger {...props}>
|
|
|
|
|
<Dragger {...props} >
|
|
|
|
|
<p className="ant-upload-drag-icon">
|
|
|
|
|
<i className="iconfont icon-shangchuan font-50 color-blue" />
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p className="ant-upload-hint mt20">
|
|
|
|
|
<p className="ant-upload-hint mt30">
|
|
|
|
|
拖拽文件或 <span className="color-blue" >点击此处上传</span>
|
|
|
|
|
</p>
|
|
|
|
|
</Dragger>
|
|
|
|
@ -191,7 +261,7 @@ class RepositoryAddFileupload_files extends Component {
|
|
|
|
|
</div>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/repository`} onSubmits={() => this.handleSubmit()}/>
|
|
|
|
|
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/${Repositoryflag}`} onSubmits={() => this.handleSubmit()}/>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|