diff --git a/src/forge/Activity/ActivityItem.js b/src/forge/Activity/ActivityItem.js index b8fe7ed4..90e5e83d 100644 --- a/src/forge/Activity/ActivityItem.js +++ b/src/forge/Activity/ActivityItem.js @@ -32,7 +32,7 @@ class ActivityItem extends Component{

} - + {item.user_name} diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 453d55e5..9452eaba 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -122,7 +122,7 @@ class CoderRootCommit extends Component{ {/* 浏览代码 */}

- + {item.image_url?:""} diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index a67b0689..e5b61931 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -376,7 +376,7 @@ class CoderRootDirectory extends Component { {lastCommitAuthor.login ? ( forked from - {projectDetail.fork_info.fork_project_user_name} + {projectDetail.fork_info.fork_project_user_name} / {projectDetail.fork_info.fork_form_name} : "" @@ -338,7 +338,7 @@ class Detail extends Component {

{projectDetail && projectDetail.author && - + {projectDetail.author.name} } diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index 8414c7df..0b38a718 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -19,7 +19,7 @@ class IndexItem extends Component { projects && projects.length > 0 ? projects.map((item, key) => { return (

- +
diff --git a/src/forge/Merge/MergeItem.js b/src/forge/Merge/MergeItem.js index 74f2b1e5..dd9eb809 100644 --- a/src/forge/Merge/MergeItem.js +++ b/src/forge/Merge/MergeItem.js @@ -90,7 +90,7 @@ class MergeItem extends Component {
  • {item.assign_user_name ? ( {item.assign_user_name} diff --git a/src/forge/Merge/MergeSubmit.js b/src/forge/Merge/MergeSubmit.js index 9da32477..76f16c38 100644 --- a/src/forge/Merge/MergeSubmit.js +++ b/src/forge/Merge/MergeSubmit.js @@ -92,7 +92,7 @@ class MergeSubmit extends Component{ width:"10%", render: (text,item) => ( - + diff --git a/src/forge/Merge/MessageCount.js b/src/forge/Merge/MessageCount.js index 9864a7ef..4b0e335a 100644 --- a/src/forge/Merge/MessageCount.js +++ b/src/forge/Merge/MessageCount.js @@ -1,16 +1,27 @@ -import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; +import React, { Component } from "react"; +import { Link } from "react-router-dom"; -import axios from 'axios'; -import UploadComponent from '../Upload/Index'; -import { getImageUrl } from 'educoder'; -import { Modal, Form, Input, Tooltip, Popconfirm, Pagination, Spin, Dropdown, Icon, Menu, Select } from 'antd' -import Attachments from '../Upload/attachment' -import './merge.css'; -import MergeSubmit from './MergeSubmit'; -import AmplifyImg from '../Order/AmplifyImg'; -import MDEditor from '../../modules/tpm/challengesnew/tpm-md-editor'; -import RenderHtml from '../../components/render-html'; +import axios from "axios"; +import { getImageUrl } from "educoder"; +import { + Form, + Input, + Pagination, + Spin, + Dropdown, + Icon, + Menu, + Select, + Tag, +} from "antd"; +import Attachments from "../Upload/attachment"; +import "./merge.css"; +import MergeSubmit from "./MergeSubmit"; +import AmplifyImg from "../Order/AmplifyImg"; +// import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor"; +import RenderHtml from "../../components/render-html"; +import Comments from "../comments/comments"; +import "../Order/order.css"; const Option = Select.Option; const TextArea = Input.TextArea; @@ -21,12 +32,12 @@ class MessageCount extends Component { this.state = { data: undefined, isShow: false, - imgsrc: '', + imgsrc: "", journalsdata: undefined, //图片区域是否显示 none 隐藏 block 显示 - display: 'none', - titledisplay: 'none', - countvalue: '', + display: "none", + titledisplay: "none", + countvalue: "", //是否需要编辑 isedit: undefined, fileList: undefined, @@ -35,12 +46,12 @@ class MessageCount extends Component { search_count: undefined, isSpin: false, showFiles: true, - ismesrge: 'none', - buttonshow: 'none', - mergename: '合并请求', - mergekey: 'merge', - title: '', - body: '', + ismesrge: "none", + buttonshow: "none", + mergename: "合并请求", + mergekey: "merge", + title: "", + body: "", commentsContent: undefined, quillFlag: false, SpinFlag: true, @@ -53,305 +64,334 @@ class MessageCount extends Component { visible: false, SpinMerge: false, journal_spin: false, - edit_spin: false - } + edit_spin: false, + }; } componentDidMount = () => { const url = this.props.history.location.pathname; if (url.indexOf("updatemerge") > -1) { this.setState({ - editMerge: true - }) + editMerge: true, + }); } this.setState({ - SpinFlag: true - }) + SpinFlag: true, + }); this.getDetail(); - } + }; getDetail = () => { const { projectsId, mergeId } = this.props.match.params; const url = `/projects/${projectsId}/pull_requests/${mergeId}.json`; - axios.get(url).then((result) => { - if (result) { + axios + .get(url) + .then((result) => { + if (result) { + this.setState({ + data: result.data, + SpinFlag: false, + }); + // this.getjournalslist(); + } + }) + .catch((error) => { this.setState({ - data: result.data - }) - this.getjournalslist(); - } - }).catch((error) => { - console.log(error); - }) - } + SpinFlag: false, + }); + console.log(error); + }); + }; handleok = () => { this.setState({ - isShow: false + isShow: false, }); }; handleCancel = () => { this.setState({ - isShow: false - }); - } - - imgshow = () => { - this.setState({ - isShow: true + isShow: false, }); }; - //添加评论 - addjournals = () => { - const { data, page, limit, fileList, commentsContent } = this.state; + imgshow = () => { this.setState({ - journal_spin: true - }) - if (!commentsContent) { - this.setState({ - quillFlag: true - }) - return; - } - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - const url = `/issues/${data.issue.id}/journals.json`; - axios.post(url, { - ...values, - content: commentsContent, - issue_id: data.id, - attachment_ids: fileList - }).then(result => { - if (result) { - this.props.form.setFieldsValue({ - content: "", - attachments_ids: undefined - }); - this.setState({ - showFiles: false, - quillFlag: false, - commentsContent: '', - journal_spin: false - }) - this.getjournalslist(page, limit); - this.props.showNotification("评论成功!"); - } - }).catch(error => { - this.setState({ - journal_spin: false - }) - console.log(error); - }) - }else{ - this.setState({ - journal_spin: false - }) - } - }) - } - //获取评论信息 - getjournalslist = (page, limit) => { - const { data } = this.state; - const url = `/issues/${data.issue.id}/journals.json`; - let id = data.id; - axios.get(url, { - params: { - id, page, limit - } - }).then(result => { - if (result) { - this.setState({ - journalsdata: result.data, - search_count: result.data.journals_count, - isSpin: false, - fileList: undefined, - showFiles: true, - SpinFlag: false - }) - } - }).catch(error => { - console.log(error); - }) - } + isShow: true, + }); + }; + //添加评论 + // addjournals = () => { + // const { data, page, limit, fileList, commentsContent } = this.state; + // this.setState({ + // journal_spin: true, + // }); + // if (!commentsContent) { + // this.setState({ + // quillFlag: true, + // }); + // return; + // } + // this.props.form.validateFieldsAndScroll((err, values) => { + // if (!err) { + // const url = `/issues/${data.issue.id}/journals.json`; + // axios + // .post(url, { + // ...values, + // content: commentsContent, + // issue_id: data.id, + // attachment_ids: fileList, + // }) + // .then((result) => { + // if (result) { + // this.props.form.setFieldsValue({ + // content: "", + // attachments_ids: undefined, + // }); + // this.setState({ + // showFiles: false, + // quillFlag: false, + // commentsContent: "", + // journal_spin: false, + // }); + // this.getjournalslist(page, limit); + // this.props.showNotification("评论成功!"); + // } + // }) + // .catch((error) => { + // this.setState({ + // journal_spin: false, + // }); + // console.log(error); + // }); + // } else { + // this.setState({ + // journal_spin: false, + // }); + // } + // }); + // }; + // //获取评论信息 + // getjournalslist = (page, limit) => { + // const { data } = this.state; + // const url = `/issues/${data.issue.id}/journals.json`; + // let id = data.id; + // axios + // .get(url, { + // params: { + // id, + // page, + // limit, + // }, + // }) + // .then((result) => { + // if (result) { + // this.setState({ + // journalsdata: result.data, + // search_count: result.data.journals_count, + // isSpin: false, + // fileList: undefined, + // showFiles: true, + // SpinFlag: false, + // }); + // } + // }) + // .catch((error) => { + // console.log(error); + // }); + // }; //关闭任务 closedetail = (id) => { const { projectsId, orderId } = this.props.match.params; const { data } = this.state; const url = `/projects/${projectsId}/issues/${data.issue.id}/close_issue.json`; - axios.post(url, { - project_id: projectsId, - id: orderId, - status_id: id, - }).then(result => { - if (result) { - this.getDetail(); - } - }).catch(error => { - console.log(error); - }) - } + axios + .post(url, { + project_id: projectsId, + id: orderId, + status_id: id, + }) + .then((result) => { + if (result) { + this.getDetail(); + } + }) + .catch((error) => { + console.log(error); + }); + }; //合并请求 prmerge = () => { this.setState({ - SpinMerge: true - }) + SpinMerge: true, + }); const { projectsId } = this.props.match.params; const { data, title, body, mergekey } = this.state; const url = `/projects/${projectsId}/pull_requests/${data.pull_request.id}/pr_merge.json`; - axios.post(url, { - project_id: projectsId, - id: data.pull_request.id, - do: mergekey, - body: body, - title: title, - }).then(result => { - if (result) { - this.getDetail(); - this.setState({ - SpinMerge: false - }) - } - }).catch(error => { - this.setState({ - SpinMerge: false + axios + .post(url, { + project_id: projectsId, + id: data.pull_request.id, + do: mergekey, + body: body, + title: title, }) - console.log(error); - }) - } + .then((result) => { + if (result) { + this.getDetail(); + this.setState({ + SpinMerge: false, + }); + } + }) + .catch((error) => { + this.setState({ + SpinMerge: false, + }); + console.log(error); + }); + }; //修改评论 - updatedetail = (id) => { - this.setState({ - edit_spin: true - }) - const { page, limit, data } = this.state; - const { orderId } = this.props.match.params; - const url = `/issues/${data.issue.id}/journals/${id}.json`; - axios.put(url, { - issue_id: orderId, - id: id, - content: this.state.countvalue - }).then(result => { - if (result) { - this.setState({ - isedit: undefined, - edit_spin: false - }) - this.getjournalslist(page, limit); - } - }).catch(error => { - this.setState({ - edit_spin: false - }) - console.log(error); - }) - } + // updatedetail = (id) => { + // this.setState({ + // edit_spin: true, + // }); + // const { page, limit, data } = this.state; + // const { orderId } = this.props.match.params; + // const url = `/issues/${data.issue.id}/journals/${id}.json`; + // axios + // .put(url, { + // issue_id: orderId, + // id: id, + // content: this.state.countvalue, + // }) + // .then((result) => { + // if (result) { + // this.setState({ + // isedit: undefined, + // edit_spin: false, + // }); + // this.getjournalslist(page, limit); + // } + // }) + // .catch((error) => { + // this.setState({ + // edit_spin: false, + // }); + // console.log(error); + // }); + // }; // 获取上传后的文件id数组 UploadFunc = (fileList) => { this.setState({ - fileList - }) - } + fileList, + }); + }; //删除评论 - deleteorder = (id) => { - const { orderId } = this.props.match.params; - const { page, limit, data } = this.state; - const url = `/issues/${data.issue.id}/journals/${id}.json`; - axios.delete(url, { - data: { - issue_id: orderId, - id: id - } - }).then((result) => { - if (result) { - this.getjournalslist(page, limit) - } - }).catch((error) => { - console.log(error); - }) - } + // deleteorder = (id) => { + // const { orderId } = this.props.match.params; + // const { page, limit, data } = this.state; + // const url = `/issues/${data.issue.id}/journals/${id}.json`; + // axios + // .delete(url, { + // data: { + // issue_id: orderId, + // id: id, + // }, + // }) + // .then((result) => { + // if (result) { + // this.getjournalslist(page, limit); + // } + // }) + // .catch((error) => { + // console.log(error); + // }); + // }; changmodelname = (value) => { this.setState({ - countvalue: value - }) - } + countvalue: value, + }); + }; changtitlepr = (e) => { this.setState({ - title: e.target.value - }) - } + title: e.target.value, + }); + }; changbodypr = (e) => { this.setState({ - body: e.target.value - }) - } + body: e.target.value, + }); + }; editdetail = (count, status) => { this.setState({ countvalue: count, - isedit: status - }) - } + isedit: status, + }); + }; submitmerge = () => { if (this.state.mergekey === "rebase") { this.setState({ - buttonshow: 'block', - ismesrge: 'none' - }) + buttonshow: "block", + ismesrge: "none", + }); } else { this.setState({ - ismesrge: 'block', - buttonshow: 'block' - }) + ismesrge: "block", + buttonshow: "block", + }); } - - } - + }; nonemerge = () => { this.setState({ - ismesrge: 'none', - buttonshow: 'none' - }) - } + ismesrge: "none", + buttonshow: "none", + }); + }; renderJournalList = (list) => { if (list && list.length > 0) { - return ( - list.map((item, key) => { - return ( -
    - - {item.detail}: - - - {item.old_value && item.old_value.length > 0 ? "更新为" : "新增"} - - - {item.value && item.value.length > 0 ? - item.detail === "标签" ? {item.value[0].name} : item.value - : - "无" - } - -
    - ) - }) - ) + return list.map((item, key) => { + return ( +
    + {item.detail}: + + {item.old_value && item.old_value.length > 0 ? "更新为" : "新增"} + + + {item.value && item.value.length > 0 ? ( + item.detail === "标签" ? ( + + {item.value[0].name} + + ) : ( + item.value + ) + ) : ( + "无" + )} + +
    + ); + }); } else { return (
    没有评论~
    - ) + ); } - } + }; handleSubmit = () => { this.props.form.validateFieldsAndScroll((err, values) => { @@ -359,456 +399,573 @@ class MessageCount extends Component { const { projectsId, mergeId } = this.props.match.params; const url = `/projects/${projectsId}/pull_requests/${mergeId}/simple_update.json`; - if (values.issue_tag_ids === '') { - values.issue_tag_ids = [] + if (values.issue_tag_ids === "") { + values.issue_tag_ids = []; } else { - values.issue_tag_ids = [parseInt(values.issue_tag_ids)] + values.issue_tag_ids = [parseInt(values.issue_tag_ids)]; } if (values.assigned_to_id === 0) { - values.assigned_to_id = "" + values.assigned_to_id = ""; } - axios.post(url, { - ...values - }).then(result => { - if (result.data.status === 0) { - this.setState({ - editMerge: false - }) - this.getDetail() - this.props.showNotification(result.data.message); - - } - - }).catch(error => { - console.log(error); - }) - + axios + .post(url, { + ...values, + }) + .then((result) => { + if (result.data.status === 0) { + this.setState({ + editMerge: false, + }); + this.getDetail(); + this.props.showNotification(result.data.message); + } + }) + .catch((error) => { + console.log(error); + }); } - }) - } + }); + }; renderSelect = (list) => { if (list && list.length > 0) { - return ( - list.map((item, key) => { - return ( - - ) - }) - ) + return list.map((item, key) => { + return ( + + ); + }); } - } - + }; // 翻页 - ChangePage = (page) => { - this.setState({ - page, - isSpin: true - }) - const { limit } = this.state; - this.getjournalslist(page, limit); - } + // ChangePage = (page) => { + // this.setState({ + // page, + // isSpin: true, + // }); + // const { limit } = this.state; + // this.getjournalslist(page, limit); + // }; getOption = (e) => { if (e.key === "rebase") { this.setState({ mergename: e.item.props.value, mergekey: e.key, - title: '', - body: '', - buttonshow: 'block' - }) + title: "", + body: "", + buttonshow: "block", + }); } else { this.setState({ mergename: e.item.props.value, mergekey: e.key, - title: '', - body: '', - ismesrge: 'block', - buttonshow: 'block' - }) + title: "", + body: "", + ismesrge: "block", + buttonshow: "block", + }); } - - } + }; changeComments = (value) => { this.setState({ - commentsContent: value - }) + commentsContent: value, + }); if (value) { this.setState({ - quillFlag: false - }) + quillFlag: false, + }); } - } + }; cancelSubmit = () => { this.setState({ - editMerge: false - }) - } + editMerge: false, + }); + }; change_to_edit = () => { const { projectsId, mergeId } = this.props.match.params; const url = `/projects/${projectsId}/pull_requests/${mergeId}/edit.json`; - axios.get(url).then((result) => { - if (result) { - this.setState({ - issue_chosen: result.data.issue.issue_chosen, - issue_tag_ids: result.data.issue.issue_tags && result.data.issue.issue_tags[0].id, - fixed_version_id: result.data.issue.fixed_version_id, - assigned_to_id: result.data.issue.assigned_to_id, - editMerge: true - }) - } - }).catch((error) => { - console.log(error); - }) - } - + axios + .get(url) + .then((result) => { + if (result) { + this.setState({ + issue_chosen: result.data.issue.issue_chosen, + issue_tag_ids: + result.data.issue.issue_tags && + result.data.issue.issue_tags[0].id, + fixed_version_id: result.data.issue.fixed_version_id, + assigned_to_id: result.data.issue.assigned_to_id, + editMerge: true, + }); + } + }) + .catch((error) => { + console.log(error); + }); + }; commentCtx = (v) => { - return ( - - ) + return ; }; handleShowImage = (value) => { this.setState({ imageUrl: value, - visible: true - }) - } + visible: true, + }); + }; setVisible = (flag) => { this.setState({ - visible: flag - }) - } + visible: flag, + }); + }; render() { const { projectsId, mergeId } = this.props.match.params; - const { data, journalsdata, page, limit, search_count, isSpin, isedit, showFiles, commentsContent, quillFlag, editMerge, issue_tag_ids, issue_chosen, fixed_version_id, assigned_to_id, visible, imageUrl, SpinMerge, journal_spin, edit_spin } = this.state; + const { + data, + journalsdata, + page, + limit, + search_count, + isSpin, + isedit, + showFiles, + commentsContent, + quillFlag, + editMerge, + issue_tag_ids, + issue_chosen, + fixed_version_id, + assigned_to_id, + visible, + imageUrl, + SpinMerge, + journal_spin, + edit_spin, + } = this.state; const { getFieldDecorator } = this.props.form; const { current_user } = this.props; const url = this.props.history.location.pathname; + const get_color = (type) => { + if (type === 0) { + return "#21ba45"; + } else if (type === 1) { + return "#a333c8"; + } else { + return "#e60b0b"; + } + }; const editMergeForm = () => { return (
    - - {getFieldDecorator('issue_tag_ids', { - initialValue: issue_tag_ids ? [issue_tag_ids] : '', + + {getFieldDecorator("issue_tag_ids", { + initialValue: issue_tag_ids ? [issue_tag_ids] : "", rules: [], })( )} - - {getFieldDecorator('fixed_version_id', { + + {getFieldDecorator("fixed_version_id", { initialValue: fixed_version_id ? fixed_version_id : "", rules: [], })( )} - - {getFieldDecorator('assigned_to_id', { + + {getFieldDecorator("assigned_to_id", { initialValue: assigned_to_id ? assigned_to_id : "", })( )}

    - 保存 - 取消 + + 保存 + + + 取消 +

    - ) - } - + ); + }; const menu = ( this.getOption(e)}> - 合并请求 - 变基并合并 - 变基合并 --no-ff - 压缩提交并合并 + + 合并请求 + + + 变基并合并 + + + 变基合并 --no-ff + + + 压缩提交并合并 + - ) + ); const Paginations = ( - { - search_count > limit ? -
    - -
    : "" - } -
    - ) - const renderList = () => { - if (journalsdata && journalsdata.issue_journals && journalsdata.issue_journals.length > 0) { - return ( -
    { - journalsdata.issue_journals.map((item, key) => { - return ( -
  • -
    - - - -
    -
    -

    - {item.user_name} - 评论于 - - {item.created_at} - -

    -
    - this.editdetail(item.content, item.id)} className="detail_edit_action">编辑 - this.deleteorder(item.id)}> - 删除 - -
    -
    -
    -
    - { - item.content ? - this.commentCtx(item.content) - : -
    - {this.renderJournalList(item.journal_details)} -
    - } - { - item && item.attachments.length > 0 ? - - : - "" - } -
    - -
    -
    -
    - -
    -
    -
    -
    -
  • - ) - }) - } + {search_count > limit ? ( +
    +
    - ) - } - } + ) : ( + "" + )} + + ); return ( -
    - {visible && } -
    -
    - { - data && -

    - 【{data.issue && (data.issue.issue_classify === 'issue' ? data.issue.tracker : "合并")}】 - {data.issue && data.issue.subject} -

    - } -

    - {data && data.issue.issue_status === "关闭" ? "关闭中" : data && data.pull_request.status === 0 ? "开启中" : "已合并"} - - 由 {data && data.issue.author_name} 于 {data && data.issue.created_at}创建{data && data.issue.journals_count && data.issue.journals_count > 0 ? ` · ${data.issue.journals_count} 条评论` : ""} - +

    + {visible && ( + + )} +
    +
    +
    + + + +
    +
    + + 【合并请求 】 + + {data && data.issue.subject} + + - - 请求从 {data && data.pull_request.head} 分支合并到 {data && data.pull_request.base} 分支 - - - { - data && data.issue.user_permission ? - 编辑 - : '' - } - -

    - { - data && data.attachments.length > 0 ? -
    - + {data && data.pull_request && ( + + {data.pull_request.status === 0 + ? "开启中" + : (data.pull_request.status === 1 + ? "已合并" + : "已拒绝")} + + )} +
    +
    + + + {data && data.issue.author_name} + + + 添加于 {data && data.issue.created_at} + + + 请求从 {data && data.pull_request.head} + 分支合并到 + {data && data.pull_request.base} + 分支 + + {data && data.issue.user_permission ? ( + + + this.closedetail( + data && data.issue.issue_status === "关闭" ? 2 : 5 + ) + } + > + {data && data.issue.issue_status === "关闭" + ? "点击开启" + : "关闭"} + + + 编辑 + + + ) : ( + "" + )}
    - : - "" - } - -
    -
    -
      -
    • 0 ? "active" : ""}>对话内容
    • -
    • 0 ? "active" : ""}>代码提交
    • -
    - {data && data.issue.user_permission && - - }
    + {data && data.attachments.length > 0 ? ( +
    + +
    + ) : ( + "" + )} +
    +
    +
      +
    • 0 ? "active" : ""} + > + + 对话内容 + +
    • +
    • 0 ? "active" : ""} + > + + 代码提交 + +
    • +
    +
    +
    - { - (url.indexOf("Messagecount") > 0 || url.indexOf("updatemerge") > 0) ? - -
    -
    - { - data && data.issue.user_permission ? -
    -
    - - - -
    - { - data && data.issue.issue_status !== "关闭" && -
    -

    该合并请求可以进行自动合并操作

    -

    - - }> - {this.state.mergename} - -

    -
    - } -
    - -