diff --git a/package-lock.json b/package-lock.json index 318e116c..71c63968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -980,6 +980,13 @@ "lodash.throttle": "^4.1.1", "resize-observer-polyfill": "^1.5.1", "screenfull": "^5.0.0" + }, + "dependencies": { + "intersection-observer": { + "version": "0.7.0", + "resolved": "https://registry.npmmirror.com/intersection-observer/-/intersection-observer-0.7.0.tgz", + "integrity": "sha512-Id0Fij0HsB/vKWGeBe9PxeY45ttRiBmhFyyt/geBdDHBYNctMRTE3dC1U3ujzz3lap+hVXlEcVaB56kZP/eEUg==" + } } }, "ajv": { @@ -9478,9 +9485,9 @@ "dev": true }, "intersection-observer": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/intersection-observer/-/intersection-observer-0.7.0.tgz", - "integrity": "sha512-Id0Fij0HsB/vKWGeBe9PxeY45ttRiBmhFyyt/geBdDHBYNctMRTE3dC1U3ujzz3lap+hVXlEcVaB56kZP/eEUg==" + "version": "0.12.2", + "resolved": "https://registry.npmmirror.com/intersection-observer/-/intersection-observer-0.12.2.tgz", + "integrity": "sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==" }, "invariant": { "version": "2.2.4", @@ -16459,6 +16466,11 @@ "resolved": "https://registry.npmjs.org/scroll-into-view/-/scroll-into-view-1.16.2.tgz", "integrity": "sha512-vyTE0i27o6eldt9xinjHec41Dw05y+faoI+s2zNKJAVOdbA5M2XZrYq/obJ8E+QDQulJ2gDjgui9w9m9RZSRng==" }, + "scrollama": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/scrollama/-/scrollama-3.2.0.tgz", + "integrity": "sha512-PIPwB1kYBnbw/ezvPBJa5dCN5qEwokfpAkI3BmpZWAwcVID4nDf1qH6WV16A2fQaJmsKx0un5S/zhxN+PQeKDQ==" + }, "scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmmirror.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index d90afec6..dbdd83ab 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -473,8 +473,8 @@ class Detail extends Component { /*** * fork自己的项目,弹窗确定按钮方法 */ - forkSelfSuccess=()=>{ - + forkSelfSuccess=(new_name,new_identifier)=>{ + this.forkFunc(new_name,new_identifier); } /*** @@ -487,27 +487,25 @@ class Detail extends Component { } // fork项目 - forkFunc = () => { - - if(true){ - this.forkSelfFunc(); - return; - } - + forkFunc = (new_name,new_identifier) => { + const { projectsId, owner } = this.props.match.params; const { platform } = this.state; if (!platform) return; this.setState({ forkSpin: true }) - const { current_user } = this.props - const { projectsId, owner } = this.props.match.params; + const { current_user } = this.props; + let params = {}; + if(new_name && new_identifier){ + params = {new_name,new_identifier} + } const url = `/${owner}/${projectsId}/forks.json`; - axios.post(url).then(result => { + axios.post(url,{...params}).then(result => { + if (result && result.data.status === -2) { + this.forkSelfFunc(); + return; + } if (result && result.data.status === 0) { - if (result.data.message === "fork失败,你已拥有了这个项目") { - this.props.history.push(`/${current_user && current_user.login}/${projectsId}`); - return; - } this.props.history.push(`/${current_user && current_user.login}/${result.data.identifier}`); this.props.showNotification(result.data.message); this.props.showNpsModal("indexProject", 3); @@ -575,7 +573,14 @@ class Detail extends Component { } return (
- {this.setState({forkSelfVisible:false})}} onSuccess={this.forkSelfSuccess}/> + {this.setState({forkSelfVisible:false})}} + onSuccess={this.forkSelfSuccess} + projectsId={projectsId} + projectName={projectDetail && projectDetail.name} + owner={owner} + />
diff --git a/src/forge/Main/fork/index.jsx b/src/forge/Main/fork/index.jsx index 384beeeb..c54a2dd8 100644 --- a/src/forge/Main/fork/index.jsx +++ b/src/forge/Main/fork/index.jsx @@ -1,41 +1,148 @@ import React ,{ useEffect , useState } from 'react'; -import { Modal , Form } from 'antd'; +import { Modal , Form , Input, Button , Spin } from 'antd'; import './index.scss'; +import axios from 'axios'; +import { getImageUrl } from 'educoder'; function ForkSelfModal(props){ - const { visible , onCancel , onSuccess } = props; + const { form } = props; + const { visible , onCancel , onSuccess , projectsId , owner , projectName } = props; + const { getFieldDecorator, validateFields , setFieldsValue } = form; + + const [ isSpin , setIsSpin ] = useState(false); + const [ userList, setUserList] = useState(undefined); + // const [ organizationsList, setOrganizationsList] = useState(undefined); + + + useEffect(()=>{ + if(visible && owner && projectsId){ + setIsSpin(true); + const url = `/${owner}/${projectsId}/forks/fork_list.json`; + axios.get(url).then(response=>{ + if(response){ + setUserList(response.data.user); + setIsSpin(false); + // setOrganizationsList(response.data.organizations); + setFieldsValue({ + project_identify:`${projectsId}_1`, + project_name:`${projectName}_1` + }) + } + }).catch(error=>{}) + } + },[visible,owner,projectsId]) + + function sureFunc(){ + validateFields((error,values)=>{ + if(!error){ + onSuccess(values.project_name,values.project_identify); + } + }) + } + + function identifyConfirm(rule, value, callback){ + if(value){ + if(value === projectsId){ + callback("您已fork相同标识的项目!"); + } + } + callback(); + } return( -
-

您希望将项目Fork至何处?

-
-
-
    - -
  • -

    - 蒋宇航 - 个人 - 存在同名/同标识项目 -

    -

    handsome@qq.com

    -
  • -
-
-

当前用户已存在同名/同标识项目:https://www.gitlink.org.cn/forgeplus/issues/2615请使用/修改新项目名称与标识完成本次fork

-
+ +
+ {/*

您希望将项目Fork至何处?

*/} +
+ { + userList && userList.login && +
+
    + +
  • +

    + {userList.name} + 个人 + {userList.forked && 存在同名/同标识项目 } +

    + {userList.mail &&

    {userList.mail}

    } +
  • +
+
+

当前用户已存在同名/同标识项目:{window.location.hostname}{window.location.port==3007?":3007":""}/{owner}/{projectsId} 请使用/修改新项目名称与标识完成本次fork

+
+ + {getFieldDecorator('project_name',{ + rules:[ + { + required:true, + message:"请输入新项目名称" + } + ], + validateTrigger:"onInput", + })()} + + + {getFieldDecorator('project_identify', { + rules: [ + { + required:true, + message:"请输入新项目标识" + }, + { + validator: identifyConfirm + } + ] + })( + , + )} + +
+
+
+ } + {/* { + organizationsList && organizationsList.length > 0 && + organizationsList.map((i,k)=>{ + return( +
+
    + +
  • +

    + {i.nickname} + 组织 + {i.forked && 存在同名/同标识项目 } +

    +
  • +
+
+ ) + }) + } */} +
+
+ +
-
+ ) } -export default ForkSelfModal; \ No newline at end of file +export default Form.create({ name: 'ForkSelfModal' })(ForkSelfModal); \ No newline at end of file diff --git a/src/forge/Main/fork/index.scss b/src/forge/Main/fork/index.scss index 51e4b04c..8cc5d435 100644 --- a/src/forge/Main/fork/index.scss +++ b/src/forge/Main/fork/index.scss @@ -1,10 +1,49 @@ +.forkModal{ + .ant-modal-body{ + padding:0px!important; + position: relative; + } +} .self_box{ + height: 410px; + overflow-y: auto; + padding:20px; + .fork_modal_foot{ + position: absolute; + width: 100%; + bottom: 0px; + left: 0px; + padding:25px 0px; + background-color: #fff; + text-align: center; + } .self_b_list{ .self_b_card{ padding:18px 13px; border:1px solid rgba(158, 169, 185, 0.23); border-radius:4px; margin-top: 15px; + cursor: pointer; + .new_fork_form{ + display: flex; + align-items: flex-start; + justify-content: space-between; + margin-top: 20px; + .ant-row.ant-form-item{ + margin-bottom: 0px!important; + width: 42%; + } + .ant-form-explain{ + position: absolute; + } + } + &:hover{ + background-color:rgba(202, 211, 224, 0.18); + } + &.active{ + border-color: rgba(70, 106, 255, 1); + background-color:rgba(70, 106, 255, 0.05); + } .s_b_ul{ display: flex; align-items: center;