diff --git a/src/forge/Main/DetailTop.js b/src/forge/Main/DetailTop.js index 841ddbf7c..5856742cd 100644 --- a/src/forge/Main/DetailTop.js +++ b/src/forge/Main/DetailTop.js @@ -1,18 +1,18 @@ -import React , { Component } from 'react'; -import { Link} from 'react-router-dom'; +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; -class DetailTop extends Component{ - render(){ +class DetailTop extends Component { + render() { const { projectDetail } = this.props; const { projectsId } = this.props.match.params; const { pathname } = this.props.location; - return( + return (

- 0 ? "active" : ""}> + 0 ? "active" : ""}> {projectDetail && projectDetail.commits_count}提交 - 0 ? "active" : ""}> + 0 ? "active" : ""}> {projectDetail && projectDetail.branches_count}分支 diff --git a/src/forge/Main/Index.js b/src/forge/Main/Index.js index 26cb9a07d..95218e8fc 100644 --- a/src/forge/Main/Index.js +++ b/src/forge/Main/Index.js @@ -1,41 +1,38 @@ -import React , { Component } from 'react'; +import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -import { Menu , Input , Dropdown , Icon, Spin , Pagination } from 'antd'; +import { Menu, Input, Dropdown , Spin, Pagination } from 'antd'; import '../css/index.css' import './list.css'; - - import ListItem from './IndexItem' import axios from 'axios'; - import img_new from '../Images/new.png'; import img_array from '../Images/array.png'; const Search = Input.Search; -class Index extends Component{ - constructor(props){ +class Index extends Component { + constructor(props) { super(props); - this.state={ - projectsList:undefined, - page:1, - limit:15, - search:undefined, - sort:undefined, - total:0, - isSpin:true, - project_type:undefined, - category_id:undefined, + this.state = { + projectsList: undefined, + page: 1, + limit: 15, + search: undefined, + sort: undefined, + total: 0, + isSpin: true, + project_type: undefined, + category_id: undefined, - typeList:undefined, - categoryList:undefined + typeList: undefined, + categoryList: undefined } } - componentDidMount=()=>{ - const { page,limit, search , sort ,project_type,category_id} = this.state; - this.getListData(page,limit, search , sort,project_type,category_id); + componentDidMount = () => { + const { page, limit, search, sort, project_type, category_id } = this.state; + this.getListData(page, limit, search, sort, project_type, category_id); this.getType(); @@ -43,43 +40,45 @@ class Index extends Component{ } // 获取列表 - getListData=(page,limit, search , sort,project_type,category_id)=>{ + getListData = (page, limit, search, sort, project_type, category_id) => { const { current_user } = this.props; const url = `/projects.json`; - axios.get(url,{params:{ - user_id:current_user && current_user.user_id, - page, - limit, - search, - sort_by:sort, - project_type, - category_id - }}).then((result)=>{ - if(result){ + axios.get(url, { + params: { + user_id: current_user && current_user.user_id, + page, + limit, + search, + sort_by: sort, + project_type, + category_id + } + }).then((result) => { + if (result) { this.setState({ - projectsList:result.data.projects, - total:result.data.total_count, - isSpin:false + projectsList: result.data.projects, + total: result.data.total_count, + isSpin: false }) } - }).catch((error)=>{}) + }).catch((error) => { }) } // 获取类型 - getType=()=>{ + getType = () => { const url = `/projects/group_type_list.json`; - axios.get(url).then((result)=>{ - if(result && result.data){ + axios.get(url).then((result) => { + if (result && result.data) { this.setTypeList(result.data, undefined) } - }).catch((error)=>{}) + }).catch((error) => { }) } - setTypeList=(list, active_type)=>{ + setTypeList = (list, active_type) => { this.setState({ - typeList:list.map((item,key)=>{ - return( -

  • this.changeType(`${item.project_type}`, list)}> + typeList: list.map((item, key) => { + return ( +
  • this.changeType(`${item.project_type}`, list)}>

    {item.name} {item.projects_count} @@ -91,33 +90,33 @@ class Index extends Component{ } // 切换类型 - changeType=(type,list)=>{ + changeType = (type, list) => { this.setState({ - isSpin:true, - project_type:type, - search:undefined + isSpin: true, + project_type: type, + search: undefined }) - this.setTypeList(list,type) - const { page,limit, sort,category_id } = this.state; - this.getListData(page,limit, undefined , sort, type ,category_id); + this.setTypeList(list, type) + const { page, limit, sort, category_id } = this.state; + this.getListData(page, limit, undefined, sort, type, category_id); } // 获取类型 - getCategory=()=>{ + getCategory = () => { const url = `/project_categories/group_list.json`; - axios.get(url).then((result)=>{ - if(result && result.data){ + axios.get(url).then((result) => { + if (result && result.data) { this.setCategoryList(result.data, undefined); } - }).catch((error)=>{}) + }).catch((error) => { }) } - setCategoryList=(list, active_id)=>{ + setCategoryList = (list, active_id) => { this.setState({ - categoryList:list.map((item,key)=>{ - return( -

  • this.changeCategory(`${item.id}`,list)}> + categoryList: list.map((item, key) => { + return ( +
  • this.changeCategory(`${item.id}`, list)}>

    {item.name} {item.projects_count} @@ -128,58 +127,58 @@ class Index extends Component{ }) } - changeCategory=(id,list)=>{ + changeCategory = (id, list) => { this.setState({ - category_id:id, - page:1 + category_id: id, + page: 1 }); - this.setCategoryList(list,id) - const { limit , sort, project_type } = this.state; - this.getListData(1,limit, undefined , sort, project_type ,id); + this.setCategoryList(list, id) + const { limit, sort, project_type } = this.state; + this.getListData(1, limit, undefined, sort, project_type, id); } // 排序 - ChangeSoryBy=(e)=>{ + ChangeSoryBy = (e) => { this.setState({ - sort_by:e.key, - page:1, - search:undefined, - isSpin:true + sort_by: e.key, + page: 1, + search: undefined, + isSpin: true }) - const { limit,project_type,category_id } = this.state; - this.getListData(1 ,limit , undefined , e.key,project_type,category_id); + const { limit, project_type, category_id } = this.state; + this.getListData(1, limit, undefined, e.key, project_type, category_id); } // 搜索 - searchFun=(value)=>{ + searchFun = (value) => { // console.log(value) this.setState({ - page:1, - search:value, - isSpin:true, - project_type:undefined, + page: 1, + search: value, + isSpin: true, + project_type: undefined, sort: "updated_on" }) - const { limit , sort , category_id } = this.state; - this.getListData(1 ,limit, value , sort , undefined,category_id); + const { limit, sort, category_id } = this.state; + this.getListData(1, limit, value, sort, undefined, category_id); } - changeSearchValue=(e)=>{ + changeSearchValue = (e) => { this.setState({ - search:e.target.value + search: e.target.value }) } // 翻页 - ChangePage=(page)=>{ + ChangePage = (page) => { this.setState({ page }) - const { limit, search , sort,project_type,category_id } = this.state; - this.getListData(page,limit, search , sort,project_type,category_id); + const { limit, search, sort, project_type, category_id } = this.state; + this.getListData(page, limit, search, sort, project_type, category_id); } - render(){ + render() { const { current_user } = this.props; - const menu=( + const menu = (

    更新时间排序 创建时间排序 @@ -187,35 +186,35 @@ class Index extends Component{ 点赞数量排序 ) - const newItem=( + const newItem = ( 新建镜像项目 新建托管项目 ) - const { projectsList , isSpin , total , search , limit , page , typeList , categoryList } = this.state; + const { projectsList, isSpin, total, search, limit, page, typeList, categoryList } = this.state; const pagination = ( total && total > limit ? -
    - -
    :"" +
    + +
    : "" ) - return( -
    + return ( +

    • 项目类型
    • - { typeList } + {typeList}
    • 项目类别
    • - { categoryList } + {categoryList}
    @@ -226,14 +225,14 @@ class Index extends Component{ current_user && current_user.login && - 新建 + 新建 } - + - 排序 + 排序
    @@ -248,7 +247,7 @@ class Index extends Component{ />
    - { pagination } + {pagination}
    diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index a5dc39397..efea56ad2 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -1,44 +1,37 @@ -import React , { Component } from 'react'; +import React, { Component } from 'react'; import { getImageUrl } from 'educoder'; import { Link } from 'react-router-dom'; import '../css/index.css' import './list.css'; import img_parise from '../Images/parise.png'; import img_fork from '../Images/fork.png'; -class IndexItem extends Component{ - // constructor(props){ - // super(props); - // } - - TurnToDetail=(login,url)=>{ +class IndexItem extends Component { + TurnToDetail = (login, url) => { this.props.history.push({ - pathname:url, - state:login + pathname: url, + state: login }) } - render(){ + render() { const { projects } = this.props; - // item.author.login const renderList = ( - projects && projects.length >0 ? projects.map((item,key)=>{ - return( + projects && projects.length > 0 ? projects.map((item, key) => { + return (
    -
    - + {item.author.name}/{item.name} { item.forked_from_project_id ? - + : "" } - { item.is_public ? "" : @@ -46,28 +39,27 @@ class IndexItem extends Component{ }
    -

    {item.description}

    +

    {item.description}

    - {/* { item.forked_count ? { item.forked_count}:"" } */} - 赞 ({ item.praises_count }) - { item.language && item.language.id ? :"" } + 赞 ({item.praises_count}) + {item.language && item.language.id ? : ""}
    {item.visits} - { item.category && item.category.id && {item.category.name}} - {item.last_update_time ? {item.time_ago} : "" } + {item.category && item.category.id && {item.category.name}} + {item.last_update_time ? {item.time_ago} : ""}
    ) - }):"" + }) : "" ) - return( + return (
    - { renderList } + {renderList}
    ) } diff --git a/src/forge/Merge/MergeDetail.js b/src/forge/Merge/MergeDetail.js index 9013ae77d..cf73802c3 100644 --- a/src/forge/Merge/MergeDetail.js +++ b/src/forge/Merge/MergeDetail.js @@ -1,343 +1,317 @@ -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 Nav from '../Order/Nav'; import UploadComponent from '../Upload/Index'; - -import{ Modal,Col,Form,Input,Tooltip,Popconfirm } from 'antd' +import { Modal , Form, Input, Tooltip, Popconfirm } from 'antd' import NoneData from '../Nodata'; - const TextArea = Input.TextArea; -class MergeDetail extends Component{ - constructor(props){ +class MergeDetail extends Component { + constructor(props) { super(props); - this.state={ - data:undefined, - isShow:false, - imgsrc:'', - journalsdata:undefined, + this.state = { + data: undefined, + isShow: false, + imgsrc: '', + journalsdata: undefined, //图片区域是否显示 none 隐藏 block 显示 - display:'none', - titledisplay:'none', - countvalue:'', + display: 'none', + titledisplay: 'none', + countvalue: '', //是否需要编辑 - isedit:'block', + isedit: 'block', showFiles: true } } - - componentDidMount=()=>{ + + componentDidMount = () => { this.getDetail(); } - getDetail=()=>{ - const { projectsId , mergeid} = this.props.match.params; + 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, + data: result.data, }) - this.getjournalslist(); + this.getjournalslist(); } - }).catch((error)=>{ + }).catch((error) => { console.log(error); }) } - handleok=() => { - this.setState({ - isShow:false - }); - }; - handleCancel=()=>{ - this.setState({ - isShow:false - }); - } + handleok = () => { + this.setState({ + isShow: false + }); + }; + handleCancel = () => { + this.setState({ + isShow: false + }); + } - imgshow=()=>{ - this.setState({ - isShow:true - }); - }; + imgshow = () => { + this.setState({ + isShow: true + }); + }; - //添加评论 - addjournals=()=>{ - this.props.form.validateFieldsAndScroll((err, values) => { - if(!err){ - const { data } = this.state; - const url = `/issues/${data.pull_request.id}/journals.json`; - axios.post(url,{ - ...values, - issue_id:data.id, - }).then(result=>{ - if(result){ - this.setState({ - showFiles: false - }) - this.getjournalslist(); - } - }).catch(error=>{ - console.log(error); - }) - } - }) - } - //获取评论信息 - getjournalslist=()=>{ - const { data } = this.state; - const url = `/issues/${data.pull_request.id}/journals.json`; - let id=data.id; - axios.get(url,{ - params:{ - id - } - }).then(result=>{ - if(result){ - this.setState({ - journalsdata:result.data - }) - } - }).catch(error=>{ - console.log(error); - }) - } - - //关闭任务 - closedetail=(id)=>{ - const {projectsId,orderId} = this.props.match.params; + //添加评论 + addjournals = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + const { data } = this.state; + const url = `/issues/${data.pull_request.id}/journals.json`; + axios.post(url, { + ...values, + issue_id: data.id, + }).then(result => { + if (result) { + this.setState({ + showFiles: false + }) + this.getjournalslist(); + } + }).catch(error => { + console.log(error); + }) + } + }) + } + //获取评论信息 + getjournalslist = () => { + const { data } = this.state; + const url = `/issues/${data.pull_request.id}/journals.json`; + let id = data.id; + axios.get(url, { + params: { + id + } + }).then(result => { + if (result) { + this.setState({ + journalsdata: result.data + }) + } + }).catch(error => { + console.log(error); + }) + } + + //关闭任务 + closedetail = (id) => { + const { projectsId, orderId } = this.props.match.params; const url = `/projects/${projectsId}/issues/${orderId}/close_issue.json`; - axios.post(url,{ - project_id:projectsId, - id:orderId, - status_id:id, - }).then(result=>{ - if(result){ + axios.post(url, { + project_id: projectsId, + id: orderId, + status_id: id, + }).then(result => { + if (result) { this.getDetail(); } - }).catch(error=>{ + }).catch(error => { console.log(error); }) - } + } - //修改评论 - updatedetail=(id)=>{ - const {mergeid} = this.props.match.params; - const url = `/issues/${mergeid}/journals/${id}.json`; - axios.put(url,{ - issue_id:mergeid, - id:id, - content:this.state.countvalue - }).then(result=>{ - if(result){ - this.setState({ - isedit:'block' - }) - this.getjournalslist(); - } - }).catch(error=>{ - console.log(error); - }) - } - - changmodelname=(e)=>{ - this.setState({ - countvalue:e.target.value - }) - } - editdetail=(count,status)=>{ - this.setState({ - countvalue:count, - isedit:status - }) - } - -// 判断是否重新上传文件 - changeIsComplete=(flag)=>{ - this.setState({ - showFiles:flag + //修改评论 + updatedetail = (id) => { + const { mergeid } = this.props.match.params; + const url = `/issues/${mergeid}/journals/${id}.json`; + axios.put(url, { + issue_id: mergeid, + id: id, + content: this.state.countvalue + }).then(result => { + if (result) { + this.setState({ + isedit: 'block' + }) + this.getjournalslist(); + } + }).catch(error => { + console.log(error); }) } - render(){ - const { projectsId , mergeid } = this.props.match.params; - const { data,journalsdata, showFiles } = this.state; + + changmodelname = (e) => { + this.setState({ + countvalue: e.target.value + }) + } + editdetail = (count, status) => { + this.setState({ + countvalue: count, + isedit: status + }) + } + + // 判断是否重新上传文件 + changeIsComplete = (flag) => { + this.setState({ + showFiles: flag + }) + } + render() { + const { projectsId, mergeid } = this.props.match.params; + const { data, journalsdata, showFiles } = this.state; const { getFieldDecorator } = this.props.form; const url = this.props.history.location.pathname; - 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,'none')}> -
    - this.deletedetail(item.id)}> - - -
    - -
    -
    -

    {item.content}

    -
    -