diff --git a/package.json b/package.json index 397d4ee5..36235f0f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "dependencies": { "@monaco-editor/react": "^2.3.0", "@novnc/novnc": "^1.1.0", + "actioncable": "^5.2.4-3", "antd": "^3.26.15", "array-flatten": "^2.1.2", "autoprefixer": "7.1.6", diff --git a/public/css/edu-purge.css b/public/css/edu-purge.css index fa82f304..9f6e8b28 100644 --- a/public/css/edu-purge.css +++ b/public/css/edu-purge.css @@ -1569,6 +1569,7 @@ a.edu-txt-w80, .font-80 { font-size: 80px !important; } +.color-grey-b{color: #bbb !important} /*a标签的下划线*/ a.decoration { diff --git a/public/css/merge.css b/public/css/merge.css index c72b582a..59200bb6 100755 --- a/public/css/merge.css +++ b/public/css/merge.css @@ -29,4 +29,12 @@ color:#fff !important; } .display-flex{display: flex !important;} -.merge-flex1{flex:1} \ No newline at end of file +.merge-flex1{flex:1} +.ant-tag.pr-branch-tag{ + border-radius: 12px; + height: 24px; + background: rgba(241,248,255,1); + border: none; + font-size: 13px; + padding: 0 10px; +} \ No newline at end of file diff --git a/src/AppConfig.js b/src/AppConfig.js index 620f6d68..dadadc5f 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -59,52 +59,14 @@ function setpostcookie() { } setpostcookie(); - -function railsgettimes(proxy) { - clearAllCookie() - if (timestamp && checkSubmitFlg === false) { - $.ajax({ - url: proxy, async: true, success: function (data) { - if (data.status === 0) { - timestamp = data.message; - setpostcookie(); - } - } - }) - checkSubmitFlg = true - window.setTimeout(() => { - checkSubmitFlg = false; - }, 2000); - } else if (checkSubmitFlg === false) { - $.ajax({ - url: proxy, async: true, success: function (data) { - if (data.status === 0) { - timestamp = data.message; - setpostcookie(); - } - } - }) - checkSubmitFlg = true - window.setTimeout(() => { - checkSubmitFlg = false; - }, 2000); - } - -} - window._debugType = debugType; export function initAxiosInterceptors(props) { initOnlineOfflineListener() - // TODO 避免重复的请求 https://github.com/axios/axios#cancellation - // TODO 读取到package.json中的配置? - var proxy = "http://localhost:3000" - // proxy = "https://pre-newweb.educoder.net" - proxy = "http://192.168.2.59:3000" + var + proxy = "http://localhost:3000" + proxy = "https://testforgeplus.trustie.net" - // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; - - // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 const requestMap = {}; window.setfalseInRequestMap = function (keyName) { requestMap[keyName] = false; @@ -115,19 +77,13 @@ export function initAxiosInterceptors(props) { setpostcookie() clearAllCookie() - if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) { + if (config.url.indexOf(proxy) !== -1 || config.url.indexOf(':') !== -1) { return config } requestProxy(config) let url = `/api${config.url}`; - //qq登录去掉api - if (config.params && config.params.redirect_uri !== undefined) { - if (config.params.redirect_uri.indexOf('otherloginqq') !== -1) { - url = `${config.url}`; - } - } if (`${config[0]}` !== `true`) { if (window.location.port === "3007") { config.url = `${proxy}${url}`; diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 74dbca7d..4102fd75 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -241,7 +241,7 @@ class CoderRootDirectory extends Component { message: item.commit && item.commit.message, ...item, }); - if (item.name === "README.md") { + if (item.is_readme_file) { readMeContent.push({ ...item }); readMeFile.push({ ...item }); } @@ -348,7 +348,7 @@ class CoderRootDirectory extends Component { dataIndex: 'name', width:"30%", render: (text,item) => ( - this.goToSubRoot(item.path,item.type)} className="ml12"> + this.goToSubRoot(item.path,item.type)} className="ml12 task-hide" style={{ display: "block", maxWidth: "345px" }}> {text} ), @@ -482,7 +482,7 @@ class CoderRootDirectory extends Component { )}
- {subFileType && (isManager || isDeveloper) && ( + {subFileType && parseInt(projectDetail.type) !== 2 && (isManager || isDeveloper) && (
import('../Order/Milepost'), loading: Loading, }) + const OrdernewMilepost = Loadable({ loader: () => import('../Order/newMilepost'), loading: Loading, }) + const OrderupdateMilepost = Loadable({ loader: () => import('../Order/UpdateMilepost'), loading: Loading, }) + const OrderupdateDetail = Loadable({ loader: () => import('../Order/UpdateDetail'), loading: Loading, }) + const OrdercopyDetail = Loadable({ loader: () => import('../Order/CopyDetail'), loading: Loading, }) + //合并请求 const MergeIndexDetail = Loadable({ loader: () => import('../Merge/merge'), loading: Loading, }) + const CreateMerge = Loadable({ loader: () => import('../Merge/NewMerge'), loading: Loading, }) + const MessageCount = Loadable({ loader: () => import('../Merge/MessageCount'), loading: Loading, }) + const UpdateMerge = Loadable({ loader: () => import('../Merge/UpdateMerge'), loading: Loading, }) + const MilepostDetail = Loadable({ loader: () => import('../Order/MilepostDetail'), loading: Loading, @@ -106,6 +115,8 @@ const ForkUsers = Loadable({ loader: () => import('../UsersList/fork_users'), loading: Loading, }) + + const TrendsIndex = Loadable({ loader: () => import('../Activity/Activity'), loading: Loading, @@ -114,11 +125,11 @@ const TrendsIndex = Loadable({ /** * permission:Manager:管理员,Reporter:报告人员(只有读取权限),Developer:开发人员(除不能设置仓库信息外) */ + class Detail extends Component { constructor(props) { super(props); this.state = { - isMirror: true, projectDetail: undefined, isManager: false, isReporter: false, @@ -133,7 +144,9 @@ class Detail extends Component { author: undefined, branchs: undefined, branchList: undefined, - project: null + project: null, + firstSync:false, + secondSync:false } } @@ -147,54 +160,64 @@ class Detail extends Component { } } - getProject = () => { + getProject = (num) => { + const name = window.location.hostname === "localhost" ? "testforgeplus.trustie.net":window.location.hostname; + console.log(`ws:${name}/cable`); const { projectsId } = this.props.match.params; - const url = `ws://192.168.2.59:3000/cable`; - const scoket = new WebSocket(url); - scoket.onopen=()=>{ - scoket.send(JSON.stringify({ "id": `${projectsId}`})); - console.log(1); - } - scoket.onmessage=(result)=>{ - console.log(2," ",result); - if(result){ + const url = `/projects/${projectsId}/simple.json`; + axios.get(url).then((result) => { + if (result && result.data) { this.setState({ project: result.data }) - let mirror_status = result.data.mirror_status; - // this.checkMirror(mirror_status); - scoket.close(); + if (result.data.type !== 0 && result.data.mirror_status === 1) { + console.log("--------start channel --------"); + // 是镜像项目,且未完成迁移 + this.canvasChannel(); + if(num){ + this.setState({ + secondSync:true, + firsrtSync:false + }) + }else{ + this.setState({ + firstSync:true, + secondSync:false + }) + } + }else{ + this.getDetail(); + this.setState({ + firsrtSync:false, + secondSync:false + }) + } } - } - scoket.onclose=(event)=>{ - console.log(3," ",event); - } - // const url = `/projects/${projectsId}/simple.json`; - - // axios.get(url).then((result) => { - // if (result) { - // this.setState({ - // project: result.data - // }) - // let mirror_status = result.data.mirror_status; - // this.checkMirror(mirror_status); - // } - // }) + }) } - checkMirror=(mirror_status)=>{ - if (!mirror_status || (mirror_status && mirror_status === 0)) { - this.setState({ - isMirror:false - }) - this.getDetail(); - } else { - this.setState({ - isMirror: true - }) - setTimeout(() => { - this.getProject(); - }, 600000); - } + canvasChannel = () => { + const name = window.location.hostname === "localhost" ? "http://testforgeplus.trustie.net":window.location.hostname; + console.log(`ws:${name}/cable`); + const actioncable = require("actioncable") + var project = this.state.project + var cable = actioncable.createConsumer(`ws:${name}/cable`); + this.canvasChannel1 = cable.subscriptions.create({ + channel: `MirrorProjectChannel`, + id: project && project.identifier + }, { + connected: () => { + console.log("###### channel connected! ######"); + }, + disconnected: () => { }, + received: data => { + console.log(`###### ---received data--- ######`); + console.log(data); + if (data) { + this.getDetail(); + cable.subscriptions.consumer.disconnect(); + } + } + }) } getDetail = () => { @@ -294,9 +317,8 @@ class Detail extends Component { const url = `/repositories/${repo_id}/sync_mirror.json`; axios.post(url).then(result => { if (result && result.data && result.data.status === 0) { - this.props.showNotification("镜像同步成功!"); - this.getProject(); - // this.getDetail(); + // this.props.showNotification("镜像同步成功!"); + this.getProject(2); } else { this.props.showNotification("镜像同步失败!"); } @@ -306,9 +328,9 @@ class Detail extends Component { } render() { - const { projectDetail, watchers_count, praises_count, forked_count, isManager, watched, praised, project, isMirror } = this.state; + const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, project } = this.state; const url = this.props.history.location.pathname; - const urlArr = url.split("/"); + const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); const { projectsId } = this.props.match.params; @@ -340,7 +362,7 @@ class Detail extends Component {
-

+

{project && project.author && {project.author.name} @@ -361,95 +383,98 @@ class Detail extends Component { { projectDetail && checkLogin && projectDetail.type && projectDetail.type === 2 ? - + : "" }

{ - isMirror ? "" : - - { - projectDetail && projectDetail.type && projectDetail.type === 2 ? - 同步镜像 : "" - } - - this.focusFunc(watched)}> - - {watched ? '取消关注' : '关注'} - - - {watchers_count} - - - - this.pariseFunc(praised)}> - - {praised ? '取消点赞' : '点赞'} - - - {praises_count} - - - - - Fork - - {forked_count} - - + firstSync ? "": + + { + projectDetail && projectDetail.type && projectDetail.type === 2 ? + 同步镜像 : "" + } + + this.focusFunc(watched)}> + + {watched ? '取消关注' : '关注'} + + + {watchers_count} + + + this.pariseFunc(praised)}> + + {praised ? '取消点赞' : '点赞'} + + + {praises_count} + + + + + Fork + + {forked_count} + + + }
{ - isMirror ? "" : + firstSync ? "" :
-
    -
  • -1 || urlFlag) ? "active" : ""}> - - 代码库 +
      +
    • -1 || urlFlag) ? "active" : ""}> + + 代码库 -
    • -
    • -1 && !(url.indexOf("Milepost") > 0 || url.indexOf("meilpost") > 0 || url.indexOf("tags") > 0)) ? "active" : ""}> - - 任务 +
    • +
    • -1 && !(url.indexOf("Milepost") > 0 || url.indexOf("meilpost") > 0 || url.indexOf("tags") > 0)) ? "active" : ""}> + + 任务 {projectDetail && projectDetail.issues_count ? {projectDetail.issues_count} : ""} - -
    • + + + { + projectDetail && parseInt(projectDetail.type) !== 2 &&
    • -1 ? "active" : ""}> 合并请求 {projectDetail && projectDetail.pull_requests_count ? {projectDetail.pull_requests_count} : ""}
    • -
    • -1 || url.indexOf("meilpost") > -1) ? "active" : ""}> - - 里程碑 + } +
    • -1 || url.indexOf("meilpost") > -1) ? "active" : ""}> + + 里程碑 {projectDetail && projectDetail.version_count && {projectDetail.version_count}} + +
    • +
    • -1 ? "active" : ""}> + + 动态 -
    • -
    • -1 ? "active" : ""}> - - 动态 - -
    • - { - isManager && -
    • 0 ? "active" : ""}>仓库设置
    • - } -
    -
+ + { + isManager && +
  • 0 ? "active" : ""}>仓库设置
  • + } + +
    }
    { - isMirror ? + firstSync ? - + : - + {/* 新建文件 */} () } > - - {/* 里程碑页面新建任务 */} () } > - {/* 修改详情 */} () } > - {/* 复制详情 */} () } > - {/* 动态 */} () } > - - {/* 代码Index */} () } > - () } > - () } > - () } > - () diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index 3aa5b441..7dde2443 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -195,7 +195,7 @@ .spincontent{ height:400px; } -.spincontent .ant-spin-text{ +.spinstyle .ant-spin-text{ margin-top:30px; color: #888; } diff --git a/src/forge/Merge/MergeItem.js b/src/forge/Merge/MergeItem.js index 5cdb2b9b..74e46cd3 100644 --- a/src/forge/Merge/MergeItem.js +++ b/src/forge/Merge/MergeItem.js @@ -2,7 +2,7 @@ import React, { Component } from "react"; import { Link } from "react-router-dom"; import { Popconfirm, Tag } from "antd"; import { getImageUrl } from "educoder"; -import "./merge.css" +import "./merge.css"; class MergeItem extends Component { constructor(props) { @@ -42,7 +42,7 @@ class MergeItem extends Component { }; render() { - const { issues, project_name } = this.props; + const { issues, project_name, project_author_name } = this.props; const { projectsId } = this.props.match.params; const { current_user } = this.props; const renderList = () => { @@ -60,7 +60,11 @@ class MergeItem extends Component { {item.name} - {item.pull_request_staus==="merged" ? "已合并" : (item.pull_request_staus === "closed"?"已拒绝" : "开启的") } + {item.pull_request_staus === "merged" + ? "已合并" + : item.pull_request_staus === "closed" + ? "已拒绝" + : "开启的"}

    @@ -92,21 +96,33 @@ class MergeItem extends Component { {item.pr_time} - + - {project_name}:{item.pull_request_head} + {item.is_original + ? item.fork_project_user + : project_author_name} + :{item.pull_request_head} - + - + - {project_name}:{item.pull_request_base} + {/* {item.is_fork ? item.pull_request_base : `${item.author_name}:${item.pull_request_base}`} */} + {project_author_name}:{item.pull_request_base} @@ -133,7 +149,7 @@ class MergeItem extends Component { )}

  • {item.version || "--"}
  • - +
  • {
    - + - {data.project_name}:{data.pull_request.head} + {data.pull_request.is_original ? data.pull_request.fork_project_user : data.issue.project_author_name}:{data.pull_request.head} @@ -271,12 +271,13 @@ class MessageCount extends Component { } > - + - {data.project_name}:{data.pull_request.base} + {/* {data.pull_request.is_fork ? data.pull_request.base : `${data.pull_request.pull_request_user}:${data.pull_request.base}`} */} + {data.issue.project_author_name}:{data.pull_request.base}
    diff --git a/src/forge/Merge/NewMerge.js b/src/forge/Merge/NewMerge.js index b11a7f02..2f210480 100644 --- a/src/forge/Merge/NewMerge.js +++ b/src/forge/Merge/NewMerge.js @@ -3,8 +3,8 @@ import { Input, Select, Button, Spin, Alert } from "antd"; import axios from "axios"; import "../Order/order.css"; import "./merge.css"; -import MergeForm from "./merge_form" -import MergeFooter from "./merge_footer" +import MergeForm from "./merge_form"; +import MergeFooter from "./merge_footer"; const Option = Select.Option; class NewMerge extends Component { constructor(props) { @@ -12,35 +12,91 @@ class NewMerge extends Component { this.state = { data: undefined, branches: undefined, - origin_branches: undefined, - merge: undefined, - pull: undefined, + merge_branches: undefined, + merge_projects: undefined, + merge: "master", + pull: "master", + is_fork: false, + projects_names: undefined, isSpin: false, show_message: true, + merge_head: false, // 是否向fork后的源项目发起合并请求 default_message: "必须选择不同的分支", + project_id: undefined, // 当前项目的id,也即开始发送合并请求的源项目id + merge_project_user: undefined }; } componentDidMount = () => { - this.getmergelist(); + const { projectsId } = this.props.match.params; + + this.getmergelist(projectsId); }; //获取新建分枝数据 - getmergelist = () => { - const { projectsId } = this.props.match.params; + getmergelist = (projectsId) => { + this.setState({isSpin: true}) const url = `/projects/${projectsId}/pull_requests/new.json`; axios .get(url) .then((result) => { if (result) { this.setState({ - data: result.data, + is_fork: result.data.is_fork, + projects_names: result.data.projects_names, + merge_projects: result.data.merge_projects, branches: result.data.branches, - origin_branches: result.data.branches, + merge_branches: result.data.branches, + project_id: result.data.project_id, }); + this.set_default_pull() + this.set_default_merge() } + this.setState({isSpin: false}) }) .catch((error) => { + this.setState({isSpin: false}) + console.log(error); + }); + }; + + set_default_pull = () => { + const {branches} = this.state; + let default_pull = branches.filter((e) => e.name === "master") + if (default_pull.length > 0){ + this.state.pull = default_pull[0].name + }else{ + this.state.pull = "master" + } + } + + set_default_merge = () => { + const {merge_branches} = this.state; + let default_merge = merge_branches.filter((e) => e.name === "master") + if (default_merge.length > 0){ + this.state.merge = default_merge[0].name + }else{ + this.state.merge = "master" + } + this.ischeckmerge(); + } + + newMergelist = (projectsId) => { + this.setState({isSpin: true}) + const url = `/projects/${projectsId}/pull_requests/get_branches.json`; + axios + .get(url) + .then((result) => { + if (result) { + this.setState({ + merge_branches: result.data + }) + this.set_default_merge() + } + this.setState({isSpin: false}) + }) + .catch((error) => { + this.setState({isSpin: false}) console.log(error); }); }; @@ -50,18 +106,37 @@ class NewMerge extends Component { this.ischeckmerge(); }; + selectProjectName = (value) => { + const { project_id, projects_names } = this.state; + + let is_fork_id = parseInt(value) !== parseInt(project_id) + this.setState({ + isSpin: true, + merge_head: is_fork_id, + data: { + is_original: is_fork_id, + fork_project_id: is_fork_id ? project_id : "", + merge_user_login: is_fork_id ? projects_names[0].project_user_login : undefined + } + }) + this.props.history.push(`/projects/${value}/merge/new`); + this.newMergelist(value); + + }; + //判断2分支是否可以合并 ischeckmerge = () => { this.setState({ isSpin: true }); const { projectsId } = this.props.match.params; - const { pull, merge } = this.state; + const { pull, merge, project_id, merge_head } = this.state; const url = `/projects/${projectsId}/pull_requests/check_can_merge.json`; axios .post(url, { - project_id: projectsId, - head: merge ? merge : "master", - base: pull ? pull : "master", + head: pull, + base: merge, + is_original: merge_head, + fork_project_id: merge_head ? project_id : undefined }) .then((result) => { if (result) { @@ -95,20 +170,38 @@ class NewMerge extends Component { const { data, branches, - origin_branches, + merge_branches, + merge_projects, pull, merge, isSpin, show_message, default_message, + merge_head, + projects_names, } = this.state; - - const renderBrances = (list) => { + const { projectsId } = this.props.match.params; + const renderBrances = (list, type) => { if (list && list.length > 0) { return list.map((item, key) => { return ( - + ); + }); + } + }; + + const renderProjectNames = (list) => { + if (list && list.length > 0) { + return list.map((item, key) => { + return ( + ); }); @@ -120,65 +213,77 @@ class NewMerge extends Component { }; return ( -
    +
    - -
    -
    -
    源分支:
    - - - - -
    -
    - -
    -
    -
    -
    目标分支:
    + +
    +
    +
    源分支:
    - +
    +
    + +
    +
    +
    +
    目标分支:
    + + + + +
    +
    -
    - {show_message ? ( -
    - -
    - ) - : - - } - + {show_message ? ( +
    + +
    + ) : ( + + )} +
    -
    + {/*
    -
    - +
    */}
    ); } diff --git a/src/forge/Merge/UpdateMerge.js b/src/forge/Merge/UpdateMerge.js index 3451766f..47377989 100644 --- a/src/forge/Merge/UpdateMerge.js +++ b/src/forge/Merge/UpdateMerge.js @@ -57,13 +57,13 @@ class UpdateMerge extends Component {
    源分支:
    + @@ -79,11 +79,10 @@ class UpdateMerge extends Component {
    目标分支:
    @@ -105,9 +104,9 @@ class UpdateMerge extends Component { )}
    -
    + {/*
    -
    +
    */}
    ); } diff --git a/src/forge/Merge/merge.js b/src/forge/Merge/merge.js index 83fa8ab5..b306d700 100644 --- a/src/forge/Merge/merge.js +++ b/src/forge/Merge/merge.js @@ -417,6 +417,7 @@ class merge extends Component { page={select_params.page} limit={select_params.limit} project_name={data.project_name} + project_author_name={data.project_author_name} {...this.props} {...this.state} > diff --git a/src/forge/Merge/merge_footer.js b/src/forge/Merge/merge_footer.js index d242cdbf..63627977 100644 --- a/src/forge/Merge/merge_footer.js +++ b/src/forge/Merge/merge_footer.js @@ -33,12 +33,12 @@ class MergeFooter extends Component { } - 提交} key="2"> + {/* 提交} key="2"> - - 文件} key="3"> + */} + {/* 文件} key="3"> - + */}
    ); diff --git a/src/forge/Merge/merge_form.js b/src/forge/Merge/merge_form.js index 9563e815..d98d15df 100644 --- a/src/forge/Merge/merge_form.js +++ b/src/forge/Merge/merge_form.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { Button, Form, Menu, Input, Select, Tag, Checkbox } from "antd"; +import { Button, Form, Menu, Input, Select, Tag, Checkbox, Spin } from "antd"; import axios from "axios"; import "../Order/order.css"; @@ -21,21 +21,55 @@ class MergeForm extends Component { mergedata: undefined, priority_id: undefined, title: undefined, + members: undefined, + issue_tags: undefined, + issue_versions: undefined, + issue_priories: undefined, }; } componentDidMount = () => { + this.check_is_login(); + this.get_default_selects(); this.set_defatul(); }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + }; + get_default_selects = () => { + const { projectsId } = this.props.match.params; + this.setState({ isSpin: true }); + axios + .get(`/projects/${projectsId}/pull_requests/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, + }); + } + 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[0], - fixed_version_id: String(data.fixed_version_id), - assigned_to_id: String(data.assigned_to_id), - priority_id: String(data.priority_id), + 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, title: data.title, }); } @@ -99,13 +133,13 @@ class MergeForm extends Component { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { const { projectsId, mergeId } = this.props.match.params; - const { merge, pull, merge_type } = this.props; + const { merge, pull, merge_type, data } = 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 = []; } - const { desc } = this.state; + const { desc } = this.state; if (merge_type === "new") { let url = `/projects/${projectsId}/pull_requests.json`; axios @@ -114,6 +148,9 @@ class MergeForm extends Component { body: desc, head: pull, base: merge, + is_original: data && data.is_original, + fork_project_id: data && data.fork_project_id, + merge_user_login: data && data.merge_user_login }) .then((result) => { if (result) { @@ -121,6 +158,8 @@ class MergeForm extends Component { isSpin: false, }); this.props.history.push(`/projects/${projectsId}/merge`); + const { getDetail } = this.props; + getDetail && getDetail(); } else { this.setState({ isSpin: false, @@ -136,30 +175,32 @@ class MergeForm extends Component { } else { let url = `/projects/${projectsId}/pull_requests/${mergeId}.json`; axios - .put(url, { - ...values, - body: desc, - head: pull, - base: merge, - }) - .then((result) => { - if (result) { + .put(url, { + ...values, + body: desc, + head: pull, + base: merge, + }) + .then((result) => { + if (result) { + this.setState({ + isSpin: false, + }); + this.props.history.push( + `/projects/${projectsId}/merge/${mergeId}/Messagecount` + ); + } else { + this.setState({ + isSpin: false, + }); + } + }) + .catch((error) => { this.setState({ isSpin: false, }); - this.props.history.push(`/projects/${projectsId}/merge/${mergeId}/Messagecount`); - } else { - this.setState({ - isSpin: false, - }); - } - }) - .catch((error) => { - this.setState({ - isSpin: false, + console.log(error); }); - console.log(error); - }); } } else { this.setState({ @@ -187,130 +228,136 @@ class MergeForm extends Component { desc, isSpin, title, + members, + issue_tags, + issue_versions, + issue_priories, } = this.state; return (
    -
    - - {merge_type === "new" ? "新建" : "编辑"}合并请求: - - - 可合并的 - -
    -
    -
    -
    - - {getFieldDecorator("title", { - rules: [ - { - required: true, - message: "请填写请求标题", - }, - ], - initialValue: title, - })()} - - -

    - - -

    -
    -
    -
    + +
    + + {merge_type === "new" ? "新建" : "编辑"}合并请求: + + + 可合并的 + +
    + +
    +
    - {getFieldDecorator("assigned_to_id", { - initialValue: assigned_to_id, - })( - - )} - - - {getFieldDecorator("fixed_version_id", { - initialValue: fixed_version_id, - })( - - )} - - - {getFieldDecorator("issue_tag_ids", { - initialValue: issue_tag_ids, - })( - - )} - - - {getFieldDecorator("priority_id", { - initialValue: priority_id, - })( - - )} - - - -
    - 必须审查代码 -
    -
    - 合并后删除提交分支 -
    -
    - 合并后关闭提到的任务 -
    -
    + {getFieldDecorator("title", { + rules: [ + { + required: true, + message: "请填写请求标题", + }, + ], + initialValue: title, + })()}
    + +

    + + +

    +
    +
    +
    + + {getFieldDecorator("assigned_to_id", { + initialValue: assigned_to_id, + })( + + )} + + + {getFieldDecorator("fixed_version_id", { + initialValue: fixed_version_id, + })( + + )} + + + {getFieldDecorator("issue_tag_ids", { + initialValue: issue_tag_ids, + })( + + )} + + + {getFieldDecorator("priority_id", { + initialValue: priority_id, + })( + + )} + + + +
    + 必须审查代码 +
    +
    + 合并后删除提交分支 +
    +
    + 合并后关闭提到的任务 +
    +
    +
    +
    -
    - + +
    ); } diff --git a/src/forge/Merge/no_data.js b/src/forge/Merge/no_data.js index d7764339..81c65f50 100644 --- a/src/forge/Merge/no_data.js +++ b/src/forge/Merge/no_data.js @@ -7,7 +7,7 @@ class Nodata extends Component{
    - +

    欢迎使用合并请求!

    diff --git a/src/forge/New/Index.js b/src/forge/New/Index.js index ca4e970f..9e293c45 100644 --- a/src/forge/New/Index.js +++ b/src/forge/New/Index.js @@ -41,21 +41,22 @@ class Index extends Component { ignore_name: undefined } } - getUserInfo = () => { - const url = `/users/me.json`; - axios.get(url).then(result => { - if (result && result.data.login) { - this.setState({ - current_user: result.data - }) - this.getDetail(); - } - }).catch(error => { - console.log(error) - }) - } + // getUserInfo = () => { + // const url = `/users/me.json`; + // axios.get(url).then(result => { + // if (result && result.data.login) { + // this.setState({ + // current_user: result.data + // }) + // this.getDetail(); + // } + // }).catch(error => { + // console.log(error) + // }) + // } componentDidMount = () => { // this.getUserInfo(); + this.check_is_login() // 获取项目类别 this.getCategory(); // 获取项目语言 @@ -64,6 +65,14 @@ class Index extends Component { this.getGitignore(); // 获取开源许可证 this.getLicenses(); + + } + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } } getCategory = () => { const url = `/project_categories.json` diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js index 78b9a99e..5ab142d2 100644 --- a/src/forge/Newfile/UserSubmitComponent.js +++ b/src/forge/Newfile/UserSubmitComponent.js @@ -55,6 +55,10 @@ class UserSubmitComponent extends Component { : `/projects/${projectsId}/coders`; this.props.history.push(url); this.props.showNotification("文件新建成功!"); + if(submitType === "1"){ + const { getDetail } = this.props; + getDetail && getDetail(); + } } }) .catch((error) => { diff --git a/src/forge/Order/newMilepost.js b/src/forge/Order/newMilepost.js index 7fca5fae..0a5435a6 100644 --- a/src/forge/Order/newMilepost.js +++ b/src/forge/Order/newMilepost.js @@ -17,6 +17,17 @@ class NewMilepost extends Component { } } + componentDidMount = () => { + this.check_is_login(); + }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + }; + onPanelChange = (time, mode) => { this.setState({ value: time diff --git a/src/forge/Order/order_form.js b/src/forge/Order/order_form.js index 37386b43..50a8259b 100644 --- a/src/forge/Order/order_form.js +++ b/src/forge/Order/order_form.js @@ -38,9 +38,17 @@ class order_form extends Component { } componentDidMount = () => { + this.check_is_login() this.getSelectList(); this.get_detail(); }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + } get_detail = () => { const { form_type } = this.props; if (form_type === "new") { diff --git a/src/forge/Settings/Collaborator.js b/src/forge/Settings/Collaborator.js index e3d23791..ab972947 100644 --- a/src/forge/Settings/Collaborator.js +++ b/src/forge/Settings/Collaborator.js @@ -56,11 +56,20 @@ class Collaborator extends Component { } componentDidMount = () => { + this.check_is_login() if (this.props.project_id) { this.getMember(); } }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + }; + componentDidUpdate = (prevState) => { if ( this.props.project_id && diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index 8d91fed1..4dfa888d 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -19,10 +19,18 @@ class Setting extends Component { } componentDidMount = () => { + this.check_is_login() this.getCategory(); this.getLanguage(); this.getInfo(); }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + }; getLanguage = () => { const url = `/project_languages.json`; axios diff --git a/src/forge/Settings/new_tags.js b/src/forge/Settings/new_tags.js index e808d8d3..87a08fa9 100644 --- a/src/forge/Settings/new_tags.js +++ b/src/forge/Settings/new_tags.js @@ -51,8 +51,16 @@ class NewTags extends Component { } componentDidMount = () => { + this.check_is_login(); this.getList(); }; + check_is_login =() =>{ + const { current_user } = this.props; + if(!current_user){ + this.props.history.push("/403") + return + } + }; getList = (page, order_name, order_type) => { const { projectsId } = this.props.match.params;