π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
chore: admin imports refactor (#6251)
sriram veeraghanta23849789f9b3
diff --git a/admin/app/authentication/github/form.tsx b/admin/app/authentication/github/form.tsxindex 23ba9ccd15..4842675cd5 100644--- a/admin/app/authentication/github/form.tsx+++ b/admin/app/authentication/github/form.tsx@@ -4,10 +4,11 @@ import { FC, useState } from "react";import isEmpty from "lodash/isEmpty";import Link from "next/link";import { useForm } from "react-hook-form";-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import { IFormattedInstanceConfiguration, TInstanceGithubAuthenticationConfigurationKeys } from "@plane/types";-// uiimport { Button, TOAST_TYPE, getButtonStyling, setToast } from "@plane/ui";+import { cn } from "@plane/utils";// componentsimport {CodeBlock,@@ -17,8 +18,6 @@ import {TControllerInputFormField,TCopyField,} from "@/components/common";-// helpers-import { API_BASE_URL, cn } from "@/helpers/common.helper";// hooksimport { useInstance } from "@/hooks/store";@@ -103,8 +102,7 @@ export const InstanceGithubConfigForm: FC<Props> = (props) => {url: originURL,description: (<>- We will auto-generate this. Paste this into the{" "}- <CodeBlock darkerShade>Authorized origin URL</CodeBlock> field{" "}+ We will auto-generate this. Paste this into the <CodeBlock darkerShade>Authorized origin URL</CodeBlock> field{" "}<atabIndex={-1}href="https://github.com/settings/applications/new"@@ -123,8 +121,8 @@ export const InstanceGithubConfigForm: FC<Props> = (props) => {url: `${originURL}/auth/github/callback/`,description: (<>- We will auto-generate this. Paste this into your{" "}- <CodeBlock darkerShade>Authorized Callback URI</CodeBlock> field{" "}+ We will auto-generate this. Paste this into your <CodeBlock darkerShade>Authorized Callback URI</CodeBlock>{" "}+ field{" "}<atabIndex={-1}href="https://github.com/settings/applications/new"diff --git a/admin/app/authentication/github/page.tsx b/admin/app/authentication/github/page.tsxindex 03e5c97f22..986a5ebd24 100644--- a/admin/app/authentication/github/page.tsx+++ b/admin/app/authentication/github/page.tsx@@ -5,12 +5,12 @@ import { observer } from "mobx-react";import Image from "next/image";import { useTheme } from "next-themes";import useSWR from "swr";+// plane internal packagesimport { Loader, ToggleSwitch, setPromiseToast } from "@plane/ui";+import { resolveGeneralTheme } from "@plane/utils";// componentsimport { AuthenticationMethodCard } from "@/components/authentication";import { PageHeader } from "@/components/common";-// helpers-import { resolveGeneralTheme } from "@/helpers/common.helper";// hooksimport { useInstance } from "@/hooks/store";// iconsdiff --git a/admin/app/authentication/gitlab/form.tsx b/admin/app/authentication/gitlab/form.tsxindex 1cc9794d37..f64158744a 100644--- a/admin/app/authentication/gitlab/form.tsx+++ b/admin/app/authentication/gitlab/form.tsx@@ -2,10 +2,11 @@ import { FC, useState } from "react";import isEmpty from "lodash/isEmpty";import Link from "next/link";import { useForm } from "react-hook-form";-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import { IFormattedInstanceConfiguration, TInstanceGitlabAuthenticationConfigurationKeys } from "@plane/types";-// uiimport { Button, TOAST_TYPE, getButtonStyling, setToast } from "@plane/ui";+import { cn } from "@plane/utils";// componentsimport {CodeBlock,@@ -15,8 +16,6 @@ import {TControllerInputFormField,TCopyField,} from "@/components/common";-// helpers-import { API_BASE_URL, cn } from "@/helpers/common.helper";// hooksimport { useInstance } from "@/hooks/store";@@ -117,8 +116,7 @@ export const InstanceGitlabConfigForm: FC<Props> = (props) => {url: `${originURL}/auth/gitlab/callback/`,description: (<>- We will auto-generate this. Paste this into the{" "}- <CodeBlock darkerShade>Redirect URI</CodeBlock> field of your{" "}+ We will auto-generate this. Paste this into the <CodeBlock darkerShade>Redirect URI</CodeBlock> field of your{" "}<atabIndex={-1}href="https://docs.gitlab.com/ee/integration/oauth_provider.html"diff --git a/admin/app/authentication/google/form.tsx b/admin/app/authentication/google/form.tsxindex 61fe7af620..10decdcb05 100644--- a/admin/app/authentication/google/form.tsx+++ b/admin/app/authentication/google/form.tsx@@ -3,10 +3,11 @@ import { FC, useState } from "react";import isEmpty from "lodash/isEmpty";import Link from "next/link";import { useForm } from "react-hook-form";-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import { IFormattedInstanceConfiguration, TInstanceGoogleAuthenticationConfigurationKeys } from "@plane/types";-// uiimport { Button, TOAST_TYPE, getButtonStyling, setToast } from "@plane/ui";+import { cn } from "@plane/utils";// componentsimport {CodeBlock,@@ -16,8 +17,6 @@ import {TControllerInputFormField,TCopyField,} from "@/components/common";-// helpers-import { API_BASE_URL, cn } from "@/helpers/common.helper";// hooksimport { useInstance } from "@/hooks/store";diff --git a/admin/app/authentication/page.tsx b/admin/app/authentication/page.tsxindex dc6aa6a6dc..279ff396a2 100644--- a/admin/app/authentication/page.tsx+++ b/admin/app/authentication/page.tsx@@ -3,10 +3,10 @@import { useState } from "react";import { observer } from "mobx-react";import useSWR from "swr";+// plane internal packagesimport { TInstanceConfigurationKeys } from "@plane/types";import { Loader, ToggleSwitch, setPromiseToast } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";// hooksimport { useInstance } from "@/hooks/store";// plane admin componentsdiff --git a/admin/app/layout.tsx b/admin/app/layout.tsxindex 19aba48e9a..ef9559af8c 100644--- a/admin/app/layout.tsx+++ b/admin/app/layout.tsx@@ -4,11 +4,11 @@ import { ReactNode } from "react";import { ThemeProvider, useTheme } from "next-themes";import { SWRConfig } from "swr";// ui+import { ADMIN_BASE_PATH, DEFAULT_SWR_CONFIG } from "@plane/constants";import { Toast } from "@plane/ui";+import { resolveGeneralTheme } from "@plane/utils";// constants-import { SWR_CONFIG } from "@/constants/swr-config";// helpers-import { ASSET_PREFIX, resolveGeneralTheme } from "@/helpers/common.helper";// libimport { InstanceProvider } from "@/lib/instance-provider";import { StoreProvider } from "@/lib/store-provider";@@ -22,6 +22,7 @@ const ToastWithTheme = () => {};export default function RootLayout({ children }: { children: ReactNode }) {+ const ASSET_PREFIX = ADMIN_BASE_PATH;return (<html lang="en"><head>@@ -34,7 +35,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {<body className={`antialiased`}><ThemeProvider themes={["light", "dark"]} defaultTheme="system" enableSystem><ToastWithTheme />- <SWRConfig value={SWR_CONFIG}>+ <SWRConfig value={DEFAULT_SWR_CONFIG}><StoreProvider><InstanceProvider><UserProvider>{children}</UserProvider>diff --git a/admin/app/workspace/create/form.tsx b/admin/app/workspace/create/form.tsxindex 958f53153a..2a7eda207e 100644--- a/admin/app/workspace/create/form.tsx+++ b/admin/app/workspace/create/form.tsx@@ -3,13 +3,11 @@ import Link from "next/link";import { useRouter } from "next/navigation";import { Controller, useForm } from "react-hook-form";// constants-import { ORGANIZATION_SIZE, RESTRICTED_URLS } from "@plane/constants";+import { WEB_BASE_URL, ORGANIZATION_SIZE, RESTRICTED_URLS } from "@plane/constants";// typesimport { IWorkspace } from "@plane/types";// componentsimport { Button, CustomSelect, getButtonStyling, Input, setToast, TOAST_TYPE } from "@plane/ui";-// helpers-import { WEB_BASE_URL } from "@/helpers/common.helper";// hooksimport { useWorkspace } from "@/hooks/store";// servicesdiff --git a/admin/app/workspace/page.tsx b/admin/app/workspace/page.tsxindex ef8a3c42d2..3ca34b69e3 100644--- a/admin/app/workspace/page.tsx+++ b/admin/app/workspace/page.tsx@@ -7,12 +7,10 @@ import useSWR from "swr";import { Loader as LoaderIcon } from "lucide-react";// typesimport { TInstanceConfigurationKeys } from "@plane/types";-// uiimport { Button, getButtonStyling, Loader, setPromiseToast, ToggleSwitch } from "@plane/ui";+import { cn } from "@plane/utils";// componentsimport { WorkspaceListItem } from "@/components/workspace";-// helpers-import { cn } from "@/helpers/common.helper";// hooksimport { useInstance, useWorkspace } from "@/hooks/store";diff --git a/admin/ce/components/authentication/authentication-modes.tsx b/admin/ce/components/authentication/authentication-modes.tsxindex 84cde94d44..3c7ec111a3 100644--- a/admin/ce/components/authentication/authentication-modes.tsx+++ b/admin/ce/components/authentication/authentication-modes.tsx@@ -10,7 +10,7 @@ import {// componentsimport { AuthenticationMethodCard } from "@/components/authentication";// helpers-import { getBaseAuthenticationModes } from "@/helpers/authentication.helper";+import { getBaseAuthenticationModes } from "@/lib/auth-helpers";// plane admin componentsimport { UpgradeButton } from "@/plane-admin/components/common";// imagesdiff --git a/admin/ce/components/common/upgrade-button.tsx b/admin/ce/components/common/upgrade-button.tsxindex c2b264baeb..208225e0ce 100644--- a/admin/ce/components/common/upgrade-button.tsx+++ b/admin/ce/components/common/upgrade-button.tsx@@ -3,10 +3,9 @@import React from "react";// iconsimport { SquareArrowOutUpRight } from "lucide-react";-// ui+// plane internal packagesimport { getButtonStyling } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";export const UpgradeButton: React.FC = () => (<a href="https://plane.so/pricing?mode=self-hosted" target="_blank" className={cn(getButtonStyling("primary", "sm"))}>diff --git a/admin/core/components/admin-sidebar/help-section.tsx b/admin/core/components/admin-sidebar/help-section.tsxindex 10d5cbd0da..d776477497 100644--- a/admin/core/components/admin-sidebar/help-section.tsx+++ b/admin/core/components/admin-sidebar/help-section.tsx@@ -5,13 +5,14 @@ import { observer } from "mobx-react";import Link from "next/link";import { ExternalLink, FileText, HelpCircle, MoveLeft } from "lucide-react";import { Transition } from "@headlessui/react";-// ui+// plane internal packages+import { WEB_BASE_URL } from "@plane/constants";import { DiscordIcon, GithubIcon, Tooltip } from "@plane/ui";-// helpers-import { WEB_BASE_URL, cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";// hooksimport { useTheme } from "@/hooks/store";// assets+// eslint-disable-next-line import/orderimport packageJson from "package.json";const helpOptions = [diff --git a/admin/core/components/admin-sidebar/sidebar-dropdown.tsx b/admin/core/components/admin-sidebar/sidebar-dropdown.tsxindex e0741f7c4a..f34372413f 100644--- a/admin/core/components/admin-sidebar/sidebar-dropdown.tsx+++ b/admin/core/components/admin-sidebar/sidebar-dropdown.tsx@@ -5,11 +5,10 @@ import { observer } from "mobx-react";import { useTheme as useNextTheme } from "next-themes";import { LogOut, UserCog2, Palette } from "lucide-react";import { Menu, Transition } from "@headlessui/react";-// plane ui+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import { Avatar } from "@plane/ui";-// helpers-import { API_BASE_URL, cn } from "@/helpers/common.helper";-import { getFileURL } from "@/helpers/file.helper";+import { getFileURL, cn } from "@plane/utils";// hooksimport { useTheme, useUser } from "@/hooks/store";// servicesdiff --git a/admin/core/components/admin-sidebar/sidebar-menu.tsx b/admin/core/components/admin-sidebar/sidebar-menu.tsxindex a985842e7f..618551ae65 100644--- a/admin/core/components/admin-sidebar/sidebar-menu.tsx+++ b/admin/core/components/admin-sidebar/sidebar-menu.tsx@@ -4,11 +4,11 @@ import { observer } from "mobx-react";import Link from "next/link";import { usePathname } from "next/navigation";import { Image, BrainCog, Cog, Lock, Mail } from "lucide-react";+// plane internal packagesimport { Tooltip, WorkspaceIcon } from "@plane/ui";+import { cn } from "@plane/utils";// hooks-import { cn } from "@/helpers/common.helper";import { useTheme } from "@/hooks/store";-// helpersconst INSTANCE_ADMIN_LINKS = [{diff --git a/admin/core/components/authentication/auth-banner.tsx b/admin/core/components/authentication/auth-banner.tsxindex 191d7a0a77..7c1e5ea292 100644--- a/admin/core/components/authentication/auth-banner.tsx+++ b/admin/core/components/authentication/auth-banner.tsx@@ -1,7 +1,7 @@import { FC } from "react";import { Info, X } from "lucide-react";-// helpers-import { TAuthErrorInfo } from "@/helpers/authentication.helper";+// plane constants+import { TAuthErrorInfo } from "@plane/constants";type TAuthBanner = {bannerData: TAuthErrorInfo | undefined;diff --git a/admin/core/components/authentication/authentication-method-card.tsx b/admin/core/components/authentication/authentication-method-card.tsxindex 50895a4592..897deb7c48 100644--- a/admin/core/components/authentication/authentication-method-card.tsx+++ b/admin/core/components/authentication/authentication-method-card.tsx@@ -2,7 +2,7 @@import { FC } from "react";// helpers-import { cn } from "helpers/common.helper";+import { cn } from "@plane/utils";type Props = {name: string;diff --git a/admin/core/components/authentication/github-config.tsx b/admin/core/components/authentication/github-config.tsxindex 07c566d684..57035580f6 100644--- a/admin/core/components/authentication/github-config.tsx+++ b/admin/core/components/authentication/github-config.tsx@@ -5,12 +5,10 @@ import { observer } from "mobx-react";import Link from "next/link";// iconsimport { Settings2 } from "lucide-react";-// types+// plane internal packagesimport { TInstanceAuthenticationMethodKeys } from "@plane/types";-// uiimport { ToggleSwitch, getButtonStyling } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";// hooksimport { useInstance } from "@/hooks/store";diff --git a/admin/core/components/authentication/gitlab-config.tsx b/admin/core/components/authentication/gitlab-config.tsxindex 735201025b..4181338d21 100644--- a/admin/core/components/authentication/gitlab-config.tsx+++ b/admin/core/components/authentication/gitlab-config.tsx@@ -5,12 +5,10 @@ import { observer } from "mobx-react";import Link from "next/link";// iconsimport { Settings2 } from "lucide-react";-// types+// plane internal packagesimport { TInstanceAuthenticationMethodKeys } from "@plane/types";-// uiimport { ToggleSwitch, getButtonStyling } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";// hooksimport { useInstance } from "@/hooks/store";diff --git a/admin/core/components/authentication/google-config.tsx b/admin/core/components/authentication/google-config.tsxindex 12d11a2f89..0f3cc98e38 100644--- a/admin/core/components/authentication/google-config.tsx+++ b/admin/core/components/authentication/google-config.tsx@@ -5,12 +5,10 @@ import { observer } from "mobx-react";import Link from "next/link";// iconsimport { Settings2 } from "lucide-react";-// types+// plane internal packagesimport { TInstanceAuthenticationMethodKeys } from "@plane/types";-// uiimport { ToggleSwitch, getButtonStyling } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";// hooksimport { useInstance } from "@/hooks/store";diff --git a/admin/core/components/common/code-block.tsx b/admin/core/components/common/code-block.tsxindex 55f8b4afb4..88ad78a1e1 100644--- a/admin/core/components/common/code-block.tsx+++ b/admin/core/components/common/code-block.tsx@@ -1,4 +1,4 @@-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";type TProps = {children: React.ReactNode;diff --git a/admin/core/components/common/controller-input.tsx b/admin/core/components/common/controller-input.tsxindex 4d0eade08e..ca8f301620 100644--- a/admin/core/components/common/controller-input.tsx+++ b/admin/core/components/common/controller-input.tsx@@ -4,10 +4,9 @@ import React, { useState } from "react";import { Controller, Control } from "react-hook-form";// iconsimport { Eye, EyeOff } from "lucide-react";-// ui+// plane internal packagesimport { Input } from "@plane/ui";-// helpers-import { cn } from "@/helpers/common.helper";+import { cn } from "@plane/utils";type Props = {control: Control<any>;@@ -37,9 +36,7 @@ export const ControllerInput: React.FC<Props> = (props) => {return (<div className="flex flex-col gap-1">- <h4 className="text-sm text-custom-text-300">- {label}- </h4>+ <h4 className="text-sm text-custom-text-300">{label}</h4><div className="relative"><Controllercontrol={control}diff --git a/admin/core/components/common/password-strength-meter.tsx b/admin/core/components/common/password-strength-meter.tsxindex 342f77efb7..f4349b24ad 100644--- a/admin/core/components/common/password-strength-meter.tsx+++ b/admin/core/components/common/password-strength-meter.tsx@@ -1,14 +1,9 @@"use client";import { FC, useMemo } from "react";-// import { CircleCheck } from "lucide-react";-// helpers-import { cn } from "@/helpers/common.helper";-import {- E_PASSWORD_STRENGTH,- // PASSWORD_CRITERIA,- getPasswordStrength,-} from "@/helpers/password.helper";+// plane internal packages+import { E_PASSWORD_STRENGTH } from "@plane/constants";+import { cn, getPasswordStrength } from "@plane/utils";type TPasswordStrengthMeter = {password: string;diff --git a/admin/core/components/instance/setup-form.tsx b/admin/core/components/instance/setup-form.tsxindex 7e987dbdf1..f033ce42e4 100644--- a/admin/core/components/instance/setup-form.tsx+++ b/admin/core/components/instance/setup-form.tsx@@ -4,13 +4,12 @@ import { FC, useEffect, useMemo, useState } from "react";import { useSearchParams } from "next/navigation";// iconsimport { Eye, EyeOff } from "lucide-react";-// ui+// plane internal packages+import { API_BASE_URL, E_PASSWORD_STRENGTH } from "@plane/constants";import { Button, Checkbox, Input, Spinner } from "@plane/ui";+import { getPasswordStrength } from "@plane/utils";// componentsimport { Banner, PasswordStrengthMeter } from "@/components/common";-// helpers-import { API_BASE_URL } from "@/helpers/common.helper";-import { E_PASSWORD_STRENGTH, getPasswordStrength } from "@/helpers/password.helper";// servicesimport { AuthService } from "@/services/auth.service";diff --git a/admin/core/components/login/sign-in-form.tsx b/admin/core/components/login/sign-in-form.tsxindex aa67d4936e..af1ba077e6 100644--- a/admin/core/components/login/sign-in-form.tsx+++ b/admin/core/components/login/sign-in-form.tsx@@ -2,24 +2,18 @@import { FC, useEffect, useMemo, useState } from "react";import { useSearchParams } from "next/navigation";-// servicesimport { Eye, EyeOff } from "lucide-react";+// plane internal packages+import { API_BASE_URL, EAdminAuthErrorCodes, TAuthErrorInfo } from "@plane/constants";import { Button, Input, Spinner } from "@plane/ui";// componentsimport { Banner } from "@/components/common";// helpers-import {- authErrorHandler,- EAuthenticationErrorCodes,- EErrorAlertType,- TAuthErrorInfo,-} from "@/helpers/authentication.helper";--import { API_BASE_URL } from "@/helpers/common.helper";+import { authErrorHandler } from "@/lib/auth-helpers";+// servicesimport { AuthService } from "@/services/auth.service";+// local componentsimport { AuthBanner } from "../authentication";-// ui-// icons// service initializationconst authService = new AuthService();@@ -102,7 +96,7 @@ export const InstanceSignInForm: FC = (props) => {useEffect(() => {if (errorCode) {- const errorDetail = authErrorHandler(errorCode?.toString() as EAuthenticationErrorCodes);+ const errorDetail = authErrorHandler(errorCode?.toString() as EAdminAuthErrorCodes);if (errorDetail) {setErrorInfo(errorDetail);}diff --git a/admin/core/components/new-user-popup.tsx b/admin/core/components/new-user-popup.tsxindex 8e1570781c..0b974b38c5 100644--- a/admin/core/components/new-user-popup.tsx+++ b/admin/core/components/new-user-popup.tsx@@ -1,13 +1,13 @@"use client";import React from "react";-import { resolveGeneralTheme } from "helpers/common.helper";import { observer } from "mobx-react";import Image from "next/image";import Link from "next/link";import { useTheme as nextUseTheme } from "next-themes";// uiimport { Button, getButtonStyling } from "@plane/ui";+import { resolveGeneralTheme } from "@plane/utils";// hooksimport { useTheme } from "@/hooks/store";// iconsdiff --git a/admin/core/components/workspace/list-item.tsx b/admin/core/components/workspace/list-item.tsxindex e0a96a6ef6..ae693eb728 100644--- a/admin/core/components/workspace/list-item.tsx+++ b/admin/core/components/workspace/list-item.tsx@@ -1,9 +1,9 @@import { observer } from "mobx-react";import { ExternalLink } from "lucide-react";-// helpers+// plane internal packages+import { WEB_BASE_URL } from "@plane/constants";import { Tooltip } from "@plane/ui";-import { WEB_BASE_URL } from "@/helpers/common.helper";-import { getFileURL } from "@/helpers/file.helper";+import { getFileURL } from "@plane/utils";// hooksimport { useWorkspace } from "@/hooks/store";diff --git a/admin/core/lib/auth-helpers.tsx b/admin/core/lib/auth-helpers.tsxnew file mode 100644index 0000000000..582b56e298--- /dev/null+++ b/admin/core/lib/auth-helpers.tsx@@ -0,0 +1,164 @@+import { ReactNode } from "react";+import Image from "next/image";+import Link from "next/link";+import { KeyRound, Mails } from "lucide-react";+// plane packages+import { SUPPORT_EMAIL, EAdminAuthErrorCodes, TAuthErrorInfo } from "@plane/constants";+import { TGetBaseAuthenticationModeProps, TInstanceAuthenticationModes } from "@plane/types";+import { resolveGeneralTheme } from "@plane/utils";+// components+import {+ EmailCodesConfiguration,+ GithubConfiguration,+ GitlabConfiguration,+ GoogleConfiguration,+ PasswordLoginConfiguration,+} from "@/components/authentication";+// images+import githubLightModeImage from "@/public/logos/github-black.png";+import githubDarkModeImage from "@/public/logos/github-white.png";+import GitlabLogo from "@/public/logos/gitlab-logo.svg";+import GoogleLogo from "@/public/logos/google-logo.svg";++export enum EErrorAlertType {+ BANNER_ALERT = "BANNER_ALERT",+ INLINE_FIRST_NAME = "INLINE_FIRST_NAME",+ INLINE_EMAIL = "INLINE_EMAIL",+ INLINE_PASSWORD = "INLINE_PASSWORD",+ INLINE_EMAIL_CODE = "INLINE_EMAIL_CODE",+}++const errorCodeMessages: {+ [key in EAdminAuthErrorCodes]: { title: string; message: (email?: string | undefined) => ReactNode };+} = {+ // admin+ [EAdminAuthErrorCodes.ADMIN_ALREADY_EXIST]: {+ title: `Admin already exists`,+ message: () => `Admin already exists. Please try again.`,+ },+ [EAdminAuthErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME]: {+ title: `Email, password and first name required`,+ message: () => `Email, password and first name required. Please try again.`,+ },+ [EAdminAuthErrorCodes.INVALID_ADMIN_EMAIL]: {+ title: `Invalid admin email`,+ message: () => `Invalid admin email. Please try again.`,+ },+ [EAdminAuthErrorCodes.INVALID_ADMIN_PASSWORD]: {+ title: `Invalid admin password`,+ message: () => `Invalid admin password. Please try again.`,+ },+ [EAdminAuthErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD]: {+ title: `Email and password required`,+ message: () => `Email and password required. Please try again.`,+ },+ [EAdminAuthErrorCodes.ADMIN_AUTHENTICATION_FAILED]: {+ title: `Authentication failed`,+ message: () => `Authentication failed. Please try again.`,+ },+ [EAdminAuthErrorCodes.ADMIN_USER_ALREADY_EXIST]: {+ title: `Admin user already exists`,+ message: () => (+ <div>+ Admin user already exists. + <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>+ Sign In+ </Link>+ now.+ </div>+ ),+ },+ [EAdminAuthErrorCodes.ADMIN_USER_DOES_NOT_EXIST]: {+ title: `Admin user does not exist`,+ message: () => (+ <div>+ Admin user does not exist. + <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>+ Sign In+ </Link>+ now.+ </div>+ ),+ },+ [EAdminAuthErrorCodes.ADMIN_USER_DEACTIVATED]: {+ title: `User account deactivated`,+ message: () => `User account deactivated. Please contact ${!!SUPPORT_EMAIL ? SUPPORT_EMAIL : "administrator"}.`,+ },+};++export const authErrorHandler = (+ errorCode: EAdminAuthErrorCodes,+ email?: string | undefined+): TAuthErrorInfo | undefined => {+ const bannerAlertErrorCodes = [+ EAdminAuthErrorCodes.ADMIN_ALREADY_EXIST,+ EAdminAuthErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME,+ EAdminAuthErrorCodes.INVALID_ADMIN_EMAIL,+ EAdminAuthErrorCodes.INVALID_ADMIN_PASSWORD,+ EAdminAuthErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD,+ EAdminAuthErrorCodes.ADMIN_AUTHENTICATION_FAILED,+ EAdminAuthErrorCodes.ADMIN_USER_ALREADY_EXIST,+ EAdminAuthErrorCodes.ADMIN_USER_DOES_NOT_EXIST,+ EAdminAuthErrorCodes.ADMIN_USER_DEACTIVATED,+ ];++ if (bannerAlertErrorCodes.includes(errorCode))+ return {+ type: EErrorAlertType.BANNER_ALERT,+ code: errorCode,+ title: errorCodeMessages[errorCode]?.title || "Error",+ message: errorCodeMessages[errorCode]?.message(email) || "Something went wrong. Please try again.",+ };++ return undefined;+};++export const getBaseAuthenticationModes: (props: TGetBaseAuthenticationModeProps) => TInstanceAuthenticationModes[] = ({+ disabled,+ updateConfig,+ resolvedTheme,+}) => [+ {+ key: "unique-codes",+ name: "Unique codes",+ description:+ "Log in or sign up for Plane using codes sent via email. You need to have set up SMTP to use this method.",+ icon: <Mails className="h-6 w-6 p-0.5 text-custom-text-300/80" />,+ config: <EmailCodesConfiguration disabled={disabled} updateConfig={updateConfig} />,+ },+ {+ key: "passwords-login",+ name: "Passwords",+ description: "Allow members to create accounts with passwords and use it with their email addresses to sign in.",+ icon: <KeyRound className="h-6 w-6 p-0.5 text-custom-text-300/80" />,+ config: <PasswordLoginConfiguration disabled={disabled} updateConfig={updateConfig} />,+ },+ {+ key: "google",+ name: "Google",+ description: "Allow members to log in or sign up for Plane with their Google accounts.",+ icon: <Image src={GoogleLogo} height={20} width={20} alt="Google Logo" />,+ config: <GoogleConfiguration disabled={disabled} updateConfig={updateConfig} />,+ },+ {+ key: "github",+ name: "GitHub",+ description: "Allow members to log in or sign up for Plane with their GitHub accounts.",+ icon: (+ <Image+ src={resolveGeneralTheme(resolvedTheme) === "dark" ? githubDarkModeImage : githubLightModeImage}+ height={20}+ width={20}+ alt="GitHub Logo"+ />+ ),+ config: <GithubConfiguration disabled={disabled} updateConfig={updateConfig} />,+ },+ {+ key: "gitlab",+ name: "GitLab",+ description: "Allow members to log in or sign up to plane with their GitLab accounts.",+ icon: <Image src={GitlabLogo} height={20} width={20} alt="GitLab Logo" />,+ config: <GitlabConfiguration disabled={disabled} updateConfig={updateConfig} />,+ },+];diff --git a/admin/core/services/auth.service.ts b/admin/core/services/auth.service.tsindex 2cea01beec..a47fd83962 100644--- a/admin/core/services/auth.service.ts+++ b/admin/core/services/auth.service.ts@@ -1,5 +1,4 @@-// helpers-import { API_BASE_URL } from "@/helpers/common.helper";+import { API_BASE_URL } from "@plane/constants";// servicesimport { APIService } from "@/services/api.service";diff --git a/admin/core/services/instance.service.ts b/admin/core/services/instance.service.tsindex feb94ceea4..510a780d79 100644--- a/admin/core/services/instance.service.ts+++ b/admin/core/services/instance.service.ts@@ -1,4 +1,5 @@-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import type {IFormattedInstanceConfiguration,IInstance,@@ -7,7 +8,6 @@ import type {IInstanceInfo,} from "@plane/types";// helpers-import { API_BASE_URL } from "@/helpers/common.helper";import { APIService } from "@/services/api.service";export class InstanceService extends APIService {diff --git a/admin/core/services/user.service.ts b/admin/core/services/user.service.tsindex 42eb6eb224..74ef2a81bf 100644--- a/admin/core/services/user.service.ts+++ b/admin/core/services/user.service.ts@@ -1,7 +1,6 @@-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import type { IUser } from "@plane/types";-// helpers-import { API_BASE_URL } from "@/helpers/common.helper";// servicesimport { APIService } from "@/services/api.service";diff --git a/admin/core/services/workspace.service.ts b/admin/core/services/workspace.service.tsindex 81ba36a6f7..787ad42698 100644--- a/admin/core/services/workspace.service.ts+++ b/admin/core/services/workspace.service.ts@@ -1,7 +1,6 @@-// types+// plane internal packages+import { API_BASE_URL } from "@plane/constants";import type { IWorkspace, TWorkspacePaginationInfo } from "@plane/types";-// helpers-import { API_BASE_URL } from "@/helpers/common.helper";// servicesimport { APIService } from "@/services/api.service";diff --git a/admin/core/store/instance.store.ts b/admin/core/store/instance.store.tsindex 01ab552846..0daadb1fcd 100644--- a/admin/core/store/instance.store.ts+++ b/admin/core/store/instance.store.ts@@ -1,5 +1,7 @@import set from "lodash/set";import { observable, action, computed, makeObservable, runInAction } from "mobx";+// plane internal packages+import { EInstanceStatus, TInstanceStatus } from "@plane/constants";import {IInstance,IInstanceAdmin,@@ -8,8 +10,6 @@ import {IInstanceInfo,IInstanceConfig,} from "@plane/types";-// helpers-import { EInstanceStatus, TInstanceStatus } from "@/helpers/instance.helper";// servicesimport { InstanceService } from "@/services/instance.service";// root storediff --git a/admin/core/store/user.store.ts b/admin/core/store/user.store.tsindex df17c9b004..7f56c0523e 100644--- a/admin/core/store/user.store.ts+++ b/admin/core/store/user.store.ts@@ -1,7 +1,7 @@import { action, observable, runInAction, makeObservable } from "mobx";+// plane internal packages+import { EUserStatus, TUserStatus } from "@plane/constants";import { IUser } from "@plane/types";-// helpers-import { EUserStatus, TUserStatus } from "@/helpers/user.helper";// servicesimport { AuthService } from "@/services/auth.service";import { UserService } from "@/services/user.service";diff --git a/admin/helpers/authentication.helper.tsx b/admin/helpers/authentication.helper.tsxdeleted file mode 100644index 627ff182ca..0000000000--- a/admin/helpers/authentication.helper.tsx+++ /dev/null@@ -1,203 +0,0 @@-import { ReactNode } from "react";-import Image from "next/image";-import Link from "next/link";-import { KeyRound, Mails } from "lucide-react";-// types-import { TGetBaseAuthenticationModeProps, TInstanceAuthenticationModes } from "@plane/types";-// components-import {- EmailCodesConfiguration,- GithubConfiguration,- GitlabConfiguration,- GoogleConfiguration,- PasswordLoginConfiguration,-} from "@/components/authentication";-// helpers-import { SUPPORT_EMAIL, resolveGeneralTheme } from "@/helpers/common.helper";-// images-import githubLightModeImage from "@/public/logos/github-black.png";-import githubDarkModeImage from "@/public/logos/github-white.png";-import GitlabLogo from "@/public/logos/gitlab-logo.svg";-import GoogleLogo from "@/public/logos/google-logo.svg";--export enum EPageTypes {- PUBLIC = "PUBLIC",- NON_AUTHENTICATED = "NON_AUTHENTICATED",- SET_PASSWORD = "SET_PASSWORD",- ONBOARDING = "ONBOARDING",- AUTHENTICATED = "AUTHENTICATED",-}--export enum EAuthModes {- SIGN_IN = "SIGN_IN",- SIGN_UP = "SIGN_UP",-}--export enum EAuthSteps {- EMAIL = "EMAIL",- PASSWORD = "PASSWORD",- UNIQUE_CODE = "UNIQUE_CODE",-}--export enum EErrorAlertType {- BANNER_ALERT = "BANNER_ALERT",- INLINE_FIRST_NAME = "INLINE_FIRST_NAME",- INLINE_EMAIL = "INLINE_EMAIL",- INLINE_PASSWORD = "INLINE_PASSWORD",- INLINE_EMAIL_CODE = "INLINE_EMAIL_CODE",-}--export enum EAuthenticationErrorCodes {- // Admin- ADMIN_ALREADY_EXIST = "5150",- REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME = "5155",- INVALID_ADMIN_EMAIL = "5160",- INVALID_ADMIN_PASSWORD = "5165",- REQUIRED_ADMIN_EMAIL_PASSWORD = "5170",- ADMIN_AUTHENTICATION_FAILED = "5175",- ADMIN_USER_ALREADY_EXIST = "5180",- ADMIN_USER_DOES_NOT_EXIST = "5185",- ADMIN_USER_DEACTIVATED = "5190",-}--export type TAuthErrorInfo = {- type: EErrorAlertType;- code: EAuthenticationErrorCodes;- title: string;- message: ReactNode;-};--const errorCodeMessages: {- [key in EAuthenticationErrorCodes]: { title: string; message: (email?: string | undefined) => ReactNode };-} = {- // admin- [EAuthenticationErrorCodes.ADMIN_ALREADY_EXIST]: {- title: `Admin already exists`,- message: () => `Admin already exists. Please try again.`,- },- [EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME]: {- title: `Email, password and first name required`,- message: () => `Email, password and first name required. Please try again.`,- },- [EAuthenticationErrorCodes.INVALID_ADMIN_EMAIL]: {- title: `Invalid admin email`,- message: () => `Invalid admin email. Please try again.`,- },- [EAuthenticationErrorCodes.INVALID_ADMIN_PASSWORD]: {- title: `Invalid admin password`,- message: () => `Invalid admin password. Please try again.`,- },- [EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD]: {- title: `Email and password required`,- message: () => `Email and password required. Please try again.`,- },- [EAuthenticationErrorCodes.ADMIN_AUTHENTICATION_FAILED]: {- title: `Authentication failed`,- message: () => `Authentication failed. Please try again.`,- },- [EAuthenticationErrorCodes.ADMIN_USER_ALREADY_EXIST]: {- title: `Admin user already exists`,- message: () => (- <div>- Admin user already exists. - <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>- Sign In- </Link>- now.- </div>- ),- },- [EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST]: {- title: `Admin user does not exist`,- message: () => (- <div>- Admin user does not exist. - <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>- Sign In- </Link>- now.- </div>- ),- },- [EAuthenticationErrorCodes.ADMIN_USER_DEACTIVATED]: {- title: `User account deactivated`,- message: () => `User account deactivated. Please contact ${!!SUPPORT_EMAIL ? SUPPORT_EMAIL : "administrator"}.`,- },-};--export const authErrorHandler = (- errorCode: EAuthenticationErrorCodes,- email?: string | undefined-): TAuthErrorInfo | undefined => {- const bannerAlertErrorCodes = [- EAuthenticationErrorCodes.ADMIN_ALREADY_EXIST,- EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME,- EAuthenticationErrorCodes.INVALID_ADMIN_EMAIL,- EAuthenticationErrorCodes.INVALID_ADMIN_PASSWORD,- EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD,- EAuthenticationErrorCodes.ADMIN_AUTHENTICATION_FAILED,- EAuthenticationErrorCodes.ADMIN_USER_ALREADY_EXIST,- EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST,- EAuthenticationErrorCodes.ADMIN_USER_DEACTIVATED,- ];-- if (bannerAlertErrorCodes.includes(errorCode))- return {- type: EErrorAlertType.BANNER_ALERT,- code: errorCode,- title: errorCodeMessages[errorCode]?.title || "Error",- message: errorCodeMessages[errorCode]?.message(email) || "Something went wrong. Please try again.",- };-- return undefined;-};--export const getBaseAuthenticationModes: (props: TGetBaseAuthenticationModeProps) => TInstanceAuthenticationModes[] = ({- disabled,- updateConfig,- resolvedTheme,-}) => [- {- key: "unique-codes",- name: "Unique codes",- description:- "Log in or sign up for Plane using codes sent via email. You need to have set up SMTP to use this method.",- icon: <Mails className="h-6 w-6 p-0.5 text-custom-text-300/80" />,- config: <EmailCodesConfiguration disabled={disabled} updateConfig={updateConfig} />,- },- {- key: "passwords-login",- name: "Passwords",- description: "Allow members to create accounts with passwords and use it with their email addresses to sign in.",- icon: <KeyRound className="h-6 w-6 p-0.5 text-custom-text-300/80" />,- config: <PasswordLoginConfiguration disabled={disabled} updateConfig={updateConfig} />,- },- {- key: "google",- name: "Google",- description: "Allow members to log in or sign up for Plane with their Google accounts.",- icon: <Image src={GoogleLogo} height={20} width={20} alt="Google Logo" />,- config: <GoogleConfiguration disabled={disabled} updateConfig={updateConfig} />,- },- {- key: "github",- name: "GitHub",- description: "Allow members to log in or sign up for Plane with their GitHub accounts.",- icon: (- <Image- src={resolveGeneralTheme(resolvedTheme) === "dark" ? githubDarkModeImage : githubLightModeImage}- height={20}- width={20}- alt="GitHub Logo"- />- ),- config: <GithubConfiguration disabled={disabled} updateConfig={updateConfig} />,- },- {- key: "gitlab",- name: "GitLab",- description: "Allow members to log in or sign up to plane with their GitLab accounts.",- icon: <Image src={GitlabLogo} height={20} width={20} alt="GitLab Logo" />,- config: <GitlabConfiguration disabled={disabled} updateConfig={updateConfig} />,- },- ];diff --git a/admin/helpers/common.helper.ts b/admin/helpers/common.helper.tsdeleted file mode 100644index e282e57925..0000000000--- a/admin/helpers/common.helper.ts+++ /dev/null@@ -1,20 +0,0 @@-import { clsx, type ClassValue } from "clsx";-import { twMerge } from "tailwind-merge";--export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || "";--export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || "";--export const SPACE_BASE_URL = process.env.NEXT_PUBLIC_SPACE_BASE_URL || "";-export const SPACE_BASE_PATH = process.env.NEXT_PUBLIC_SPACE_BASE_PATH || "";--export const WEB_BASE_URL = process.env.NEXT_PUBLIC_WEB_BASE_URL || "";--export const SUPPORT_EMAIL = process.env.NEXT_PUBLIC_SUPPORT_EMAIL || "";--export const ASSET_PREFIX = ADMIN_BASE_PATH;--export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));--export const resolveGeneralTheme = (resolvedTheme: string | undefined) =>- resolvedTheme?.includes("light") ? "light" : resolvedTheme?.includes("dark") ? "dark" : "system";diff --git a/admin/helpers/index.ts b/admin/helpers/index.tsdeleted file mode 100644index ae6aab829c..0000000000--- a/admin/helpers/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./instance.helper";-export * from "./user.helper";diff --git a/admin/helpers/password.helper.ts b/admin/helpers/password.helper.tsdeleted file mode 100644index dfe9a5c65f..0000000000--- a/admin/helpers/password.helper.ts+++ /dev/null@@ -1,67 +0,0 @@-import zxcvbn from "zxcvbn";--export enum E_PASSWORD_STRENGTH {- EMPTY = "empty",- LENGTH_NOT_VALID = "length_not_valid",- STRENGTH_NOT_VALID = "strength_not_valid",- STRENGTH_VALID = "strength_valid",-}--const PASSWORD_MIN_LENGTH = 8;-// const PASSWORD_NUMBER_REGEX = /\d/;-// const PASSWORD_CHAR_CAPS_REGEX = /[A-Z]/;-// const PASSWORD_SPECIAL_CHAR_REGEX = /[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/;--export const PASSWORD_CRITERIA = [- {- key: "min_8_char",- label: "Min 8 characters",- isCriteriaValid: (password: string) => password.length >= PASSWORD_MIN_LENGTH,- },- // {- // key: "min_1_upper_case",- // label: "Min 1 upper-case letter",- // isCriteriaValid: (password: string) => PASSWORD_NUMBER_REGEX.test(password),- // },- // {- // key: "min_1_number",- // label: "Min 1 number",- // isCriteriaValid: (password: string) => PASSWORD_CHAR_CAPS_REGEX.test(password),- // },- // {- // key: "min_1_special_char",- // label: "Min 1 special character",- // isCriteriaValid: (password: string) => PASSWORD_SPECIAL_CHAR_REGEX.test(password),- // },-];--export const getPasswordStrength = (password: string): E_PASSWORD_STRENGTH => {- let passwordStrength: E_PASSWORD_STRENGTH = E_PASSWORD_STRENGTH.EMPTY;-- if (!password || password === "" || password.length <= 0) {- return passwordStrength;- }-- if (password.length >= PASSWORD_MIN_LENGTH) {- passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_NOT_VALID;- } else {- passwordStrength = E_PASSWORD_STRENGTH.LENGTH_NOT_VALID;- return passwordStrength;- }-- const passwordCriteriaValidation = PASSWORD_CRITERIA.map((criteria) => criteria.isCriteriaValid(password)).every(- (criterion) => criterion- );- const passwordStrengthScore = zxcvbn(password).score;-- if (passwordCriteriaValidation === false || passwordStrengthScore <= 2) {- passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_NOT_VALID;- return passwordStrength;- }-- if (passwordCriteriaValidation === true && passwordStrengthScore >= 3) {- passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_VALID;- }-- return passwordStrength;-};diff --git a/admin/helpers/string.helper.ts b/admin/helpers/string.helper.tsdeleted file mode 100644index a48508118e..0000000000--- a/admin/helpers/string.helper.ts+++ /dev/null@@ -1,21 +0,0 @@-/**- * @description- * This function test whether a URL is valid or not.- *- * It accepts URLs with or without the protocol.- * @param {string} url- * @returns {boolean}- * @example- * checkURLValidity("https://example.com") => true- * checkURLValidity("example.com") => true- * checkURLValidity("example") => false- */-export const checkURLValidity = (url: string): boolean => {- if (!url) return false;-- // regex to support complex query parameters and fragments- const urlPattern =- /^(https?:\/\/)?((([a-z\d-]+\.)*[a-z\d-]+\.[a-z]{2,6})|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(:\d+)?(\/[\w.-]*)*(\?[^#\s]*)?(#[\w-]*)?$/i;-- return urlPattern.test(url);-};diff --git a/admin/tsconfig.json b/admin/tsconfig.jsonindex 1748435814..f9bb7cf10b 100644--- a/admin/tsconfig.json+++ b/admin/tsconfig.json@@ -5,7 +5,6 @@"baseUrl": ".","paths": {"@/*": ["core/*"],- "@/helpers/*": ["helpers/*"],"@/public/*": ["public/*"],"@/plane-admin/*": ["ce/*"]}diff --git a/packages/constants/src/auth.ts b/packages/constants/src/auth.tsindex 59f08a37f0..8d34766d46 100644--- a/packages/constants/src/auth.ts+++ b/packages/constants/src/auth.ts@@ -1,3 +1,36 @@+export enum E_PASSWORD_STRENGTH {+ EMPTY = "empty",+ LENGTH_NOT_VALID = "length_not_valid",+ STRENGTH_NOT_VALID = "strength_not_valid",+ STRENGTH_VALID = "strength_valid",+}++export const PASSWORD_MIN_LENGTH = 8;++export const PASSWORD_CRITERIA = [+ {+ key: "min_8_char",+ label: "Min 8 characters",+ isCriteriaValid: (password: string) =>+ password.length >= PASSWORD_MIN_LENGTH,+ },+ // {+ // key: "min_1_upper_case",+ // label: "Min 1 upper-case letter",+ // isCriteriaValid: (password: string) => PASSWORD_NUMBER_REGEX.test(password),+ // },+ // {+ // key: "min_1_number",+ // label: "Min 1 number",+ // isCriteriaValid: (password: string) => PASSWORD_CHAR_CAPS_REGEX.test(password),+ // },+ // {+ // key: "min_1_special_char",+ // label: "Min 1 special character",+ // isCriteriaValid: (password: string) => PASSWORD_SPECIAL_CHAR_REGEX.test(password),+ // },+];+export enum EAuthPageTypes {PUBLIC = "PUBLIC",NON_AUTHENTICATED = "NON_AUTHENTICATED",@@ -26,6 +59,26 @@ export enum EErrorAlertType {INLINE_EMAIL_CODE = "INLINE_EMAIL_CODE",}+export type TAuthErrorInfo = {+ type: EErrorAlertType;+ code: EAdminAuthErrorCodes;+ title: string;+ message: any;+};++export enum EAdminAuthErrorCodes {+ // Admin+ ADMIN_ALREADY_EXIST = "5150",+ REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME = "5155",+ INVALID_ADMIN_EMAIL = "5160",+ INVALID_ADMIN_PASSWORD = "5165",+ REQUIRED_ADMIN_EMAIL_PASSWORD = "5170",+ ADMIN_AUTHENTICATION_FAILED = "5175",+ ADMIN_USER_ALREADY_EXIST = "5180",+ ADMIN_USER_DOES_NOT_EXIST = "5185",+ ADMIN_USER_DEACTIVATED = "5190",+}+export enum EAuthErrorCodes {// GlobalINSTANCE_NOT_CONFIGURED = "5000",diff --git a/packages/constants/src/endpoints.ts b/packages/constants/src/endpoints.tsindex fa6db6ec73..8f7b504644 100644--- a/packages/constants/src/endpoints.ts+++ b/packages/constants/src/endpoints.ts@@ -13,6 +13,14 @@ export const SITES_URL = encodeURI(`${SPACE_BASE_URL}${SPACE_BASE_PATH}/`);export const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || "";export const LIVE_BASE_PATH = process.env.NEXT_PUBLIC_LIVE_BASE_PATH || "";export const LIVE_URL = encodeURI(`${LIVE_BASE_URL}${LIVE_BASE_PATH}/`);+// Web App Base Url+export const WEB_BASE_URL = process.env.NEXT_PUBLIC_WEB_BASE_URL || "";+export const WEB_BASE_PATH = process.env.NEXT_PUBLIC_WEB_BASE_PATH || "";+export const WEB_URL = encodeURI(`${WEB_BASE_URL}${WEB_BASE_PATH}`);// plane website urlexport const WEBSITE_URL =process.env.NEXT_PUBLIC_WEBSITE_URL || "https://plane.so";++// support email+export const SUPPORT_EMAIL =+ process.env.NEXT_PUBLIC_SUPPORT_EMAIL || "[email protected]";diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.tsindex 4189086225..6d9d5ff923 100644--- a/packages/constants/src/index.ts+++ b/packages/constants/src/index.ts@@ -1,4 +1,8 @@export * from "./auth";export * from "./endpoints";+export * from "./instance";export * from "./issue";+export * from "./metadata";+export * from "./swr";+export * from "./user";export * from "./workspace";diff --git a/admin/helpers/instance.helper.ts b/packages/constants/src/instance.tssimilarity index 100%rename from admin/helpers/instance.helper.tsrename to packages/constants/src/instance.tsdiff --git a/admin/core/constants/seo.ts b/packages/constants/src/metadata.tssimilarity index 56%rename from admin/core/constants/seo.tsrename to packages/constants/src/metadata.tsindex aafd5f7a3e..0546c25f20 100644--- a/admin/core/constants/seo.ts+++ b/packages/constants/src/metadata.ts@@ -1,8 +1,11 @@-export const SITE_NAME = "Plane | Simple, extensible, open-source project management tool.";-export const SITE_TITLE = "Plane | Simple, extensible, open-source project management tool.";+export const SITE_NAME =+ "Plane | Simple, extensible, open-source project management tool.";+export const SITE_TITLE =+ "Plane | Simple, extensible, open-source project management tool.";export const SITE_DESCRIPTION ="Open-source project management tool to manage issues, sprints, and product roadmaps with peace of mind.";export const SITE_KEYWORDS ="software development, plan, ship, software, accelerate, code management, release management, project management, issue tracking, agile, scrum, kanban, collaboration";export const SITE_URL = "https://app.plane.so/";-export const TWITTER_USER_NAME = "Plane | Simple, extensible, open-source project management tool.";+export const TWITTER_USER_NAME =+ "Plane | Simple, extensible, open-source project management tool.";diff --git a/admin/core/constants/swr-config.ts b/packages/constants/src/swr.tssimilarity index 81%rename from admin/core/constants/swr-config.tsrename to packages/constants/src/swr.tsindex 38478fcea3..d3eef1cdfe 100644--- a/admin/core/constants/swr-config.ts+++ b/packages/constants/src/swr.ts@@ -1,4 +1,4 @@-export const SWR_CONFIG = {+export const DEFAULT_SWR_CONFIG = {refreshWhenHidden: false,revalidateIfStale: false,revalidateOnFocus: false,diff --git a/admin/helpers/user.helper.ts b/packages/constants/src/user.tssimilarity index 100%rename from admin/helpers/user.helper.tsrename to packages/constants/src/user.tsdiff --git a/packages/utils/src/auth.ts b/packages/utils/src/auth.tsnew file mode 100644index 0000000000..2fe7ba732b--- /dev/null+++ b/packages/utils/src/auth.ts@@ -0,0 +1,33 @@+import zxcvbn from "zxcvbn";+import { E_PASSWORD_STRENGTH, PASSWORD_CRITERIA, PASSWORD_MIN_LENGTH } from "@plane/constants";++export const getPasswordStrength = (password: string): E_PASSWORD_STRENGTH => {+ let passwordStrength: E_PASSWORD_STRENGTH = E_PASSWORD_STRENGTH.EMPTY;++ if (!password || password === "" || password.length <= 0) {+ return passwordStrength;+ }++ if (password.length >= PASSWORD_MIN_LENGTH) {+ passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_NOT_VALID;+ } else {+ passwordStrength = E_PASSWORD_STRENGTH.LENGTH_NOT_VALID;+ return passwordStrength;+ }++ const passwordCriteriaValidation = PASSWORD_CRITERIA.map((criteria) => criteria.isCriteriaValid(password)).every(+ (criterion) => criterion+ );+ const passwordStrengthScore = zxcvbn(password).score;++ if (passwordCriteriaValidation === false || passwordStrengthScore <= 2) {+ passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_NOT_VALID;+ return passwordStrength;+ }++ if (passwordCriteriaValidation === true && passwordStrengthScore >= 3) {+ passwordStrength = E_PASSWORD_STRENGTH.STRENGTH_VALID;+ }++ return passwordStrength;+};diff --git a/admin/helpers/file.helper.ts b/packages/utils/src/file.tssimilarity index 83%rename from admin/helpers/file.helper.tsrename to packages/utils/src/file.tsindex 6e1f546360..6e3394abe9 100644--- a/admin/helpers/file.helper.ts+++ b/packages/utils/src/file.ts@@ -1,5 +1,4 @@-// helpers-import { API_BASE_URL } from "@/helpers/common.helper";+import { API_BASE_URL } from "@plane/constants";/*** @description combine the file path with the base URLdiff --git a/packages/utils/src/index.ts b/packages/utils/src/index.tsindex cf62953452..b897cdfc45 100644--- a/packages/utils/src/index.ts+++ b/packages/utils/src/index.ts@@ -1,4 +1,7 @@+export * from "./auth";export * from "./color";export * from "./common";export * from "./emoji";+export * from "./file";export * from "./string";+export * from "./theme";diff --git a/packages/utils/src/string.ts b/packages/utils/src/string.tsindex c3c8b15418..753231b923 100644--- a/packages/utils/src/string.ts+++ b/packages/utils/src/string.ts@@ -13,3 +13,25 @@ export const sanitizeHTML = (htmlString: string) => {const sanitizedText = DOMPurify.sanitize(htmlString, { ALLOWED_TAGS: [] }); // sanitize the string to remove all HTML tagsreturn sanitizedText.trim(); // trim the string to remove leading and trailing whitespaces};++/**+ * @description+ * This function test whether a URL is valid or not.+ *+ * It accepts URLs with or without the protocol.+ * @param {string} url+ * @returns {boolean}+ * @example+ * checkURLValidity("https://example.com") => true+ * checkURLValidity("example.com") => true+ * checkURLValidity("example") => false+ */+export const checkURLValidity = (url: string): boolean => {+ if (!url) return false;++ // regex to support complex query parameters and fragments+ const urlPattern =+ /^(https?:\/\/)?((([a-z\d-]+\.)*[a-z\d-]+\.[a-z]{2,6})|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(:\d+)?(\/[\w.-]*)*(\?[^#\s]*)?(#[\w-]*)?$/i;++ return urlPattern.test(url);+};diff --git a/packages/utils/src/theme.ts b/packages/utils/src/theme.tsnew file mode 100644index 0000000000..1f2c22b024--- /dev/null+++ b/packages/utils/src/theme.ts@@ -0,0 +1,2 @@+export const resolveGeneralTheme = (resolvedTheme: string | undefined) =>+ resolvedTheme?.includes("light") ? "light" : resolvedTheme?.includes("dark") ? "dark" : "system";