forked from github/plane
fix: slug field not working (#2622)
This commit is contained in:
parent
c66d76df26
commit
dd2ba2ec6f
@ -13,7 +13,7 @@ import { Button, CustomSelect, Input } from "@plane/ui";
|
|||||||
// types
|
// types
|
||||||
import { IWorkspace } from "types";
|
import { IWorkspace } from "types";
|
||||||
// constants
|
// constants
|
||||||
import { ORGANIZATION_SIZE } from "constants/workspace";
|
import { ORGANIZATION_SIZE, RESTRICTED_URLS } from "constants/workspace";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onSubmit?: (res: IWorkspace) => Promise<void>;
|
onSubmit?: (res: IWorkspace) => Promise<void>;
|
||||||
@ -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();
|
const workspaceService = new WorkspaceService();
|
||||||
|
|
||||||
export const CreateWorkspaceForm: FC<Props> = observer((props) => {
|
export const CreateWorkspaceForm: FC<Props> = observer((props) => {
|
||||||
@ -81,7 +65,7 @@ export const CreateWorkspaceForm: FC<Props> = observer((props) => {
|
|||||||
await workspaceService
|
await workspaceService
|
||||||
.workspaceSlugCheck(formData.slug)
|
.workspaceSlugCheck(formData.slug)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.status === true && !restrictedUrls.includes(formData.slug)) {
|
if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) {
|
||||||
setSlugError(false);
|
setSlugError(false);
|
||||||
|
|
||||||
await workspaceStore
|
await workspaceStore
|
||||||
@ -141,7 +125,6 @@ export const CreateWorkspaceForm: FC<Props> = observer((props) => {
|
|||||||
render={({ field: { value, ref, onChange } }) => (
|
render={({ field: { value, ref, onChange } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="workspaceName"
|
id="workspaceName"
|
||||||
name="name"
|
|
||||||
type="text"
|
type="text"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@ -167,15 +150,15 @@ export const CreateWorkspaceForm: FC<Props> = observer((props) => {
|
|||||||
rules={{
|
rules={{
|
||||||
required: "Workspace URL is required",
|
required: "Workspace URL is required",
|
||||||
}}
|
}}
|
||||||
render={({ field: { value, ref } }) => (
|
render={({ field: { onChange, value, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="workspaceUrl"
|
id="workspaceUrl"
|
||||||
name="slug"
|
|
||||||
type="text"
|
type="text"
|
||||||
value={value.toLocaleLowerCase().trim().replace(/ /g, "-")}
|
value={value.toLocaleLowerCase().trim().replace(/ /g, "-")}
|
||||||
onChange={(e) =>
|
onChange={(e) => {
|
||||||
/^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true)
|
/^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true);
|
||||||
}
|
onChange(e.target.value.toLowerCase());
|
||||||
|
}}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
hasError={Boolean(errors.slug)}
|
hasError={Boolean(errors.slug)}
|
||||||
placeholder="Enter workspace name..."
|
placeholder="Enter workspace name..."
|
||||||
|
@ -90,3 +90,19 @@ export const DEFAULT_GLOBAL_VIEWS_LIST: {
|
|||||||
label: "Subscribed",
|
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",
|
||||||
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user