forked from Gitlink/forgeplus-react
Merge remote-tracking branch 'upstream/feature_reposyncer' into gitlink_ssr_head
This commit is contained in:
commit
e936bf156b
|
|
@ -55,9 +55,9 @@ function DeleteBox({owner, projectsId, visible, setVisible, branchList, reload,
|
|||
<Form {...formItemLayout}>
|
||||
{repoTypes.length > 1 && <Form.Item label="同步仓库平台" className="storeFormItem">
|
||||
{getFieldDecorator("type",{
|
||||
rules:[],
|
||||
rules:[{required:true,message:`请选择同步仓库平台`}],
|
||||
})(
|
||||
<Select placeholder="请选择" onChange={(value)=>{
|
||||
<Select placeholder="请选择同步仓库平台" onChange={(value)=>{
|
||||
setPlatform(value)
|
||||
}}>
|
||||
<Select.Option value="Github"><img src={gitHub} alt="" className="storeLogo mr5"/>Github</Select.Option>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function EditStore(props){
|
|||
const { form, history, storeDetail} = props;
|
||||
const {sync_repositories_unique=[]} = storeDetail || {};
|
||||
const { owner , projectsId } = props.match.params;
|
||||
const { getFieldDecorator, validateFields , setFieldsValue, setFields, getFieldsValue } = form;
|
||||
const { getFieldDecorator, validateFields , resetFields, setFields, getFieldsValue } = form;
|
||||
const [step, setStep] = useState(0);
|
||||
// 仓库分支列表
|
||||
const [branchList, setBranchList] = useState();
|
||||
|
|
@ -71,7 +71,7 @@ function EditStore(props){
|
|||
// 选择仓库类型
|
||||
const [platform, setPlatform] = useState();
|
||||
// 全部分支/单个分支
|
||||
const [branch, setBranch] = useState(undefined);
|
||||
const [branch, setBranch] = useState("2");
|
||||
const [visible, setVisible] = useState();
|
||||
const stepList = [{
|
||||
step: 0,
|
||||
|
|
@ -110,18 +110,15 @@ function EditStore(props){
|
|||
}, [])
|
||||
|
||||
function submit() {
|
||||
validateFields((error,values)=>{
|
||||
if(!error){
|
||||
values["type"] = `SyncRepositories::${values.type}`
|
||||
axios.post(`/v1/${owner}/${projectsId}/sync_repositories.json`, values).then(res=>{
|
||||
if(res && res.status === 200){
|
||||
setVisible(false);
|
||||
message.success('绑定成功');
|
||||
window.location.href = `/${owner}/${projectsId}/service/reposyncer`;
|
||||
}else{
|
||||
message.error('绑定失败');
|
||||
}
|
||||
})
|
||||
const values = getFieldsValue();
|
||||
values["type"] = `SyncRepositories::${values.type}`
|
||||
axios.post(`/v1/${owner}/${projectsId}/sync_repositories.json`, values).then(res=>{
|
||||
if(res && res.status === 200){
|
||||
setVisible(false);
|
||||
message.success('绑定成功');
|
||||
window.location.href = `/${owner}/${projectsId}/service/reposyncer`;
|
||||
}else{
|
||||
message.error('绑定失败');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -175,7 +172,8 @@ function EditStore(props){
|
|||
initialValue: values.type
|
||||
})(
|
||||
<Select placeholder="请选择" onChange={(value)=>{
|
||||
setPlatform(value)
|
||||
resetFields();
|
||||
setPlatform(value);
|
||||
}}>
|
||||
{/* <Select.Option value="Github"><img src={github} alt="" className="storeLogo mr5"/>Github</Select.Option>
|
||||
<Select.Option value="Gitee"><img src={gitee} alt="" className="storeLogo mr5"/>Gitee</Select.Option> */}
|
||||
|
|
@ -188,7 +186,7 @@ function EditStore(props){
|
|||
<Form.Item label={`${platform}同步仓库地址`} className="storeFormItem" hidden={step || !platform}>
|
||||
{getFieldDecorator("external_repo_address",{
|
||||
rules:[
|
||||
{required:true,message: `请输入${platform}同步仓库地址`},
|
||||
{required:true,message: `请输入${platform || ""}同步仓库地址`},
|
||||
{pattern: pattern, message: `请输入${platform}可访问的仓库地址`}
|
||||
],
|
||||
initialValue: values.external_repo_address
|
||||
|
|
@ -198,7 +196,7 @@ function EditStore(props){
|
|||
</Form.Item>
|
||||
<Form.Item label={`${platform}同步仓库授权验证`} className="storeFormItem" hidden={step || !platform}>
|
||||
{getFieldDecorator("external_token",{
|
||||
rules:[{required:true,message: `请输入${platform}的授权token`}],
|
||||
rules:[{required:true,message: `请输入${platform || ""}授权token`}],
|
||||
initialValue: values.external_token
|
||||
})(
|
||||
<Input addonBefore="token" placeholder={`请输入${platform}的授权token`} className="storeInput" maxLength={300}/>
|
||||
|
|
@ -210,16 +208,19 @@ function EditStore(props){
|
|||
<Button type="primary" ghost>点击授权</Button>
|
||||
</div>} */}
|
||||
<div className="mt30">
|
||||
<Button type="primary" className="mr30" style={{width: '100px'}} onClick={()=>{
|
||||
<Button style={{width: '100px'}} onClick={()=>{history.go(-1)}} className="mr30">返回</Button>
|
||||
<Button type="primary" style={{width: '100px'}} onClick={()=>{
|
||||
// 保存用户已经输入的值
|
||||
const {type, external_repo_address, external_token} = getFieldsValue();
|
||||
setValues({
|
||||
...values,
|
||||
type, external_repo_address, external_token
|
||||
validateFields(['type', 'external_repo_address', 'external_token'], (error, formValues )=>{
|
||||
if(!error){
|
||||
setStep(1);
|
||||
setValues({
|
||||
...values,
|
||||
...formValues
|
||||
})
|
||||
}
|
||||
})
|
||||
setStep(1);
|
||||
}}>下一步</Button>
|
||||
<Button style={{width: '100px'}} onClick={()=>{history.go(-1)}}>返回</Button>
|
||||
</div>
|
||||
</div>}
|
||||
{/* 第二步 */}
|
||||
|
|
@ -247,8 +248,8 @@ function EditStore(props){
|
|||
}}>点击前往</Button><br/>
|
||||
4、完成配置
|
||||
<div className="mt30">
|
||||
<Button type="primary" className="mr30" style={{width: '100px'}} onClick={()=>{setStep(2)}}>下一步</Button>
|
||||
<Button style={{width: '100px'}} onClick={()=>{setStep(0)}}>上一步</Button>
|
||||
<Button style={{width: '100px'}} onClick={()=>{setStep(0)}} className="mr30">上一步</Button>
|
||||
<Button type="primary" style={{width: '100px'}} onClick={()=>{setStep(2)}}>下一步</Button>
|
||||
</div>
|
||||
</div>}
|
||||
{/* 第三步 */}
|
||||
|
|
@ -256,7 +257,9 @@ function EditStore(props){
|
|||
<div className="color-grey-6 mb15">请绑定同步分支</div>
|
||||
<Form.Item>
|
||||
{getFieldDecorator("sync_granularity",{
|
||||
rules:[]
|
||||
rules:[],
|
||||
// initialValue: values.sync_granularity
|
||||
initialValue: "2"
|
||||
})(
|
||||
<Radio.Group onChange={(e)=>{
|
||||
const {external_repo_address} = values;
|
||||
|
|
@ -273,14 +276,16 @@ function EditStore(props){
|
|||
</Form.Item>
|
||||
{branch === "2" && <Form.Item label={`${platform}分支`} {...formItemLayout}>
|
||||
{getFieldDecorator("external_branch_name",{
|
||||
rules:[{required:true,message:`请输入${platform}分支名称`}]
|
||||
rules:[{required:true,message:`请输入${platform}分支名称`}],
|
||||
initialValue: values.external_branch_name
|
||||
})(
|
||||
<Input placeholder={`请输入${platform}分支名称`} className="storeInput" maxLength={50}/>
|
||||
)}
|
||||
</Form.Item>}
|
||||
{branch === "2" && <Form.Item label="Gitlink分支" {...formItemLayout}>
|
||||
{getFieldDecorator("gitlink_branch_name",{
|
||||
rules:[{required:true,message:"请选择Gitlink仓库分支"}]
|
||||
rules:[{required:true,message:"请选择Gitlink仓库分支"}],
|
||||
initialValue: values.gitlink_branch_name
|
||||
})(
|
||||
<Select placeholder="请选择Gitlink仓库分支">
|
||||
{branchList && branchList.map(item=>{
|
||||
|
|
@ -293,7 +298,8 @@ function EditStore(props){
|
|||
{branch && <div style={{display: 'flex', alignItems: "center"}}>
|
||||
<Form.Item label="首次同步方向:" {...formItemLayout}>
|
||||
{getFieldDecorator("first_sync_direction",{
|
||||
rules:[{required:true,message:"请选择首次同步方向"}]
|
||||
rules:[{required:true,message:"请选择首次同步方向"}],
|
||||
initialValue: values.first_sync_direction
|
||||
})(
|
||||
<Select placeholder="请选择首次同步方向">
|
||||
<Select.Option value="2">{platform}同步至GitLink</Select.Option>
|
||||
|
|
@ -304,15 +310,18 @@ function EditStore(props){
|
|||
{synchronizeTips}
|
||||
</div>}
|
||||
<div className="mt30">
|
||||
{branch && <Button type="primary" className="mr30" style={{width: '100px'}} onClick={()=>{
|
||||
saveStep3Info();
|
||||
setVisible(true);
|
||||
// submit();
|
||||
}}>确认绑定</Button>}
|
||||
<Button style={{width: '100px'}} onClick={()=>{
|
||||
<Button style={{width: '100px'}} className="mr30" onClick={()=>{
|
||||
saveStep3Info();
|
||||
setStep(1)
|
||||
}}>上一步</Button>
|
||||
{branch && <Button type="primary" style={{width: '100px'}} onClick={()=>{
|
||||
saveStep3Info();
|
||||
validateFields((error,values)=>{
|
||||
if(!error){
|
||||
setVisible(true);
|
||||
}
|
||||
})
|
||||
}}>确认绑定</Button>}
|
||||
</div>
|
||||
</div>}
|
||||
{/* <div className="storeTitle pb10 mb15"><img src={gitHub} alt="" className="storeLogo"/></div>
|
||||
|
|
|
|||
|
|
@ -51,13 +51,12 @@ function RecordList(props){
|
|||
addonAfter={<a className="primaryColor" onClick={inviteClick}>复制链接</a>}
|
||||
/>
|
||||
<div className="font-15 mt20 mb7">同步仓库授权</div>
|
||||
<Input addonBefore="token" placeholder={`请输入${type.split("::")[1]}的授权token`} style={{width: '60%'}} defaultValue={item.external_token} maxLength={300} onChange={(e)=>{
|
||||
<Input.Password addonBefore="token" placeholder={`请输入${type.split("::")[1]}的授权token`} style={{width: '60%'}} defaultValue={item.external_token} maxLength={300} onChange={(e)=>{
|
||||
const objs = {...token}
|
||||
objs[external_repo_address] = e.target.value
|
||||
setToken(objs);
|
||||
}}/>
|
||||
<Button type="primary" className="ml30" onClick={()=>{
|
||||
console.log('更新', token[external_repo_address]);
|
||||
const external_token = token[external_repo_address]
|
||||
if(external_token){
|
||||
axios.post(`/v1/${owner}/${projectsId}/sync_repositories/update_info.json?sync_repository_ids=${sync_repository_ids.toString()}`, {
|
||||
|
|
|
|||
|
|
@ -99,9 +99,10 @@ function StoreList(props){
|
|||
|
||||
// 修改分支同步状态(开启/暂停)
|
||||
function updateBranchRnable(branchInfo){
|
||||
const {gitlink_branch_name, external_branch_name, enable, first_sync_direction} = branchInfo;
|
||||
const {gitlink_branch_name, external_branch_name, enable, first_sync_direction, type} = branchInfo;
|
||||
axios.post(`/v1/${owner}/${projectsId}/sync_repositories/change_enable.json`, {
|
||||
gitlink_branch_name, external_branch_name, first_sync_direction,
|
||||
repo_type: type,
|
||||
enable: new Boolean(!enable).toString()
|
||||
}).then(res=>{
|
||||
if(res && res.data && !res.data.status){
|
||||
|
|
@ -125,7 +126,7 @@ function StoreList(props){
|
|||
</span> },
|
||||
{ title: 'GitLink分支', dataIndex: 'gitlink_branch_name', className:"recordColumns"},
|
||||
{ title: '最后一次同步时间', dataIndex: 'sync_time', className:"primaryColor recordColumns"},
|
||||
{ title: '同步状态', dataIndex: 'sync_status', className:"recordColumns", render: (text)=>text === "failure" ? <Badge status="error" text="失败" className="deleteRecord"/> : <Badge status="success" text="成功" className="success"/>},
|
||||
{ title: '同步状态', dataIndex: 'sync_status', className:"recordColumns", render: (text)=>text === "failure" ? <Badge status="error" text="失败" className="deleteRecord"/> : text === "success" ? <Badge status="success" text="成功" className="success"/> : ""},
|
||||
{ title: '操作', dataIndex: 'enable', align: 'center', className:"primaryColor recordColumns", render: (text, item)=>{
|
||||
const branch = item[platform === 'GitHub' ? 'github_branch': 'gitee_branch']
|
||||
return <div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue