Skip to content

Commit

Permalink
a billion one-liner toasts with the magic of prettier-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Oct 29, 2024
1 parent dbe02c4 commit df7f302
Show file tree
Hide file tree
Showing 39 changed files with 45 additions and 315 deletions.
8 changes: 1 addition & 7 deletions app/components/AttachFloatingIpModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ export const AttachFloatingIpModal = ({
onSuccess(floatingIp) {
queryClient.invalidateQueries('floatingIpList')
queryClient.invalidateQueries('instanceExternalIpList')
addToast({
content: (
<>
IP <HLs>{floatingIp.name}</HLs> attached
</>
),
})
addToast(<>IP <HLs>{floatingIp.name}</HLs> attached</>) // prettier-ignore
onDismiss()
},
onError: (err) => {
Expand Down
8 changes: 1 addition & 7 deletions app/forms/disk-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ export function CreateDiskSideModalForm({
const createDisk = useApiMutation('diskCreate', {
onSuccess(data) {
queryClient.invalidateQueries('diskList')
addToast({
content: (
<>
Disk <HLs>{data.name}</HLs> created
</>
),
})
addToast(<>Disk <HLs>{data.name}</HLs> created</>) // prettier-ignore
onSuccess?.(data)
onDismiss(navigate)
},
Expand Down
8 changes: 1 addition & 7 deletions app/forms/firewall-rules-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,7 @@ export function CreateFirewallRuleForm() {
onSuccess(updatedRules) {
const newRule = updatedRules.rules[updatedRules.rules.length - 1]
queryClient.invalidateQueries('vpcFirewallRulesView')
addToast({
content: (
<>
Firewall rule <HLs>{newRule.name}</HLs> created
</>
),
})
addToast(<>Firewall rule <HLs>{newRule.name}</HLs> created</>) // prettier-ignore
navigate(pb.vpcFirewallRules(vpcSelector))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/firewall-rules-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ export function EditFirewallRuleForm() {
onDismiss()
queryClient.invalidateQueries('vpcFirewallRulesView')
const updatedRule = body.rules[body.rules.length - 1]
addToast({
content: (
<>
Firewall rule <HLs>{updatedRule.name}</HLs> updated
</>
),
})
addToast(<>Firewall rule <HLs>{updatedRule.name}</HLs> updated</>) // prettier-ignore
},
})

Expand Down
8 changes: 1 addition & 7 deletions app/forms/floating-ip-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ export function CreateFloatingIpSideModalForm() {
onSuccess(floatingIp) {
queryClient.invalidateQueries('floatingIpList')
queryClient.invalidateQueries('ipPoolUtilizationView')
addToast({
content: (
<>
Floating IP <HLs>{floatingIp.name}</HLs> created
</>
),
})
addToast(<>Floating IP <HLs>{floatingIp.name}</HLs> created</>) // prettier-ignore
navigate(pb.floatingIps(projectSelector))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/floating-ip-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ export function EditFloatingIpSideModalForm() {
const editFloatingIp = useApiMutation('floatingIpUpdate', {
onSuccess(_floatingIp) {
queryClient.invalidateQueries('floatingIpList')
addToast({
content: (
<>
Floating IP <HLs>{_floatingIp.name}</HLs> updated
</>
),
})
addToast(<>Floating IP <HLs>{_floatingIp.name}</HLs> updated</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/idp/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ export function CreateIdpSideModalForm() {
const createIdp = useApiMutation('samlIdentityProviderCreate', {
onSuccess(idp) {
queryClient.invalidateQueries('siloIdentityProviderList')
addToast({
content: (
<>
IdP <HLs>{idp.name}</HLs> created
</>
),
})
addToast(<>IdP <HLs>{idp.name}</HLs> created</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/image-from-snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ export function CreateImageFromSnapshotSideModalForm() {
const createImage = useApiMutation('imageCreate', {
onSuccess(image) {
queryClient.invalidateQueries('imageList')
addToast({
content: (
<>
Image <HLs>{image.name}</HLs> created
</>
),
})
addToast(<>Image <HLs>{image.name}</HLs> created</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/instance-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ export function CreateInstanceForm() {
{ path: { instance: instance.name }, query: { project } },
instance
)
addToast({
content: (
<>
Instance <HLs>{instance.name}</HLs> created
</>
),
})
addToast(<>Instance <HLs>{instance.name}</HLs> created</>) // prettier-ignore
navigate(pb.instance({ project, instance: instance.name }))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/ip-pool-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ export function CreateIpPoolSideModalForm() {
const createPool = useApiMutation('ipPoolCreate', {
onSuccess(_pool) {
queryClient.invalidateQueries('ipPoolList')
addToast({
content: (
<>
IP pool <HLs>{_pool.name}</HLs> created
</>
),
})
addToast(<>IP pool <HLs>{_pool.name}</HLs> created</>) // prettier-ignore
navigate(pb.ipPools())
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/ip-pool-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ export function EditIpPoolSideModalForm() {
onSuccess(updatedPool) {
queryClient.invalidateQueries('ipPoolList')
navigate(pb.ipPool({ pool: updatedPool.name }))
addToast({
content: (
<>
IP pool <HLs>{updatedPool.name}</HLs> updated
</>
),
})
addToast(<>IP pool <HLs>{updatedPool.name}</HLs> updated</>) // prettier-ignore

// Only invalidate if we're staying on the same page. If the name
// _has_ changed, invalidating ipPoolView causes an error page to flash
Expand Down
8 changes: 1 addition & 7 deletions app/forms/network-interface-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ export function EditNetworkInterfaceForm({
const editNetworkInterface = useApiMutation('instanceNetworkInterfaceUpdate', {
onSuccess(nic) {
queryClient.invalidateQueries('instanceNetworkInterfaceList')
addToast({
content: (
<>
Network interface <HLs>{nic.name}</HLs> updated
</>
),
})
addToast(<>Network interface <HLs>{nic.name}</HLs> updated</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/project-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ export function CreateProjectSideModalForm() {
queryClient.invalidateQueries('projectList')
// avoid the project fetch when the project page loads since we have the data
queryClient.setQueryData('projectView', { path: { project: project.name } }, project)
addToast({
content: (
<>
Project <HLs>{project.name}</HLs> created
</>
),
})
addToast(<>Project <HLs>{project.name}</HLs> created</>) // prettier-ignore
navigate(pb.project({ project: project.name }))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/project-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ export function EditProjectSideModalForm() {
queryClient.invalidateQueries('projectList')
// avoid the project fetch when the project page loads since we have the data
queryClient.setQueryData('projectView', { path: { project: project.name } }, project)
addToast({
content: (
<>
Project <HLs>{project.name}</HLs> updated
</>
),
})
addToast(<>Project <HLs>{project.name}</HLs> updated</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/silo-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ export function CreateSiloSideModalForm() {
onSuccess(silo) {
queryClient.invalidateQueries('siloList')
queryClient.setQueryData('siloView', { path: { silo: silo.name } }, silo)
addToast({
content: (
<>
Silo <HLs>{silo.name}</HLs> created
</>
),
})
addToast(<>Silo <HLs>{silo.name}</HLs> created</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/snapshot-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ export function CreateSnapshotSideModalForm() {
const createSnapshot = useApiMutation('snapshotCreate', {
onSuccess(snapshot) {
queryClient.invalidateQueries('snapshotList')
addToast({
content: (
<>
Snapshot <HLs>{snapshot.name}</HLs> created
</>
),
})
addToast(<>Snapshot <HLs>{snapshot.name}</HLs> created</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/ssh-key-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ export function CreateSSHKeySideModalForm({ onDismiss, message }: Props) {
onSuccess(sshKey) {
queryClient.invalidateQueries('currentUserSshKeyList')
handleDismiss()
addToast({
content: (
<>
SSH key <HLs>{sshKey.name}</HLs> created
</>
),
})
addToast(<>SSH key <HLs>{sshKey.name}</HLs> created</>) // prettier-ignore
},
})
const form = useForm({ defaultValues })
Expand Down
8 changes: 1 addition & 7 deletions app/forms/subnet-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export function CreateSubnetForm() {
onSuccess(subnet) {
queryClient.invalidateQueries('vpcSubnetList')
onDismiss()
addToast({
content: (
<>
Subnet <HLs>{subnet.name}</HLs> created
</>
),
})
addToast(<>Subnet <HLs>{subnet.name}</HLs> created</>) // prettier-ignore
},
})

Expand Down
8 changes: 1 addition & 7 deletions app/forms/subnet-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ export function EditSubnetForm() {
const updateSubnet = useApiMutation('vpcSubnetUpdate', {
onSuccess(subnet) {
queryClient.invalidateQueries('vpcSubnetList')
addToast({
content: (
<>
Subnet <HLs>{subnet.name}</HLs> updated
</>
),
})
addToast(<>Subnet <HLs>{subnet.name}</HLs> updated</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ export function CreateVpcSideModalForm() {
{ path: { vpc: vpc.name }, query: projectSelector },
vpc
)
addToast({
content: (
<>
VPC <HLs>{vpc.name}</HLs> created
</>
),
})
addToast(<>VPC <HLs>{vpc.name}</HLs> created</>) // prettier-ignore
navigate(pb.vpc({ vpc: vpc.name, ...projectSelector }))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ export function EditVpcSideModalForm() {
onSuccess(updatedVpc) {
queryClient.invalidateQueries('vpcList')
navigate(pb.vpc({ project, vpc: updatedVpc.name }))
addToast({
content: (
<>
VPC <HLs>{updatedVpc.name}</HLs> updated
</>
),
})
addToast(<>VPC <HLs>{updatedVpc.name}</HLs> updated</>) // prettier-ignore

// Only invalidate if we're staying on the same page. If the name
// _has_ changed, invalidating vpcView causes an error page to flash
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-router-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ export function CreateRouterSideModalForm() {
const createRouter = useApiMutation('vpcRouterCreate', {
onSuccess(router) {
queryClient.invalidateQueries('vpcRouterList')
addToast({
content: (
<>
Router <HLs>{router.name}</HLs> created
</>
),
})
addToast(<>Router <HLs>{router.name}</HLs> created</>) // prettier-ignore
onDismiss()
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-router-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ export function EditRouterSideModalForm() {
const editRouter = useApiMutation('vpcRouterUpdate', {
onSuccess(updatedRouter) {
queryClient.invalidateQueries('vpcRouterList')
addToast({
content: (
<>
Router <HLs>{updatedRouter.name}</HLs> updated
</>
),
})
addToast(<>Router <HLs>{updatedRouter.name}</HLs> updated</>) // prettier-ignore
navigate(pb.vpcRouters({ project, vpc }))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-router-route-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export function CreateRouterRouteSideModalForm() {
const createRouterRoute = useApiMutation('vpcRouterRouteCreate', {
onSuccess(route) {
queryClient.invalidateQueries('vpcRouterRouteList')
addToast({
content: (
<>
Route <HLs>{route.name}</HLs> created
</>
),
})
addToast(<>Route <HLs>{route.name}</HLs> created</>) // prettier-ignore
navigate(pb.vpcRouter(routerSelector))
},
})
Expand Down
8 changes: 1 addition & 7 deletions app/forms/vpc-router-route-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ export function EditRouterRouteSideModalForm() {
const updateRouterRoute = useApiMutation('vpcRouterRouteUpdate', {
onSuccess(updatedRoute) {
queryClient.invalidateQueries('vpcRouterRouteList')
addToast({
content: (
<>
Route <HLs>{updatedRoute.name}</HLs> updated
</>
),
})
addToast(<>Route <HLs>{updatedRoute.name}</HLs> updated</>) // prettier-ignore
navigate(pb.vpcRouter(routerSelector))
},
})
Expand Down
Loading

0 comments on commit df7f302

Please sign in to comment.