Skip to content

Commit

Permalink
organizationName -> orgName in generated client (#597)
Browse files Browse the repository at this point in the history
* organizationName -> orgName in generated client

* update code for orgName. +33 -84 haha
  • Loading branch information
david-crespo committed Jan 7, 2022
1 parent 58ddb68 commit 6d1adf6
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 280 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ Using the script is strongly recommended, but if you really don't want to, make

### Useful commands

| Command | Description |
| ----------- | ---------------------------------------------------------------- |
| `yarn test` | Jest tests. Takes Jest flags like `--onlyChanged` or `--watch` |
| `yarn lint` | ESLint |
| `yarn tsc` | Check types |
| `yarn ci` | Lint, tests, and types |
| `yarn fmt` | Format everything. Rarely necessary thanks to editor integration |
| `yarn gen` | Generate components, stories, tests, etc |
| Command | Description |
| ------------ | ---------------------------------------------------------------- |
| `yarn test` | Jest tests. Takes Jest flags like `--onlyChanged` or `--watch` |
| `yarn lint` | ESLint |
| `yarn tsc` | Check types |
| `yarn ci` | Lint, tests, and types |
| `yarn fmt .` | Format everything. Rarely necessary thanks to editor integration |
| `yarn gen` | Generate components, stories, tests, etc |

## Relevant documents

Expand Down
4 changes: 1 addition & 3 deletions app/layouts/OrgLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import { useParams } from '../hooks'

const ProjectList = (props: { className?: string }) => {
const { orgName } = useParams('orgName')
const { data: projects } = useApiQuery('organizationProjectsGet', {
organizationName: orgName,
})
const { data: projects } = useApiQuery('organizationProjectsGet', { orgName })
return (
<section className={cn('space-y-2', props.className)}>
<header className="p-1 space-x-2 uppercase text-xs font-mono text-green-500">
Expand Down
4 changes: 1 addition & 3 deletions app/pages/OrgPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { useParams } from '../hooks'

export default function OrgPage() {
const { orgName } = useParams('orgName')
const { data: org } = useApiQuery('organizationsGetOrganization', {
organizationName: orgName,
})
const { data: org } = useApiQuery('organizationsGetOrganization', { orgName })

if (!org) return null

Expand Down
8 changes: 3 additions & 5 deletions app/pages/ProjectCreatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ export default function ProjectCreatePage() {
const createProject = useApiMutation('organizationProjectsPost', {
onSuccess(project) {
// refetch list of projects in sidebar
queryClient.invalidateQueries('organizationProjectsGet', {
organizationName: orgName,
})
queryClient.invalidateQueries('organizationProjectsGet', { orgName })
// avoid the project fetch when the project page loads since we have the data
queryClient.setQueryData(
'organizationProjectsGetProject',
{ organizationName: orgName, projectName: project.name },
{ orgName, projectName: project.name },
project
)
addToast({
Expand All @@ -63,7 +61,7 @@ export default function ProjectCreatePage() {
initialValues={{ name: '', description: '' }}
onSubmit={({ name, description }) => {
createProject.mutate({
organizationName: orgName,
orgName,
body: { name, description },
})
}}
Expand Down
4 changes: 1 addition & 3 deletions app/pages/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { useParams } from '../hooks'

const ProjectsPage = () => {
const { orgName } = useParams('orgName')
const { data } = useApiQuery('organizationProjectsGet', {
organizationName: orgName,
})
const { data } = useApiQuery('organizationProjectsGet', { orgName })

if (!data) return null

Expand Down
4 changes: 2 additions & 2 deletions app/pages/project/disks/DisksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function AttachedInstance(props: {
// name. Fetch the whole list (default page size is 100 I think) and find the
// instance client-side. Fortunately, React Query dedupes the request.
const { data: instances } = useApiQuery('projectInstancesGet', {
organizationName: props.orgName,
orgName: props.orgName,
projectName: props.projectName,
})
const instance = instances?.items.find((i) => i.id === props.instanceId)
Expand All @@ -32,7 +32,7 @@ export function DisksPage() {
const { orgName, projectName } = useParams('orgName', 'projectName')
const { Table, Column } = useQueryTable(
'projectDisksGet',
{ organizationName: orgName, projectName },
{ orgName, projectName },
{ refetchInterval: 5000 }
)

Expand Down
9 changes: 3 additions & 6 deletions app/pages/project/instances/InstancesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ import { useInstanceActions } from './actions'
export const InstancesPage = () => {
const { orgName, projectName } = useParams('orgName', 'projectName')
const { data: project } = useApiQuery('organizationProjectsGetProject', {
organizationName: orgName,
orgName,
projectName,
})

const actions = useInstanceActions({ organizationName: orgName, projectName })
const actions = useInstanceActions({ orgName, projectName })

const { Table, Column } = useQueryTable(
'projectInstancesGet',
{
organizationName: orgName,
projectName,
},
{ orgName, projectName },
{
refetchInterval: 5000,
keepPreviousData: true,
Expand Down
2 changes: 1 addition & 1 deletion app/pages/project/instances/create/InstancesCreatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function InstanceCreatePage() {
) || { memory: 0, ncpus: 0 }

createInstance.mutate({
organizationName: orgName,
orgName,
projectName,
body: {
name: values['instance-name'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ export function ExistingDiskModal({
projectName,
}: Props) {
// TODO: maybe wait to fetch until you open the modal
const { data } = useApiQuery('projectDisksGet', {
organizationName: orgName,
projectName,
})
const { data } = useApiQuery('projectDisksGet', { orgName, projectName })

const disks = data?.items
.filter(isUnattached)
.map((d) => ({ value: d.id, label: d.name }))
Expand Down
5 changes: 1 addition & 4 deletions app/pages/project/instances/create/modals/network-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export function NetworkModal({
orgName,
projectName,
}: Props) {
const { data: vpcs } = useApiQuery('projectVpcsGet', {
organizationName: orgName,
projectName,
})
const { data: vpcs } = useApiQuery('projectVpcsGet', { orgName, projectName })
const vpcItems = vpcs?.items.map((v) => ({ value: v.id, label: v.name }))
return (
<SideModal
Expand Down
17 changes: 6 additions & 11 deletions app/pages/project/instances/instance/InstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ import { StorageTab } from './tabs/StorageTab'
import { MetricsTab } from './tabs/MetricsTab'

export const InstancePage = () => {
const {
orgName: organizationName,
projectName,
instanceName,
} = useParams('orgName', 'projectName', 'instanceName')
// const { Table, Column } = useQueryTable('projectInstancesGetInstance', {
// organizationName,
// projectName,
// instanceName,
// })
const { orgName, projectName, instanceName } = useParams(
'orgName',
'projectName',
'instanceName'
)

const { data: instance } = useApiQuery('projectInstancesGetInstance', {
organizationName,
orgName,
projectName,
instanceName,
})
Expand Down
2 changes: 1 addition & 1 deletion app/pages/project/instances/instance/tabs/StorageTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function StorageTab() {
)
const { data } = useApiQuery(
'instanceDisksGet',
{ organizationName: orgName, projectName, instanceName },
{ orgName, projectName, instanceName },
{ refetchInterval: 5000 }
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ import React from 'react'
import { useParams } from '../../../../../hooks'

export const VpcFirewallRulesTab = () => {
const { orgName: organizationName, ...other } = useParams(
'orgName',
'projectName',
'vpcName'
)
const vpcParams = useParams('orgName', 'projectName', 'vpcName')

const { Table, Column } = useQueryTable('vpcFirewallRulesGet', {
organizationName,
...other,
})
const { Table, Column } = useQueryTable('vpcFirewallRulesGet', vpcParams)

return (
<Table selectable>
Expand Down
11 changes: 2 additions & 9 deletions app/pages/project/networking/VpcPage/tabs/VpcRoutersTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import { useParams } from '../../../../../hooks'
import { useQueryTable, DateCell, LabelCell } from '@oxide/table'

export const VpcRoutersTab = () => {
const { orgName: organizationName, ...other } = useParams(
'orgName',
'projectName',
'vpcName'
)
const vpcParams = useParams('orgName', 'projectName', 'vpcName')

const { Table, Column } = useQueryTable('vpcRoutersGet', {
organizationName,
...other,
})
const { Table, Column } = useQueryTable('vpcRoutersGet', vpcParams)

return (
<Table selectable>
Expand Down
11 changes: 2 additions & 9 deletions app/pages/project/networking/VpcPage/tabs/VpcSubnetsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import { useParams } from '../../../../../hooks'
import { useQueryTable, TwoLineCell, DateCell } from '@oxide/table'

export const VpcSubnetsTab = () => {
const { orgName: organizationName, ...other } = useParams(
'orgName',
'projectName',
'vpcName'
)
const vpcParams = useParams('orgName', 'projectName', 'vpcName')

const { Table, Column } = useQueryTable('vpcSubnetsGet', {
organizationName,
...other,
})
const { Table, Column } = useQueryTable('vpcSubnetsGet', vpcParams)

return (
<Table selectable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import { useParams } from '../../../../../hooks'
import { useQueryTable, TypeValueCell } from '@oxide/table'

export const VpcSystemRoutesTab = () => {
const { orgName: organizationName, ...other } = useParams(
'orgName',
'projectName',
'vpcName'
)
const vpcParams = useParams('orgName', 'projectName', 'vpcName')

const { Table, Column } = useQueryTable('routersRoutesGet', {
routerName: 'system',
organizationName,
...other,
...vpcParams,
})

return (
Expand Down
10 changes: 3 additions & 7 deletions app/pages/project/networking/VpcsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { useParams } from '../../../hooks'
import { DateCell, linkCell, useQueryTable } from '@oxide/table'

export const VpcsPage = () => {
const { orgName: organizationName, projectName } = useParams(
'orgName',
'projectName'
)
const { orgName, projectName } = useParams('orgName', 'projectName')
const { Table, Column } = useQueryTable('projectVpcsGet', {
organizationName,
orgName,
projectName,
})
return (
Expand All @@ -22,8 +19,7 @@ export const VpcsPage = () => {
<Column
id="name"
cell={linkCell(
(name) =>
`/orgs/${organizationName}/projects/${projectName}/vpcs/${name}`
(name) => `/orgs/${orgName}/projects/${projectName}/vpcs/${name}`
)}
/>
<Column id="dnsName" header="dns name" />
Expand Down

1 comment on commit 6d1adf6

@vercel
Copy link

@vercel vercel bot commented on 6d1adf6 Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.