Skip to content

Commit 8e0f94b

Browse files
committed
Add search filter for the objects
1 parent 0f5440d commit 8e0f94b

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

client/packages/lowcoder/src/pages/setting/environments/components/DeployableItemsList.tsx

+44-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// components/DeployableItemsList.tsx
2-
import React from 'react';
3-
import { Table, Tag, Empty, Spin, Switch, Space, Button, Tooltip } from 'antd';
4-
import { CloudUploadOutlined } from '@ant-design/icons';
2+
import React, { useState } from 'react';
3+
import { Table, Tag, Empty, Spin, Switch, Space, Button, Tooltip, Input } from 'antd';
4+
import { CloudUploadOutlined, SearchOutlined } from '@ant-design/icons';
55
import history from '@lowcoder-ee/util/history';
66
import { DeployableItem, BaseStats, DeployableItemConfig } from '../types/deployable-item.types';
77
import { Environment } from '../types/environment.types';
88
import { useDeployModal } from '../context/DeployModalContext';
99

10+
const { Search } = Input;
11+
1012
interface DeployableItemsListProps<T extends DeployableItem, S extends BaseStats> {
1113
items: T[];
1214
loading: boolean;
@@ -30,6 +32,14 @@ function DeployableItemsList<T extends DeployableItem, S extends BaseStats>({
3032
}: DeployableItemsListProps<T, S>) {
3133

3234
const { openDeployModal } = useDeployModal();
35+
const [searchText, setSearchText] = useState('');
36+
37+
// Filter items based on search
38+
const filteredItems = searchText
39+
? items.filter(item =>
40+
item.name.toLowerCase().includes(searchText.toLowerCase()) ||
41+
item.id.toLowerCase().includes(searchText.toLowerCase()))
42+
: items;
3343

3444
// Handle row click for navigation
3545
const handleRowClick = (item: T) => {
@@ -53,8 +63,7 @@ function DeployableItemsList<T extends DeployableItem, S extends BaseStats>({
5363
onToggleManaged,
5464
openDeployModal,
5565
additionalParams
56-
})
57-
66+
});
5867

5968
if (loading) {
6069
return (
@@ -76,18 +85,36 @@ function DeployableItemsList<T extends DeployableItem, S extends BaseStats>({
7685
const hasNavigation = config.buildDetailRoute({}) !== '#';
7786

7887
return (
79-
<Table
80-
columns={columns}
81-
dataSource={items}
82-
rowKey={config.idField}
83-
pagination={{ pageSize: 10 }}
84-
size="middle"
85-
scroll={{ x: 'max-content' }}
86-
onRow={(record) => ({
87-
onClick: hasNavigation ? () => handleRowClick(record) : undefined,
88-
style: hasNavigation ? { cursor: 'pointer' } : undefined,
89-
})}
90-
/>
88+
<>
89+
{/* Search Bar */}
90+
<div style={{ marginBottom: 16 }}>
91+
<Search
92+
placeholder={`Search ${config.pluralLabel} by name or ID`}
93+
allowClear
94+
onSearch={value => setSearchText(value)}
95+
onChange={e => setSearchText(e.target.value)}
96+
style={{ width: 300 }}
97+
/>
98+
{searchText && filteredItems.length !== items.length && (
99+
<div style={{ marginTop: 8 }}>
100+
Showing {filteredItems.length} of {items.length} {config.pluralLabel.toLowerCase()}
101+
</div>
102+
)}
103+
</div>
104+
105+
<Table
106+
columns={columns}
107+
dataSource={filteredItems}
108+
rowKey={config.idField}
109+
pagination={{ pageSize: 10 }}
110+
size="middle"
111+
scroll={{ x: 'max-content' }}
112+
onRow={(record) => ({
113+
onClick: hasNavigation ? () => handleRowClick(record) : undefined,
114+
style: hasNavigation ? { cursor: 'pointer' } : undefined,
115+
})}
116+
/>
117+
</>
91118
);
92119
}
93120

0 commit comments

Comments
 (0)