- {journals && (journals.length > 0 && journals.map(item=>{return item.is_journal_detail ? (!item.closeAndSpan || item.id === item.start || open === item.start) ?
+ {journals && (journals.length > 0 &&
+ journals.map(item=>{return item.is_journal_detail ? (!item.closeAndSpan || item.id === item.start || open === item.start) ?
+
{/* 操作日志 */}
diff --git a/src/forge/Issues/Component/date.jsx b/src/forge/Issues/Component/date.jsx
index bd4f00a9..f8e8aa30 100644
--- a/src/forge/Issues/Component/date.jsx
+++ b/src/forge/Issues/Component/date.jsx
@@ -136,7 +136,7 @@ function Date({name , today , setDate , editFlag},ref){
visible={visible}
trigger={['click']}
>
-
+
{name}
{!editFlag && setVisible(visible ? false : true)}> }
diff --git a/src/forge/Issues/Component/dropMenu.jsx b/src/forge/Issues/Component/dropMenu.jsx
index 962243c0..04d19c33 100644
--- a/src/forge/Issues/Component/dropMenu.jsx
+++ b/src/forge/Issues/Component/dropMenu.jsx
@@ -40,6 +40,7 @@ function DropMenu({
const refFa = useRef(null);
const refBox = useRef(null);
+
// 根据选中的列表循环出id数组
useEffect(()=>{
if(selectValueList && selectValueList.length > 0 ){
@@ -80,7 +81,7 @@ function DropMenu({
}
function chooseMenu(i){
- let list = selectValueList;
+ let list = selectValueList||[];
let re = [];
re = list && list.length > 0 ? list:[];
let filter = [];
@@ -153,7 +154,7 @@ function DropMenu({
}
return(
-
+
{placeholder}
{!editFlag &&
diff --git a/src/forge/Issues/Component/menus.jsx b/src/forge/Issues/Component/menus.jsx
index b5c13120..885a413b 100644
--- a/src/forge/Issues/Component/menus.jsx
+++ b/src/forge/Issues/Component/menus.jsx
@@ -62,7 +62,7 @@ function Menus({className,name, ids , lists , size , imgControl , searchFunc , c
function menu(data){
return
{ size !== "small" &&
-
searchFunc(e.target.value)}/>
+
searchFunc(e.target.value)}/>
}
{
data && data.length>0 ?
@@ -86,7 +86,7 @@ function Menus({className,name, ids , lists , size , imgControl , searchFunc , c
{showValue || (update ? `更换${name}` : name) }
-
+
)
diff --git a/src/forge/Issues/index.scss b/src/forge/Issues/index.scss
index a1f4c7b8..ff5770f4 100644
--- a/src/forge/Issues/index.scss
+++ b/src/forge/Issues/index.scss
@@ -448,69 +448,69 @@
.shortwidth{
width: 330px;
padding-left: 50px;
- &>li{
- border-bottom: 1px solid rgba(172, 176, 191, 0.17);
- padding-bottom: 8px;
- margin-bottom: 22px!important;
- &>span{
- font-size: 15px;
- position: relative;
- color: #40424a;
- display: flex;
- width: 100%;
+}
+li.dropliComponent{
+ border-bottom: 1px solid rgba(172, 176, 191, 0.17);
+ padding-bottom: 8px;
+ margin-bottom: 22px!important;
+ &>span{
+ font-size: 15px;
+ position: relative;
+ color: #40424a;
+ display: flex;
+ width: 100%;
+ height: 20px;
+ line-height: 20px;
+ font-weight: 600;
+ a{
+ position: absolute;
+ right: 0px;
+ }
+ }
+ .operatevalue{
+ line-height: 30px;
+ color: #acb0bf;
+ margin-top: 10px;
+ display: flex;
+ flex-wrap: wrap;
+ .colorsborder{
+ padding: 0px 8px;
+ height: 20px;
+ line-height: 18px;
+ border-radius: 4px;
+ text-align: center;
+ border:1px solid ;
+ font-size: 13px;
+ }
+ .colorsquare{
+ padding: 0px 8px;
height: 20px;
line-height: 20px;
- font-weight: 600;
- a{
- position: absolute;
- right: 0px;
+ border-radius: 4px;
+ text-align: center;
+ color: #fff;
+ font-size: 13px;
+ }
+ &>p{
+ margin-top: 5px!important;
+ position: relative;
+ padding-right: 15px;
+ &.removeFlag>span{
+ max-width: 230px;
+ }
+ .removeicon{
+ display: none;
}
}
- .operatevalue{
- line-height: 30px;
- color: #acb0bf;
- margin-top: 10px;
- display: flex;
- flex-wrap: wrap;
- .colorsborder{
- padding: 0px 8px;
- height: 20px;
- line-height: 18px;
- border-radius: 4px;
- text-align: center;
- border:1px solid ;
- font-size: 13px;
- }
- .colorsquare{
- padding: 0px 8px;
- height: 20px;
- line-height: 20px;
- border-radius: 4px;
- text-align: center;
- color: #fff;
- font-size: 13px;
- }
- &>p{
- margin-top: 5px!important;
- position: relative;
- padding-right: 15px;
- &.removeFlag>span{
- max-width: 230px;
- }
- .removeicon{
- display: none;
- }
- }
- .removeFlag:hover{
- border-radius:2px;
- .removeicon{
- display: block;
- }
- }
- &>p:first-child{
- margin-top: 0px;
+ .removeFlag:hover{
+ border-radius:2px;
+ .removeicon{
+ display: block;
}
}
+ &>p:first-child{
+ margin-top: 0px;
+ }
}
}
.addTags_form{
diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js
index 1c29f584..8d7b5f66 100644
--- a/src/forge/Main/Detail.js
+++ b/src/forge/Main/Detail.js
@@ -931,6 +931,11 @@ class Detail extends Component {
(props) => (
)
}
>
+
()
+ }
+ >
()
diff --git a/src/forge/Merge/MergeLinkFooter.jsx b/src/forge/Merge/MergeLinkFooter.jsx
index 8a8271d8..9a3e6490 100644
--- a/src/forge/Merge/MergeLinkFooter.jsx
+++ b/src/forge/Merge/MergeLinkFooter.jsx
@@ -6,6 +6,7 @@ import axios from 'axios';
import Commits from './Commits';
import Comments from '../comments/comments';
import Files from './Files';
+import OperateDate from './components/operateDate';
import '../Order/order.scss';
import './merge.css';
@@ -72,6 +73,8 @@ class MergeFooter extends Component {
} else if (pathname.indexOf('files') > -1) {
activeKey = '3';
this.getFile(owner, projectsId, mergeId);
+ }else if (pathname.indexOf('date') > -1) {
+ activeKey = '4';
}
if (isTabChange && activeKey === '1') {
this.refreshComment();
@@ -235,6 +238,15 @@ class MergeFooter extends Component {
)}
+
+ 操作日志
+
+ }
+ key="4">
+
+
diff --git a/src/forge/Merge/MessageCount.js b/src/forge/Merge/MessageCount.js
index a44ea8f7..5488cff2 100644
--- a/src/forge/Merge/MessageCount.js
+++ b/src/forge/Merge/MessageCount.js
@@ -546,7 +546,6 @@ class MessageCount extends Component {
onClick={this.codeReview}
>
代码评审
-
)}
{cancelOperate && (
diff --git a/src/forge/Merge/components/operateDate.jsx b/src/forge/Merge/components/operateDate.jsx
new file mode 100644
index 00000000..fa7e2625
--- /dev/null
+++ b/src/forge/Merge/components/operateDate.jsx
@@ -0,0 +1,69 @@
+import React , { useState ,useEffect} from 'react';
+import axios from 'axios';
+import { Link } from 'react-router-dom';
+import { getImageUrl , timeAgo } from 'educoder';
+import "../../Issues/Component/comments/list.scss";
+
+function OperateDate(props){
+ // 一个合并请求就是一个issue,order_id是pull详情接口中返回的issue的详情
+ const { order_id , match } = props;
+ const { mergeId, owner , projectsId } = match.params;
+ const [journals , setJournals ] =useState([])
+ const journalsIcon ={
+ 'issue': 'icon-chuangjianqianbao',
+ 'branch_name': 'icon-fenzhi3',
+ 'assigner': 'icon-chengyuan2',
+ 'status_id': 'icon-xiugaibaobiaomoban',
+ 'fixed_version_id': 'icon-lichengbeiicon2',
+ 'due_date': 'icon-riqi',
+ 'issue_tag': 'icon-biaoji2',
+ 'description': 'icon-xiugaibaobiaomoban',
+ 'subject': 'icon-xiugaibaobiaomoban',
+ 'start_date': 'icon-riqi',
+ 'priority_id': 'icon-youxian',
+ 'attachment': 'icon-xiugaibaobiaomoban'
+ }
+
+ useEffect(()=>{
+ if(order_id && mergeId){
+ getDate();
+ }
+ },[order_id,mergeId])
+
+ function getDate(){
+ const url = `/v1/${owner}/${projectsId}/issues/${order_id}/journals`;
+ axios.get(url,{
+ params:{
+ category:"operate",
+ page:1,
+ limit:50
+ }
+ }).then(response=>{
+ if(response){
+ setJournals(response.data.journals);
+ }
+ }).catch(error=>{})
+ }
+ return(
+
+ { journals.map(item=>{
+ return
+ {/* 操作日志 */}
+
+
+
+
+
+
})
+
{item.user.name}
+ {(item.user.name.length + item.operate_content.length) > 62 ?
{item.user.name} }>
:
}
+
+
{timeAgo(item.created_at)}
+
+
+
}
+ )}
+
+ )
+}
+export default OperateDate;
\ No newline at end of file
diff --git a/src/forge/Merge/merge.js b/src/forge/Merge/merge.js
index d8d83e15..f02456d0 100644
--- a/src/forge/Merge/merge.js
+++ b/src/forge/Merge/merge.js
@@ -1,4 +1,4 @@
-import React, { Component } from "react";
+import React, { useEffect, useState } from "react";
import { Input, Dropdown, Menu, Icon, Pagination, Spin } from "antd";
import "./merge.css";
import "../Order/order.scss";
@@ -7,6 +7,7 @@ import NoneData from "./no_data";
import MergeItem from "./MergeItem";
import './Index.scss';
import { turnbar } from "educoder";
+import Menus from '../Issues/Component/menus';
import axios from "axios";
import CheckProfile from '../Component/ProfileModal/Profile';
@@ -25,99 +26,63 @@ const { Search } = Input;
* search_count:列表总条数
* issue_type:搜索条件
*/
-class merge extends Component {
- constructor(props) {
- super(props);
- this.state = {
- issue_chosen: undefined,
- data: undefined,
- issues: undefined,
- isSpin: false,
- search: undefined,
- author_id: undefined,
- assigned_to_id: undefined,
- // limit: 15,
- // page: 1,
- search_count: undefined,
- issue_type: undefined,
- status_type: "1",
- //设置选择高亮
- openselect: 1,
- closeselect: undefined,
- issue_tag_ids: "标记",
- fixed_version_ids: "里程碑",
- assigned_to_ids: "审查人员",
- paix: "排序",
- priority_ids: "优先级",
- has_created_pull_requests:false,
- select_params: {
- status_type: "1", //开启中和关闭中,默认为开启中的
- assigned_to_id: undefined, // 指派人
- fixed_version_id: undefined,
- priority_id: undefined,
- order_name: undefined,
- order_type: undefined,
- search: undefined,
- page: 1,
- limit: 15,
- },
- disable_pr_vew:false //访问pr的权限
- };
- }
+function merge(props){
+ const [ tag , setTag ] = useState("");
+ const [ tagList , setTagList ] = useState([]);
+ const [ millstoneList , setMillstoneList ] = useState(undefined);
+ const [ millstone , setMillstone ] = useState(undefined);
+ const [ prioritiesList , setPrioritiesList ] = useState(undefined);
+ const [ chargeList , setChargeList ] = useState(undefined);
+ const [ charge , setCharge ] = useState(undefined);
+ const [ data , setData ] = useState(undefined)
+ const [ issues , setIssues ] = useState([])
+ const [ isSpin , setIsSpin ] = useState(false)
+ const [ search , setSearch ] = useState(undefined)
+ const limit = 15;
+ const [ page , setPage ] = useState(1)
+ const [ total , setTotal ] = useState(0)
+ const [ status_type , setStatus_type ] = useState("1")//1:开启,11:已合并,2:已拒绝
+ const [ order , setOrder ] = useState({order_name:undefined,order_type:undefined})
+ const [ assigned , setAssigned ] = useState({})
+ const [ priority , setPriority ] = useState({})
+ const [ fixed_version , setFixedVersion ] = useState({})
+ const [ issue_tag , setIssueTag ] = useState({})
- componentDidMount = () => {
- this.getSelectList();
- this.getIssueList();
- };
-
- componentDidUpdate(){
- this.updateDocumentTitle();
- }
+ const { projectsId , owner } = props.match.params;
+ const { project , projectDetail , defaultBranch } = props;
+ const open_blockchain = project && project.open_blockchain;
+ useEffect(()=>{
+ setPage(1);
+ getIssueList(search,1);
+ },[status_type,assigned,priority,fixed_version,issue_tag,order])
+
// 更新网页标题
- updateDocumentTitle(){
- const {projectDetail} = this.props;
+ useEffect(()=>{
if(projectDetail){
const { author, name} = projectDetail;
document.title = `合并请求-${author.name}/${name}`;
}
- }
+ },[projectDetail])
- getSelectList = () => {
- const { projectsId,owner } = this.props.match.params;
-
- const url = `/${owner}/${projectsId}/issues/index_chosen.json`;
- axios
- .get(url)
- .then((result) => {
- if (result) {
- this.setState({
- issue_chosen: result.data.issue_chosen,
- });
- }
- })
- .catch((error) => {
- console.log(error);
- });
- };
// 获取列表数据
- getIssueList = () => {
- const { select_params } = this.state;
- const { projectsId , owner } = this.props.match.params;
+ const getIssueList = (searchvalue,page) => {
const url = `/${owner}/${projectsId}/pulls.json`;
axios.get(url, {
- params: select_params,
+ params: {
+ limit,
+ page,
+ search:searchvalue,status_type,
+ order_name:order.order_name,order_type:order.order_type,
+ priority_id:priority.id,assigned_to_id:assigned.id,fixed_version_id:fixed_version.id,issue_tag_id:issue_tag.id
+ },
}).then((result) => {
if (result) {
- this.setState({
- data: result.data,
- issues: result.data.issues,
- search_count: result.data.search_count,
- isSpin: false,
- has_created_pull_requests:result.data.has_created_pull_requests,
- disable_pr_vew:result.data.disable_pr_vew
- });
+ setTotal(result.data.search_count);
+ setData(result.data);
+ setIssues(result.data.issues)
+ setIsSpin(false)
}
})
.catch((error) => {
@@ -125,335 +90,404 @@ class merge extends Component {
});
};
- getMenu = (e, id, name) => {
- this.setState({
- isSpin: true,
- });
- let key_name = e.key.split("-");
- if (key_name[0] === "created_on") {
- if (e.item.props.value === "desc") {
- this.setState({
- paix: "最新创建",
- });
- } else {
- this.setState({
- paix: "最早创建",
- });
- }
- this.state.select_params.order_name = e.key;
- } else if (key_name[0] === "updated_on") {
- if (e.item.props.value === "desc") {
- this.setState({
- paix: "最新更新",
- });
- } else {
- this.setState({
- paix: "最早更新",
- });
- }
- }
- this.state.select_params.order_name = key_name[0];
- this.state.select_params.order_type = e.item.props.value;
- this.state.select_params.page = 1;
- this.getIssueList();
- };
+ // getMenu = (e, id, name) => {
+ // this.setState({
+ // isSpin: true,
+ // });
+ // let key_name = e.key.split("-");
+ // if (key_name[0] === "created_on") {
+ // if (e.item.props.value === "desc") {
+ // this.setState({
+ // paix: "最新创建",
+ // });
+ // } else {
+ // this.setState({
+ // paix: "最早创建",
+ // });
+ // }
+ // this.state.select_params.order_name = e.key;
+ // } else if (key_name[0] === "updated_on") {
+ // if (e.item.props.value === "desc") {
+ // this.setState({
+ // paix: "最新更新",
+ // });
+ // } else {
+ // this.setState({
+ // paix: "最早更新",
+ // });
+ // }
+ // }
+ // this.state.select_params.order_name = key_name[0];
+ // this.state.select_params.order_type = e.item.props.value;
+ // this.state.select_params.page = 1;
+ // this.getIssueList();
+ // };
- getOption = (e, id, name) => {
- this.setState({
- isSpin: true,
- });
- let option_id = e.key === "all" ? undefined : e.key;
- this.setState({
- ["${id}s"]: name,
- });
- this.state.select_params[`${id}`] = option_id;
- this.state.select_params.page = 1;
- this.state[`${id}s`] = name;
- this.getIssueList();
- };
+ // getOption = (e, id, name) => {
+ // this.setState({
+ // isSpin: true,
+ // });
+ // let option_id = e.key === "all" ? undefined : e.key;
+ // this.setState({
+ // ["${id}s"]: name,
+ // });
+ // this.state.select_params[`${id}`] = option_id;
+ // this.state.select_params.page = 1;
+ // this.state[`${id}s`] = name;
+ // this.getIssueList();
+ // };
- renderMenu = (array, name, id) => {
- return (
-
- );
- };
+ // renderMenu = (array, name, id) => {
+ // return (
+ //
+ // );
+ // };
// 翻页
- ChangePage = (page) => {
- this.setState({
- isSpin: true,
- });
- this.state.select_params.page = page;
- this.getIssueList();
+ const ChangePage = (page) => {
+ setIsSpin(true);
+ setPage(page);
+ getIssueList(search,1);
};
// 搜索
- searchFunc = (value) => {
- this.setState({
- search: value,
- isSpin: true,
- });
- this.state.select_params.search = value;
- this.state.select_params.page = 1;
- this.getIssueList();
+ const searchFunc = (value) => {
+ setIsSpin(true);
+ setSearch(value);
+ setPage(1);
+ getIssueList(value,1);
};
- openorder = (type) => {
- this.setState({
- isSpin: true,
- });
- this.setState({
- status_type: type,
- issue_tag_ids: "标记",
- fixed_version_ids: "里程碑",
- assigned_to_ids: "审查人员",
- paix: "排序",
- priority_ids: "优先级",
- });
- this.state.select_params.status_type = type;
- this.state.select_params.page=1;
- this.state.select_params.limit=15;
-
- this.getIssueList();
+ const openorder = (type) => {
+ setIsSpin(true);
+ setStatus_type(type);
+ setPage(1);
+ clearFunc();
};
- checkOperation() {
- const { defaultBranch,projectDetail } = this.props;
- const { projectsId,owner } = this.props.match.params;
+ const clearFunc=()=>{
+ setAssigned({});
+ setPriority({});
+ setFixedVersion({});
+ setIssueTag({});
+ setOrder({});
+ }
+ function checkOperation() {
let branch = turnbar(defaultBranch) || "master";
if (projectDetail && projectDetail.fork_info) {
- this.props.history.push(`/${projectDetail.fork_info.fork_project_user_login}/${projectDetail.fork_info.fork_project_identifier}/compare/${branch}...${owner + '/' + projectsId +':' + branch}`)
+ props.history.push(`/${projectDetail.fork_info.fork_project_user_login}/${projectDetail.fork_info.fork_project_identifier}/compare/${branch}...${owner + '/' + projectsId +':' + branch}`)
} else {
- this.props.history.push(`/${owner}/${projectsId}/compare/${branch}...${branch}`);
+ props.history.push(`/${owner}/${projectsId}/compare/${branch}...${branch}`);
}
}
- render() {
- const { projectsId , owner } = this.props.match.params;
- const { project } = this.props;
- const open_blockchain = project && project.open_blockchain;
- const {
- issue_chosen,
- issues,
- limit,
- page,
- search_count,
- data,
- isSpin,
- status_type,
- select_params,has_created_pull_requests,disable_pr_vew
- } = this.state;
- const menu = (
-
- );
- return (
-
-
-
- {
- data && data.user_admin_or_developer &&
- this.checkOperation()}>
- + 新建合并请求
-
- }
-
-
-
-
- - this.openorder(undefined)}
- >
-
- {data && data.search_count}
-
- - this.openorder("1")}
- >
-
-
- {data && data.open_count}
-
- - this.openorder("11")}
- >
-
-
- {data && data.merged_issues_size}
-
- - this.openorder("2")}
- >
-
-
- {data && data.close_count}
-
-
-
-
- { open_blockchain && - 关联疑修
}
- -
-
-
- {this.state.priority_ids}
-
-
-
-
- -
-
-
- {this.state.issue_tag_ids}
-
-
-
-
- -
-
-
- {this.state.assigned_to_ids}
-
-
-
-
+
+ // 获取标记列表
+ useEffect(()=>{
+ getSign();
+ },[tag])
- -
-
-
- {this.state.fixed_version_ids}
-
-
-
-
+ function getSign(){
+ const url = `/v1/${owner}/${projectsId}/issue_tags`;
+ axios.get(url,{params:{keyword:tag,only_name:true}}).then(result=>{
+ if(result && result.data){
+ let list = [{id:-1,name:"无标记"}];
+ list = [...list,...result.data.issue_tags];
+ setTagList(list);
+ }
+ })
+ }
+ // 获取里程碑列表
+ useEffect(()=>{
+ getMillstone();
+ },[millstone])
- -
-
-
- {this.state.paix}
-
-
-
+ function getMillstone(){
+ const url = `/v1/${owner}/${projectsId}/milestones`;
+ axios.get(url,{params:{keyword:millstone,only_name:true}}).then(result=>{
+ if(result && result.data){
+ let list = [{id:-1,name:"无里程碑"}];
+ list = [...list,...result.data.milestones];
+ setMillstoneList(list);
+ }
+ })
+ }
+ // 获取优先级列表
+ useEffect(()=>{
+ getPriorities();
+ },[])
+
+ function getPriorities(){
+ const url = `/v1/${owner}/${projectsId}/issue_priorities`;
+ axios.get(url).then(result=>{
+ if(result && result.data){
+ setPrioritiesList(result.data.priorities);
+ }
+ })
+ }
+ // 获取负责人列表
+ useEffect(()=>{
+ getCharge();
+ },[charge])
+
+ function getCharge(){
+ let list = [{id:-1,name:"未指派负责人"}];
+ const url = `/v1/${owner}/${projectsId}/collaborators`;
+ axios.get(url,{params:{keyword:charge,only_name:true}}).then(result=>{
+ if(result && result.data){
+ list = [...list,...result.data.collaborators];
+ setChargeList(list);
+ }
+ })
+ }
+ const orderList=[
+ {order_name:"created_on",order_type:"desc",name:"最新创建",id:"1"},
+ {order_name:"created_on",order_type:"asc",name:"最早创建",id:"2"},
+ {order_name:"updated_on",order_type:"desc",name:"最新更新",id:"3"},
+ {order_name:"updated_on",order_type:"asc",name:"最早更新",id:"4"}
+ ]
+ return (
+
+
+
+
+
+ - openorder(undefined)}
+ >
+
+ {total}
+
+ - openorder("1")}
+ >
+
+
+ {data && data.open_count}
+
+ - openorder("11")}
+ >
+
+
+ {data && data.merged_issues_size}
+
+ - openorder("2")}
+ >
+
+
+ {data && data.close_count}
+
+ { open_blockchain &&
- 关联疑修
}
+ {setPriority({id:id.join(","),name});}}
+ />
+ setTag(value)}
+ chooseFunc={(id,name)=>{setIssueTag({id:id.join(","),name});}}
+ />
+ setCharge(value)}
+ chooseFunc={(id,name)=>{setAssigned({id:id.join(","),name});}}
+ />
+ setMillstone(value)}
+ chooseFunc={(id,name)=>{setFixedVersion({id:id.join(","),name});}}
+ />
+ {let filter=orderList.filter(i=>String(i.id)===id.join(","));setOrder(filter && filter.length>0 ? filter[0]:{});}}
+ />
+ {/* -
+
+
+ {this.state.priority_ids}
+
+
+
+
+ -
+
+
+ {this.state.issue_tag_ids}
+
+
+
+
+ -
+
+
+ {this.state.assigned_to_ids}
+
+
+
+
+
+ -
+
+
+ {this.state.fixed_version_ids}
+
+
+
+
+
+ -
+
+
+ {this.state.paix}
+
+
+
+
*/}
+
+
+ { data &&
- {data && data.search_count && data.search_count > 0 ? (
+ {total > 0 ? (
):""}
- {search_count > select_params.limit ? (
+ {total > limit ? (
) : (
""
)}
- { data && data.issues && data.issues.length === 0 ?
+ { issues && issues.length === 0 ?
+ has_created_pull_requests={data.has_created_pull_requests}
+ projectsId={projectsId}
+ owner={owner}
+ defaultBranch={props && turnbar(props.defaultBranch) }/>
:""
-
}
-
- );
- }
+ }
+
+ );
}
export default merge;
diff --git a/src/forge/Merge/merge_form.js b/src/forge/Merge/merge_form.js
index 2525cd5f..e7ed802f 100644
--- a/src/forge/Merge/merge_form.js
+++ b/src/forge/Merge/merge_form.js
@@ -1,59 +1,49 @@
-import React, { Component } from "react";
-import { Button, Form, Menu, Input, Select, Tag, Checkbox, Spin } from "antd";
+import React, { useEffect, useState } from "react";
+import { Button, Form, Menu, Input, Select, Tag, Spin } from "antd";
import axios from "axios";
-
+import ChooseMenu from '../Issues/Component/chooseMenu';
+import DropMenu from '../Issues/Component/dropMenu';
import "../Order/order.scss";
import "./merge.css";
import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor";
const Option = Select.Option;
-class MergeForm extends Component {
- constructor(props) {
- super(props);
- this.state = {
- desc: undefined,
- issue_tag_ids: undefined,
- fixed_version_id: undefined,
- assigned_to_id: undefined,
- titledata: undefined,
- isSpin: false,
- mergedata: undefined,
- priority_id: undefined,
- title: undefined,
- members: undefined,
- issue_tags: undefined,
- issue_versions: undefined,
- issue_priories: undefined,
- atWhoLoginList:undefined,
- issue_lists:undefined,
- issue_id:undefined,
- disable_pr_vew:false//是否有权限访问pr
- };
- }
+function MergeForm(props){
+ const [ desc , setDesc ] = useState(undefined);
+ const [issue_tag_ids , setIssueTagIds] = useState(undefined);
+ const [fixed_version_id , setFixedVersionId] = useState(undefined);
+ const [assigned_to_id , setAssignedToId] = useState(undefined);
+ const [isSpin , setIsSpin ] = useState(false);
+ const [priority_id, setPriorityId] = useState(undefined);
+ const [title,setTitle] = useState(undefined);
+ const [members,setMembers] = useState(undefined);
+ const [issue_tags,setIssueTags] = useState(undefined);
+ const [issue_versions,setIssueVersions] = useState(undefined);
+ const [issue_priories,setIssuePriories] = useState(undefined);
+ const [atWhoLoginList,setAtWhoLoginList] = useState(undefined);
+ const [issue_lists,setIssuelists] = useState(undefined);
+ const [issue_id,setIssueId] = useState(undefined);
+ const [disable_pr_vew,setDisableprview] = useState(undefined);
+ const { projectsId, mergeId ,owner } = props.match.params;
+ const { checkIfLogin , form , merge_type , project ,data , merge , files_count , commits_count ,pull } = props;
+ const open_blockchain = project && project.open_blockchain;
+ const permission = props && props.projectDetail && props.projectDetail.permission;
+ const { getFieldDecorator } = props.form;
- componentDidMount = () => {
- // this.check_is_login();
- this.get_default_selects();
- this.set_defatul();
- this.getIssueList();
- };
- componentDidUpdate=(prevPros)=>{
- const { projectsId ,owner } = this.props.match.params;
- const pId = prevPros.match.params.projectsId;
- const oId = prevPros.match.params.owner;
- if(pId !== projectsId || oId !== owner ){
- // console.log("切换了项目分支···········");
- this.get_default_selects();
- }
- if(prevPros && this.props && !this.props.checkIfLogin()){
- this.props.history.push("/403")
+ useEffect(()=>{
+ getIssueList();
+ },[])
+
+ useEffect(()=>{
+ if(!checkIfLogin()){
+ props.history.push("/403");
return
}
- }
+ get_default_selects();
+ },[projectsId,owner])
- getIssueList=()=>{
- const { projectsId ,owner } = this.props.match.params;
+ const getIssueList=()=>{
const url = `/v1/${owner}/${projectsId}/issues`;
axios.get(url,{
params:{
@@ -61,119 +51,69 @@ class MergeForm extends Component {
}
}).then(result=>{
if(result && result.data){
- this.setState({
- issue_lists:result.data.issues
- })
+ setIssuelists(result.data.issues)
}
})
}
- get_default_selects = () => {
- const { projectsId ,owner } = this.props.match.params;
- this.setState({ isSpin: true });
- axios
- .get(`/${owner}/${projectsId}/pulls/create_merge_infos.json`)
- .then((result) => {
- if (result) {
- this.setState({
- members: result.data.members,
- issue_tags: result.data.issue_tags,
- issue_versions: result.data.issue_versions,
- issue_priories: result.data.issue_priories,
- disable_pr_vew:result.data.disable_pr_vew
- });
+ function get_default_selects(){
+ setIsSpin(true);
+ axios.get(`/${owner}/${projectsId}/pulls/create_merge_infos.json`).then((result) => {
+ if (result && result.data) {
+ setIssueTags(result.data.issue_tags);
+ setIssueVersions(result.data.issue_versions);
+ setDisableprview(result.data.disable_pr_vew);
+
+ let priorities = result.data.issue_priories;
+ let array =[];
+ let colors = ["#1abcb1","#28be6c","#e67e22","#db3d1d"];
+ if(priorities && priorities.length>0){
+ array = priorities.map((i,k)=>{
+ let arr = {...i,color:colors[k]}
+ return arr;
+ })
}
- this.setState({ isSpin: false });
- })
- .catch((error) => {
- this.setState({ isSpin: false });
- console.log(error);
- });
- };
- set_defatul = () => {
- const { data, merge_type } = this.props;
- if (data && merge_type === "edit") {
- this.setState({
- desc: data.body,
- issue_tag_ids: data.issue_tag_ids ? data.issue_tag_ids[0] : undefined,
- fixed_version_id: data.fixed_version_id ? String(data.fixed_version_id) : undefined,
- assigned_to_id: data.assigned_to_id ? String(data.assigned_to_id) : undefined,
- priority_id: data.priority_id ? String(data.priority_id) :undefined,
- issue_id:data.attached_issues && data.attached_issues.length>0 ? String(data.attached_issues[0].id) :undefined,
- title: data.title,
- },()=>{
- this.InitData();
- });
- }
- };
- InitData = () => {
- console.log(this.state.issue_id);
- this.props.form.setFieldsValue({
- ...this.state,
+ setIssuePriories(array);
+ let mem = result.data.members;
+ mem = mem && mem.length > 0 && mem.map(i=>{return {...i,image_url:i.avatar_url}});
+ setMembers(mem);
+ if (data && merge_type === "edit") {
+ set_defatul(result.data.issue_tags,mem,array,result.data.issue_versions);
+ }
+ }
+ setIsSpin(false);
+ }).catch((error) => {
+ setIsSpin(false)
});
};
-
- onPanelChange = (time, mode) => {
- this.setState({
- value: time,
- });
- };
-
- onSelect = (time) => {
- this.setState({
- value: time,
- selectedValue: time,
- });
- };
-
- renderMenu = (array, id) => {
- return (
-
- );
- };
-
- renderSelect = (list) => {
- if (list && list.length > 0) {
- return list.map((item, key) => {
- return (
-
- );
- });
- }
+ function set_defatul(tag,member,priority,version){
+ setDesc(data.body);
+ setIssueTagIds(tag.filter(i=>data.issue_tag_ids.includes(String(i.id))));
+ setFixedVersionId(version.filter(i=>String(i.id)===String(data.fixed_version_id)));
+ setAssignedToId(member.filter(i=>String(i.id)===String(data.assigned_to_id)));
+ setPriorityId(priority.filter(i=>String(i.id)===String(data.priority_id)));
+ setIssueId(data.attached_issues);
+ setTitle(data.title);
+ form.setFieldsValue({title:data.title})
};
//创建合并请求
-
- handleSubmit = () => {
- this.setState({
- isSpin: true,
- });
- this.props.form.validateFieldsAndScroll((err, values) => {
+ const handleSubmit = () => {
+ setIsSpin(true);
+ form.validateFieldsAndScroll((err, values) => {
if (!err) {
- const { projectsId, mergeId , owner } = this.props.match.params;
- const { merge, pull, merge_type, data , commits_count , files_count } = this.props;
- if (values.issue_tag_ids && values.issue_tag_ids.length > 0) {
- values.issue_tag_ids = [parseInt(values.issue_tag_ids)];
- } else {
- values.issue_tag_ids = [];
+ let params={
+ priority_id:priority_id ? priority_id.map(i=>i.id).join(",") : undefined,
+ issue_tag_ids:issue_tag_ids ? issue_tag_ids.map(i=>i.id) : undefined,
+ fixed_version_id:fixed_version_id ? fixed_version_id.map(i=>i.id).join(",") : undefined,
+ assigned_to_id:assigned_to_id ? assigned_to_id.map(i=>i.id).join(",") : undefined,
}
- const { desc , atWhoLoginList , disable_pr_vew } = this.state;
+ console.log(params);
if (merge_type === "new") {
let url = `/${owner}/${projectsId}/pulls.json`;
axios.post(url, {
...values,
+ ...params,
body: desc,
head: pull,
base: merge,
@@ -184,273 +124,174 @@ class MergeForm extends Component {
files_count,
commits_count,
receivers_login:atWhoLoginList,
- attached_issue_ids:values.issue_id ? [values.issue_id] :undefined
+ attached_issue_ids:issue_id && issue_id.length > 0 ? issue_id.map(i=>i.id) :undefined
})
.then((result) => {
if (result) {
- this.setState({
- isSpin: false,
- });
+ setIsSpin(false);
const { pull_request_number } = result.data;
- this.props.history.push({pathname: disable_pr_vew ? `/${owner}/${projectsId}/pulls`:`/${owner}/${projectsId}/pulls/${pull_request_number}`, query:{showNps: true}});
- const { getDetail } = this.props;
+ props.history.push({pathname: disable_pr_vew ? `/${owner}/${projectsId}/pulls`:`/${owner}/${projectsId}/pulls/${pull_request_number}`, query:{showNps: true}});
+ const { getDetail } = props;
getDetail && getDetail();
} else {
- this.setState({
- isSpin: false,
- });
+ setIsSpin(false);
}
- })
- .catch((error) => {
- this.setState({
- isSpin: false,
- });
+ }).catch((error) => {
+ setIsSpin(false);
});
} else {
let url = `/${owner}/${projectsId}/pulls/${mergeId}.json`;
axios
.put(url, {
...values,
+ ...params,
body: desc,
head: pull,
base: merge,
receivers_login:atWhoLoginList,
- attached_issue_ids:values.issue_id ? [values.issue_id] :undefined
+ attached_issue_ids:issue_id && issue_id.length > 0 ? issue_id.map(i=>i.id) :undefined
})
.then((result) => {
if (result) {
- this.setState({
- isSpin: false,
- });
- // , query:{showNps: true}
- this.props.history.push({pathname: `/${owner}/${projectsId}/pulls/${mergeId}`});
+ setIsSpin(false);
+ props.history.push({pathname: `/${owner}/${projectsId}/pulls/${mergeId}`});
} else {
- this.setState({
- isSpin: false,
- });
+ setIsSpin(false)
}
- })
- .catch((error) => {
- this.setState({
- isSpin: false,
- });
- console.log(error);
+ }).catch((error) => {
+ setIsSpin(false)
});
}
} else {
- this.setState({
- isSpin: false,
- });
+ setIsSpin(false)
}
});
};
- onContentChange = (value) => {
- this.setState({
- desc: value,
- });
+ const onContentChange = (value) => {
+ setDesc(value)
};
//合并请求中at谁列表(存储:login)
- changeAtWhoLoginList = (loginList) =>{
- this.setState({
- atWhoLoginList:loginList,
- });
+ const changeAtWhoLoginList = (loginList) =>{
+ setAtWhoLoginList(loginList)
};
- render() {
- const { merge_type , project } = this.props;
- const open_blockchain = project && project.open_blockchain;
- const { getFieldDecorator } = this.props.form;
- const { projectsId, mergeId ,owner } = this.props.match.params;
- const {
- issue_tag_ids,
- fixed_version_id,
- assigned_to_id,
- priority_id,
- desc,
- isSpin,
- title,
- members,
- issue_tags,
- issue_versions,
- issue_priories,
- issue_lists,
- issue_id
- } = this.state;
- return (
-
-
-
-
- {merge_type === "new" ? "新建" : "编辑"}合并请求:
-
-
- 可合并的
-
-
-