-
Notifications
You must be signed in to change notification settings - Fork 65
OSAC-2936: add catalog item create wizard for Cluster, VM, and Bare Metal #102
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
Open
ElayAharoni
wants to merge
33
commits into
osac-project:main
Choose a base branch
from
ElayAharoni:OSAC-2936-catalog-item-create-wizard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f826af3
OSAC-2936: add field definition value model and protobuf Value serial…
ElayAharoni 6518dd5
OSAC-2936: add shared field definition primitives
ElayAharoni e6d7878
OSAC-2936: add NodeSetsFieldEditor for cluster catalog item configura…
ElayAharoni b154320
OSAC-2936: add template, organization, and project list hooks for the…
ElayAharoni 8af9995
OSAC-2936: add CatalogItemGeneralFields shared wizard step
ElayAharoni e51aa0e
OSAC-2936: bind the wizard Name field to title, not metadata.name
ElayAharoni c58ac0f
OSAC-2936: add cluster catalog item step components and create hook
ElayAharoni 9f8342f
OSAC-2936: add VM catalog item step components and create hook
ElayAharoni cae826f
OSAC-2936: add bare metal catalog item step components and create hook
ElayAharoni 8f189ea
OSAC-2936: add kind-specific catalog item create wizard pages
ElayAharoni 2235067
OSAC-2936: add test for unrecognized :type route fallback
ElayAharoni 112ef6d
OSAC-2936: address CodeRabbit review feedback on catalog item wizards
ElayAharoni a5f2671
OSAC-2936: address second round of CodeRabbit feedback, fix i18n lint…
ElayAharoni da2392f
OSAC-2936: scope cluster node sets to the selected template's host types
ElayAharoni 9e9a173
OSAC-2936: fix imports dropped by rebase in baremetal-instance.test.ts
ElayAharoni 7d8c0c7
OSAC-2936: regenerate translation.json after rebasing onto main
ElayAharoni e7d22af
OSAC-2936: regenerate translation.json after rebasing onto latest main
ElayAharoni 6652a02
OSAC-2936: fix AdminCatalogRoutes test after rebasing onto OSAC-2932
ElayAharoni cb69e1e
OSAC-2936: fix import order after rebase conflict resolution
ElayAharoni 21b3583
OSAC-2936: fix organizations 404 and stop polling wizard lookup data
ElayAharoni c24a572
OSAC-2936: register well-known types so Any-packed template defaults …
ElayAharoni 4522c5f
OSAC-2936: fix catalog item wizard validation, authz, and layout issues
ElayAharoni 8acc8d7
OSAC-2936: use project.metadata.name for the project selector label
ElayAharoni 157bb8e
OSAC-2936: fix PR review comments (rawagner takes precedence)
ElayAharoni cf9fb16
OSAC-2936: enhance the node sets editor's layout
ElayAharoni c133279
OSAC-2936: make field-definition group headings bolder and clearer
ElayAharoni 01e629b
OSAC-2936: give NodeSetsFieldEditor a top-level Node Sets heading
ElayAharoni 6ad2812
OSAC-2936: remove cores/memory_gib fields from VM catalog item wizard
ElayAharoni f3a373b
OSAC-2936: rename Display name/Resource name to Title/Name, make Titl…
ElayAharoni 91547e8
OSAC-2936: remove deprecated is_windows field, rename Image to Source…
ElayAharoni 3d60a9e
OSAC-2936: address rawagner and batzionb review comments
ElayAharoni 5d19b80
OSAC-2936: clean up node set headers and field labels
ElayAharoni 6406e9a
OSAC-2936: show host type alone as each node set's header
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { MemoryRouter, Route, Routes } from 'react-router-dom'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { AdminCatalogRoutes } from './AdminCatalogRoutes'; | ||
|
|
||
| vi.mock('@osac/ui-components/pages/admin/cluster/ClusterCatalogItemCreatePage', () => ({ | ||
| default: () => <div>Cluster create page</div>, | ||
| })); | ||
| vi.mock( | ||
| '@osac/ui-components/pages/admin/compute-instance/ComputeInstanceCatalogItemCreatePage', | ||
| () => ({ | ||
| default: () => <div>Compute instance create page</div>, | ||
| }), | ||
| ); | ||
| vi.mock( | ||
| '@osac/ui-components/pages/admin/baremetal-instance/BareMetalInstanceCatalogItemCreatePage', | ||
| () => ({ | ||
| default: () => <div>Bare metal create page</div>, | ||
| }), | ||
| ); | ||
| vi.mock('@osac/ui-components/pages/admin/CatalogManagementListPage', () => ({ | ||
| default: () => <div>Catalog management list page</div>, | ||
| })); | ||
| vi.mock('@osac/ui-components/hooks/useTranslation', () => ({ | ||
| useTranslation: () => ({ t: (key: string) => key }), | ||
| })); | ||
|
|
||
| // Mounted at /admin/catalog/* to match the real route registered in AppShell.tsx, so | ||
| // AdminCatalogRoutes' internal <Navigate to="/admin/catalog" /> fallback resolves correctly. | ||
| const renderAt = (path: string) => | ||
| render( | ||
| <MemoryRouter initialEntries={[path]}> | ||
| <Routes> | ||
| <Route path="/admin/catalog/*" element={<AdminCatalogRoutes />} /> | ||
| </Routes> | ||
| </MemoryRouter>, | ||
| ); | ||
|
|
||
| describe('AdminCatalogRoutes', () => { | ||
| it('renders the cluster create page for :type = cluster', () => { | ||
| renderAt('/admin/catalog/cluster/create'); | ||
|
|
||
| expect(screen.getByText('Cluster create page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the compute instance create page for :type = compute-instance', () => { | ||
| renderAt('/admin/catalog/compute-instance/create'); | ||
|
|
||
| expect(screen.getByText('Compute instance create page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the bare metal create page for :type = baremetal-instance', () => { | ||
| renderAt('/admin/catalog/baremetal-instance/create'); | ||
|
|
||
| expect(screen.getByText('Bare metal create page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('redirects to the list page for an unrecognized :type', () => { | ||
| renderAt('/admin/catalog/not-a-real-type/create'); | ||
|
|
||
| expect(screen.getByText('Catalog management list page')).toBeInTheDocument(); | ||
| expect(screen.queryByText('Cluster create page')).not.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,41 @@ | ||
| import { fromJson } from '@bufbuild/protobuf'; | ||
| import { AnySchema } from '@bufbuild/protobuf/wkt'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { wellKnownTypeRegistry } from './wellKnownTypeRegistry'; | ||
|
|
||
| describe('wellKnownTypeRegistry', () => { | ||
| it.each([ | ||
| ['google.protobuf.BoolValue', true], | ||
| ['google.protobuf.BytesValue', 'AQI='], | ||
| ['google.protobuf.StringValue', 'hello'], | ||
| ['google.protobuf.Int32Value', 42], | ||
| ['google.protobuf.Int64Value', '42'], | ||
| ['google.protobuf.UInt32Value', 42], | ||
| ['google.protobuf.UInt64Value', '42'], | ||
| ['google.protobuf.DoubleValue', 4.2], | ||
| ['google.protobuf.FloatValue', 4.2], | ||
| ['google.protobuf.Value', { nested: true }], | ||
| ['google.protobuf.Struct', { nested: true }], | ||
| ['google.protobuf.ListValue', [1, 2, 3]], | ||
| ['google.protobuf.Timestamp', '2026-01-01T00:00:00Z'], | ||
| ['google.protobuf.Duration', '5s'], | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ])('resolves %s packed in a google.protobuf.Any', (typeName, value) => { | ||
| const decode = () => | ||
| fromJson( | ||
| AnySchema, | ||
| { '@type': `type.googleapis.com/${typeName}`, value }, | ||
| { registry: wellKnownTypeRegistry }, | ||
| ); | ||
| expect(decode).not.toThrow(); | ||
| }); | ||
|
|
||
| it('fails to resolve an Any-packed well-known type without the registry', () => { | ||
| const decode = () => | ||
| fromJson(AnySchema, { | ||
| '@type': 'type.googleapis.com/google.protobuf.BoolValue', | ||
| value: true, | ||
| }); | ||
| expect(decode).toThrow(/not in the type registry/); | ||
| }); | ||
| }); | ||
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,42 @@ | ||
| import { createRegistry } from '@bufbuild/protobuf'; | ||
| import { | ||
| BoolValueSchema, | ||
| BytesValueSchema, | ||
| DoubleValueSchema, | ||
| DurationSchema, | ||
| FloatValueSchema, | ||
| Int32ValueSchema, | ||
| Int64ValueSchema, | ||
| ListValueSchema, | ||
| StringValueSchema, | ||
| StructSchema, | ||
| TimestampSchema, | ||
| UInt32ValueSchema, | ||
| UInt64ValueSchema, | ||
| ValueSchema, | ||
| } from '@bufbuild/protobuf/wkt'; | ||
|
|
||
| // google.protobuf.Any is decoded by looking up its packed type by name in a registry — unlike a | ||
| // field with a static well-known type (e.g. metadata.creation_timestamp), Any's packed type is | ||
| // only known at runtime from its "@type" URL. Without an entry here, @bufbuild/protobuf throws | ||
| // "cannot decode message google.protobuf.Any from JSON: <type> is not in the type registry". | ||
| // | ||
| // ClusterTemplateParameterDefinition.default (and the equivalent field on other template types) is | ||
| // documented to pack one of these well-known types, so all of them must be registered for the | ||
| // catalog item wizards' template dropdowns to decode successfully. | ||
| export const wellKnownTypeRegistry = createRegistry( | ||
| BoolValueSchema, | ||
| BytesValueSchema, | ||
| DoubleValueSchema, | ||
| DurationSchema, | ||
| FloatValueSchema, | ||
| Int32ValueSchema, | ||
| Int64ValueSchema, | ||
| ListValueSchema, | ||
| StringValueSchema, | ||
| StructSchema, | ||
| TimestampSchema, | ||
| UInt32ValueSchema, | ||
| UInt64ValueSchema, | ||
| ValueSchema, | ||
| ); |
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.
Uh oh!
There was an error while loading. Please reload this page.