Skip to content
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
2 changes: 1 addition & 1 deletion app/components/form/fields/SshKeysField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { usePrefetchedApiQuery } from '@oxide/api'
import { Key16Icon } from '@oxide/design-system/icons/react'

import type { InstanceCreateInput } from '~/forms/instance-create'
import { CreateSSHKeySideModalForm } from '~/forms/ssh-key-create'
import { Component as CreateSSHKeySideModalForm } from '~/forms/ssh-key-create'
import { Button } from '~/ui/lib/Button'
import { Checkbox } from '~/ui/lib/Checkbox'
import { Divider } from '~/ui/lib/Divider'
Expand Down
32 changes: 19 additions & 13 deletions app/forms/image-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ import { pb } from '~/util/path-builder'
import { capitalize } from '~/util/str'
import { bytesToGiB } from '~/util/units'

EditProjectImageSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
const { project, image } = getProjectImageSelector(params)
await apiQueryClient.prefetchQuery('imageView', { path: { image }, query: { project } })
return null
export const ProjectImageEdit = {
loader: async ({ params }: LoaderFunctionArgs) => {
const { project, image } = getProjectImageSelector(params)
await apiQueryClient.prefetchQuery('imageView', { path: { image }, query: { project } })
return null
},
Component: EditProjectImageSideModalForm,
}

export function EditProjectImageSideModalForm() {
export const SiloImageEdit = {
loader: async ({ params }: LoaderFunctionArgs) => {
const { image } = getSiloImageSelector(params)
await apiQueryClient.prefetchQuery('imageView', { path: { image } })
return null
},
Component: EditSiloImageSideModalForm,
}

function EditProjectImageSideModalForm() {
const { project, image } = useProjectImageSelector()
const { data } = usePrefetchedApiQuery('imageView', {
path: { image },
Expand All @@ -46,20 +58,14 @@ export function EditProjectImageSideModalForm() {
return <EditImageSideModalForm image={data} dismissLink={dismissLink} type="Project" />
}

EditSiloImageSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
const { image } = getSiloImageSelector(params)
await apiQueryClient.prefetchQuery('imageView', { path: { image } })
return null
}

export function EditSiloImageSideModalForm() {
function EditSiloImageSideModalForm() {
const { image } = useSiloImageSelector()
const { data } = usePrefetchedApiQuery('imageView', { path: { image } })

return <EditImageSideModalForm image={data} dismissLink={pb.siloImages()} type="Silo" />
}

export function EditImageSideModalForm({
function EditImageSideModalForm({
image,
dismissLink,
type,
Expand Down
3 changes: 2 additions & 1 deletion app/forms/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ const CHUNK_SIZE_BYTES = 512 * KiB
// TODO: make sure cleanup, cancelEverything, and resetMainFlow are called in
// the right places

Component.displayName = 'ImageCreate'
/**
* Upload an image. Opens a second modal to show upload progress.
*/
export function CreateImageSideModalForm() {
export function Component() {
const navigate = useNavigate()
const queryClient = useApiQueryClient()
const { project } = useProjectSelector()
Expand Down
5 changes: 3 additions & 2 deletions app/forms/ip-pool-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import { pb } from '~/util/path-builder'

import { IpPoolVisibilityMessage } from './ip-pool-create'

EditIpPoolSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { pool } = getIpPoolSelector(params)
await apiQueryClient.prefetchQuery('ipPoolView', { path: { pool } })
return null
}

export function EditIpPoolSideModalForm() {
Component.displayName = 'EditIpPoolSideModalForm'
export function Component() {
const queryClient = useApiQueryClient()
const navigate = useNavigate()
const poolSelector = useIpPoolSelector()
Expand Down
3 changes: 2 additions & 1 deletion app/forms/ip-pool-range-add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ function resolver(values: IpRange) {
return Object.keys(errors).length > 0 ? { values: {}, errors } : { values, errors: {} }
}

export function IpPoolAddRangeSideModalForm() {
Component.displayName = 'IpPoolAddRange'
export function Component() {
const { pool } = useIpPoolSelector()
const navigate = useNavigate()
const queryClient = useApiQueryClient()
Expand Down
3 changes: 2 additions & 1 deletion app/forms/project-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const defaultValues: ProjectCreate = {
description: '',
}

export function CreateProjectSideModalForm() {
Component.displayName = 'ProjectCreateSideModalForm'
export function Component() {
const navigate = useNavigate()
const queryClient = useApiQueryClient()

Expand Down
3 changes: 2 additions & 1 deletion app/forms/snapshot-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const defaultValues: SnapshotCreate = {
name: '',
}

export function CreateSnapshotSideModalForm() {
Component.displayName = 'SnapshotCreate'
export function Component() {
const queryClient = useApiQueryClient()
const projectSelector = useProjectSelector()
const navigate = useNavigate()
Expand Down
3 changes: 2 additions & 1 deletion app/forms/ssh-key-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type Props = {
message?: React.ReactNode
}

export function CreateSSHKeySideModalForm({ onDismiss, message }: Props) {
Component.displayName = 'SSHKeyCreate'
export function Component({ onDismiss, message }: Props) {
const queryClient = useApiQueryClient()
const navigate = useNavigate()

Expand Down
3 changes: 2 additions & 1 deletion app/forms/vpc-router-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const defaultValues: VpcRouterCreate = {
description: '',
}

export function CreateRouterSideModalForm() {
Component.displayName = 'RouterCreate'
export function Component() {
const queryClient = useApiQueryClient()
const vpcSelector = useVpcSelector()
const navigate = useNavigate()
Expand Down
3 changes: 2 additions & 1 deletion app/hooks/use-crumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type MatchWithCrumb = UIMatch<unknown, Crumb>
type MakeStr = string | ((p: Params) => string)

/** Helper to make crumb definitions less verbose */
export const makeCrumb = (crumb: MakeStr, path?: MakeStr) => ({ crumb, path })
export const makeCrumb = (crumb: MakeStr, path?: MakeStr): Crumb => ({ crumb, path })
export const titleCrumb = (crumb: string): Crumb => ({ crumb, titleOnly: true })

function hasCrumb(m: UIMatch): m is MatchWithCrumb {
return !!(m.handle && typeof m.handle === 'object' && 'crumb' in m.handle)
Expand Down
5 changes: 3 additions & 2 deletions app/layouts/SystemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ContentPane, PageContainer } from './helpers'
* error. We're being a little cavalier here with the error. If it's something
* other than a 403, that would be strange and we would want to know.
*/
SystemLayout.loader = async () => {
export async function loader() {
// we don't need to use the ErrorsAllowed version here because we're 404ing
// immediately on error, so we don't need to pick the result up from the cache
const isFleetViewer = await apiQueryClient
Expand All @@ -49,7 +49,8 @@ SystemLayout.loader = async () => {
return null
}

export function SystemLayout() {
Component.displayName = 'SystemLayout'
export function Component() {
// Only show silo picker if we are looking at a particular silo. The more
// robust way of doing this would be to make a separate layout for the
// silo-specific routes in the route config, but it's overkill considering
Expand Down
5 changes: 3 additions & 2 deletions app/pages/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const EmptyState = () => (
/>
)

ProjectsPage.loader = async () => {
export async function loader() {
await apiQueryClient.prefetchQuery('projectList', { query: { limit: PAGE_SIZE } })
return null
}
Expand All @@ -56,7 +56,8 @@ const staticCols = [
colHelper.accessor('timeCreated', Columns.timeCreated),
]

export function ProjectsPage() {
Component.displayName = 'ProjectsPage'
export function Component() {
const navigate = useNavigate()

const queryClient = useApiQueryClient()
Expand Down
5 changes: 3 additions & 2 deletions app/pages/SiloAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const EmptyState = ({ onClick }: { onClick: () => void }) => (
</TableEmptyBox>
)

SiloAccessPage.loader = async () => {
export async function loader() {
await Promise.all([
apiQueryClient.prefetchQuery('policyView', {}),
// used to resolve user names
Expand All @@ -72,7 +72,8 @@ type UserRow = {

const colHelper = createColumnHelper<UserRow>()

export function SiloAccessPage() {
Component.displayName = 'SiloAccessPage'
export function Component() {
const [addModalOpen, setAddModalOpen] = useState(false)
const [editingUserRow, setEditingUserRow] = useState<UserRow | null>(null)

Expand Down
5 changes: 3 additions & 2 deletions app/pages/SiloUtilizationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ import { bytesToGiB, bytesToTiB } from '~/util/units'

const toListboxItem = (x: { name: string; id: string }) => ({ label: x.name, value: x.id })

SiloUtilizationPage.loader = async () => {
export async function loader() {
await Promise.all([
apiQueryClient.prefetchQuery('projectList', {}),
apiQueryClient.prefetchQuery('utilizationView', {}),
])
return null
}

export function SiloUtilizationPage() {
Component.displayName = 'SiloUtilizationPage'
export function Component() {
const { me } = useCurrentUser()

const siloId = me.siloId
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/access/ProjectAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const EmptyState = ({ onClick }: { onClick: () => void }) => (
</TableEmptyBox>
)

ProjectAccessPage.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project } = getProjectSelector(params)
await Promise.all([
apiQueryClient.prefetchQuery('policyView', {}),
Expand All @@ -81,7 +81,8 @@ type UserRow = {

const colHelper = createColumnHelper<UserRow>()

export function ProjectAccessPage() {
Component.displayName = 'ProjectAccessPage'
export function Component() {
const [addModalOpen, setAddModalOpen] = useState(false)
const [editingUserRow, setEditingUserRow] = useState<UserRow | null>(null)
const { project } = useProjectSelector()
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/instances/instance/SerialConsolePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const statusMessage: Record<WsState, string> = {
error: 'error',
}

SerialConsolePage.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, instance } = getInstanceSelector(params)
await apiQueryClient.prefetchQuery('instanceView', {
path: { instance },
Expand All @@ -57,7 +57,8 @@ function isStarting(i: Instance | undefined) {
return i?.runState === 'creating' || i?.runState === 'starting'
}

export function SerialConsolePage() {
Component.displayName = 'SerialConsolePage'
export function Component() {
const instanceSelector = useInstanceSelector()
const { project, instance } = instanceSelector

Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/instances/instance/tabs/ConnectTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { cliCmd } from '~/util/cli-cmd'
import { links } from '~/util/links'
import { pb } from '~/util/path-builder'

ConnectTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, instance } = getInstanceSelector(params)
await apiQueryClient.prefetchQuery('instanceExternalIpList', {
path: { instance },
Expand All @@ -27,7 +27,8 @@ ConnectTab.loader = async ({ params }: LoaderFunctionArgs) => {
return null
}

export function ConnectTab() {
Component.displayName = 'ConnectTab'
export function Component() {
const { project, instance } = useInstanceSelector()
const { data: externalIps } = usePrefetchedApiQuery('instanceExternalIpList', {
path: { instance },
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/instances/instance/tabs/MetricsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function DiskMetric({
// Considering the data is going to be swapped out as soon as they change the
// date range, I'm inclined to punt.

MetricsTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, instance } = getInstanceSelector(params)
await apiQueryClient.prefetchQuery('instanceDiskList', {
path: { instance },
Expand All @@ -159,7 +159,8 @@ MetricsTab.loader = async ({ params }: LoaderFunctionArgs) => {
return null
}

export function MetricsTab() {
Component.displayName = 'MetricsTab'
export function Component() {
const { project, instance } = useInstanceSelector()
const { data } = usePrefetchedApiQuery('instanceDiskList', {
path: { instance },
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/instances/instance/tabs/NetworkingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const SubnetNameFromId = ({ value }: { value: string }) => {
return <span className="text-secondary">{subnet.name}</span>
}

NetworkingTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, instance } = getInstanceSelector(params)
await Promise.all([
apiQueryClient.prefetchQuery('instanceNetworkInterfaceList', {
Expand Down Expand Up @@ -177,7 +177,8 @@ const staticIpCols = [
}),
]

export function NetworkingTab() {
Component.displayName = 'NetworkingTab'
export function Component() {
const instanceSelector = useInstanceSelector()
const { instance: instanceName, project } = instanceSelector

Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/instances/instance/tabs/StorageTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { links } from '~/util/links'

import { fancifyStates } from './common'

StorageTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, instance } = getInstanceSelector(params)
const selector = { path: { instance }, query: { project } }
await Promise.all([
Expand Down Expand Up @@ -75,7 +75,8 @@ const staticCols = [
colHelper.accessor('timeCreated', Columns.timeCreated),
]

export function StorageTab() {
Component.displayName = 'StorageTab'
export function Component() {
const [showDiskCreate, setShowDiskCreate] = useState(false)
const [showDiskAttach, setShowDiskAttach] = useState(false)

Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/vpcs/RouterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { TableControls, TableTitle } from '~/ui/lib/Table'
import { docLinks } from '~/util/links'
import { pb } from '~/util/path-builder'

RouterPage.loader = async function ({ params }: LoaderFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, vpc, router } = getVpcRouterSelector(params)
await Promise.all([
apiQueryClient.prefetchQuery('vpcRouterView', {
Expand Down Expand Up @@ -80,7 +80,8 @@ const RouterRouteTypeValueBadge = ({
)
}

export function RouterPage() {
Component.displayName = 'RouterPage'
export function Component() {
const { project, vpc, router } = useVpcRouterSelector()
const { data: routerData } = usePrefetchedApiQuery('vpcRouterView', {
path: { router },
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/vpcs/VpcPage/tabs/VpcRoutersTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ import { pb } from '~/util/path-builder'

const colHelper = createColumnHelper<VpcRouter>()

VpcRoutersTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, vpc } = getVpcSelector(params)
await apiQueryClient.prefetchQuery('vpcRouterList', {
query: { project, vpc, limit: PAGE_SIZE },
})
return null
}

export function VpcRoutersTab() {
Component.displayName = 'VpcRoutersTab'
export function Component() {
const vpcSelector = useVpcSelector()
const navigate = useNavigate()
const { project, vpc } = vpcSelector
Expand Down
5 changes: 3 additions & 2 deletions app/pages/project/vpcs/VpcPage/tabs/VpcSubnetsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ import { pb } from '~/util/path-builder'

const colHelper = createColumnHelper<VpcSubnet>()

VpcSubnetsTab.loader = async ({ params }: LoaderFunctionArgs) => {
export async function loader({ params }: LoaderFunctionArgs) {
const { project, vpc } = getVpcSelector(params)
await apiQueryClient.prefetchQuery('vpcSubnetList', {
query: { project, vpc, limit: PAGE_SIZE },
})
return null
}

export function VpcSubnetsTab() {
Component.displayName = 'VpcSubnetsTab'
export function Component() {
const vpcSelector = useVpcSelector()
const queryClient = useApiQueryClient()

Expand Down
Loading
Loading