search by name/labels

This commit is contained in:
typescreep
2025-09-18 15:36:04 +03:00
parent 363c15bd1a
commit 4f3e52d056
6 changed files with 52 additions and 13 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.119",
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.120",
"@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.119",
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.119.tgz",
"integrity": "sha512-e0AwwmMBAyjrpTPWMC9eSiyUimTzxskaNhAzs/+7DV7u0MqjJLOPehsko/AIpm/RkOoU6qOYjAHTjWZHV1hLhA==",
"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==",
"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.119",
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.120",
"@readme/openapi-parser": "4.0.0",
"@reduxjs/toolkit": "2.2.5",
"@tanstack/react-query": "5.62.2",

View File

@@ -26,7 +26,7 @@ import {
TABLE_ADD_BUTTON_HEIGHT,
} from 'constants/blocksSizes'
import { OverflowContainer } from './atoms'
import { getBackLinkToTable, getLinkToForm } from './utils'
import { getDataItems, getBackLinkToTable, getLinkToForm } from './utils'
type TTableApiBuiltinProps = {
namespace?: string
@@ -34,6 +34,8 @@ type TTableApiBuiltinProps = {
apiGroup?: string // api
apiVersion?: string // api
typeName: string
specificName?: string
labels?: string[]
limit: string | null
inside?: boolean
customizationIdPrefix: string
@@ -46,6 +48,8 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
apiGroup,
apiVersion,
typeName,
specificName,
labels,
limit,
inside,
customizationIdPrefix,
@@ -150,6 +154,8 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
clusterName: cluster,
namespace,
typeName,
specificName,
labels,
limit,
isEnabled: resourceType === 'builtin',
})
@@ -164,6 +170,8 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
apiGroup: apiGroup || '',
apiVersion: apiVersion || '',
typeName,
specificName,
labels,
limit,
isEnabled: resourceType === 'api' && !!apiGroup && !!apiVersion,
})
@@ -222,7 +230,7 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
cluster={cluster}
theme={theme}
baseprefix={inside ? `${baseprefix}/inside` : baseprefix}
dataItems={resourceType === 'builtin' ? dataBuiltin?.items || [] : dataApi?.items || []}
dataItems={getDataItems({ resourceType, dataBuiltin, dataApi, isSingle: !!specificName })}
dataForControls={{
cluster,
syntheticProject: params.syntheticProject,

View File

@@ -1,3 +1,28 @@
import { TBuiltinResources, TApiResources, TJSON } from '@prorobotech/openapi-k8s-toolkit'
export const getDataItems = ({
resourceType,
dataBuiltin,
dataApi,
isSingle,
}: {
resourceType: 'builtin' | 'api'
dataBuiltin?: TBuiltinResources
dataApi?: TApiResources
isSingle?: boolean
}): TJSON[] => {
if (isSingle) {
if (resourceType === 'builtin') {
return dataBuiltin ? [dataBuiltin] : []
}
if (resourceType === 'api') {
return dataApi ? [dataApi] : []
}
}
return resourceType === 'builtin' ? dataBuiltin?.items || [] : dataApi?.items || []
}
export const getBackLinkToBuiltinTable = ({
cluster,
baseprefix,

View File

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

View File

@@ -7,9 +7,11 @@ import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersio
type TSearchEntryProps = {
resource: string
name?: string
labels?: string[]
}
export const SearchEntry: FC<TSearchEntryProps> = ({ resource }) => {
export const SearchEntry: FC<TSearchEntryProps> = ({ resource, name, labels }) => {
const { namespace, syntheticProject } = useParams()
const [searchParams] = useSearchParams()
@@ -27,14 +29,18 @@ export const SearchEntry: FC<TSearchEntryProps> = ({ resource }) => {
<Typography.Title level={4}>
{apiGroup.length > 0 ? `${apiGroup}/${apiVersion}/` : 'v1/'}
{typeName}
{name ? ` & name=${name}` : ''}
{labels ? ` & labels=${labels.join('+')}` : ''}
</Typography.Title>
{typeName && apiGroup && apiVersion && (
{typeName && (
<TableApiBuiltin
resourceType={apiGroup ? 'api' : 'builtin'}
resourceType={apiGroup.length > 0 ? 'api' : 'builtin'}
namespace={namespace}
apiGroup={apiGroup.length > 0 ? apiGroup : undefined}
apiVersion={apiGroup.length > 0 ? apiVersion : undefined}
typeName={typeName}
specificName={name?.length ? name : undefined}
labels={labels?.length ? labels : undefined}
limit={searchParams.get('limit')}
customizationIdPrefix={tableCustomizationIdPrefix}
searchMount