diff --git a/abc.json b/abc.json index 06a1bce22a227ad9e820ea812cfe2c7a41ffc66d..320de5e96508fad2aafadeed7fa455bb8e06f3e8 100644 --- a/abc.json +++ b/abc.json @@ -4,10 +4,10 @@ "command": { "cmd": [ "pnpm install", - "pnpm build", + "pnpm build:tone", "mv ./dist $BUILD_DEST" ] } }, - "nodeVersion": 16 -} \ No newline at end of file + "nodeVersion": 20 +} diff --git a/package.json b/package.json index 24b4a6987a1598549c00a85f62db8bc8f30b477c..44bb0a4a5e04095b69adec66ef42d96e87f26253 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "tone-front", - "version": "1.18.0", + "version": "1.19.0", "private": true, "description": "Tone front", "scripts": { - "start": "cross-env BUILD_APP_ENV=\"opensource\" PORT=8888 umi dev", - "build": "cross-env BUILD_APP_ENV=\"opensource\" umi build", - "start:openanolis": "cross-env PORT=8888 BUILD_APP_ENV=\"openanolis\" umi dev", - "build:openanolis": "cross-env BUILD_APP_ENV=\"openanolis\" umi build", - "start:tone": "cross-env BUILD_APP_ENV= PORT=8888 umi dev", - "build:tone": "cross-env BUILD_APP_ENV= PORT=8888 umi build", + "start": "cross-env NODE_OPTIONS=--openssl-legacy-provider BUILD_APP_ENV=\"opensource\" PORT=8888 umi dev", + "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider BUILD_APP_ENV=\"opensource\" umi build", + "start:openanolis": "cross-env NODE_OPTIONS=--openssl-legacy-provider PORT=8888 BUILD_APP_ENV=\"openanolis\" umi dev", + "build:openanolis": "cross-env NODE_OPTIONS=--openssl-legacy-provider BUILD_APP_ENV=\"openanolis\" umi build", + "start:tone": "cross-env NODE_OPTIONS=--openssl-legacy-provider BUILD_APP_ENV= PORT=8888 umi dev", + "build:tone": "cross-env NODE_OPTIONS=--openssl-legacy-provider BUILD_APP_ENV= PORT=8888 umi build", "analyze": "cross-env ANALYZE=1 umi build", "deploy": "npm run site && npm run gh-pages", "dev": "npm run start:dev", diff --git a/src/app.tsx b/src/app.tsx index 39700ab225eb4308c9e2ad81519e3f75e01485a9..095287b87e61a7e4749ff6e683ee873d91dcd4a2 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -101,7 +101,7 @@ export async function getInitialState(): Promise { redirectErrorPage(401) return baseAppState } - const ws: any = await enterWsAndGetList(ws_id) + const ws: any = await enterWsAndGetList(ws_id) || {} if (ws?.first_entry) { history.push(`/ws/${ws_id}/workspace/initSuccess`) } diff --git a/src/components/Header/components/HeaderDropdown.tsx b/src/components/Header/components/HeaderDropdown.tsx index 40e90da7fef1432efd06b9ee5069ebdb8bd3732e..9bf4a31a86cca9d2620f99ea3ee22eb19bdba956 100644 --- a/src/components/Header/components/HeaderDropdown.tsx +++ b/src/components/Header/components/HeaderDropdown.tsx @@ -93,7 +93,7 @@ export const HearderDropdown: React.FC = (props) => { const current = React.useMemo(() => { if (!wsList) return {} - const [workspace] = wsList?.data?.filter(({ id }: any) => id === ws_id) + const [workspace] = (wsList?.data || [])?.filter(({ id }: any) => id === ws_id) // wsList?.data?.filter(({ id }: any) => id === ws_id) if (workspace) return workspace return {} }, [wsList, ws_id]) diff --git a/src/components/Header/components/JobModal.tsx b/src/components/Header/components/JobModal.tsx index a159523b9f8deb4d9f19da208b91609ff7caaaa9..ac027f7cdc2e0303e8a6b17ca89161f401e747d9 100644 --- a/src/components/Header/components/JobModal.tsx +++ b/src/components/Header/components/JobModal.tsx @@ -15,7 +15,7 @@ const JobTemplateModal: React.FC> = (props) => { const dataSourceCopy = props.getData(jobTemplates) return ( - + { - setSelectValue(row.role_list.map((item: any) => (item.id))[0]) + setSelectValue(row?.role_list?.map((item: any) => (item.id))[0]) }, [row.role_list]) - // console.log('selectValue:', selectValue) - return (
diff --git a/src/pages/WorkSpace/DeviceManage/CloudManage/AddMachinePubilc/index.tsx b/src/pages/WorkSpace/DeviceManage/CloudManage/AddMachinePubilc/index.tsx index d9d1a663d71d89b5db1af44522adb74c99d97a0f..168ba723b06ec446e265c208aab89377ebadb55e 100644 --- a/src/pages/WorkSpace/DeviceManage/CloudManage/AddMachinePubilc/index.tsx +++ b/src/pages/WorkSpace/DeviceManage/CloudManage/AddMachinePubilc/index.tsx @@ -1117,7 +1117,7 @@ const NewMachine: React.FC = (props) => { - {!is_instance && BUILD_APP_ENV === 'openanolis' && + {!is_instance && BUILD_APP_ENV !== 'opensource' && = (props) => { rules={[{ required: false, message: formatMessage({ id: 'please.select' }) }]} > - + {BUILD_APP_ENV === 'openanolis' && + + } diff --git a/src/pages/WorkSpace/DeviceManage/CloudManage/Aligroup/index.tsx b/src/pages/WorkSpace/DeviceManage/CloudManage/Aligroup/index.tsx index 65f3beaf9ade0052fea98cfa4f47e09ff4a6f013..bdd2a30ff50fcbde01d6db27284230b47370c4d8 100644 --- a/src/pages/WorkSpace/DeviceManage/CloudManage/Aligroup/index.tsx +++ b/src/pages/WorkSpace/DeviceManage/CloudManage/Aligroup/index.tsx @@ -14,10 +14,11 @@ import SelectTags from '@/components/Public/SelectTags'; import Highlighter from 'react-highlight-words'; import AddCluster from './AddGroup' import { FilterFilled } from '@ant-design/icons'; -import { useParams, useIntl, FormattedMessage, useLocation, history } from 'umi'; +import { useParams, useIntl, FormattedMessage, useLocation, history, getLocale } from 'umi'; import { useClientSize } from '@/utils/hooks'; import { AccessTootip, handlePageNum, requestCodeMessage, saveRefenerceData, useStateRef } from '@/utils/utils'; import { Access, useAccess } from 'umi' +import SelectRadio from '@/components/Public/SelectRadio'; import Log from '@/components/Public/Log'; import OverflowList from '@/components/TagOverflow/index'; import CommonPagination from '@/components/CommonPagination'; @@ -35,6 +36,7 @@ interface AligroupParams { page_num?: number, page_size?: number, name?: string, + is_temporary?: string, owner?: any, tags?: any, description?: string, @@ -45,6 +47,7 @@ const Aligroup: React.ForwardRefRenderFunction = (props) => { const { tab } = props const { query } = useLocation() as any const { formatMessage } = useIntl() + const enLocale = getLocale() === 'en-US' const { ws_id }: any = useParams() const [form] = Form.useForm(); const access = useAccess(); @@ -85,8 +88,11 @@ const Aligroup: React.ForwardRefRenderFunction = (props) => { const getList = async ($params: any = {}) => { setLoading(true) const data: any = await querysCluster({ ...$params }) - history.replace(`/ws/${ws_id}/device/cloud?${stringify({ ...$params, is_instance: $params.is_instance ? 1 : 0 })}`) - data && setSource(data) + if (data.code === 200) { + history.replace(`/ws/${ws_id}/device/cloud?${stringify({ ...$params, is_instance: $params.is_instance ? 1 : 0 })}`) + console.log('data:', data) + data && setSource(data) + } setLoading(false) }; const totalCurrent = useStateRef(source) @@ -175,6 +181,18 @@ const Aligroup: React.ForwardRefRenderFunction = (props) => { filterIcon: () => , }) + const radioFilterCommonFields = (dataIndex: string, list: any[]) => ({ + filterIcon: () => , + filterDropdown: ({ confirm }: any) => ( + setParams({ ...params, [dataIndex]: val, page_num: 1 })} + /> + ), + }) + const columns: any = [ { title: , @@ -192,6 +210,22 @@ const Aligroup: React.ForwardRefRenderFunction = (props) => { ) }, + { + title: , + ...radioFilterCommonFields("is_temporary", [ + { id: 0, name: formatMessage({ id: 'cluster' }) }, + { id: 1, name: formatMessage({ id: 'device.temporary.cluster' }) }, + ]), + dataIndex: 'is_temporary', + width: enLocale ? 170 : 150, + ellipsis: { + showTitle: false + }, + render: (_: any, row: any) => { + const text = _ ? formatMessage({ id: 'device.temporary.cluster' }): formatMessage({ id: 'cluster' }) + return {row.hasOwnProperty('is_temporary') ? text: '-'} + } + }, { title: 'Owner', dataIndex: 'owner_name', diff --git a/src/pages/WorkSpace/DeviceManage/GroupManage/Cluster/index.tsx b/src/pages/WorkSpace/DeviceManage/GroupManage/Cluster/index.tsx index fcd16df3d9688d5a1eeed540a2021c065e6b2bf5..fd90623a642ed5d7272a3ad6c216bea7a3e14d25 100644 --- a/src/pages/WorkSpace/DeviceManage/GroupManage/Cluster/index.tsx +++ b/src/pages/WorkSpace/DeviceManage/GroupManage/Cluster/index.tsx @@ -1,6 +1,6 @@ import { useState, useCallback, useRef, forwardRef, useImperativeHandle } from 'react' import styles from './index.less' -import { useIntl, FormattedMessage, useParams } from 'umi' +import { useIntl, FormattedMessage, useParams, getLocale } from 'umi' import { Layout, Button, Space, Tag, message, Typography, Spin, Modal, Table } from 'antd' import { deleteServerGroup, queryServerDel } from '../services' import { CaretRightFilled, FilterFilled, ExclamationCircleOutlined } from '@ant-design/icons' @@ -15,6 +15,7 @@ import CommonPagination from '@/components/CommonPagination' import { usePageInit } from './hooks' import { requestCodeMessage, AccessTootip, saveRefenerceData } from '@/utils/utils'; import { Access, useAccess } from 'umi'; +import SelectRadio from '@/components/Public/SelectRadio'; import OverflowList from '@/components/TagOverflow/index' import { ColumnEllipsisText } from '@/components/ColumnComponents' import { v4 as uuid } from 'uuid' @@ -26,6 +27,7 @@ import DelConfirmModal from "@/pages/WorkSpace/DeviceManage/components/DelConfir */ const Cluster = (props: any, ref: any) => { const { formatMessage } = useIntl() + const enLocale = getLocale() === 'en-US' const { ws_id } = useParams() as any const access = useAccess(); const { loading, dataSource, params, setParams, setRefresh } = usePageInit() @@ -101,6 +103,18 @@ const Cluster = (props: any, ref: any) => { }, [] ) + const radioFilterCommonFields = (dataIndex: string, list: any[]) => ({ + filterIcon: () => , + filterDropdown: ({ confirm }: any) => ( + setParams({ ...params, [dataIndex]: val, page_num: 1 })} + /> + ), + }) + const columns: any = [ { title: , @@ -111,6 +125,22 @@ const Cluster = (props: any, ref: any) => { setParams({ ...params, page_num: 1, name })} /> ) }, + { + title: , + ...radioFilterCommonFields("is_temporary", [ + { id: 0, name: formatMessage({ id: 'cluster' }) }, + { id: 1, name: formatMessage({ id: 'device.temporary.cluster' }) }, + ]), + dataIndex: 'is_temporary', + width: enLocale ? 170 : 150, + ellipsis: { + showTitle: false + }, + render: (_: any, row: any) => { + const text = _ ? formatMessage({ id: 'device.temporary.cluster' }): formatMessage({ id: 'cluster' }) + return {row.hasOwnProperty('is_temporary') ? text: '-'} + } + }, { title: 'Owner', width: 150, diff --git a/src/pages/WorkSpace/DeviceManage/locales/en-US.ts b/src/pages/WorkSpace/DeviceManage/locales/en-US.ts index c2ddbdf82ff2d6bb42da90ba785a083a60734c71..4b0ac6500cf95596003428b0eafed59eb3887afb 100644 --- a/src/pages/WorkSpace/DeviceManage/locales/en-US.ts +++ b/src/pages/WorkSpace/DeviceManage/locales/en-US.ts @@ -109,6 +109,9 @@ export default { 'device.cluster.name.s': 'Cluster Name', 'device.cluster.name.s.message': 'Cluster name cannot be empty.', 'device.cluster.name.s.existed': 'Cluster name already exists', + 'device.cluster/temporary.cluster': 'Cluster/Temporary Cluster', + // '集群': '集群', + 'device.temporary.cluster': 'Temporary Cluster', 'please.select.owner': 'Please select Owner', 'device.cluster.delete.tips': 'The cluster has been configured with an existing template. After deleting the server, the corresponding test server configuration will be automatically changed to random. Please delete it carefully.', 'device.is_single': 'Is it from the stand-alone pool?', @@ -155,8 +158,8 @@ export default { 'device.extended.fields': 'Extended Fields', 'device.aliyun.params': 'Alibaba Cloud openAPI parameters', 'device.toneagent.working.mode': 'Toneagent working mode', - 'device.active.mode': 'Active mode', - 'device.passive.mode': 'Passive mode', + 'device.active.mode': 'Active', + 'device.passive.mode': 'Passive', 'device.tips': 'Tips', 'device.delete.config': 'Are you sure you want to delete the configuration ({data})?', 'device.delete.instance': 'Are you sure you want to delete the instance({data})?', diff --git a/src/pages/WorkSpace/DeviceManage/locales/zh-CN.ts b/src/pages/WorkSpace/DeviceManage/locales/zh-CN.ts index 67f94df173934962ae7fc21476232b90cf1af6da..e449504198deb00fb0091ff4c6730401c5d8ce8c 100644 --- a/src/pages/WorkSpace/DeviceManage/locales/zh-CN.ts +++ b/src/pages/WorkSpace/DeviceManage/locales/zh-CN.ts @@ -109,6 +109,9 @@ export default { 'device.cluster.name.s': '集群名称', 'device.cluster.name.s.message': '集群名称不能为空', 'device.cluster.name.s.existed': '集群名称已存在', + 'device.cluster/temporary.cluster': '集群/临时集群', + // '集群': '集群', + 'device.temporary.cluster': '临时集群', 'please.select.owner': '请选择Owner', 'device.cluster.delete.tips': '已有模板配置了该集群,删除机器后对应的测试机配置会自动改为随机,请谨慎删除!!', 'device.is_single': '是否是单机池', diff --git a/src/pages/WorkSpace/TestReport/NewReport/hooks.ts b/src/pages/WorkSpace/TestReport/NewReport/hooks.ts index 05deedef5ec0295f0766c26a4e416a823d9f56b7..befa9fd42c3712006822ec2e3dc13bd8ea13fef8 100644 --- a/src/pages/WorkSpace/TestReport/NewReport/hooks.ts +++ b/src/pages/WorkSpace/TestReport/NewReport/hooks.ts @@ -81,24 +81,30 @@ export const CreatePageData = (props: any) => { let resLen: any = [] resLen = perfArr.concat(funcArr) setSuiteLen(resLen.length) - resLen.map((item: any, i: number) => queryCompareResultFn(item) - .then(res => { - if (res.code === 200) { - setLoading(false) - if (res.data.test_type === 'functional') { - compareResult.func_data_result = compareResult.func_data_result.concat(res.data) + try { + resLen.map((item: any, i: number) => queryCompareResultFn(item) + .then(res => { + if (res.code === 200) { + setLoading(false) + if (res.data.test_type === 'functional') { + compareResult.func_data_result = compareResult.func_data_result.concat(res.data) + } + if (res.data.test_type === 'performance') { + compareResult.perf_data_result = compareResult.perf_data_result.concat(res.data) + } } - if (res.data.test_type === 'performance') { - compareResult.perf_data_result = compareResult.perf_data_result.concat(res.data) + setCompareResult({ ...compareResult }) + if (res.code !== 200) { + message.error(res.msg) + return } - } - setCompareResult({ ...compareResult }) - if (res.code !== 200) { - message.error(res.msg) - return - } - }) - ) + }) + ) + } catch (error) { + setLoading(false) + } finally { + setLoading(false) + } } useEffect(() => { diff --git a/src/utils/hooks.tsx b/src/utils/hooks.tsx index 61198b72c95a4697300bda83478cfc4f8746cecb..d06795f8ff610efd9853b0b32a451393438b85cd 100644 --- a/src/utils/hooks.tsx +++ b/src/utils/hooks.tsx @@ -10,7 +10,7 @@ const { document, location }: any = window export const enterWsAndGetList = async (ws_id: any) => { try { - const { data } = await enterWorkspaceHistroy({ ws_id }) + const { data } = await enterWorkspaceHistroy({ ws_id }) || {} const { code, ...historyWorkspaces } = await queryWorkspaceHistory({ page_num: 1, page_size: 20, diff --git a/src/wrappers/WorkspaceAuth.tsx b/src/wrappers/WorkspaceAuth.tsx index 32da761a4a1a93bee935448f156ce6def559f66b..af06f33e3041a0778b9cc90c65f7790f00595bf5 100644 --- a/src/wrappers/WorkspaceAuth.tsx +++ b/src/wrappers/WorkspaceAuth.tsx @@ -29,7 +29,7 @@ export default (props: any) => { /* 切换ws请求记录历史接口 */ /* getHistoryFetcher() */ - const ws = await enterWsAndGetList(ws_id) + const ws = await enterWsAndGetList(ws_id) || {} setInitialState((p: any) => ({ ...p, ...ws,