Skip to content

Commit dc4e0d4

Browse files
authored
chore: convert more routes to RR v7 format (#2712)
* convert a bunch more route modules * convert silo and idp forms * floating ips routes
1 parent 381f374 commit dc4e0d4

30 files changed

+169
-153
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104
{
105105
// default exports are needed in the route modules and the config files,
106106
// but we want to avoid them anywhere else
107-
files: ['app/pages/**/*', 'app/layouts/**/*', '*.config.ts'],
107+
files: ['app/pages/**/*', 'app/layouts/**/*', 'app/forms/**/*', '*.config.ts'],
108108
rules: { 'import/no-default-export': 'off' },
109109
},
110110
{

app/forms/firewall-rules-create.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919

2020
import { SideModalForm } from '~/components/form/SideModalForm'
2121
import { HL } from '~/components/HL'
22+
import { titleCrumb } from '~/hooks/use-crumbs'
2223
import { getVpcSelector, useVpcSelector } from '~/hooks/use-params'
2324
import { addToast } from '~/stores/toast'
2425
import { ALL_ISH } from '~/util/consts'
@@ -27,6 +28,8 @@ import { pb } from '~/util/path-builder'
2728
import { CommonFields } from './firewall-rules-common'
2829
import { valuesToRuleUpdate, type FirewallRuleValues } from './firewall-rules-util'
2930

31+
export const handle = titleCrumb('New Rule')
32+
3033
/** Empty form for when we're not creating from an existing rule */
3134
const defaultValuesEmpty: FirewallRuleValues = {
3235
enabled: true,
@@ -55,7 +58,7 @@ const ruleToValues = (rule: VpcFirewallRule): FirewallRuleValues => ({
5558
hosts: rule.filters.hosts || [],
5659
})
5760

58-
CreateFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
61+
export async function clientLoader({ params }: LoaderFunctionArgs) {
5962
const { project, vpc } = getVpcSelector(params)
6063
await Promise.all([
6164
apiQueryClient.prefetchQuery('vpcFirewallRulesView', { query: { project, vpc } }),
@@ -69,7 +72,7 @@ CreateFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
6972
return null
7073
}
7174

72-
export function CreateFirewallRuleForm() {
75+
export default function CreateFirewallRuleForm() {
7376
const vpcSelector = useVpcSelector()
7477
const queryClient = useApiQueryClient()
7578

app/forms/firewall-rules-edit.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import { trigger404 } from '~/components/ErrorBoundary'
2020
import { SideModalForm } from '~/components/form/SideModalForm'
2121
import { HL } from '~/components/HL'
22+
import { titleCrumb } from '~/hooks/use-crumbs'
2223
import {
2324
getFirewallRuleSelector,
2425
useFirewallRuleSelector,
@@ -32,7 +33,9 @@ import { pb } from '~/util/path-builder'
3233
import { CommonFields } from './firewall-rules-common'
3334
import { valuesToRuleUpdate, type FirewallRuleValues } from './firewall-rules-util'
3435

35-
EditFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
36+
export const handle = titleCrumb('Edit Rule')
37+
38+
export async function clientLoader({ params }: LoaderFunctionArgs) {
3639
const { project, vpc, rule } = getFirewallRuleSelector(params)
3740

3841
const [firewallRules] = await Promise.all([
@@ -50,7 +53,7 @@ EditFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
5053
return null
5154
}
5255

53-
export function EditFirewallRuleForm() {
56+
export default function EditFirewallRuleForm() {
5457
const { project, vpc, rule } = useFirewallRuleSelector()
5558
const vpcSelector = useVpcSelector()
5659
const queryClient = useApiQueryClient()

app/forms/floating-ip-create.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ListboxField } from '~/components/form/fields/ListboxField'
2424
import { NameField } from '~/components/form/fields/NameField'
2525
import { SideModalForm } from '~/components/form/SideModalForm'
2626
import { HL } from '~/components/HL'
27+
import { titleCrumb } from '~/hooks/use-crumbs'
2728
import { useProjectSelector } from '~/hooks/use-params'
2829
import { addToast } from '~/stores/toast'
2930
import { Message } from '~/ui/lib/Message'
@@ -36,7 +37,9 @@ const defaultValues: Omit<FloatingIpCreate, 'ip'> = {
3637
pool: undefined,
3738
}
3839

39-
export function CreateFloatingIpSideModalForm() {
40+
export const handle = titleCrumb('New Floating IP')
41+
42+
export default function CreateFloatingIpSideModalForm() {
4043
// Fetch 1000 to we can be sure to get them all. Don't bother prefetching
4144
// because the list is hidden under the Advanced accordion.
4245
const { data: allPools } = useApiQuery('projectIpPoolList', { query: { limit: ALL_ISH } })

app/forms/floating-ip-edit.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField'
2020
import { NameField } from '~/components/form/fields/NameField'
2121
import { SideModalForm } from '~/components/form/SideModalForm'
2222
import { HL } from '~/components/HL'
23+
import { titleCrumb } from '~/hooks/use-crumbs'
2324
import { getFloatingIpSelector, useFloatingIpSelector } from '~/hooks/use-params'
2425
import { addToast } from '~/stores/toast'
2526
import { EmptyCell } from '~/table/cells/EmptyCell'
@@ -35,7 +36,7 @@ const floatingIpView = ({ project, floatingIp }: PP.FloatingIp) =>
3536
const instanceList = (project: string) =>
3637
getListQFn('instanceList', { query: { project, limit: ALL_ISH } })
3738

38-
EditFloatingIpSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
39+
export async function clientLoader({ params }: LoaderFunctionArgs) {
3940
const selector = getFloatingIpSelector(params)
4041
await Promise.all([
4142
queryClient.fetchQuery(floatingIpView(selector)),
@@ -44,7 +45,9 @@ EditFloatingIpSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
4445
return null
4546
}
4647

47-
export function EditFloatingIpSideModalForm() {
48+
export const handle = titleCrumb('Edit Floating IP')
49+
50+
export default function EditFloatingIpSideModalForm() {
4851
const navigate = useNavigate()
4952

5053
const floatingIpSelector = useFloatingIpSelector()

app/forms/idp/create.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { NameField } from '~/components/form/fields/NameField'
1717
import { TextField } from '~/components/form/fields/TextField'
1818
import { SideModalForm } from '~/components/form/SideModalForm'
1919
import { HL } from '~/components/HL'
20+
import { titleCrumb } from '~/hooks/use-crumbs'
2021
import { useSiloSelector } from '~/hooks/use-params'
2122
import { addToast } from '~/stores/toast'
2223
import { Checkbox } from '~/ui/lib/Checkbox'
@@ -50,7 +51,9 @@ const defaultValues: IdpCreateFormValues = {
5051
},
5152
}
5253

53-
export function CreateIdpSideModalForm() {
54+
export const handle = titleCrumb('New Identity Provider')
55+
56+
export default function CreateIdpSideModalForm() {
5457
const navigate = useNavigate()
5558
const queryClient = useApiQueryClient()
5659

app/forms/idp/edit.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField'
1515
import { NameField } from '~/components/form/fields/NameField'
1616
import { TextField } from '~/components/form/fields/TextField'
1717
import { SideModalForm } from '~/components/form/SideModalForm'
18+
import { titleCrumb } from '~/hooks/use-crumbs'
1819
import { getIdpSelector, useIdpSelector } from '~/hooks/use-params'
1920
import { FormDivider } from '~/ui/lib/Divider'
2021
import { PropertiesTable } from '~/ui/lib/PropertiesTable'
2122
import { ResourceLabel, SideModal } from '~/ui/lib/SideModal'
2223
import { pb } from '~/util/path-builder'
2324

24-
EditIdpSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
25+
export async function clientLoader({ params }: LoaderFunctionArgs) {
2526
const { silo, provider } = getIdpSelector(params)
2627
await apiQueryClient.prefetchQuery('samlIdentityProviderView', {
2728
path: { provider },
@@ -30,7 +31,9 @@ EditIdpSideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
3031
return null
3132
}
3233

33-
export function EditIdpSideModalForm() {
34+
export const handle = titleCrumb('Edit Identity Provider')
35+
36+
export default function EditIdpSideModalForm() {
3437
const { silo, provider } = useIdpSelector()
3538
const { data: idp } = usePrefetchedApiQuery('samlIdentityProviderView', {
3639
path: { provider },

app/forms/instance-create.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const baseDefaultValues: InstanceCreateInput = {
157157
externalIps: [{ type: 'ephemeral' }],
158158
}
159159

160-
CreateInstanceForm.loader = async ({ params }: LoaderFunctionArgs) => {
160+
export async function clientLoader({ params }: LoaderFunctionArgs) {
161161
const { project } = getProjectSelector(params)
162162
await Promise.all([
163163
// fetch both project and silo images
@@ -173,7 +173,9 @@ CreateInstanceForm.loader = async ({ params }: LoaderFunctionArgs) => {
173173
return null
174174
}
175175

176-
export function CreateInstanceForm() {
176+
export const handle = { crumb: 'New instance' }
177+
178+
export default function CreateInstanceForm() {
177179
const [isSubmitting, setIsSubmitting] = useState(false)
178180
const queryClient = useApiQueryClient()
179181
const { project } = useProjectSelector()

app/forms/silo-create.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { TextField } from '~/components/form/fields/TextField'
2020
import { TlsCertsField } from '~/components/form/fields/TlsCertsField'
2121
import { SideModalForm } from '~/components/form/SideModalForm'
2222
import { HL } from '~/components/HL'
23+
import { titleCrumb } from '~/hooks/use-crumbs'
2324
import { addToast } from '~/stores/toast'
2425
import { FormDivider } from '~/ui/lib/Divider'
2526
import { FieldLabel } from '~/ui/lib/FieldLabel'
@@ -48,7 +49,9 @@ const defaultValues: SiloCreateFormValues = {
4849
},
4950
}
5051

51-
export function CreateSiloSideModalForm() {
52+
export const handle = titleCrumb('New Silo')
53+
54+
export default function CreateSiloSideModalForm() {
5255
const navigate = useNavigate()
5356
const queryClient = useApiQueryClient()
5457

app/forms/ssh-key-edit.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ import { DescriptionField } from '~/components/form/fields/DescriptionField'
1515
import { NameField } from '~/components/form/fields/NameField'
1616
import { TextField } from '~/components/form/fields/TextField'
1717
import { SideModalForm } from '~/components/form/SideModalForm'
18+
import { titleCrumb } from '~/hooks/use-crumbs'
1819
import { getSshKeySelector, useSshKeySelector } from '~/hooks/use-params'
1920
import { CopyToClipboard } from '~/ui/lib/CopyToClipboard'
2021
import { PropertiesTable } from '~/ui/lib/PropertiesTable'
2122
import { ResourceLabel } from '~/ui/lib/SideModal'
2223
import { pb } from '~/util/path-builder'
2324

24-
EditSSHKeySideModalForm.loader = async ({ params }: LoaderFunctionArgs) => {
25+
export async function clientLoader({ params }: LoaderFunctionArgs) {
2526
const { sshKey } = getSshKeySelector(params)
2627
await apiQueryClient.prefetchQuery('currentUserSshKeyView', { path: { sshKey } })
2728
return null
2829
}
2930

30-
export function EditSSHKeySideModalForm() {
31+
export const handle = titleCrumb('View SSH Key')
32+
33+
export default function EditSSHKeySideModalForm() {
3134
const navigate = useNavigate()
3235
const { sshKey } = useSshKeySelector()
3336

0 commit comments

Comments
 (0)