From 69b1600d0687c62dcb4f238c26d131cc6c5002a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= Date: Fri, 19 Sep 2025 15:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/DevOps/cardList/api.js | 77 +++++-------- src/forge/DevOps/cardList/fetch.js | 7 -- src/forge/DevOps/cardList/index.jsx | 156 ++++++++++++++++----------- src/forge/DevOps/cardList/index.scss | 18 ++++ src/forge/Main/sub/DetailBanner.jsx | 1 - 5 files changed, 136 insertions(+), 123 deletions(-) delete mode 100644 src/forge/DevOps/cardList/fetch.js diff --git a/src/forge/DevOps/cardList/api.js b/src/forge/DevOps/cardList/api.js index 7dce8c03c..de157299f 100644 --- a/src/forge/DevOps/cardList/api.js +++ b/src/forge/DevOps/cardList/api.js @@ -1,65 +1,40 @@ -import fetch from './fetch'; -export function addPipelines(owner, repo, data) { - return fetch({ - url:`/v1/${ owner }/${ repo }/pipelines`, - method: 'POST', - data - }) +import axios from 'axios'; +export async function addPipelines(owner, repo, data) { + const res = await axios.post(`/v1/${ owner }/${ repo }/pipelines`, data); + return res.data; } -export function getCardList(owner, repo, params) { - return fetch({ - url:`/v1/${ owner }/${ repo }/pipelines`, - method: 'get', - params - }) +export async function getCardList(owner, repo, params) { + const res = await axios.get(`/v1/${owner}/${repo}/pipelines`, { params }); + return res.data; } -export function getTemplateList() { - return fetch({ - url:`/action/templates.json`, - method: 'get', - }) +export async function getTemplateList() { + const res = await axios.get(`/action/templates.json`); + return res.data; } -export function getProjectBranch(owner, repo) { - return fetch({ - url:`/${ owner }/${ repo }/branches.json`, - method: 'GET', - }) +export async function getProjectBranch(owner, repo) { + const res = await axios.get(`/${ owner }/${ repo }/branches.json`); + return res.data; } -export function runPipeline(owner, repo, params) { - return fetch({ - url:`/v1/${ owner }/${ repo }/actions/runs.json`, - method: 'post', - data: params - }) +export async function runPipeline(owner, repo, params) { + const res = await axios.get(`/v1/${ owner }/${ repo }/actions/runs.json`, { params }); + return res.data; } -export function delPipelines(owner, repo, id) { - return fetch({ - url:`/v1/${ owner }/${ repo }/pipelines/${ id }.json`, - method: 'DELETE', - }) +export async function delPipelines(owner, repo, id) { + const res = await axios.delete(`/v1/${ owner }/${ repo }/pipelines/${ id }.json`); + return res.data; } -export function stopPipelines(owner, repo, params) { - return fetch({ - url:`/v1/${ owner }/${ repo }/actions/disable.json`, - method: 'POST', - data: params - }) +export async function stopPipelines(owner, repo, data) { + const res = await axios.post(`/v1/${ owner }/${ repo }/actions/disable.json`, data); + return res.data; } -export function startPipelines(owner, repo, params) { - return fetch({ - url:`/v1/${ owner }/${ repo }/actions/enable.json`, - method: 'POST', - data: params - }) -} - - - - +export async function startPipelines(owner, repo, data) { + const res = await axios.post(`/v1/${ owner }/${ repo }/actions/enable.json`, data); + return res.data; +} \ No newline at end of file diff --git a/src/forge/DevOps/cardList/fetch.js b/src/forge/DevOps/cardList/fetch.js deleted file mode 100644 index babbe58fe..000000000 --- a/src/forge/DevOps/cardList/fetch.js +++ /dev/null @@ -1,7 +0,0 @@ -import javaFetch from '../../javaFetch'; - -// let settings = JSON.parse(localStorage.chromesetting); - -const service = javaFetch('/api'); -export default service; -export const TokenKey = 'autologin_trustie'; \ No newline at end of file diff --git a/src/forge/DevOps/cardList/index.jsx b/src/forge/DevOps/cardList/index.jsx index e14bb2172..337db25e7 100644 --- a/src/forge/DevOps/cardList/index.jsx +++ b/src/forge/DevOps/cardList/index.jsx @@ -1,25 +1,28 @@ import { message, Popover, Button, Divider, Switch, Modal, Pagination } from "antd"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useRef } from "react"; import './index.scss'; import { secondsToTimeFormat, timeAgo } from "../../../common/DateUtil"; import { runPipeline, delPipelines, stopPipelines, startPipelines, getCardList } from './api' import Nodata from "../../Nodata"; import New from "./newModal"; +import devops from '../../Images/devops.png'; const { confirm } = Modal; -function CardDevops(props) { - const { project, match } = props || {}; +function CardDevops(props) { + const { project, match, isManager, isDeveloper, isReporter } = props || {}; const {owner, projectsId} = match.params; const [list, setList] = useState([]) const [ visible , setVisible ] = useState(false); const [ pageNum , setPageNum ] = useState(1); const [ total , setTotal ] = useState(0); const pageSize = 20; + + const intervalRef = useRef(null); let settings = localStorage.chromesetting && JSON.parse(localStorage.chromesetting); let pipelineUrl = settings && settings.common.pipeline; - + const isMember = isManager || isDeveloper || isReporter; useEffect(() => { document.title = `流水线-${owner}/${projectsId}`; @@ -27,21 +30,38 @@ function CardDevops(props) { useEffect(()=>{ getList(); - const intervalId = setInterval(() => { - getList(); - }, 10000); - return () => clearInterval(intervalId); - }, [pageNum]) + + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + + if(isMember){ + intervalRef.current = setInterval(() => { + getList(); + }, 10000); + } + + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + }, [isMember, pageNum]) function getList(){ - getCardList(owner, projectsId, { limit: pageSize, page: pageNum }).then(res => { + isMember && getCardList(owner, projectsId, { limit: pageSize, page: pageNum }).then(res => { if (res.status === 0) { setList(res.pipelines.map(e => { e.run_data = e.run_data || {} return e })) setTotal(res.count) - } + }else{ + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + } }) } @@ -114,64 +134,72 @@ function CardDevops(props) { onCancel={()=>setVisible(false)} onOk={()=>{setVisible(false);getList()}} /> - -
- {list && list.map(e=>{ - if (!e.run_data.status && e.run_data.status !== 0) { - e.run_data.status = (!e.json && !e.yaml) ? -1 : 0 - } - return
-
-
-
{ - // window.location.href = `${mygetHelmetapi && mygetHelmetapi.common.zone}/${owner}/pipeline/${e.id}` - window.open(`${ pipelineUrl }/devops/${owner}/${projectsId}/${e.id}`) - }}> -
-
{listType[e.pipeline_type]}
- {e.pipeline_name} -
-
-

-

- {statusEnum[+e.run_data.status] || ((!e.json && !e.yaml) ? "待设计" : "待启动")} - {!!e.run_data.total && #{e.run_data.total}    {timeAgo(e.run_data.stopped)} 执行时长{secondsToTimeFormat(e.run_data.length)}} -

-

分支:{e.branch}

-
{e.run_data.schedule && 定时}历史共执行{e.run_data.total || 0}次(成功{e.run_data.success || 0}次,失败{e.run_data.failure || 0}次)
-
-
- -
-
- run(e) }/> - window.open(`${ pipelineUrl }/devops/${owner}/${projectsId}/${e.id}/edit`) }/> - delPipelineFunc(e.id) }/> + {isMember ? + +
+ {list && list.map(e=>{ + if (!e.run_data.status && e.run_data.status !== 0) { + e.run_data.status = (!e.json && !e.yaml) ? -1 : 0 + } + return
+
+
+
{ + window.open(`${ pipelineUrl }/devops/${owner}/${projectsId}/${e.id}`) + }}> +
+
{listType[e.pipeline_type]}
+ {e.pipeline_name}
-
-
- stopPipelineFunc(e.id, e.disable, e.file_name)} /> - { e.disable? '禁用' : '启用' } +
+

+

+ {statusEnum[+e.run_data.status] || ((!e.json && !e.yaml) ? "待设计" : "待启动")} + {!!e.run_data.total && #{e.run_data.total}    {timeAgo(e.run_data.stopped)} 执行时长{secondsToTimeFormat(e.run_data.length)}} +

+

分支:{e.branch}

+
{e.run_data.schedule && 定时}历史共执行{e.run_data.total || 0}次(成功{e.run_data.success || 0}次,失败{e.run_data.failure || 0}次)
+
+
+ +
+
+ run(e) }/> + window.open(`${ pipelineUrl }/devops/${owner}/${projectsId}/${e.id}/edit`) }/> + delPipelineFunc(e.id) }/> +
+
+
+ stopPipelineFunc(e.id, e.disable, e.file_name)} /> + { e.disable? '禁用' : '启用' } +
-
+
-
- })} - {list && !list.length &&
} -
- { - total > pageSize && -
- + })} + {list && !list.length &&
}
- } + { + total > pageSize && +
+ +
+ } +
: +
+
+ +
暂无权限,仅仓库成员可访问
+
+
+
}
} diff --git a/src/forge/DevOps/cardList/index.scss b/src/forge/DevOps/cardList/index.scss index 3c06a7502..7e8966d01 100644 --- a/src/forge/DevOps/cardList/index.scss +++ b/src/forge/DevOps/cardList/index.scss @@ -243,3 +243,21 @@ } } } +.unJurisdictionBox{ + color:#333333; + .jurTil{ + width:1200px; + padding: 15px 16px; + background-color:#fafcff; + border:1px solid rgba(42, 97, 255, 0.23); + border-radius:3px 3px 0px 0px; + } + .jurCont{ + width:1200px; + height:317px; + padding-top: 45px; + background-color:#fafcff; + border-radius:4px 4px 0px 0px; + text-align: center; + } +} \ No newline at end of file diff --git a/src/forge/Main/sub/DetailBanner.jsx b/src/forge/Main/sub/DetailBanner.jsx index e822109be..dd86ed912 100644 --- a/src/forge/Main/sub/DetailBanner.jsx +++ b/src/forge/Main/sub/DetailBanner.jsx @@ -93,7 +93,6 @@ function DetailBanner({ history,list , owner , projectsId ,showNotification , ur :"" } - {/* 引擎仅对当前仓库管理员可见 */} { item.menu_name === "devops" ?