-
Notifications
You must be signed in to change notification settings - Fork 18
Add router tab and routes pages #2359
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
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
373d70e
first stub of Routers and RouterRoutes pages
charliepark 6422957
continuing stub of router routes pages
charliepark ddb2a53
Merge main; resolve conflicts
charliepark a7e6f44
Add more info to Router Route page
charliepark 588cffd
adjustments; TypeValueCell
charliepark 0507f0a
deleting a route works
charliepark d74f0c5
Updating strings in target / destination type-value rendering
charliepark 95b184f
Update based on feedback in oxide-product-eng
charliepark 007a961
remove underscores in badge
charliepark d224f1d
add limit to route list prefetch to match QueryTable fetch
david-crespo 0a1c5ac
Progress on side modals to create router and route
charliepark 50187a8
Router create works
charliepark 266c923
Route create working
charliepark a6114e6
Router and route creation / editing working, mostly
charliepark 4384645
Move Router edit side modal to Routers overview page
charliepark ad203e8
Add TopBar pickers for VPC and Router
charliepark 226814a
vpcRouterDelete implemented
charliepark 131c7f5
Updating a router route now works
charliepark ef29208
Update tests
charliepark 240524f
Update to routes, path-builder spec
charliepark ff12b75
alphabetize routes
charliepark 6afd415
add in a missing route to the spec
charliepark 7440f84
Update test to match new error text in console
charliepark 136b129
Update app/forms/vpc-router-create.tsx
charliepark ccfb037
Slight refactor on onDismiss
charliepark 8bfaf3b
Clean up some duplicated code
charliepark f6f03e5
Removed old stubbed code
charliepark 50c5b72
Simpler table construction; add link to VPC in TopBar
charliepark a2e3a83
refactoring
charliepark 2f67e0d
Optimize route fields
charliepark ac75b10
Adjust mock db values
charliepark d52df65
Refactor
charliepark 3a16b0b
Paginate routes
charliepark 572a136
Adding some error handling for issues unearthed when using this bran…
charliepark 9c876be
VPCs can not be used as destinations or targets in cusom routes
charliepark 027e275
additional validations in forms; better comments
charliepark 4ff67ed
small test improvement
charliepark 812e010
Additional restrictions on routes / routers
charliepark 442fa07
Update tests
charliepark 75ba267
switch to expectRowVisible
charliepark 7e62450
use clickRowAction
charliepark 0673c21
Refactoring post-review
charliepark fe2df7d
More refactoring
charliepark f4975c7
Rename to RouterPage
charliepark 7d88539
git add womp womp
charliepark 014fb89
badge and IP Net updates
charliepark 7a81ef0
Add disabled link for 'New route' on system router page
charliepark 8c139fc
Add DescriptionCell file and update imports
charliepark dcd1d7f
update msw handler for name/description for VPC Route
charliepark 80f94bb
Update how form handles drop target
charliepark 8cc4744
Move from useEffect to onChange for TargetType
charliepark dbb47f1
Merge branch 'main' into routers-pages
charliepark 8ac44d0
refactor; pull onChange inline
charliepark 20423b0
Update handlers to error if route or router name already exists
charliepark e0813a1
Use VPC ID for testing Router uniqueness on update
charliepark 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
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 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import { useNavigate } from 'react-router-dom' | ||
|
|
||
| import { useApiMutation, useApiQueryClient, type VpcRouterCreate } from '@oxide/api' | ||
|
|
||
| import { DescriptionField } from '~/components/form/fields/DescriptionField' | ||
| import { NameField } from '~/components/form/fields/NameField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { useForm, useVpcSelector } from '~/hooks' | ||
| import { addToast } from '~/stores/toast' | ||
| import { pb } from '~/util/path-builder' | ||
|
|
||
| const defaultValues: VpcRouterCreate = { | ||
| name: '', | ||
| description: '', | ||
| } | ||
|
|
||
| export function CreateRouterSideModalForm() { | ||
| const queryClient = useApiQueryClient() | ||
| const vpcSelector = useVpcSelector() | ||
| const navigate = useNavigate() | ||
|
|
||
| const onDismiss = () => navigate(pb.vpcRouters(vpcSelector)) | ||
|
|
||
| const createRouter = useApiMutation('vpcRouterCreate', { | ||
| onSuccess() { | ||
| queryClient.invalidateQueries('vpcRouterList') | ||
| addToast({ content: 'Your router has been created' }) | ||
| onDismiss() | ||
| }, | ||
| }) | ||
|
|
||
| const form = useForm({ defaultValues }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="create" | ||
| resourceName="router" | ||
| onDismiss={onDismiss} | ||
| onSubmit={(body) => createRouter.mutate({ query: vpcSelector, body })} | ||
| loading={createRouter.isPending} | ||
| submitError={createRouter.error} | ||
| > | ||
| <NameField name="name" control={form.control} /> | ||
| <DescriptionField name="description" control={form.control} /> | ||
| </SideModalForm> | ||
| ) | ||
| } |
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,87 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import { | ||
| useNavigate, | ||
| type LoaderFunctionArgs, | ||
| type NavigateFunction, | ||
| } from 'react-router-dom' | ||
|
|
||
| import { | ||
| apiQueryClient, | ||
| useApiMutation, | ||
| useApiQueryClient, | ||
| usePrefetchedApiQuery, | ||
| type VpcRouterUpdate, | ||
| } from '@oxide/api' | ||
|
|
||
| import { DescriptionField } from '~/components/form/fields/DescriptionField' | ||
| import { NameField } from '~/components/form/fields/NameField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { getVpcRouterSelector, useForm, useVpcRouterSelector } from '~/hooks' | ||
| import { addToast } from '~/stores/toast' | ||
| import { pb } from '~/util/path-builder' | ||
|
|
||
| EditRouterSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => { | ||
| const { router, project, vpc } = getVpcRouterSelector(params) | ||
| await apiQueryClient.prefetchQuery('vpcRouterView', { | ||
| path: { router }, | ||
| query: { project, vpc }, | ||
| }) | ||
| return null | ||
| } | ||
|
|
||
| export function EditRouterSideModalForm() { | ||
| const queryClient = useApiQueryClient() | ||
| const routerSelector = useVpcRouterSelector() | ||
| const { project, vpc, router } = routerSelector | ||
| const { data: routerData } = usePrefetchedApiQuery('vpcRouterView', { | ||
| path: { router }, | ||
| query: { project, vpc }, | ||
| }) | ||
| const navigate = useNavigate() | ||
|
|
||
| const onDismiss = (navigate: NavigateFunction) => { | ||
| navigate(pb.vpcRouters({ project, vpc })) | ||
| } | ||
|
|
||
| const editRouter = useApiMutation('vpcRouterUpdate', { | ||
| onSuccess() { | ||
| queryClient.invalidateQueries('vpcRouterList') | ||
| addToast({ content: 'Your router has been updated' }) | ||
| navigate(pb.vpcRouters({ project, vpc })) | ||
| }, | ||
| }) | ||
|
|
||
| const defaultValues: VpcRouterUpdate = { | ||
| name: router, | ||
| description: routerData.description, | ||
| } | ||
|
|
||
| const form = useForm({ defaultValues }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="edit" | ||
| resourceName="router" | ||
| onDismiss={() => onDismiss(navigate)} | ||
| onSubmit={(body) => | ||
| editRouter.mutate({ | ||
| path: { router }, | ||
| query: { project, vpc }, | ||
| body, | ||
| }) | ||
| } | ||
| loading={editRouter.isPending} | ||
| submitError={editRouter.error} | ||
| > | ||
| <NameField name="name" control={form.control} /> | ||
| <DescriptionField name="description" control={form.control} /> | ||
| </SideModalForm> | ||
| ) | ||
| } |
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,98 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import { useNavigate } from 'react-router-dom' | ||
|
|
||
| import { useApiMutation, useApiQueryClient, type RouterRouteCreate } from '@oxide/api' | ||
|
|
||
| import { DescriptionField } from '~/components/form/fields/DescriptionField' | ||
| import { ListboxField } from '~/components/form/fields/ListboxField' | ||
| import { NameField } from '~/components/form/fields/NameField' | ||
| import { TextField } from '~/components/form/fields/TextField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { fields, targetValueDescription } from '~/forms/vpc-router-route/shared' | ||
| import { useForm, useVpcRouterSelector } from '~/hooks' | ||
| import { addToast } from '~/stores/toast' | ||
| import { pb } from '~/util/path-builder' | ||
|
|
||
| const defaultValues: RouterRouteCreate = { | ||
| name: '', | ||
| description: '', | ||
| destination: { type: 'ip', value: '' }, | ||
| target: { type: 'ip', value: '' }, | ||
| } | ||
|
|
||
| export function CreateRouterRouteSideModalForm() { | ||
| const queryClient = useApiQueryClient() | ||
| const routerSelector = useVpcRouterSelector() | ||
| const navigate = useNavigate() | ||
|
|
||
| const onDismiss = () => { | ||
| navigate(pb.vpcRouter(routerSelector)) | ||
| } | ||
|
|
||
| const createRouterRoute = useApiMutation('vpcRouterRouteCreate', { | ||
| onSuccess() { | ||
| queryClient.invalidateQueries('vpcRouterRouteList') | ||
| addToast({ content: 'Your route has been created' }) | ||
| onDismiss() | ||
| }, | ||
| }) | ||
|
|
||
| const form = useForm({ defaultValues }) | ||
| const targetType = form.watch('target.type') | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="create" | ||
| resourceName="route" | ||
| onDismiss={onDismiss} | ||
| onSubmit={({ name, description, destination, target }) => | ||
| createRouterRoute.mutate({ | ||
| query: routerSelector, | ||
| body: { | ||
| name, | ||
| description, | ||
| destination, | ||
| // drop has no value | ||
| target: target.type === 'drop' ? { type: target.type } : target, | ||
| }, | ||
| }) | ||
| } | ||
| loading={createRouterRoute.isPending} | ||
| submitError={createRouterRoute.error} | ||
| > | ||
| <NameField name="name" control={form.control} /> | ||
| <DescriptionField name="description" control={form.control} /> | ||
| <ListboxField {...fields.destType} control={form.control} /> | ||
| <TextField {...fields.destValue} control={form.control} /> | ||
| <ListboxField | ||
| {...fields.targetType} | ||
| control={form.control} | ||
| onChange={(value) => { | ||
| // 'outbound' is only valid option when targetType is 'internet_gateway' | ||
| if (value === 'internet_gateway') { | ||
| form.setValue('target.value', 'outbound') | ||
| } | ||
| if (value === 'drop') { | ||
| form.setValue('target.value', '') | ||
| } | ||
| }} | ||
| /> | ||
| {targetType !== 'drop' && ( | ||
| <TextField | ||
| {...fields.targetValue} | ||
| control={form.control} | ||
| // when targetType is 'internet_gateway', we set it to `outbound` and make it non-editable | ||
| disabled={targetType === 'internet_gateway'} | ||
| description={targetValueDescription(targetType)} | ||
| /> | ||
| )} | ||
| </SideModalForm> | ||
| ) | ||
| } |
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.