新增重新分析按钮
This commit is contained in:
parent
c1434c9d4b
commit
830b96cdc9
|
|
@ -44,7 +44,7 @@ export function initSonar(open, owner, repo) {
|
|||
}
|
||||
|
||||
// 开始分析
|
||||
export function startAlalyze( branch , owner, repo) {
|
||||
export function startAnalyze( branch , owner, repo) {
|
||||
return fetch({
|
||||
url: `/api/v1/${owner}/${repo}/sonarqubes/insert_file.json?branch=${ branch }`,
|
||||
method: 'post',
|
||||
|
|
@ -67,6 +67,14 @@ export function getActionList(owner, repo ) {
|
|||
});
|
||||
}
|
||||
|
||||
// 重新运行分析
|
||||
export function reAnalize(owner, repo, branch ) {
|
||||
return fetch({
|
||||
url: `/api/v1/${owner}/${repo}/actions/runs?ref=${ branch }&workflow=SonarScanner.yaml`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
// 获取classes、files地址
|
||||
export function getAnalizeUrl(owner, repo ) {
|
||||
return fetch({
|
||||
|
|
|
|||
|
|
@ -321,6 +321,21 @@
|
|||
}
|
||||
.issue-total {
|
||||
font-family: 'alibabaReg';
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
.reanalize {
|
||||
display: inline-block;
|
||||
color: rgb(255, 255, 255);
|
||||
background: linear-gradient(89.95deg, rgb(18, 97, 255) 0.01%, rgb(65, 77, 241) 99.99%);
|
||||
border-radius: 9px;
|
||||
padding: 4px 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.result-box {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
.nodata {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
|
|
@ -636,6 +651,7 @@
|
|||
}
|
||||
|
||||
.headBox{
|
||||
width: 100%;
|
||||
height:60px;
|
||||
line-height: 60px;
|
||||
background-color:#fafcff;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState, useEffect, Fragment, useRef } from "react";
|
||||
import { getList, getProblemDetail, getProblemData, initSonar, startAlalyze, getActionList, getAnalizeUrl } from "../api";
|
||||
import { getList, getProblemDetail, getProblemData, initSonar, startAnalyze, getActionList, getAnalizeUrl, reAnalize } from "../api";
|
||||
import './detail.scss';
|
||||
import ProblemDetail from "./component/ProblemDetail";
|
||||
import { issueType, maintainability, issueTypeIcon, maintainabilityIcon, labelIcon } from "../constants/quality";
|
||||
|
|
@ -67,10 +67,6 @@ function IssueList(props) {
|
|||
const timeRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
console.log(props);
|
||||
|
||||
console.log(projectDetail);
|
||||
|
||||
if (projectDetail) {
|
||||
const { author, name } = projectDetail;
|
||||
document.title = `代码质量分析-${author.name}/${name}`;
|
||||
|
|
@ -117,6 +113,31 @@ function IssueList(props) {
|
|||
};
|
||||
}, [url]); // 如果 URL 改变,重新绑定监听器
|
||||
|
||||
useEffect(() => {
|
||||
if (pageNum === 1) {
|
||||
getIssueList()
|
||||
} else {
|
||||
setPageNum(1)
|
||||
}
|
||||
}, [selectedType, selectedSeverity, selectedTag]);
|
||||
|
||||
useEffect(() => {
|
||||
if (projectDetail && analysisStatus === actionStatus.success) {
|
||||
getIssueList()
|
||||
}
|
||||
}, [pageNum, pageSize]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!tagShowMore) {
|
||||
setTimeout(() => {
|
||||
setTagShowMoreDelay(tagShowMore)
|
||||
}, 450);
|
||||
} else {
|
||||
setTagShowMoreDelay(tagShowMore)
|
||||
}
|
||||
}, [tagShowMore])
|
||||
|
||||
|
||||
const clearTimer = () => {
|
||||
if (timeRef.current) {
|
||||
clearTimeout(timeRef.current);
|
||||
|
|
@ -212,30 +233,6 @@ function IssueList(props) {
|
|||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (pageNum === 1) {
|
||||
getIssueList()
|
||||
} else {
|
||||
setPageNum(1)
|
||||
}
|
||||
}, [selectedType, selectedSeverity, selectedTag]);
|
||||
|
||||
useEffect(() => {
|
||||
if (projectDetail && analysisStatus === actionStatus.success) {
|
||||
getIssueList()
|
||||
}
|
||||
}, [pageNum, pageSize]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!tagShowMore) {
|
||||
setTimeout(() => {
|
||||
setTagShowMoreDelay(tagShowMore)
|
||||
}, 450);
|
||||
} else {
|
||||
setTagShowMoreDelay(tagShowMore)
|
||||
}
|
||||
}, [tagShowMore])
|
||||
|
||||
const detail = (e) => {
|
||||
setSelectedIssue(e);
|
||||
getProblemDetail(e.rule, owner, projectsId).then(res => {
|
||||
|
|
@ -349,7 +346,7 @@ function IssueList(props) {
|
|||
setLoading(true)
|
||||
initSonar(true, owner, projectsId).then(res => {
|
||||
if (res.status === 0) {
|
||||
startAlalyze(projectDetail.default_branch, owner, projectsId).then(res1=> {
|
||||
startAnalyze(projectDetail.default_branch, owner, projectsId).then(res1=> {
|
||||
if (res1.status === 0) {
|
||||
message.success('创建分析成功,请等待分析完成')
|
||||
setAnalysisStatus(actionStatus.waiting)
|
||||
|
|
@ -366,6 +363,20 @@ function IssueList(props) {
|
|||
})
|
||||
}
|
||||
|
||||
const reRunAnalize = () => {
|
||||
setLoading(true)
|
||||
reAnalize(owner, projectsId, projectDetail.default_branch).then(res => {
|
||||
if (res.status === 0) {
|
||||
message.success('重新分析成功,请等待分析完成')
|
||||
setAnalysisStatus(actionStatus.waiting)
|
||||
if (timeRef.current) clearTimer();
|
||||
timeRef.current = setTimeout(() => {
|
||||
getAction()
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 开始按钮状态
|
||||
const getStatusButton = () => {
|
||||
switch (analysisStatus) {
|
||||
|
|
@ -403,6 +414,7 @@ function IssueList(props) {
|
|||
issueDetail={issueInfo}
|
||||
onClose={() => setDetailVisible(false)}
|
||||
/>
|
||||
{ analysisStatus === actionStatus.success && <span className="reanalize" onClick={reRunAnalize}>重新分析</span> }
|
||||
{
|
||||
analysisStatus !== actionStatus.success && <Fragment>
|
||||
<div className="headBox font-16 pl15">sonar代码质量分析工具</div>
|
||||
|
|
@ -418,7 +430,7 @@ function IssueList(props) {
|
|||
</Fragment>
|
||||
}
|
||||
{
|
||||
analysisStatus === actionStatus.success && <div>
|
||||
analysisStatus === actionStatus.success && <div className="result-box">
|
||||
<div className="container total-info">
|
||||
<div className="sub-container">
|
||||
<p>软件质量统计结果,全方位精准定位问题</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue