-
Notifications
You must be signed in to change notification settings - Fork 76
OSAC-3780: Add provider-admin instance type routing, nav, and list page #129
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 8 commits into
osac-project:main
from
batzionb:feature/OSAC-3780-admin-instance-types-nav-list
Aug 10, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20f2c2b
OSAC-3780: add admin instance type admin routes and list page
batzionb 330f263
OSAC-3780: address cross-cutting review findings
batzionb 1c71ff8
OSAC-3780: add create button to instance type list page
batzionb 211abd9
OSAC-3780: extract instance type table and improve empty state
batzionb 6ae157a
OSAC-3780: address cross-cutting review findings
batzionb 2bfb4cd
OSAC-3780: Address review feedback — use Record for instance type lif…
batzionb 93528c8
OSAC-3780: Address review feedback — use translated Unspecified label…
batzionb c1a49dc
OSAC-3780: Address review feedback — extract shared TruncatedText pri…
batzionb 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { screen, waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { SessionProvider } from '@osac/ui-components/hooks/use-session'; | ||
| import { renderWithProviders } from '@osac/ui-components/test-utils/TestProviders'; | ||
|
|
||
| vi.mock('./StorageRoutes', () => ({ | ||
| StorageRoutes: () => <h1>Storage routes</h1>, | ||
| })); | ||
|
|
||
| import { AppShell } from './AppShell'; | ||
|
|
||
| const renderAppShell = (entry: string) => | ||
| renderWithProviders( | ||
| <SessionProvider role="admin" username="test-admin" tenantId="tenant-1"> | ||
| <AppShell logout={vi.fn().mockResolvedValue(undefined)} /> | ||
| </SessionProvider>, | ||
| { | ||
| apiFixtures: { privateInstanceTypes: [] }, | ||
| routerEntries: [entry], | ||
| }, | ||
| ); | ||
|
|
||
| describe('AppShell', () => { | ||
| it('renders the storage route through the admin shell', () => { | ||
| renderAppShell('/admin/infrastructure/storage/backends'); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'Storage routes' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the instance type list route through the admin shell', async () => { | ||
| renderAppShell('/admin/infrastructure/instance-types'); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'Instance types' })).toBeInTheDocument(); | ||
| await waitFor(() => { | ||
| expect(screen.getByText('No instance types yet.')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('renders the instance type create shell through the admin shell', () => { | ||
| renderAppShell('/admin/infrastructure/instance-types/create'); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'Create instance type' })).toBeInTheDocument(); | ||
| }); | ||
| }); |
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,35 @@ | ||
| import { MemoryRouter, Route, Routes } from 'react-router-dom'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| vi.mock('@osac/ui-components/components/InstanceType/AdminInstanceTypeListPage', () => ({ | ||
| default: () => <h1>Instance types</h1>, | ||
| })); | ||
|
|
||
| vi.mock('@osac/ui-components/components/InstanceType/AdminInstanceTypeCreatePage', () => ({ | ||
| default: () => <h1>Create instance type</h1>, | ||
| })); | ||
|
|
||
| import { InstanceTypeRoutes } from './InstanceTypeRoutes'; | ||
|
|
||
| const renderRoutes = (initialEntry: string) => ( | ||
| <MemoryRouter initialEntries={[initialEntry]}> | ||
| <Routes> | ||
| <Route path="/admin/infrastructure/instance-types/*" element={<InstanceTypeRoutes />} /> | ||
| </Routes> | ||
| </MemoryRouter> | ||
| ); | ||
|
|
||
| describe('InstanceTypeRoutes', () => { | ||
| it('renders the list page on the index route', () => { | ||
| render(renderRoutes('/admin/infrastructure/instance-types')); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'Instance types' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the create page shell on the create route', () => { | ||
| render(renderRoutes('/admin/infrastructure/instance-types/create')); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'Create instance type' })).toBeInTheDocument(); | ||
| }); | ||
| }); |
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,11 @@ | ||
| import { Route, Routes } from 'react-router-dom'; | ||
|
|
||
| import AdminInstanceTypeCreatePage from '@osac/ui-components/components/InstanceType/AdminInstanceTypeCreatePage'; | ||
| import AdminInstanceTypeListPage from '@osac/ui-components/components/InstanceType/AdminInstanceTypeListPage'; | ||
|
|
||
| export const InstanceTypeRoutes = () => ( | ||
| <Routes> | ||
| <Route index element={<AdminInstanceTypeListPage />} /> | ||
| <Route path="create" element={<AdminInstanceTypeCreatePage />} /> | ||
| </Routes> | ||
| ); | ||
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
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
71 changes: 71 additions & 0 deletions
71
libs/ui-components/src/api/v1/private/instance-type.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,71 @@ | ||
| import React, { type ReactNode, createElement } from 'react'; | ||
| import { create } from '@bufbuild/protobuf'; | ||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
| import { renderHook, waitFor } from '@testing-library/react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { | ||
| InstanceTypeSchema, | ||
| InstanceTypeState, | ||
| type InstanceType as PrivateInstanceType, | ||
| } from '@osac/types/private'; | ||
|
|
||
| import { useAdminInstanceTypes } from './instance-type'; | ||
| import { createMockConnectTransport } from '../../../test-utils/createMockConnectTransport'; | ||
| import { ApiProvider } from '../../api-context'; | ||
|
|
||
| const makeInstanceType = ( | ||
| id: string, | ||
| state: InstanceTypeState = InstanceTypeState.ACTIVE, | ||
| ): PrivateInstanceType => | ||
| create(InstanceTypeSchema, { | ||
| id, | ||
| metadata: { name: `instance-type-${id}` }, | ||
| spec: { | ||
| description: `${id} description`, | ||
| cores: 4, | ||
| memoryGib: 16, | ||
| state, | ||
| }, | ||
| }); | ||
|
|
||
| const makeWrapper = (transport: ReturnType<typeof createMockConnectTransport>) => { | ||
| const queryClient = new QueryClient({ | ||
| defaultOptions: { queries: { retry: false }, mutations: { retry: false } }, | ||
| }); | ||
| const wrapper = ({ children }: { children: ReactNode }) => | ||
| createElement( | ||
| ApiProvider, | ||
| { transport } as React.ComponentProps<typeof ApiProvider>, | ||
| createElement(QueryClientProvider, { client: queryClient }, children), | ||
| ); | ||
| return { wrapper, queryClient }; | ||
| }; | ||
|
|
||
| describe('useAdminInstanceTypes', () => { | ||
| it('returns all private instance type items from the list response', async () => { | ||
| const transport = createMockConnectTransport({ | ||
| privateInstanceTypes: [ | ||
| makeInstanceType('active-1', InstanceTypeState.ACTIVE), | ||
| makeInstanceType('deprecated-1', InstanceTypeState.DEPRECATED), | ||
| ], | ||
| }); | ||
| const { wrapper } = makeWrapper(transport); | ||
| const { result } = renderHook(() => useAdminInstanceTypes(), { wrapper }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(result.current.data?.map((item) => item.id)).toEqual(['active-1', 'deprecated-1']); | ||
| }); | ||
|
|
||
| it('stores query results under the private instance type cache key', async () => { | ||
| const transport = createMockConnectTransport({ | ||
| privateInstanceTypes: [makeInstanceType('active-1')], | ||
| }); | ||
| const { wrapper, queryClient } = makeWrapper(transport); | ||
| const { result } = renderHook(() => useAdminInstanceTypes(), { wrapper }); | ||
|
|
||
| await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
| expect(queryClient.getQueryData(['v1/private/instance_types'])).toBeDefined(); | ||
| expect(queryClient.getQueryData(['v1/instance_types'])).toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have this file in
ui-components/src/components/InstanceType?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InstanceTypeRoutes.tsx mirrors the existing TenantRoutes.tsx exactly — a thin wrapper composing page components, living alongside StorageRoutes.tsx and TenantRoutes.tsx in apps/app-frontend/src/shell/. All routing files live there because they depend on react-router-dom, an app-level dependency not otherwise used inside the framework-agnostic ui-components package. Moving it would break with the established convention and pull a routing dependency into a shared package.
Proposed response: "This follows the same pattern as TenantRoutes.tsx/StorageRoutes.tsx — all our routing wrappers live in apps/app-frontend/src/shell since they depend on react-router-dom, which ui-components doesn't otherwise use. Keeping it here for consistency.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no consistency now. Some routes are defined in app, others in ui-components (for example
<ClusterRoutes />).I think it is better to place these route definitions into ui-components. The components there expect a specific route structure (as they use
navigatewith specific strings).