Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Oct 28, 2024
1 parent 8618c05 commit 95df676
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export const DeletePermission: React.FC<Props> = ({ trigger, permission }) => {
const [open, setOpen] = useState(false);

const formSchema = z.object({
name: z
.string()
.refine((v) => v === permission.name, "Please confirm the role's name"),
name: z.string().refine((v) => v === permission.name, "Please confirm the role's name"),
});

const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -86,15 +84,10 @@ export const DeletePermission: React.FC<Props> = ({ trigger, permission }) => {
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form
className="flex flex-col space-y-8"
onSubmit={form.handleSubmit(onSubmit)}
>
<form className="flex flex-col space-y-8" onSubmit={form.handleSubmit(onSubmit)}>
<Alert variant="alert">
<AlertTitle>Warning</AlertTitle>
<AlertDescription>
This action is not reversible. Please be certain.
</AlertDescription>
<AlertDescription>This action is not reversible. Please be certain.</AlertDescription>
</Alert>

<FormField
Expand All @@ -105,10 +98,8 @@ export const DeletePermission: React.FC<Props> = ({ trigger, permission }) => {
<FormLabel className="font-normal text-content-subtle">
{" "}
Enter the permission's name{" "}
<span className="font-medium text-content break-all">
{permission.name}
</span>{" "}
to continue:
<span className="font-medium text-content break-all">{permission.name}</span> to
continue:
</FormLabel>
<FormControl>
<Input {...field} autoComplete="off" className="w-full" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,11 @@ export const CreateNewPermission: React.FC<Props> = ({ trigger }) => {
<DialogContent>
<DialogHeader>
<DialogTitle>Create a new permission</DialogTitle>
<DialogDescription>
Permissions allow your key to do certain actions.
</DialogDescription>
<DialogDescription>Permissions allow your key to do certain actions.</DialogDescription>
</DialogHeader>

<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col gap-8"
>
<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-8">
<FormField
control={form.control}
name="name"
Expand All @@ -106,10 +101,10 @@ export const CreateNewPermission: React.FC<Props> = ({ trigger }) => {
<Input placeholder="domain.create" {...field} />
</FormControl>
<FormDescription>
A unique key to identify your permission. We suggest using{" "}
<code>.</code> (dot) separated names, to structure your
hierarchy. For example we use <code>api.create_key</code> or{" "}
<code>api.update_api</code> in our own permissions.
A unique key to identify your permission. We suggest using <code>.</code> (dot)
separated names, to structure your hierarchy. For example we use{" "}
<code>api.create_key</code> or <code>api.update_api</code> in our own
permissions.
</FormDescription>
<FormMessage />
</FormItem>
Expand All @@ -128,9 +123,7 @@ export const CreateNewPermission: React.FC<Props> = ({ trigger }) => {
</FormLabel>
<FormControl>
<Textarea
rows={
form.getValues().description?.split("\n").length ?? 3
}
rows={form.getValues().description?.split("\n").length ?? 3}
placeholder="Create a new domain in this account."
{...field}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const DeleteRole: React.FC<Props> = ({ trigger, role }) => {
const [open, setOpen] = useState(false);

const formSchema = z.object({
name: z
.string()
.refine((v) => v === role.name, "Please confirm the role's name"),
name: z.string().refine((v) => v === role.name, "Please confirm the role's name"),
});

const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -83,20 +81,15 @@ export const DeleteRole: React.FC<Props> = ({ trigger, role }) => {
<DialogHeader>
<DialogTitle>Delete Role</DialogTitle>
<DialogDescription>
This role will be deleted, keys with this role will be disconnected
from all permissions granted by this role.
This role will be deleted, keys with this role will be disconnected from all permissions
granted by this role.
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form
className="flex flex-col space-y-8"
onSubmit={form.handleSubmit(onSubmit)}
>
<form className="flex flex-col space-y-8" onSubmit={form.handleSubmit(onSubmit)}>
<Alert variant="alert">
<AlertTitle>Warning</AlertTitle>
<AlertDescription>
This action is not reversible. Please be certain.
</AlertDescription>
<AlertDescription>This action is not reversible. Please be certain.</AlertDescription>
</Alert>

<FormField
Expand All @@ -107,10 +100,7 @@ export const DeleteRole: React.FC<Props> = ({ trigger, role }) => {
<FormLabel className="font-normal text-content-subtle">
{" "}
Enter the role's key{" "}
<span className="font-medium text-content">
{role.name}
</span>{" "}
to continue:
<span className="font-medium text-content">{role.name}</span> to continue:
</FormLabel>
<FormControl>
<Input {...field} autoComplete="off" />
Expand Down
30 changes: 8 additions & 22 deletions apps/dashboard/app/(app)/authorization/roles/create-new-role.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const formSchema = z.object({
z.object({
label: z.string(),
value: z.string(),
})
}),
)
.optional(),
});
Expand Down Expand Up @@ -103,16 +103,11 @@ export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
<DialogContent>
<DialogHeader>
<DialogTitle>Create a new role</DialogTitle>
<DialogDescription>
Roles group permissions together.
</DialogDescription>
<DialogDescription>Roles group permissions together.</DialogDescription>
</DialogHeader>

<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col gap-8"
>
<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-8">
<FormField
control={form.control}
name="name"
Expand All @@ -123,8 +118,8 @@ export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
<Input placeholder="domain.manager" {...field} />
</FormControl>
<FormDescription>
A unique name for your role. You will use this when managing
roles through the API. These are not customer facing.
A unique name for your role. You will use this when managing roles through the
API. These are not customer facing.
</FormDescription>
<FormMessage />
</FormItem>
Expand All @@ -143,9 +138,7 @@ export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
</FormLabel>
<FormControl>
<Textarea
rows={
form.getValues().description?.split("\n").length ?? 3
}
rows={form.getValues().description?.split("\n").length ?? 3}
placeholder="Manage domains and DNS records "
{...field}
/>
Expand Down Expand Up @@ -175,10 +168,7 @@ export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
selected={field.value ?? []}
setSelected={(cb) => {
if (typeof cb === "function") {
return form.setValue(
"permissionOptions",
cb(field.value ?? [])
);
return form.setValue("permissionOptions", cb(field.value ?? []));
}
}}
/>
Expand All @@ -189,11 +179,7 @@ export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
) : null}
<DialogFooter>
<Button type="submit">
{createRole.isLoading ? (
<Loading className="w-4 h-4" />
) : (
"Create"
)}
{createRole.isLoading ? <Loading className="w-4 h-4" /> : "Create"}
</Button>
</DialogFooter>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { Button } from "@/components/ui/button";
import type React from "react";
import { useState } from "react";

import {
Card,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/toaster";

Expand Down Expand Up @@ -52,12 +46,8 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
const [open, setOpen] = useState(false);

const formSchema = z.object({
name: z
.string()
.refine((v) => v === namespace.name, "Please confirm the namespace name"),
intent: z
.string()
.refine((v) => v === intent, "Please confirm your intent"),
name: z.string().refine((v) => v === namespace.name, "Please confirm the namespace name"),
intent: z.string().refine((v) => v === intent, "Please confirm your intent"),
});

const form = useForm<z.infer<typeof formSchema>>({
Expand All @@ -68,8 +58,7 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
const deleteNamespace = trpc.ratelimit.namespace.delete.useMutation({
async onSuccess() {
toast.message("Namespace Deleted", {
description:
"Your namespace and all its overridden identifiers have been deleted.",
description: "Your namespace and all its overridden identifiers have been deleted.",
});

await revalidate();
Expand All @@ -81,8 +70,7 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
},
});

const isValid =
form.watch("intent") === intent && form.watch("name") === namespace.name;
const isValid = form.watch("intent") === intent && form.watch("name") === namespace.name;

async function onSubmit(_values: z.infer<typeof formSchema>) {
deleteNamespace.mutate({ namespaceId: namespace.id });
Expand All @@ -99,8 +87,8 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
<CardHeader>
<CardTitle>Delete</CardTitle>
<CardDescription>
This namespace will be deleted, along with all of its identifiers
and data. This action cannot be undone.
This namespace will be deleted, along with all of its identifiers and data. This action
cannot be undone.
</CardDescription>
</CardHeader>

Expand All @@ -115,15 +103,12 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
<DialogHeader>
<DialogTitle>Delete namespace</DialogTitle>
<DialogDescription>
This namespace will be deleted, along with all of its identifiers
and data. This action cannot be undone.
This namespace will be deleted, along with all of its identifiers and data. This
action cannot be undone.
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form
className="flex flex-col space-y-8"
onSubmit={form.handleSubmit(onSubmit)}
>
<form className="flex flex-col space-y-8" onSubmit={form.handleSubmit(onSubmit)}>
<Alert variant="alert">
<AlertTitle>Warning</AlertTitle>
<AlertDescription>
Expand All @@ -139,10 +124,8 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
<FormLabel className="font-normal text-content-subtle">
{" "}
Enter the namespace name{" "}
<span className="font-medium text-content">
{namespace.name}
</span>{" "}
to continue:
<span className="font-medium text-content">{namespace.name}</span> to
continue:
</FormLabel>
<FormControl>
<Input {...field} autoComplete="off" />
Expand All @@ -158,8 +141,7 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {
render={({ field }) => (
<FormItem>
<FormLabel className="font-normal text-content-subtle">
To verify, type{" "}
<span className="font-medium text-content">{intent}</span>{" "}
To verify, type <span className="font-medium text-content">{intent}</span>{" "}
below:
</FormLabel>
<FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { Button } from "@/components/ui/button";
import type React from "react";
import { useState } from "react";

import {
Card,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/toaster";

Expand Down Expand Up @@ -52,12 +46,8 @@ export const DeleteGateway: React.FC<Props> = ({ gateway }) => {
const [open, setOpen] = useState(false);

const formSchema = z.object({
name: z
.string()
.refine((v) => v === gateway.name, "Please confirm the gateway name"),
intent: z
.string()
.refine((v) => v === intent, "Please confirm your intent"),
name: z.string().refine((v) => v === gateway.name, "Please confirm the gateway name"),
intent: z.string().refine((v) => v === intent, "Please confirm your intent"),
});

const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -86,8 +76,7 @@ export const DeleteGateway: React.FC<Props> = ({ gateway }) => {
},
});

const isValid =
form.watch("intent") === intent && form.watch("name") === gateway.name;
const isValid = form.watch("intent") === intent && form.watch("name") === gateway.name;

async function onSubmit(_values: z.infer<typeof formSchema>) {
deleteGateway.mutate({ gatewayId: gateway.id });
Expand Down Expand Up @@ -122,10 +111,7 @@ export const DeleteGateway: React.FC<Props> = ({ gateway }) => {
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form
className="flex flex-col space-y-8"
onSubmit={form.handleSubmit(onSubmit)}
>
<form className="flex flex-col space-y-8" onSubmit={form.handleSubmit(onSubmit)}>
<Alert variant="alert">
<AlertTitle>Warning</AlertTitle>
<AlertDescription>
Expand All @@ -141,10 +127,7 @@ export const DeleteGateway: React.FC<Props> = ({ gateway }) => {
<FormLabel className="font-normal text-content-subtle">
{" "}
Enter the gateway name{" "}
<span className="font-medium text-content">
{gateway.name}
</span>{" "}
to continue:
<span className="font-medium text-content">{gateway.name}</span> to continue:
</FormLabel>
<FormControl>
<Input {...field} autoComplete="off" />
Expand All @@ -160,8 +143,7 @@ export const DeleteGateway: React.FC<Props> = ({ gateway }) => {
render={({ field }) => (
<FormItem>
<FormLabel className="font-normal text-content-subtle">
To verify, type{" "}
<span className="font-medium text-content">{intent}</span>{" "}
To verify, type <span className="font-medium text-content">{intent}</span>{" "}
below:
</FormLabel>
<FormControl>
Expand Down

0 comments on commit 95df676

Please sign in to comment.