代码克隆检测
This commit is contained in:
parent
9ed4e94d3b
commit
ae3bb79ac4
|
|
@ -12,7 +12,6 @@ import axios from 'axios';
|
|||
import Path from './CoderDepotPath';
|
||||
import Catalogue from './CoderDepotCatalogue';
|
||||
import ReadMe from './CoderDepotReadme';
|
||||
// import CoderRootFileDetail from './CoderRootFileDetail';
|
||||
import './Index.scss';
|
||||
import Releases from '../Component/Releases';
|
||||
import Contributors from '../Component/Contributors';
|
||||
|
|
@ -21,12 +20,12 @@ import DrawerPanel from '../Component/DrawerPanel';
|
|||
import UpdateDescModal from './sub/UpdateDescModal';
|
||||
import Nodata from '../Nodata';
|
||||
import Invite from './sub/Invite';
|
||||
import RenderHtml from '../../components/render-html';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../Loading';
|
||||
import ProjectPortrait from '../Component/projectPortrait';
|
||||
import imNoneImg from './img/importNone.png';
|
||||
import LicenseModal from '../Component/licenseModal/index';
|
||||
import CheckModal from './Modal/checkModal';
|
||||
import moment from 'moment';
|
||||
|
||||
const ProjectCompass = Loadable({
|
||||
|
|
@ -78,9 +77,11 @@ function CoderDepot(props){
|
|||
const [ issuesFlag , setIssuesFlag ] = useState(true);
|
||||
const [ releaseVersions , setReleaseVersions] = useState(undefined);
|
||||
const [ licenseVisible ,setLicenseVisible] = useState(false);
|
||||
const [ checkVisible ,setCheckVisible] = useState(false);
|
||||
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
|
||||
let branchName = props.match.params.branchName;
|
||||
branchName = returnbar(branchName);
|
||||
let pathname = props.history.location.pathname;
|
||||
|
|
@ -438,6 +439,7 @@ function CoderDepot(props){
|
|||
const fileOperate = type === "dir" && projectDetail && projectDetail.type !==2 && ((projectDetail.permission && projectDetail.permission !=="Reporter") || (current_user && current_user.admin));
|
||||
return(
|
||||
<div className='WhiteBack'>
|
||||
<CheckModal owner={owner} projectsId={projectsId} visible={checkVisible} onCancel={()=>setCheckVisible(false)}/>
|
||||
{mirror_status ===0 && <UpdateDescModal desc={desc} website={website} lesson_url={lesson_url} topicsInfo={topics} visible={openModal} onCancel={()=>setOpenModal(false)} onOk={okUpdate}/> }
|
||||
<LicenseModal visible={licenseVisible} onCancel={()=>{setLicenseVisible(false)}} createDefaultLicense={createDefaultLicense}/>
|
||||
<Spin spinning={isSpin}>
|
||||
|
|
@ -548,10 +550,14 @@ function CoderDepot(props){
|
|||
</div>
|
||||
<div className="depotBtn AlignCenter">
|
||||
<div className="addOptionBtn">
|
||||
{
|
||||
baseOperate &&
|
||||
<CheckProfile {...props} sureFunc={compare}>+ 合并请求</CheckProfile>
|
||||
}
|
||||
{
|
||||
projectDetail && projectDetail.permission && projectDetail.permission !=="Reporter" &&
|
||||
<a style={{width:"110px"}} onClick={()=>{setCheckVisible(true)}}>代码克隆检测</a>
|
||||
}
|
||||
{
|
||||
baseOperate &&
|
||||
<CheckProfile {...props} sureFunc={compare}>+ 合并请求</CheckProfile>
|
||||
}
|
||||
{
|
||||
issuesFlag &&
|
||||
<CheckProfile {...props} sureFunc={createIssue} checklogin>+ 疑修</CheckProfile>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
import React , { useState , forwardRef } from 'react';
|
||||
import { Button, message, Modal , Form , Input , Select} from 'antd';
|
||||
import CloneLogo from '../img/cloneLogo.png';
|
||||
import '../Index.scss';
|
||||
import './index.scss';
|
||||
import axios from 'axios';
|
||||
const { Option } = Select;
|
||||
|
||||
function CheckModal(props){
|
||||
const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form;
|
||||
const { visible , onCancel , owner, projectsId } = props;
|
||||
const [ loading , setLoading ] = useState(false);
|
||||
|
||||
const [ language , setLanguage ] = useState(["C","Java","Python","C#","C++","PHP","Ruby","Swift","JavaScript","TypeScript","Lisp","Pascal"])
|
||||
|
||||
function beginFunc(){
|
||||
validateFields((error,values)=>{
|
||||
if(!error){
|
||||
setLoading(true);
|
||||
const url = `/api/${owner}/${projectsId}/clone_detection.json`;
|
||||
axios.post(url,{...values}).then(res=>{
|
||||
if(res && res.data && res.data.status === 0){
|
||||
message.success("检测成功!");
|
||||
setLoading(false);
|
||||
setTimeout(()=>{
|
||||
window.location.href = res.data.view_url;
|
||||
},500)
|
||||
}else{
|
||||
setLoading(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
title={null}
|
||||
width="600px"
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
footer={null}
|
||||
centered={true}
|
||||
wrapClassName='cloneCheck'
|
||||
maskClosable={false}
|
||||
>
|
||||
<div>
|
||||
<div className='df' style={{alignItems:"center"}}>
|
||||
<div>
|
||||
<p className='font-20' style={{color:"#222",fontFamily:"alibaba"}}>代码克隆检测</p>
|
||||
<p className='mt15' style={{color:"#403e63"}}>提供可扩展的代码克隆检测能力,支持大规模代码库的多语言比对与结果可视化</p>
|
||||
</div>
|
||||
<img src={CloneLogo} width={196}/>
|
||||
</div>
|
||||
<Form>
|
||||
<Form.Item label="请输入需对比检测的本平台仓库地址">
|
||||
{getFieldDecorator("target_url",{
|
||||
rules:[
|
||||
{required:true,message:"请输入需对比检测的本平台仓库地址"}
|
||||
]
|
||||
})(
|
||||
<Input placeholder="示例:https//github/com/Stability-Al/StableStudio.git" autoComplete={"off"}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="仓库语言">
|
||||
{getFieldDecorator("language",{
|
||||
rules:[
|
||||
{required:true,message:"请选择仓库语言"}
|
||||
]
|
||||
})(
|
||||
<Select placeholder="请选择仓库语言">
|
||||
{
|
||||
language.map((i,k)=>{
|
||||
return(
|
||||
<Option key={k} value={i}>{i}</Option>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div className='center'>
|
||||
<Button loading={loading} onClick={beginFunc} type='primary'>{!loading ? "开始检测" : "检测中"}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default Form.create()(forwardRef(CheckModal));
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
.cloneCheck{
|
||||
.ant-modal-content{
|
||||
border-radius: 14px;
|
||||
.ant-modal-body{
|
||||
background-image: url("../img/cloneback.png");
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
padding-top: 0px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
.ant-modal-close-x{
|
||||
font-size: 26px;
|
||||
}
|
||||
.ant-form-item-label{
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.ant-form-explain{
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 245 KiB |
Loading…
Reference in New Issue