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

React Router 7 #2628

Merged
merged 6 commits into from
Dec 29, 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
2 changes: 1 addition & 1 deletion app/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { ErrorBoundary as BaseErrorBoundary } from 'react-error-boundary'
import { useRouteError } from 'react-router-dom'
import { useRouteError } from 'react-router'

import { type ApiError } from '~/api/errors'

Expand Down
2 changes: 1 addition & 1 deletion app/components/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import type { ReactNode } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { Error12Icon, PrevArrow12Icon } from '@oxide/design-system/icons/react'

Expand Down
2 changes: 1 addition & 1 deletion app/components/QueryParamTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import { useSearchParams } from 'react-router-dom'
import { useSearchParams } from 'react-router'

import { Tabs, type TabsRootProps } from '~/ui/lib/Tabs'

Expand Down
2 changes: 1 addition & 1 deletion app/components/RouteTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import cn from 'classnames'
import type { ReactNode } from 'react'
import { Link, Outlet } from 'react-router-dom'
import { Link, Outlet } from 'react-router'

import { useIsActivePath } from '~/hooks/use-is-active-path'
import { KEYS } from '~/ui/util/keys'
Expand Down
2 changes: 1 addition & 1 deletion app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import cn from 'classnames'
import { NavLink, useLocation } from 'react-router-dom'
import { NavLink, useLocation } from 'react-router'

import { Action16Icon, Document16Icon } from '@oxide/design-system/icons/react'

Expand Down
2 changes: 1 addition & 1 deletion app/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import cn from 'classnames'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { navToLogin, useApiMutation } from '@oxide/api'
import {
Expand Down
2 changes: 1 addition & 1 deletion app/components/form/FullPageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { cloneElement, useEffect, type ReactNode } from 'react'
import type { FieldValues, UseFormReturn } from 'react-hook-form'
import { useBlocker, type Blocker } from 'react-router-dom'
import { useBlocker, type Blocker } from 'react-router'

import type { ApiError } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/components/form/SideModalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { useEffect, useId, useState, type ReactNode } from 'react'
import type { FieldValues, UseFormReturn } from 'react-hook-form'
import { NavigationType, useNavigationType } from 'react-router-dom'
import { NavigationType, useNavigationType } from 'react-router'

import type { ApiError } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/disk-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { filesize } from 'filesize'
import { useMemo } from 'react'
import { useController, useForm, type Control } from 'react-hook-form'
import { useNavigate, type NavigateFunction } from 'react-router-dom'
import { useNavigate, type NavigateFunction } from 'react-router'

import {
useApiMutation,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/firewall-rules-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, useParams, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, useParams, type LoaderFunctionArgs } from 'react-router'

import {
apiQueryClient,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/firewall-rules-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import {
apiQueryClient,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/floating-ip-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as Accordion from '@radix-ui/react-accordion'
import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import {
useApiMutation,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/floating-ip-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiq, queryClient, useApiMutation, usePrefetchedApiQuery } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/idp/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/idp/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiQueryClient, usePrefetchedApiQuery } from '@oxide/api'
import { Access16Icon } from '@oxide/design-system/icons/react'
Expand Down
2 changes: 1 addition & 1 deletion app/forms/image-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiQueryClient, usePrefetchedApiQuery, type Image } from '@oxide/api'
import { Images16Icon } from '@oxide/design-system/icons/react'
Expand Down
2 changes: 1 addition & 1 deletion app/forms/image-from-snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { filesize } from 'filesize'
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import {
apiq,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import pMap from 'p-map'
import pRetry from 'p-retry'
import { useRef, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import {
useApiMutation,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/instance-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as Accordion from '@radix-ui/react-accordion'
import { useEffect, useMemo, useState } from 'react'
import { useController, useForm, useWatch, type Control } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
import type { SetRequired } from 'type-fest'

import {
Expand Down
2 changes: 1 addition & 1 deletion app/forms/ip-pool-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type IpPoolCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/ip-pool-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import {
apiQueryClient,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/ip-pool-range-add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm, type FieldErrors } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type IpRange } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/project-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type ProjectCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/project-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiq, queryClient, useApiMutation, usePrefetchedQuery } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/silo-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type SiloCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/snapshot-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { useMemo } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import {
diskCan,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/ssh-key-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type SshKeyCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/ssh-key-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiQueryClient, usePrefetchedApiQuery } from '@oxide/api'
import { Key16Icon } from '@oxide/design-system/icons/react'
Expand Down
2 changes: 1 addition & 1 deletion app/forms/subnet-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type VpcSubnetCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/subnet-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import {
apiq,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/vpc-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type VpcCreate } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/vpc-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

import { apiq, queryClient, useApiMutation, usePrefetchedQuery } from '@oxide/api'

Expand Down
2 changes: 1 addition & 1 deletion app/forms/vpc-router-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import { useApiMutation, useApiQueryClient, type VpcRouterCreate } from '@oxide/api'

Expand Down
6 changes: 1 addition & 5 deletions app/forms/vpc-router-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import {
useNavigate,
type LoaderFunctionArgs,
type NavigateFunction,
} from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs, type NavigateFunction } from 'react-router'

import {
apiq,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/vpc-router-route-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'

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

Expand Down
2 changes: 1 addition & 1 deletion app/forms/vpc-router-route-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
import * as R from 'remeda'

import {
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-crumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import { useMatches, type Params, type UIMatch } from 'react-router-dom'
import { useMatches, type Params, type UIMatch } from 'react-router'

import { invariant } from '~/util/invariant'

Expand Down
4 changes: 2 additions & 2 deletions app/hooks/use-is-active-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import { useLocation, useResolvedPath } from 'react-router-dom'
import { useLocation, useResolvedPath } from 'react-router'

interface ActivePathOptions {
to: string
Expand All @@ -16,7 +16,7 @@ interface ActivePathOptions {
*
* This implementation is based on logic from React Router's NavLink component.
*
* @see https://github.com/remix-run/react-router/blob/67f16e73603765158c63a27afb70d3a4b3e823d3/packages/react-router-dom/index.tsx#L448-L467
* @see https://github.com/remix-run/react-router/blob/67f16e73603765158c63a27afb70d3a4b3e823d3/packages/react-router/index.tsx#L448-L467
*
* @param to The path to check
* @param options.end Ensure this path isn't matched as "active" when its descendant paths are matched.
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { hashKey } from '@tanstack/react-query'
import { useMemo } from 'react'
import { useParams, type Params } from 'react-router-dom'
import { useParams, type Params } from 'react-router'

import { invariant } from '~/util/invariant'

Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-quick-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useEffect, useMemo } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { useLocation, useNavigate } from 'react-router'
import { create } from 'zustand'

import { useCurrentUser } from '~/layouts/AuthenticatedLayout'
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-scroll-restoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import { useEffect } from 'react'
import { useLocation, useNavigation } from 'react-router-dom'
import { useLocation, useNavigation } from 'react-router'

function getScrollPosition(key: string) {
const pos = window.sessionStorage.getItem(key)
Expand Down
2 changes: 1 addition & 1 deletion app/layouts/AuthLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import { Outlet } from 'react-router-dom'
import { Outlet } from 'react-router'

import { OxideLogo } from '~/components/OxideLogo'

Expand Down
2 changes: 1 addition & 1 deletion app/layouts/AuthenticatedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import { Outlet } from 'react-router-dom'
import { Outlet } from 'react-router'

import { apiQueryClient, useApiQueryErrorsAllowed, usePrefetchedApiQuery } from '@oxide/api'

Expand Down
Loading
Loading