Skip to content

Commit

Permalink
Refactor Router deletion process (#2371)
Browse files Browse the repository at this point in the history
* Update message on Router deletion to warn about routes; disable system router deletion

---------

Co-authored-by: David Crespo <david-crespo@users.noreply.github.com>
  • Loading branch information
charliepark and david-crespo authored Aug 15, 2024
1 parent 29398e7 commit bb53f1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/forms/vpc-router-route/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export const routeFormMessage = {
// https://github.com/oxidecomputer/omicron/blob/914f5fd7d51f9b060dcc0382a30b607e25df49b2/nexus/src/app/vpc_router.rs#L201-L204
noNewRoutesOnSystemRouter: 'User-provided routes cannot be added to a system router',
// https://github.com/oxidecomputer/omicron/blob/914f5fd7d51f9b060dcc0382a30b607e25df49b2/nexus/src/app/vpc_router.rs#L300-L304
noDeletingRoutesOnSystemRouter: 'System routes can not be deleted',
noDeletingRoutesOnSystemRouter: 'System routes cannot be deleted',
// https://github.com/oxidecomputer/omicron/blob/914f5fd7d51f9b060dcc0382a30b607e25df49b2/nexus/src/app/vpc_router.rs#L136-L138
noDeletingSystemRouters: 'System routers cannot be deleted',
}

export const targetValueDescription = (targetType: RouteTarget['type']) =>
Expand Down
4 changes: 4 additions & 0 deletions app/pages/project/vpcs/VpcPage/tabs/VpcRoutersTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Outlet, useNavigate, type LoaderFunctionArgs } from 'react-router-dom'

import { apiQueryClient, useApiMutation, type VpcRouter } from '@oxide/api'

import { routeFormMessage } from '~/forms/vpc-router-route/shared'
import { getVpcSelector, useVpcSelector } from '~/hooks'
import { confirmDelete } from '~/stores/confirm-delete'
import { addToast } from '~/stores/toast'
Expand Down Expand Up @@ -84,14 +85,17 @@ export function VpcRoutersTab() {
},
{
label: 'Delete',
className: 'destructive',
onActivate: confirmDelete({
doDelete: () =>
deleteRouter.mutateAsync({
path: { router: router.name },
query: { project, vpc },
}),
extraContent: 'This will also delete any routes belonging to this router.',
label: router.name,
}),
disabled: router.kind === 'system' && routeFormMessage.noDeletingSystemRouters,
},
],
[deleteRouter, project, vpc, navigate]
Expand Down

0 comments on commit bb53f1b

Please sign in to comment.