Skip to content
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

Refactor Router deletion process #2371

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading