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

fix: disable save button when workspace name is empty #2294

Merged
merged 18 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ import { useForm } from "react-hook-form";
import { z } from "zod";

export const dynamic = "force-dynamic";

const validCharactersRegex = /^[a-zA-Z0-9-_]+$/;

const formSchema = z.object({
workspaceId: z.string(),
name: z.string(),
name: z
chronark marked this conversation as resolved.
Show resolved Hide resolved
.string()
.min(3)
.refine((v) => validCharactersRegex.test(v), {
message: "worksapce can only contain letters, numbers, dashes and underscores",
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

}),
});

type Props = {
Expand Down Expand Up @@ -53,7 +61,7 @@ export const UpdateWorkspaceName: React.FC<Props> = ({ workspace }) => {
async function onSubmit(values: z.infer<typeof formSchema>) {
await updateName.mutateAsync(values);
}

const isDisabled = form.formState.isLoading || !form.formState.isValid;
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
Expand Down Expand Up @@ -84,7 +92,7 @@ export const UpdateWorkspaceName: React.FC<Props> = ({ workspace }) => {
<Button
variant={updateName.isLoading ? "disabled" : "primary"}
type="submit"
disabled={updateName.isLoading}
disabled={updateName.isLoading || isDisabled}
Copy link
Collaborator

Choose a reason for hiding this comment

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

put it all in here or all in a separate variable, but please don't do it half and half

>
{updateName.isLoading ? <Loading /> : "Save"}
</Button>
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { ThemeProvider } from "./theme-provider";
const inter = Inter({
subsets: ["latin"],
variable: "--font-inter",
display: "swap",
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because of that previous pr

I will resolve all issues

adjustFontFallback: false,
});

const pangea = localFont({
Expand Down
2 changes: 2 additions & 0 deletions apps/engineering/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "./global.css";

const inter = Inter({
subsets: ["latin"],
display: "swap",
chronark marked this conversation as resolved.
Show resolved Hide resolved
adjustFontFallback: false,
});

export default function Layout({ children }: { children: ReactNode }) {
Expand Down
Loading