From c625546579c1eaf6ec54fe6c8f5a8eb1f710f93b Mon Sep 17 00:00:00 2001 From: tianweiweiliang <875658254@qq.com> Date: Tue, 26 Mar 2024 17:17:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SuiteSelectDrawer/ServerObjectSelect.tsx | 29 +++++++++++++---- src/pages/WorkSpace/TestJob/index.tsx | 8 +++-- .../PipLine/PipLineItemStep/index.tsx | 12 +++++++ .../ViewDetail/components/PipLine/index.tsx | 2 +- .../TestPlan/PlanView/ViewDetail/index.tsx | 16 ++++++++-- .../NewReport/components/Catalog.tsx | 4 +-- .../TestDataChild/ChartTypeChild.tsx | 13 ++++---- .../components/TestDataChild/PrefReview.tsx | 6 ++-- .../components/TestDataChild/TypeChart.tsx | 18 +++++++---- .../Details/components/TagsEditer.tsx | 32 ++++++++++++++----- .../TestResult/JobList/ListTable.tsx | 9 ++++-- 11 files changed, 109 insertions(+), 40 deletions(-) diff --git a/src/pages/WorkSpace/TestJob/components/SuiteSelectDrawer/ServerObjectSelect.tsx b/src/pages/WorkSpace/TestJob/components/SuiteSelectDrawer/ServerObjectSelect.tsx index 536d953b..766d718a 100644 --- a/src/pages/WorkSpace/TestJob/components/SuiteSelectDrawer/ServerObjectSelect.tsx +++ b/src/pages/WorkSpace/TestJob/components/SuiteSelectDrawer/ServerObjectSelect.tsx @@ -2,6 +2,7 @@ import { Select, Badge, Typography, Form } from 'antd' import React, { useContext, useEffect, useMemo, useState } from 'react' import { standloneServerList, queryClusterServer, queryClusterStandaloneServer, queryClusterGroupServer } from './services'; +import debounce from 'lodash/debounce'; import { DrawerProvider } from './Provider' import { useParams, useIntl } from 'umi' import DropdownRender from '../DropdownRender'; @@ -30,28 +31,33 @@ const ServerObjectSelect = (props: any) => { const [fetching, setFetching] = useState(true) const [pageNum, setPageNum] = useState(1) const [pageVisibleState, setPageVisibleState] = React.useState(false) - //内网单机 + const [searchValue, setSearchValue] = useState(undefined) + //内网单机 const standaloneServerRequest = async (page_num = 1) => { - const { data, code } = await standloneServerList({ ws_id, state: ['Available', 'Occupied', 'Reserved'], page_num, page_size: PAGE_SIZE }) //, page_size : 2 + const search = searchValue ? { ip: searchValue }: {} + const { data, code } = await standloneServerList({ ws_id, state: ['Available', 'Occupied', 'Reserved'], page_num, page_size: PAGE_SIZE, ...search }) //, page_size : 2 if (code === 200 && data) setServerList((p: any) => filterRepeat(p, data)) } //内网集群 const clusterServerRequest = async (page_num = 1) => { - const { data, code } = await queryClusterServer({ cluster_type: 'aligroup', ws_id, page_num, page_size: PAGE_SIZE }) + const search = searchValue ? { ip: searchValue }: {} + const { data, code } = await queryClusterServer({ cluster_type: 'aligroup', ws_id, page_num, page_size: PAGE_SIZE, ...search }) if (code === 200 && data) setServerList((p: any) => filterRepeat(p, data)) } //云上单机 const clusterStandaloneRequest = async () => { - const { data, code } = await queryClusterStandaloneServer({ ws_id, no_page: true, is_instance: serverObjectType === 'instance', state: ['Available', 'Occupied', 'Reserved'] }) + const search = searchValue ? { ip: searchValue }: {} + const { data, code } = await queryClusterStandaloneServer({ ws_id, no_page: true, is_instance: serverObjectType === 'instance', state: ['Available', 'Occupied', 'Reserved'], ...search }) if (code === 200 && data) setServerList((p: any) => filterRepeat(p, data)) } //云上集群 const clusterGroupRequest = async () => { - const { data, code } = await queryClusterGroupServer({ cluster_type: 'aliyun', ws_id, no_page: true }) + const search = searchValue ? { ip: searchValue }: {} + const { data, code } = await queryClusterGroupServer({ cluster_type: 'aliyun', ws_id, no_page: true, ...search }) if (code === 200 && data) setServerList((p: any) => filterRepeat(p, data)) } @@ -81,7 +87,7 @@ const ServerObjectSelect = (props: any) => { return () => { setPageVisibleState(false) } - }, [serverObjectType]) + }, [serverObjectType, searchValue]) const state = useDocumentVisibility() @@ -104,6 +110,16 @@ const ServerObjectSelect = (props: any) => { } } + // 搜索 + const onSearch = (word: any)=> { + // console.log('word:', word) + if (word) { + setSearchValue(word) + } else { + setSearchValue(undefined) + } + } + const switchServerMessage = useMemo( () => { switch (serverObjectType) { @@ -180,6 +196,7 @@ const ServerObjectSelect = (props: any) => { placeholder={switchServerMessage} dropdownMatchSelectWidth={340} showSearch + onSearch={debounce(onSearch, 300)} loading={fetching} onPopupScroll={handleServerPopupScroll} popupClassName="job_select_drop_cls" diff --git a/src/pages/WorkSpace/TestJob/index.tsx b/src/pages/WorkSpace/TestJob/index.tsx index 8e742491..98888c75 100644 --- a/src/pages/WorkSpace/TestJob/index.tsx +++ b/src/pages/WorkSpace/TestJob/index.tsx @@ -260,7 +260,9 @@ const TestJob: React.FC = (props) => { build_config, build_machine, scripts, ...rest } - const kernel_info = { hotfix_install, scripts, kernel_packages } + const kernel_info = { hotfix_install, scripts, + kernel_packages: kernel_packages?.map((item: any)=> item?.trim()), // 去除输入内容两端空格 + } let scriptInfo = script_info let rpmInfo = rpm_info @@ -740,8 +742,8 @@ const TestJob: React.FC = (props) => { const handleCancelTemplate = (key: any) => { notification.close(key) - setFetching(false) - history.push({ pathname: `/ws/${ws_id}/job/templates`, state: state || {} }) + // setFetching(false) + // history.push({ pathname: `/ws/${ws_id}/job/templates`, state: state || {} }) } const handleSaveTemplateModify = async () => { diff --git a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/PipLineItemStep/index.tsx b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/PipLineItemStep/index.tsx index a7939da6..5358bd18 100644 --- a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/PipLineItemStep/index.tsx +++ b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/PipLineItemStep/index.tsx @@ -1,5 +1,7 @@ import { useState } from 'react' import { history } from 'umi'; +import { Popover } from 'antd' +import { QuestionCircleOutlined } from '@ant-design/icons'; import { getColorByState, getStepColorByState } from '@/utils/utils' import { IconByState, ArrowSolid, TemplateItem } from '../modules' import { @@ -79,6 +81,16 @@ const PipLineItemGrey = (props: any) => { {fail || '-'} + {item.error_info && + + + + } diff --git a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/index.tsx b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/index.tsx index 84924b8b..f1c61d44 100644 --- a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/index.tsx +++ b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/components/PipLine/index.tsx @@ -37,7 +37,7 @@ const PipLine = (props: any) => { {/** 测试阶段, .... */} {test_result?.map((item: any, index: any): any => { - return + return })} {/** 结束 */} diff --git a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/index.tsx b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/index.tsx index a0c4bc4e..46a53d70 100644 --- a/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/index.tsx +++ b/src/pages/WorkSpace/TestPlan/PlanView/ViewDetail/index.tsx @@ -1,6 +1,7 @@ /* eslint-disable react-hooks/exhaustive-deps */ import { useState, useEffect, useCallback, useRef } from 'react' -import { Breadcrumb, Typography, Row, Tag, Button, Spin } from 'antd' +import { Breadcrumb, Typography, Row, Tag, Button, Spin, Popover } from 'antd' +import { QuestionCircleOutlined } from '@ant-design/icons'; import styled from 'styled-components' import { FormattedMessage, history } from 'umi' import { useClientSize, writeDocumentTitle } from '@/utils/hooks' @@ -88,7 +89,7 @@ const ViewDetail = (props: any) => { }, [plan_id]) const TagInfo = ({ data }: any) => { - const { state, start_time, end_time } = data + const { state, start_time, end_time, error_info } = data const rowStyle = { display: 'flex', alignItems: 'center' } const normalStyle = { background: '#F2F4F6', border: '1px solid #F2F4F6' } return ( @@ -100,7 +101,16 @@ const ViewDetail = (props: any) => { Running )} {state === 'fail' && ( - Fail +
+ Fail + + + +
)} {state === 'success' && ( Complete diff --git a/src/pages/WorkSpace/TestReport/NewReport/components/Catalog.tsx b/src/pages/WorkSpace/TestReport/NewReport/components/Catalog.tsx index 96226389..71ebb7b5 100644 --- a/src/pages/WorkSpace/TestReport/NewReport/components/Catalog.tsx +++ b/src/pages/WorkSpace/TestReport/NewReport/components/Catalog.tsx @@ -230,8 +230,8 @@ const TemplateCatalog = () => { } leftTitle?.classList.add('toc-selected'); const parentNode = leftTitle?.id.substring(5, 14) - const parentTop = (document.querySelector(`#left_${parentNode}`) as any).offsetTop - const parentTreeTop = (document.querySelector(`#left_tree_${parentNode}`) as any).offsetTop + const parentTop = (document.querySelector(`#left_${parentNode}`) as any)?.offsetTop || 0 + const parentTreeTop = (document.querySelector(`#left_tree_${parentNode}`) as any)?.offsetTop || 0 if (leftTitle.attributes['class'].nodeValue == 'toc-selected') { if (leftTitle?.id === 'left_perf_item' || leftTitle?.id === 'left_func_item') { setRoundHeight(parentTop) diff --git a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/ChartTypeChild.tsx b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/ChartTypeChild.tsx index a3b56851..98747a69 100644 --- a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/ChartTypeChild.tsx +++ b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/ChartTypeChild.tsx @@ -1,15 +1,16 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Typography, Space, Select, } from 'antd'; import { FormattedMessage } from 'umi'; const ChartTypeChild = (props: any) => { - const { btn, isReport, obj, suiteId, setPerData } = props; - const [chartType, setChartType] = useState('1') - const hanldeChangeChartType = (val: string) => { + const { btn, isReport, obj, suiteId, setPerData, chartType, setChartType } = props; + // const [chartType, setChartType] = useState('1') + const onChange = (val: string) => { setChartType(val) if (isReport) { setPerData({ - ...obj, list: obj.list.map((item: any) => { + ...obj, + list: obj.list.map((item: any) => { if (suiteId === item.suite_id) { return { ...item, @@ -36,7 +37,7 @@ const ChartTypeChild = (props: any) => { {!btn && - diff --git a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/PrefReview.tsx b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/PrefReview.tsx index 8562eede..3d83a4e8 100644 --- a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/PrefReview.tsx +++ b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/PrefReview.tsx @@ -76,6 +76,7 @@ const Performance = (props: any) => { const isEditPage = !!~pathname?.indexOf('/edit') const [filterName, setFilterName] = useState('all') + const [chartType, setChartType] = useState('1') const [perData, setPerData] = useState({}) const [sortKeys, setSortKeys] = React.useState([]) const baseIndex = useMemo(() => { @@ -89,7 +90,7 @@ const Performance = (props: any) => { ...child, list: child.list?.map((item: any) => { return { ...item, - chartType: '1' + chartType, } }) }) @@ -259,7 +260,8 @@ const Performance = (props: any) => { } - + {!domainResult.is_default && diff --git a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/TypeChart.tsx b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/TypeChart.tsx index 7fa56d70..cf5a6bb7 100644 --- a/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/TypeChart.tsx +++ b/src/pages/WorkSpace/TestReport/NewReport/components/TestDataChild/TypeChart.tsx @@ -129,7 +129,7 @@ const TypeChart = (props: any) => { } } return obj; - }, [data]) + }, [data, chartType]) useEffect(() => { const { series, subText, xAxisData, legData, dataZoom_end } = ChartList @@ -284,12 +284,16 @@ const TypeChart = (props: any) => { } const timer = setTimeout(() => { // 渲染数据展示 - const chartObj = echarts.init(chart.current, undefined, { - renderer: 'svg', - }); - chartObj.setOption(option as any) - callBackColor(chartObj.getOption().color) - chartDom.current = chartObj + let chartObj: any = null + try { + chartObj = echarts?.init(chart.current, undefined, { renderer: 'svg' }) + } catch { + } + if (chartObj) { + chartObj.setOption(option as any) + callBackColor(chartObj.getOption().color) + chartDom.current = chartObj + } }, duration) return () => { diff --git a/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx b/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx index f8ca164d..60cad46f 100644 --- a/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx +++ b/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx @@ -33,6 +33,14 @@ const editBtn = { const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { + // 设定任务标签清理时间间隔 + const tag_catch = [ + {id: 'keep_three_months', name: '保留三个月'}, + {id: 'keep_six_months', name: '保留六个月'}, + {id: 'keep_one_year', name: '保留一年'}, + ] + const tag_catch_value = tag_catch.map((key)=> key.id) + const { ws_id, id: job_id, share_id } = useParams() as any const isSharePage = !!share_id const access = useAccess(); @@ -42,7 +50,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { const [state, setState] = useState(false) const [keys, setKeys] = useState([]) const [params, setParams] = React.useState(DEFAULT_LIST_PARAMS) - const [list, setList] = React.useState([]) + const [list, setList] = React.useState(tag_catch) // [] const jobTagsCreateModal: any = useRef(null) const { data: tagList, loading, refresh } = useRequest( @@ -57,7 +65,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { React.useEffect(() => { return () => { if (!state) { - setList([]) + setList(tag_catch) setParams(DEFAULT_LIST_PARAMS) } } @@ -138,7 +146,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { onPopupScroll={handleTagePopupScroll} getPopupContainer={node => node.parentNode} onSearch={lodash.debounce((name) => { - setList([]) + setList(tag_catch) // [] setParams({ ...DEFAULT_LIST_PARAMS, name }) }, 300)} filterOption={false} @@ -153,7 +161,8 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { { access.WsMemberOperateSelf() &&
- + +
@@ -161,10 +170,17 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { )} options={ - list.map((tag: any) => ({ - value: tag.id, - label: {tag.name} - })) + list.map((tag: any) => { + // 判断:标签清理时间选项,已选 + const intersect = keys.filter(x => tag_catch_value.indexOf(x) > -1 ); + const disabled = tag_catch_value.includes(tag.id)? (intersect.length? (tag.id !== intersect[0]): false): false + const text = disabled? {tag.name}: tag.name + return ({ + value: tag.id, + label: {text}, + disabled, + }) + }) } /> diff --git a/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx b/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx index 4f234cc9..ec45dc03 100644 --- a/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx +++ b/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx @@ -208,8 +208,13 @@ const ListTable: React.FC = (props) => { ), dataIndex: 'test_result', width: 140, - render: (_: any) => { - const result = JSON.parse(_) + render: (_: any, record: any) => { + let result = {} + try { + result = JSON.parse(_) + } catch { + console.log('JSON格式不对') + } if (lodash.isNull(result)) { return ( -- Gitee From 4ffab70800bc38c109f2ac680fad4f59d3306c33 Mon Sep 17 00:00:00 2001 From: tianweiweiliang <875658254@qq.com> Date: Mon, 1 Apr 2024 16:19:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E6=A0=87=E7=AD=BE=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=8D=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Details/components/TagsEditer.tsx | 29 +++++-------------- .../TestResult/JobList/ListTable.tsx | 6 ++-- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx b/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx index 60cad46f..a8402566 100644 --- a/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx +++ b/src/pages/WorkSpace/TestResult/Details/components/TagsEditer.tsx @@ -33,14 +33,6 @@ const editBtn = { const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { - // 设定任务标签清理时间间隔 - const tag_catch = [ - {id: 'keep_three_months', name: '保留三个月'}, - {id: 'keep_six_months', name: '保留六个月'}, - {id: 'keep_one_year', name: '保留一年'}, - ] - const tag_catch_value = tag_catch.map((key)=> key.id) - const { ws_id, id: job_id, share_id } = useParams() as any const isSharePage = !!share_id const access = useAccess(); @@ -50,7 +42,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { const [state, setState] = useState(false) const [keys, setKeys] = useState([]) const [params, setParams] = React.useState(DEFAULT_LIST_PARAMS) - const [list, setList] = React.useState(tag_catch) // [] + const [list, setList] = React.useState([]) const jobTagsCreateModal: any = useRef(null) const { data: tagList, loading, refresh } = useRequest( @@ -65,7 +57,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { React.useEffect(() => { return () => { if (!state) { - setList(tag_catch) + setList([]) setParams(DEFAULT_LIST_PARAMS) } } @@ -146,7 +138,7 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { onPopupScroll={handleTagePopupScroll} getPopupContainer={node => node.parentNode} onSearch={lodash.debounce((name) => { - setList(tag_catch) // [] + setList([]) setParams({ ...DEFAULT_LIST_PARAMS, name }) }, 300)} filterOption={false} @@ -170,17 +162,10 @@ const TagsEditer: React.FC = ({ tags = [], onOk, creator_id, width }) => { )} options={ - list.map((tag: any) => { - // 判断:标签清理时间选项,已选 - const intersect = keys.filter(x => tag_catch_value.indexOf(x) > -1 ); - const disabled = tag_catch_value.includes(tag.id)? (intersect.length? (tag.id !== intersect[0]): false): false - const text = disabled? {tag.name}: tag.name - return ({ - value: tag.id, - label: {text}, - disabled, - }) - }) + list.map((tag: any) => ({ + value: tag.id, + label: {tag.name} + })) } /> diff --git a/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx b/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx index ec45dc03..509ca489 100644 --- a/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx +++ b/src/pages/WorkSpace/TestResult/JobList/ListTable.tsx @@ -226,9 +226,9 @@ const ListTable: React.FC = (props) => { } else { return ( - {result.total} - {result.pass} - {result.fail} + {result.total || '-'} + {result.pass || '-'} + {result.fail || '-'} ) } -- Gitee