diff --git a/web/components/workspace/create-workspace-form.tsx b/web/components/workspace/create-workspace-form.tsx index b127a077b..41251dac6 100644 --- a/web/components/workspace/create-workspace-form.tsx +++ b/web/components/workspace/create-workspace-form.tsx @@ -13,7 +13,7 @@ import { Button, CustomSelect, Input } from "@plane/ui"; // types import { IWorkspace } from "types"; // constants -import { ORGANIZATION_SIZE } from "constants/workspace"; +import { ORGANIZATION_SIZE, RESTRICTED_URLS } from "constants/workspace"; type Props = { onSubmit?: (res: IWorkspace) => Promise; @@ -30,22 +30,6 @@ type Props = { }; }; -const restrictedUrls = [ - "api", - "installations", - "404", - "create-workspace", - "error", - "invitations", - "magic-sign-in", - "onboarding", - "profile", - "reset-password", - "sign-up", - "spaces", - "workspace-member-invitation", -]; - const workspaceService = new WorkspaceService(); export const CreateWorkspaceForm: FC = observer((props) => { @@ -81,7 +65,7 @@ export const CreateWorkspaceForm: FC = observer((props) => { await workspaceService .workspaceSlugCheck(formData.slug) .then(async (res) => { - if (res.status === true && !restrictedUrls.includes(formData.slug)) { + if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) { setSlugError(false); await workspaceStore @@ -141,7 +125,6 @@ export const CreateWorkspaceForm: FC = observer((props) => { render={({ field: { value, ref, onChange } }) => ( { @@ -167,15 +150,15 @@ export const CreateWorkspaceForm: FC = observer((props) => { rules={{ required: "Workspace URL is required", }} - render={({ field: { value, ref } }) => ( + render={({ field: { onChange, value, ref } }) => ( - /^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true) - } + onChange={(e) => { + /^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true); + onChange(e.target.value.toLowerCase()); + }} ref={ref} hasError={Boolean(errors.slug)} placeholder="Enter workspace name..." diff --git a/web/constants/workspace.ts b/web/constants/workspace.ts index 8f55fac4c..084bdc68a 100644 --- a/web/constants/workspace.ts +++ b/web/constants/workspace.ts @@ -90,3 +90,19 @@ export const DEFAULT_GLOBAL_VIEWS_LIST: { label: "Subscribed", }, ]; + +export const RESTRICTED_URLS = [ + "api", + "installations", + "404", + "create-workspace", + "error", + "invitations", + "magic-sign-in", + "onboarding", + "profile", + "reset-password", + "sign-up", + "spaces", + "workspace-member-invitation", +];