feat(componentTest): 添加实例搜索功能并优化界面

master
钟良源 2 months ago
parent cd02dd1df6
commit 8db295e871

@ -16,6 +16,7 @@ const ComponentTest = () => {
const [count, setCount] = useState({ total: 0, passed: 0, failed: 0 }); const [count, setCount] = useState({ total: 0, passed: 0, failed: 0 });
const [currentView, setCurrentView] = useState<'list' | 'test'>('list'); const [currentView, setCurrentView] = useState<'list' | 'test'>('list');
const [selectedInstance, setSelectedInstance] = useState<any>(null); const [selectedInstance, setSelectedInstance] = useState<any>(null);
const [searchValue, setSearchValue] = useState<string>('');
// 标签配置 // 标签配置
const tagList = [ const tagList = [
@ -82,15 +83,12 @@ const ComponentTest = () => {
<Space split={<Divider type="vertical" />}> <Space split={<Divider type="vertical" />}>
<Input <Input
prefix={<IconSearch />} prefix={<IconSearch />}
placeholder={'搜索'} placeholder={'搜索实例标识或实例名'}
style={{ width: 236 }} style={{ width: 236 }}
value={searchValue}
onChange={(value) => setSearchValue(value)}
allowClear
/> />
<Button
type="primary"
style={{ marginLeft: 5, borderRadius: 4 }}
>
</Button>
</Space> </Space>
</div> </div>
<div className={styles['content']}> <div className={styles['content']}>
@ -102,6 +100,7 @@ const ComponentTest = () => {
identifier={selectedIdentifier} identifier={selectedIdentifier}
refreshKey={refreshKey} refreshKey={refreshKey}
onGoToTest={handleGoToTest} onGoToTest={handleGoToTest}
searchValue={searchValue}
/> />
</div> </div>
</div> </div>

@ -4,10 +4,11 @@ import { getTreeComponents } from '@/api/componentTestCase';
import { runStatusConstant, runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy'; import { runStatusConstant, runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
const InstanceList = ({ identifier, refreshKey, onGoToTest }: { const InstanceList = ({ identifier, refreshKey, onGoToTest, searchValue }: {
identifier: string; identifier: string;
refreshKey: number; refreshKey: number;
onGoToTest: (instance: any) => void; onGoToTest: (instance: any) => void;
searchValue?: string;
}) => { }) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@ -39,6 +40,20 @@ const InstanceList = ({ identifier, refreshKey, onGoToTest }: {
fetchInstanceData(identifier); fetchInstanceData(identifier);
}, [identifier, refreshKey]); }, [identifier, refreshKey]);
// 根据搜索值过滤数据
const filteredData = React.useMemo(() => {
if (!searchValue || searchValue.trim() === '') {
return data;
}
const searchTerm = searchValue.toLowerCase().trim();
return data.filter((item: any) => {
const identifier = (item.identifier || '').toLowerCase();
const name = (item.name || '').toLowerCase();
return identifier.includes(searchTerm) || name.includes(searchTerm);
});
}, [data, searchValue]);
// 定义表格列 // 定义表格列
const columns: TableColumnProps[] = [ const columns: TableColumnProps[] = [
{ {
@ -95,7 +110,7 @@ const InstanceList = ({ identifier, refreshKey, onGoToTest }: {
return ( return (
<Table <Table
columns={columns} columns={columns}
data={data} data={filteredData}
loading={loading} loading={loading}
pagination={false} pagination={false}
rowKey="id" rowKey="id"

Loading…
Cancel
Save