search by fields

This commit is contained in:
typescreep
2025-09-19 17:47:22 +03:00
parent e205de3d15
commit 1cdc39e92c
5 changed files with 26 additions and 9 deletions

8
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"@ant-design/icons": "5.6.0",
"@monaco-editor/react": "4.6.0",
"@originjs/vite-plugin-federation": "1.3.6",
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.120",
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.121",
"@readme/openapi-parser": "4.0.0",
"@reduxjs/toolkit": "2.2.5",
"@tanstack/react-query": "5.62.2",
@@ -2802,9 +2802,9 @@
}
},
"node_modules/@prorobotech/openapi-k8s-toolkit": {
"version": "0.0.1-alpha.120",
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.120.tgz",
"integrity": "sha512-mykTMrnI4Fxsj4wrkFISZJTIYWqKFAxPd11Lkn+LPUsoOoeRCZRpDC6iRnxyxTw2jnBjLEPJ4eTS2A6bagTWyw==",
"version": "0.0.1-alpha.121",
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.121.tgz",
"integrity": "sha512-lH693F4RGC8QT5GymDkyY4NHQgDGW67ncTbbT94r/U7ZdHWoME6+z17XNThEMi65OnaMES2PpbF++hEI/Um+IQ==",
"license": "MIT",
"dependencies": {
"@monaco-editor/react": "4.6.0",

View File

@@ -20,7 +20,7 @@
"@ant-design/icons": "5.6.0",
"@monaco-editor/react": "4.6.0",
"@originjs/vite-plugin-federation": "1.3.6",
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.120",
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.121",
"@readme/openapi-parser": "4.0.0",
"@reduxjs/toolkit": "2.2.5",
"@tanstack/react-query": "5.62.2",

View File

@@ -36,6 +36,7 @@ type TTableApiBuiltinProps = {
typeName: string
specificName?: string
labels?: string[]
fields?: string[]
limit: string | null
inside?: boolean
customizationIdPrefix: string
@@ -50,6 +51,7 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
typeName,
specificName,
labels,
fields,
limit,
inside,
customizationIdPrefix,
@@ -156,6 +158,7 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
typeName,
specificName,
labels,
fields,
limit,
isEnabled: resourceType === 'builtin',
})
@@ -172,6 +175,7 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
typeName,
specificName,
labels,
fields,
limit,
isEnabled: resourceType === 'api' && !!apiGroup && !!apiVersion,
})

View File

@@ -8,14 +8,24 @@ import { SearchEntry } from './molecules'
export const Search: FC = () => {
const cluster = useSelector((state: RootState) => state.cluster.cluster)
const [currentSearch, setCurrentSearch] = useState<{ resources?: string[]; name?: string; labels?: string[] }>()
const [currentSearch, setCurrentSearch] = useState<{
resources?: string[]
name?: string
labels?: string[]
fields?: string[]
}>()
return (
<>
<PackageSearch cluster={cluster} updateCurrentSearch={value => setCurrentSearch(value)} />
{currentSearch?.resources?.map(item => (
<Fragment key={item}>
<SearchEntry resource={item} name={currentSearch.name} labels={currentSearch.labels} />
<SearchEntry
resource={item}
name={currentSearch.name}
labels={currentSearch.labels}
fields={currentSearch.fields}
/>
<Spacer $space={50} $samespace />
</Fragment>
))}

View File

@@ -9,9 +9,10 @@ type TSearchEntryProps = {
resource: string
name?: string
labels?: string[]
fields?: string[]
}
export const SearchEntry: FC<TSearchEntryProps> = ({ resource, name, labels }) => {
export const SearchEntry: FC<TSearchEntryProps> = ({ resource, name, labels, fields }) => {
const { namespace, syntheticProject } = useParams()
const [searchParams] = useSearchParams()
@@ -30,7 +31,8 @@ export const SearchEntry: FC<TSearchEntryProps> = ({ resource, name, labels }) =
{apiGroup.length > 0 ? `${apiGroup}/${apiVersion}/` : 'v1/'}
{typeName}
{name ? ` & name=${name}` : ''}
{labels ? ` & labels=${labels.join('+')}` : ''}
{labels && labels.length ? ` & labels=${labels.join('+')}` : ''}
{fields && fields.length ? ` & labels=${fields.join('+')}` : ''}
</Typography.Title>
{typeName && (
<TableApiBuiltin
@@ -41,6 +43,7 @@ export const SearchEntry: FC<TSearchEntryProps> = ({ resource, name, labels }) =
typeName={typeName}
specificName={name?.length ? name : undefined}
labels={labels?.length ? labels : undefined}
fields={fields?.length ? fields : undefined}
limit={searchParams.get('limit')}
customizationIdPrefix={tableCustomizationIdPrefix}
searchMount