forked from Gitlink/forgeplus-react
fork-over
This commit is contained in:
parent
2c52c45e76
commit
c9059623dd
|
@ -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",
|
||||
|
|
|
@ -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 (
|
||||
<div>
|
||||
<ForkSelfModal visible={forkSelfVisible} onCancel={()=>{this.setState({forkSelfVisible:false})}} onSuccess={this.forkSelfSuccess}/>
|
||||
<ForkSelfModal
|
||||
visible={forkSelfVisible}
|
||||
onCancel={()=>{this.setState({forkSelfVisible:false})}}
|
||||
onSuccess={this.forkSelfSuccess}
|
||||
projectsId={projectsId}
|
||||
projectName={projectDetail && projectDetail.name}
|
||||
owner={owner}
|
||||
/>
|
||||
<div className="detailHeader-wrapper">
|
||||
<div className="normal">
|
||||
<AlignTop style={{ padding: "18px 0px 10px", justifyContent: "space-between" }}>
|
||||
|
|
|
@ -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(
|
||||
<Modal
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
title={'Fork项目'}
|
||||
closable
|
||||
width="648px"
|
||||
maskClosable={false}
|
||||
centered
|
||||
footer={null}
|
||||
wrapClassName="forkModal"
|
||||
onCancel={onCancel}
|
||||
>
|
||||
<div className="self_box">
|
||||
<p style={{color:"#1f2329",fontSize:"15px"}}>您希望将项目Fork至何处?</p>
|
||||
<div className="self_b_list">
|
||||
<div className="self_b_card">
|
||||
<ul className="s_b_ul">
|
||||
<img className="info_img" src="https://testforgeplus.trustie.net/images/avatars/User/36480?t=1686645429" alt="" />
|
||||
<li>
|
||||
<p style={{marginBottom:'10px!important'}}>
|
||||
<span className="s_info_name">蒋宇航</span>
|
||||
<span className="s_info_tag onwer">个人</span>
|
||||
<span style={{color:'rgba(216, 98, 7, 1)',marginLeft:"12px"}}><i className="iconfont icon-erciqueren_icon mr3 font-15"></i>存在同名/同标识项目</span>
|
||||
</p>
|
||||
<p style={{color:'#4c5b76'}}>handsome@qq.com</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<p style={{color:'#202d40',marginTop:'18px'}}>当前用户已存在同名/同标识项目:<a className="color-blue">https://www.gitlink.org.cn/forgeplus/issues/2615</a>请使用/修改新项目名称与标识完成本次fork</p>
|
||||
</div>
|
||||
<Spin spinning={isSpin}>
|
||||
<div className="self_box">
|
||||
{/* <p style={{color:"#1f2329",fontSize:"15px"}}>您希望将项目Fork至何处?</p> */}
|
||||
<div className="self_b_list">
|
||||
{
|
||||
userList && userList.login &&
|
||||
<div className="self_b_card">
|
||||
<ul className="s_b_ul">
|
||||
<img className="info_img" src={getImageUrl(userList.image_url)} alt="" />
|
||||
<li>
|
||||
<p style={{marginBottom:'10px!important'}}>
|
||||
<span className="s_info_name">{userList.name}</span>
|
||||
<span className="s_info_tag onwer">个人</span>
|
||||
{userList.forked && <span style={{color:'rgba(216, 98, 7, 1)',marginLeft:"12px"}}><i className="iconfont icon-erciqueren_icon mr3 font-15"></i>存在同名/同标识项目</span> }
|
||||
</p>
|
||||
{userList.mail && <p className="mt3" style={{color:'#4c5b76'}}>{userList.mail}</p> }
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<p style={{color:'#202d40',marginTop:'18px'}}>当前用户已存在同名/同标识项目:<a href={`${window.location.hostname}${window.location.port==3007?":3007":""}/${owner}/${projectsId}`} target="_blank" className="color-blue">{window.location.hostname}{window.location.port==3007?":3007":""}/{owner}/{projectsId}</a> 请使用/修改新项目名称与标识完成本次fork</p>
|
||||
<Form
|
||||
className="new_fork_form"
|
||||
layout={"vertical"}
|
||||
>
|
||||
<Form.Item label="新项目名称">
|
||||
{getFieldDecorator('project_name',{
|
||||
rules:[
|
||||
{
|
||||
required:true,
|
||||
message:"请输入新项目名称"
|
||||
}
|
||||
],
|
||||
validateTrigger:"onInput",
|
||||
})(<Input size="middle" placeholder="请输入新项目名称"/>)}
|
||||
</Form.Item>
|
||||
<Form.Item label="新项目标识">
|
||||
{getFieldDecorator('project_identify', {
|
||||
rules: [
|
||||
{
|
||||
required:true,
|
||||
message:"请输入新项目标识"
|
||||
},
|
||||
{
|
||||
validator: identifyConfirm
|
||||
}
|
||||
]
|
||||
})(
|
||||
<Input size="middle" placeholder="请输入新项目标识" />,
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
{/* {
|
||||
organizationsList && organizationsList.length > 0 &&
|
||||
organizationsList.map((i,k)=>{
|
||||
return(
|
||||
<div className="self_b_card">
|
||||
<ul className="s_b_ul">
|
||||
<img className="info_img" src={getImageUrl(i.avatar_url)} alt="" />
|
||||
<li>
|
||||
<p style={{marginBottom:'10px!important'}}>
|
||||
<span className="s_info_name">{i.nickname}</span>
|
||||
<span className="s_info_tag org">组织</span>
|
||||
{i.forked && <span style={{color:'rgba(216, 98, 7, 1)',marginLeft:"12px"}}><i className="iconfont icon-erciqueren_icon mr3 font-15"></i>存在同名/同标识项目</span> }
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
} */}
|
||||
</div>
|
||||
<div className="fork_modal_foot">
|
||||
<Button onClick={onCancel} className="mr20" style={{width:"95px"}}>取消</Button>
|
||||
<Button type={"primary"} onClick={sureFunc} className="ml20" style={{width:"95px"}}>确定</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default ForkSelfModal;
|
||||
export default Form.create({ name: 'ForkSelfModal' })(ForkSelfModal);
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue