-
Notifications
You must be signed in to change notification settings - Fork 65
OSAC-2932: [UI] Catalog management list page with resource type tabs #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 15 commits into
osac-project:main
from
ElayAharoni:OSAC-2932-catalog-management-list-page
Jul 28, 2026
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4ee9480
OSAC-2932: widen CatalogItem type and add scope derivation for admin …
ElayAharoni ed41374
OSAC-2932: support private-v1 catalog item kinds in CatalogItemIcon
ElayAharoni 1c34988
OSAC-2932: add role-aware admin catalog item hooks (list + publish to…
ElayAharoni 192cb3f
OSAC-2932: add CatalogItemScopeBadge, CatalogItemStatusLabel, Catalog…
ElayAharoni 2218b09
OSAC-2932: add scope badge, status label, and publish toggle slots to…
ElayAharoni 3d28c4c
OSAC-2932: add CatalogManagementListPage with resource type tabs
ElayAharoni c71dc95
OSAC-2932: fix prettier formatting in admin catalog hook tests
ElayAharoni 9402235
OSAC-2932: address cross-cutting review findings
ElayAharoni 9fb3e1e
OSAC-2932: Address review feedback — shared test harness, param order…
ElayAharoni 390f0cc
OSAC-2932: address rawagner PR review — remove publish toggle, split …
ElayAharoni 11357d0
Merge remote-tracking branch 'origin/main' into OSAC-2932-catalog-man…
ElayAharoni ba422a1
OSAC-2932: fix formatting after merge with main
ElayAharoni f3fcf0b
OSAC-2932: extract shared catalog hook test factory
ElayAharoni 5c3d592
Merge remote-tracking branch 'origin/main' into OSAC-2932-catalog-man…
ElayAharoni dfacec5
Merge remote-tracking branch 'origin/main' into OSAC-2932-catalog-man…
ElayAharoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { createRouterTransport } from '@connectrpc/connect'; | ||
| import { waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import type { BareMetalInstanceCatalogItem } from '@osac/types'; | ||
| import { BareMetalInstanceCatalogItems } from '@osac/types'; | ||
|
|
||
| import { useBareMetalInstanceCatalogItems } from './baremetal-instance'; | ||
| import { renderHookWithProviders } from '../../test-utils/TestProviders'; | ||
|
|
||
| const item: BareMetalInstanceCatalogItem = { | ||
| $typeName: 'osac.public.v1.BareMetalInstanceCatalogItem', | ||
| id: 'public-1', | ||
| title: 'Public bare metal item', | ||
| description: '', | ||
| template: '', | ||
| published: true, | ||
| fieldDefinitions: [], | ||
| }; | ||
|
|
||
| describe('useBareMetalInstanceCatalogItems', () => { | ||
| it('fetches items from the public BareMetalInstanceCatalogItems List endpoint', async () => { | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(BareMetalInstanceCatalogItems, { list: () => ({ items: [item] }) }); | ||
| }); | ||
|
|
||
| const { result } = renderHookWithProviders(() => useBareMetalInstanceCatalogItems(), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(result.current.data).toEqual([item]); | ||
| }); | ||
|
|
||
| it('does not fetch when disabled', async () => { | ||
| let listCalled = false; | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(BareMetalInstanceCatalogItems, { | ||
| list: () => { | ||
| listCalled = true; | ||
| return { items: [item] }; | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| renderHookWithProviders(() => useBareMetalInstanceCatalogItems({}, false), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 10)); | ||
| expect(listCalled).toBe(false); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
libs/ui-components/src/api/v1/cluster-catalog-item.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { createRouterTransport } from '@connectrpc/connect'; | ||
| import { waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import type { ClusterCatalogItem } from '@osac/types'; | ||
| import { ClusterCatalogItems } from '@osac/types'; | ||
|
|
||
| import { useClusterCatalogItems } from './cluster-catalog-item'; | ||
| import { renderHookWithProviders } from '../../test-utils/TestProviders'; | ||
|
|
||
| const item: ClusterCatalogItem = { | ||
| $typeName: 'osac.public.v1.ClusterCatalogItem', | ||
| id: 'public-1', | ||
| title: 'Public cluster item', | ||
| description: '', | ||
| template: '', | ||
| published: true, | ||
| fieldDefinitions: [], | ||
| }; | ||
|
|
||
| describe('useClusterCatalogItems', () => { | ||
| it('fetches items from the public ClusterCatalogItems List endpoint', async () => { | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(ClusterCatalogItems, { list: () => ({ items: [item] }) }); | ||
| }); | ||
|
|
||
| const { result } = renderHookWithProviders(() => useClusterCatalogItems(), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(result.current.data).toEqual([item]); | ||
| }); | ||
|
|
||
| it('does not fetch when disabled', async () => { | ||
| let listCalled = false; | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(ClusterCatalogItems, { | ||
| list: () => { | ||
| listCalled = true; | ||
| return { items: [item] }; | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| renderHookWithProviders(() => useClusterCatalogItems({}, false), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 10)); | ||
| expect(listCalled).toBe(false); | ||
| }); | ||
| }); |
55 changes: 55 additions & 0 deletions
55
libs/ui-components/src/api/v1/compute-instance-catalog-item.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { createRouterTransport } from '@connectrpc/connect'; | ||
| import { waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import type { ComputeInstanceCatalogItem } from '@osac/types'; | ||
| import { ComputeInstanceCatalogItems } from '@osac/types'; | ||
|
|
||
| import { useComputeInstanceCatalogItems } from './compute-instance-catalog-item'; | ||
| import { renderHookWithProviders } from '../../test-utils/TestProviders'; | ||
|
|
||
| const item: ComputeInstanceCatalogItem = { | ||
| $typeName: 'osac.public.v1.ComputeInstanceCatalogItem', | ||
| id: 'public-1', | ||
| title: 'Public VM item', | ||
| description: '', | ||
| template: '', | ||
| published: true, | ||
| fieldDefinitions: [], | ||
| }; | ||
|
|
||
| describe('useComputeInstanceCatalogItems', () => { | ||
| it('fetches items from the public ComputeInstanceCatalogItems List endpoint', async () => { | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(ComputeInstanceCatalogItems, { list: () => ({ items: [item] }) }); | ||
| }); | ||
|
|
||
| const { result } = renderHookWithProviders(() => useComputeInstanceCatalogItems(), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(result.current.data).toEqual([item]); | ||
| }); | ||
|
|
||
| it('does not fetch when disabled', async () => { | ||
| let listCalled = false; | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(ComputeInstanceCatalogItems, { | ||
| list: () => { | ||
| listCalled = true; | ||
| return { items: [item] }; | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| renderHookWithProviders(() => useComputeInstanceCatalogItems({}, false), { | ||
| role: 'tenantAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 10)); | ||
| expect(listCalled).toBe(false); | ||
| }); | ||
| }); |
56 changes: 56 additions & 0 deletions
56
libs/ui-components/src/api/v1/private/baremetal-instance-catalog-item.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { createRouterTransport } from '@connectrpc/connect'; | ||
| import { waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import type { BareMetalInstanceCatalogItem } from '@osac/types/private'; | ||
| import { BareMetalInstanceCatalogItems } from '@osac/types/private'; | ||
|
|
||
| import { usePrivateBareMetalInstanceCatalogItems } from './baremetal-instance-catalog-item'; | ||
| import { renderHookWithProviders } from '../../../test-utils/TestProviders'; | ||
|
|
||
| const item: BareMetalInstanceCatalogItem = { | ||
| $typeName: 'osac.private.v1.BareMetalInstanceCatalogItem', | ||
| id: 'private-1', | ||
| title: 'Private bare metal item', | ||
| description: '', | ||
| template: '', | ||
| published: true, | ||
| tenant: 'acme-corp', | ||
| fieldDefinitions: [], | ||
| }; | ||
|
|
||
| describe('usePrivateBareMetalInstanceCatalogItems', () => { | ||
| it('fetches items from the private BareMetalInstanceCatalogItems List endpoint', async () => { | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(BareMetalInstanceCatalogItems, { list: () => ({ items: [item] }) }); | ||
| }); | ||
|
|
||
| const { result } = renderHookWithProviders(() => usePrivateBareMetalInstanceCatalogItems(), { | ||
| role: 'providerAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(result.current.data).toEqual([item]); | ||
| }); | ||
|
|
||
| it('does not fetch when disabled', async () => { | ||
| let listCalled = false; | ||
| const transport = createRouterTransport((router) => { | ||
| router.service(BareMetalInstanceCatalogItems, { | ||
| list: () => { | ||
| listCalled = true; | ||
| return { items: [item] }; | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| renderHookWithProviders(() => usePrivateBareMetalInstanceCatalogItems({}, false), { | ||
| role: 'providerAdmin', | ||
| transport, | ||
| }); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 10)); | ||
| expect(listCalled).toBe(false); | ||
| }); | ||
| }); |
18 changes: 18 additions & 0 deletions
18
libs/ui-components/src/api/v1/private/baremetal-instance-catalog-item.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { BareMetalInstanceCatalogItems } from '@osac/types/private'; | ||
|
|
||
| import { useApiFetch } from '../../api-context'; | ||
| import { type ListParams, apiQueryKey } from '../../types'; | ||
| import { useApiQuery } from '../../use-api-query'; | ||
|
|
||
| export const usePrivateBareMetalInstanceCatalogItems = ( | ||
| params: ListParams = {}, | ||
| enabled = true, | ||
| ) => { | ||
| const client = useApiFetch(BareMetalInstanceCatalogItems); | ||
| return useApiQuery({ | ||
| queryKey: apiQueryKey('v1/private/baremetal_instance_catalog_items', undefined, params), | ||
| queryFn: () => client.list(params), | ||
| select: (data) => data.items, | ||
| enabled, | ||
| }); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.