diff --git a/src/forge/Server/Index.jsx b/src/forge/Server/Index.jsx
index 9b47adeae..b760d3039 100644
--- a/src/forge/Server/Index.jsx
+++ b/src/forge/Server/Index.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import React, { useEffect, useState } from 'react';
import { Route, Switch } from 'react-router-dom';
import "./index.scss";
import Loadable from 'react-loadable';
@@ -37,6 +37,7 @@ const QualityDetail = Loadable({
function ServerIndex(props){
const { projectDetail } = props;
const { owner , projectsId } = props.match.params;
+ const [ qualityClass, setQualityClass ] = useState(false)
useEffect(()=>{
// 非项目协作者不可进入服务tab (3397)
@@ -45,8 +46,12 @@ function ServerIndex(props){
}
}, [projectDetail])
+ const changeClass = (isServer = false ) => {
+ setQualityClass(isServer);
+ }
+
return(
-
+
()
+ () => ()
}
>
()
+ () => ()
}
>
{/* 个人建站服务 */}
diff --git a/src/forge/Server/constants/quality.js b/src/forge/Server/constants/quality.js
index 6e69d2437..fa150cc13 100644
--- a/src/forge/Server/constants/quality.js
+++ b/src/forge/Server/constants/quality.js
@@ -27,7 +27,7 @@ export const maintainability = {
LOW: '次要',
MEDIUM: '主要',
HIGH: '严重',
- Blocked: '阻塞'
+ BLOCKED: '阻塞'
}
export const issueTypeIcon = {
diff --git a/src/forge/Server/index.scss b/src/forge/Server/index.scss
index ab9749dfe..79afc2706 100644
--- a/src/forge/Server/index.scss
+++ b/src/forge/Server/index.scss
@@ -2,6 +2,15 @@
width: 1200px;
margin:20px auto;
}
+.panels-quality {
+ background:#f3f5f9;
+ background-image: url("./img/quality/page-bg.png");
+ background-repeat: no-repeat;
+ background-size: 100%;
+ box-sizing: content-box;
+ width: 100%;
+ margin: 0;
+}
.btnhover{
background-color: #466aff;
color: #fff!important;
diff --git a/src/forge/Server/quality/detail.scss b/src/forge/Server/quality/detail.scss
index a3a7973b9..05a84fe6f 100644
--- a/src/forge/Server/quality/detail.scss
+++ b/src/forge/Server/quality/detail.scss
@@ -8,15 +8,6 @@
background: #FFFFFF;
}
}
-.panels {
- background:#f3f5f9;
- background-image: url("../img/quality/page-bg.png");
- background-repeat: no-repeat;
- background-size: 100%;
- box-sizing: content-box;
- width: 100%;
- margin: 0;
-}
.bug-details {
max-height: 90vh;
diff --git a/src/forge/Server/quality/index.jsx b/src/forge/Server/quality/index.jsx
index cf1252934..2b83724b2 100644
--- a/src/forge/Server/quality/index.jsx
+++ b/src/forge/Server/quality/index.jsx
@@ -50,19 +50,12 @@ function IssueList(props) {
const [tagShowMoreDelay, setTagShowMoreDelay] = useState(false);
const [codeSelected, setCodeSelected] = useState(false);
const [url, setUrl] = useState(null);
- const { projectDetail, history } = props;
+ const { projectDetail, history, changeClass } = props;
const metricKeys = 'lines,coverage,lines_to_cover,duplicated_lines_density,maintainability_issues,vulnerabilities,bugs,code_smells';
const facets = 'impactSeverities,tags,types';
const { owner , projectsId } = props.match.params;
const iframeRef = useRef(null);
-
- useEffect(() => {
- let newContainer = document.getElementsByClassName("newContainer")[0];
- newContainer.style.backgroundColor = '#F7F9FCFF';
- return () => {
- newContainer.style.backgroundColor = '#FFFFFF';
- };
- }, []);
+ const timeRef = useRef();
useEffect(() => {
if (projectDetail) {
@@ -73,25 +66,16 @@ function IssueList(props) {
return
}
setPageLoading(true)
- getActionList(owner, projectsId).then(res => {
- setPageLoading(false)
- if (res.status !== 0) {
- if (res.runs.length === 0) {
- setAnalysisStatus(actionStatus.none)
- } else {
- setAnalysisStatus(res.runs[0].status)
- if (res.runs[0].status) {
- getData()
- getIssueList()
- }
- }
- } else {
- message.error(res.message)
- }
- })
+ getAction()
}
}, [projectDetail]);
+ useEffect(() => {
+ return () => {
+ clearTimer()
+ }
+ },[])
+
useEffect(() => {
const iframe = iframeRef.current;
if (!iframe || !url) return; // 确保 iframe 和 url 已存在
@@ -107,6 +91,7 @@ function IssueList(props) {
iframe.style.height = contentHeight + 'px';
}
} catch (e) {
+ iframe.style.height = '770px';
// 如果实际上是跨域的,这里很可能会触发错误
console.error("调整同源 iframe 大小出错 (或者它实际是跨域的):", e);
}
@@ -120,6 +105,41 @@ function IssueList(props) {
};
}, [url]); // 如果 URL 改变,重新绑定监听器
+ const clearTimer = () => {
+ if (timeRef.current) {
+ clearTimeout(timeRef.current);
+ timeRef.current = undefined; // 清空引用
+ }
+ }
+
+ const getAction = () => {
+ getActionList(owner, projectsId).then(res => {
+ setPageLoading(false)
+ if (res.status !== 0) {
+ if (res.runs.length === 0) {
+ setAnalysisStatus(actionStatus.none)
+ } else {
+ if (res.runs[0].status === actionStatus.success) {
+ changeClass(true)
+ }
+ if ([actionStatus.waiting, actionStatus.running].includes(res.runs[0].status)) {
+ if (timeRef.current) clearTimer();
+ timeRef.current = setTimeout(() => {
+ getAction()
+ }, 3000);
+ }
+ setAnalysisStatus(res.runs[0].status)
+ if (res.runs[0].status) {
+ getData()
+ getIssueList()
+ }
+ }
+ } else {
+ message.error(res.message)
+ }
+ })
+ }
+
const getData = () => {
getProblemData(owner, projectsId, metricKeys).then(res => {
if (res.status === 0) {
@@ -134,18 +154,21 @@ function IssueList(props) {
}
const getIssueList = () => {
+ const isBLOCKED = selectedSeverity.join(',') === 'BLOCKED' //手动添加阻塞,当只选BLOCKED时筛选为空
let params = {
facets: facets,
types: selectedType.join(','),
- impactSeverities: selectedSeverity.join(','),
+ impactSeverities: selectedSeverity.join(',').replace('BLOCKED', ''),
tags: selectedTag.join(','),
p: pageNum,
ps: pageSize
};
- setPageLoading(true)
+ if (!timeRef.current) {
+ setPageLoading(true)
+ }
getList(params, owner, projectsId).then(res => {
setPageLoading(false)
- const issues = res.issues? res.issues.reduce((acc, issue) => {
+ const issues = res.issues && !isBLOCKED ? res.issues.reduce((acc, issue) => {
if (acc[issue.component]) {
acc[issue.component].push(issue);
} else {
@@ -155,10 +178,25 @@ function IssueList(props) {
}, {}) : [];
const filter = res.facets ? res.facets.reduce((acc, facet) => {
+ if (facet.property === 'impactSeverities') {
+ facet.values.unshift({
+ count: 0,
+ val: "BLOCKED"
+ })
+ }
+
+ if (isBLOCKED && facet.property !== 'impactSeverities') {
+ if (facet.property === 'tags') facet.values = []
+ facet.values.map(e => {
+ e.count = 0
+ })
+ }
+
acc[facet.property] = facet.values;
return acc;
}, {}) : [];
+ if (isBLOCKED) res.total = 0
setListFilter(filter);
setBaseInfo(res);
setIssues(issues);
@@ -294,6 +332,10 @@ function IssueList(props) {
if (res1.status === 0) {
message.success('创建分析成功,请等待分析完成')
setAnalysisStatus(actionStatus.waiting)
+ if (timeRef.current) clearTimer();
+ timeRef.current = setTimeout(() => {
+ getAction()
+ }, 3000);
}
setLoading(false)
})
@@ -310,7 +352,7 @@ function IssueList(props) {
return
case actionStatus.waiting:
case actionStatus.running:
- return
+ return
case actionStatus.failure:
return