sonar质量分析列表增加获取推荐按钮

This commit is contained in:
caishi 2021-11-19 17:06:07 +08:00
parent a58188c662
commit 260239b5d2
4 changed files with 71 additions and 4 deletions

View File

@ -228,7 +228,7 @@
li{
text-align: center;
padding:0px;
margin-right: 40px;
margin-right: 35px;
display: flex;
& > a{
position: relative;

View File

@ -5,6 +5,7 @@ import moment from 'moment'
import axios from 'axios';
import Nodata from '../Nodata';
import './Index.scss';
import RecommedModal from './sub/RecommedModal';
const limit = 15;
@ -12,15 +13,18 @@ function Index(props) {
const [ page , setPage ] = useState(1);
const [ total , setTotal ] = useState(0);
const [ data , setData ] = useState(undefined);
const [ visible , setVisible ] = useState(false);
const [ content ,setContent ] = useState(undefined);
const { owner , projectsId } = props.match.params;
useEffect(()=>{
getInit();
},[page])
function getInit() {
// MLh8klm46f_ceshi ${owner}_${projectsId}
const url = `https://sonar.learnerhub.net/api/issues/search?componentKeys=MLh8klm46f_ceshi&s=FILE_LINE&resolved=false&types=BUG&ps=${limit}&facets=owaspTop10%2CsansTop25%2Cseverities%2CsonarsourceSecurity%2Ctypes&additionalFields=_all&timeZone=Asia%2FShanghai&p=${page}`
const url = `https://sonar.learnerhub.net/api/issues/search?componentKeys=${owner}_${projectsId}&s=FILE_LINE&resolved=false&types=BUG&ps=${limit}&facets=owaspTop10%2CsansTop25%2Cseverities%2CsonarsourceSecurity%2Ctypes&additionalFields=_all&timeZone=Asia%2FShanghai&p=${page}`
axios.get(url,{
headers:{Authorization:`Basic ${Base64.encode('ecae161ce05add6121c6263f843c76d79fcd953c:')}`}
}).then(result=>{
@ -36,7 +40,7 @@ function Index(props) {
title: '文件',
dataIndex: 'component',
key: 'component',
width:"20%",
width:"15%",
render:(v,l,i)=>{
const name = l.component && l.component.split(":")[1];
return(
@ -79,7 +83,7 @@ function Index(props) {
title: '问题信息',
dataIndex: 'message',
key: 'message',
width:"45%"
width:"40%"
},
{
title: '创建时间',
@ -92,9 +96,38 @@ function Index(props) {
)
}
},
{
title: '问题修复推荐',
dataIndex: 'recommend',
key: 'recommend',
align:"center",
render:(v,l,i)=>{
return(
<a className="color-blue" onClick={()=>receiveRecommend(l)}>获取推荐</a>
)
}
},
];
function receiveRecommend(l){
// http://ng.learnerhub.net/mulan/repair
// 线 https://api.learnerhub.net/mulan/repair
const url = `https://api.learnerhub.net/mulan/repair`;
axios.get(url,{
params:{
data:l
}
}).then(result=>{
if(result){
setContent(result.data.data && result.data.data.content);
setVisible(true);
}
}).catch(error=>{})
}
return(
<div className="main" style={{padding:"0px"}}>
<RecommedModal visible={visible} content={content} onCancel={()=>setVisible(false)}/>
{
total > 0 ?
<div style={{minHeight:"300px"}}>

View File

@ -2,4 +2,15 @@
.ant-table-thead > tr > th, .ant-table-tbody > tr > td{
padding:10px 12px;
}
}
.recommendbox{
.ant-modal-body{
padding:0px;
padding-bottom: 20px;
div{
height: 620px;
overflow-y: auto;
padding:20px
}
}
}

View File

@ -0,0 +1,23 @@
import { Modal } from 'antd';
import React from 'react';
import '../Index.scss';
function RecommedModal({content,visible,onCancel}){
return(
<Modal
visible={visible}
footer={null}
width="1000px"
closable={true}
onCancel={onCancel}
title="推荐内容"
centered={true}
className="recommendbox"
>
<div>
<pre style={{whiteSpace: "pre-line"}}>{content}</pre>
</div>
</Modal>
)
}
export default RecommedModal;