mirror of
https://github.com/outbackdingo/openapi-ui.git
synced 2026-01-27 18:19:50 +00:00
search by name/labels
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user