diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index b6a43b54..5878c780 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -344,7 +344,7 @@ class CoderRootDirectory extends Component{ return(
-
+
diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index fa607f70..172959ad 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -2,12 +2,7 @@ import React , { Component } from "react"; import { Popconfirm } from 'antd'; import './list.css'; import axios from 'axios'; - -import CodeMirror from 'react-codemirror'; -require('codemirror/lib/codemirror.css'); -require('codemirror/mode/javascript/javascript'); -require('codemirror/mode/xml/xml'); -require('codemirror/mode/markdown/markdown'); +import Meditor from "../Newfile/m_editor" function bytesToSize(bytes) { if (bytes === 0) return '0 B'; @@ -76,28 +71,28 @@ class CoderRootFileDetail extends Component{ - // 确认修改文件 - UpdateFile=()=>{ - const { branch , detail}= this.props; - const { projectsId } = this.props.match.params; - const { value } = this.state; - const url =`/repositories/${projectsId}/update_file.json`; - axios.put(url,{ - filepath:detail.path, - branch, - content:value, - sha:detail.sha, - }).then(result=>{ - if(result){ - this.props.showNotification("修改成功!"); - this.setState({ - readOnly:true - }) - } - }).catch(error=>{ - console.log(error); - }) - } + // // 确认修改文件 + // UpdateFile=()=>{ + // const { branch , detail}= this.props; + // const { projectsId } = this.props.match.params; + // const { value } = this.state; + // const url =`/repositories/${projectsId}/update_file.json`; + // axios.put(url,{ + // filepath:detail.path, + // branch, + // content:value, + // sha:detail.sha, + // }).then(result=>{ + // if(result){ + // this.props.showNotification("修改成功!"); + // this.setState({ + // readOnly:true + // }) + // } + // }).catch(error=>{ + // console.log(error); + // }) + // } updateCode=(value)=> { this.setState({ value, @@ -108,16 +103,16 @@ class CoderRootFileDetail extends Component{ const { detail , current_user , isManager , isDeveloper } = this.props; const { readOnly } = this.state; let flag = current_user && current_user.login && (isManager || isDeveloper); - var options = { - lineNumbers: true, - mode: 'javascript', - readOnly:readOnly?'nocursor':false, - autofocus:readOnly?false:true, - styleActiveLine:true - }; + // var options = { + // lineNumbers: true, + // mode: 'javascript', + // readOnly:readOnly?'nocursor':false, + // autofocus:readOnly?false:true, + // styleActiveLine:true + // }; return( -
-
+
+

{bytesToSize(detail && detail.size)} { @@ -125,13 +120,13 @@ class CoderRootFileDetail extends Component{ { readOnly ? - + : - + {/* */} } @@ -142,14 +137,22 @@ class CoderRootFileDetail extends Component{ }

-
+
{ detail.direct_download ? : - + + }
diff --git a/src/forge/Main/DetailTop.js b/src/forge/Main/DetailTop.js index 09d020bb..4d4d584f 100644 --- a/src/forge/Main/DetailTop.js +++ b/src/forge/Main/DetailTop.js @@ -30,7 +30,7 @@ class DetailTop extends Component { */} - 仓库 {projectDetail && projectDetail.size}kb + 仓库 {projectDetail && projectDetail.size}

) diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index 778b8285..34170e71 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -430,7 +430,7 @@ padding:12px 10px; color: #333; font-size: 16px; - background: #EEEEEE; + background:rgba(241,248,255,1); } .branchUl{ padding:0px 30px; diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js index b1212caf..421fb347 100644 --- a/src/forge/Newfile/Index.js +++ b/src/forge/Newfile/Index.js @@ -1,10 +1,8 @@ import React , { Component } from "react"; -import Editor from "react-monaco-editor"; - -import UserSubmitComponent from './UserSubmitComponent'; +import Meditor from "./m_editor" import Top from '../Main/DetailTop'; -import { Input } from 'antd'; import './index.css'; +import { Input } from 'antd'; class Index extends Component{ constructor(props){ @@ -15,54 +13,45 @@ class Index extends Component{ } } - // 命名文件 - changeFileName=(e)=>{ - this.setState({ - filename:e.target.value - }) - } - // 取消,弹框询问 - CancelAddFile=()=>{ - this.props.history.goBack(); - } - - changeEditor=(editorValue)=>{ - this.setState({ - editorValue - }) - } + // 命名文件 + changeFileName=(e)=>{ + this.setState({ + filename:e.target.value + }) + } + // 取消,弹框询问 + CancelAddFile=()=>{ + this.props.history.goBack(); + } render(){ - const { editorValue , filename } = this.state; - const { projectDetail } = this.props; - const { pathname } = this.props.location; + const { filename } = this.state; const urlroot = pathname.split("newfile")[1]; + const file_path = `${urlroot}/${filename}` + const { projectDetail } = this.props; return(

新建文件

+
-
- -
- + filepath={`${file_path}`} + content={""} + readOnly={false} + editorType="new" + > + +
) diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js index 5523c649..b02eb12d 100644 --- a/src/forge/Newfile/UserSubmitComponent.js +++ b/src/forge/Newfile/UserSubmitComponent.js @@ -1,115 +1,204 @@ -import React,{Component} from 'react'; -import { getImageUrl } from 'educoder'; -import { Form , Input , Button , Radio , Icon } from 'antd'; +import React, { Component } from "react"; +import { getImageUrl } from "educoder"; +import { Form, Input, Button, Radio, Icon } from "antd"; +import { Link } from "react-router-dom"; +import "./index.css"; -import './index.css'; - -import axios from 'axios'; +import axios from "axios"; const TextArea = Input.TextArea; -class UserSubmitComponent extends Component{ - constructor(props){ +class UserSubmitComponent extends Component { + constructor(props) { super(props); - this.state={ - submitType:"0" - } + this.state = { + submitType: "0" + }; } - changeSubmittype=(e)=>{ + changeSubmittype = (e) => { this.setState({ - submitType:e.target.value - }) - } + submitType: e.target.value, + }); + }; // 提交变更 - subMitFrom=()=>{ - const { filepath , content } = this.props; - const { branch , projectsId } = this.props.match.params; + subMitFrom = () => { + const { filepath, content } = this.props; + const { branch, projectsId } = this.props.match.params; const { submitType } = this.state; let path = filepath.substr(1); this.props.form.validateFieldsAndScroll((err, values) => { - if(!err){ + if (!err) { const url = `/repositories/${projectsId}/create_file.json`; - axios.post(url,{ - filepath:path, - branch:branch, - new_branch:submitType==="1" ? values.branchname:undefined, - content, - message:values.desc - }).then((result)=>{ - if(result && result.data.name){ - const url = values.branchname ? `/projects/${projectsId}/coders?branch=${values.branchname}` : `/projects/${projectsId}/coders`; - this.props.history.push(url); + axios + .post(url, { + filepath: path, + branch: branch, + new_branch: submitType === "1" ? values.branchname : undefined, + content, + message: values.desc, + }) + .then((result) => { + if (result && result.data.name) { + const url = values.branchname + ? `/projects/${projectsId}/coders?branch=${values.branchname}` + : `/projects/${projectsId}/coders`; + this.props.history.push(url); + } + }) + .catch((error) => { + console.log(error); + }); + } + }); + }; + + + // 确认修改文件 + UpdateFile=()=>{ + const { branch , detail,content,filepath}= this.props; + const { projectsId } = this.props.match.params; + const { submitType } = this.state; + const url =`/repositories/${projectsId}/update_file.json`; + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + axios.put(url,{ + filepath:detail.path, + branch: branch, + new_branch: submitType === "1" ? values.branchname : undefined, + content:content, + sha:detail.sha, + }).then(result=>{ + if(result){ + const url = `/projects/${projectsId}/coders?url=${detail.path.split("/")[0]}`; + this.props.history.push(url); + this.props.showNotification("修改成功!"); + } }).catch(error=>{ console.log(error); }) } }) + } - render(){ + + render() { const { submitType } = this.state; const { getFieldDecorator } = this.props.form; - const { branch , projectsId } = this.props.match.params; + const { branch, projectsId } = this.props.match.params; - const { current_user , filepath , projectDetail } = this.props; + const { current_user, filepath, projectDetail } = this.props; + const {editor_type} = this.props - const changeSubmitBranch = ()=>{ - if(submitType==="1"){ - return( + const changeSubmitBranch = () => { + if (submitType === "1") { + return (
- - {getFieldDecorator('branchname', { - rules: [{ - required: true, message: '请输入分支名称' - }], + + {getFieldDecorator("branchname", { + rules: [ + { + required: true, + message: "请输入分支名称", + }, + ], })( - + )}
- ) + ); } - } - return( + }; + return (
- - - 用户名:{current_user && current_user.username} + + + + + {current_user && current_user.username}: + + + + 提交变更
- - {getFieldDecorator('path', { + + {getFieldDecorator("path", { rules: [], })( - + )} - {getFieldDecorator('desc', { - rules: [{ - required:true,message:'请输入合并请求的描述内容' - }], + {getFieldDecorator("desc", { + rules: [ + { + required: true, + message: "请输入合并请求的描述内容", + }, + ], })( -