chore: app dir improvement (#4750)

* chore: remove constants package.

* fix: useRouter import in editor.

* chore: improve `peekCycle` and `peekModule` logic.

* style: update app progress bar color.
This commit is contained in:
Prateek Shourya 2024-06-10 19:05:32 +05:30 committed by GitHub
parent a88f2e3cba
commit 7ac07b7b73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 10 additions and 394 deletions

View File

@ -14,7 +14,6 @@
"@headlessui/react": "^1.7.19",
"@plane/types": "*",
"@plane/ui": "*",
"@plane/constants": "*",
"@tailwindcss/typography": "^0.5.9",
"@types/lodash": "^4.17.0",
"autoprefixer": "10.4.14",

View File

@ -1,10 +0,0 @@
{
"name": "@plane/constants",
"version": "0.21.0",
"private": true,
"main": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./*": "./src/*"
}
}

View File

@ -1,372 +0,0 @@
import { ReactNode } from "react";
// import Link from "next/link";
// import { EAuthenticationErrorCodes } from "@/helpers/authentication.helper";
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",
}
// TODO: remove this
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 EAuthErrorCodes {
// Global
INSTANCE_NOT_CONFIGURED = "5000",
INVALID_EMAIL = "5005",
EMAIL_REQUIRED = "5010",
SIGNUP_DISABLED = "5015",
MAGIC_LINK_LOGIN_DISABLED = "5017",
PASSWORD_LOGIN_DISABLED = "5019",
SMTP_NOT_CONFIGURED = "5025",
// Password strength
INVALID_PASSWORD = "5020",
// Sign Up
// USER_ACCOUNT_DEACTIVATED = "5019",
USER_ALREADY_EXIST = "5030",
AUTHENTICATION_FAILED_SIGN_UP = "5035",
REQUIRED_EMAIL_PASSWORD_SIGN_UP = "5040",
INVALID_EMAIL_SIGN_UP = "5045",
INVALID_EMAIL_MAGIC_SIGN_UP = "5050",
MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED = "5055",
// Sign In
USER_DOES_NOT_EXIST = "5060",
AUTHENTICATION_FAILED_SIGN_IN = "5065",
REQUIRED_EMAIL_PASSWORD_SIGN_IN = "5070",
INVALID_EMAIL_SIGN_IN = "5075",
INVALID_EMAIL_MAGIC_SIGN_IN = "5080",
MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED = "5085",
// Both Sign in and Sign up for magic
INVALID_MAGIC_CODE = "5090",
EXPIRED_MAGIC_CODE = "5095",
EMAIL_CODE_ATTEMPT_EXHAUSTED = "5100",
// Oauth
GOOGLE_NOT_CONFIGURED = "5105",
GITHUB_NOT_CONFIGURED = "5110",
GOOGLE_OAUTH_PROVIDER_ERROR = "5115",
GITHUB_OAUTH_PROVIDER_ERROR = "5120",
// Reset Password
INVALID_PASSWORD_TOKEN = "5125",
EXPIRED_PASSWORD_TOKEN = "5130",
// Change password
INCORRECT_OLD_PASSWORD = "5135",
MISSING_PASSWORD= "5138",
INVALID_NEW_PASSWORD = "5140",
// set passowrd
PASSWORD_ALREADY_SET = "5145",
// 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",
}
export type TAuthErrorInfo = {
type: EErrorAlertType;
code: EAuthErrorCodes;
title: string;
message: ReactNode;
};
// const errorCodeMessages: {
// [key in EAuthErrorCodes]: { title: string; message: (email?: string | undefined) => ReactNode };
// } = {
// // global
// [EAuthErrorCodes.INSTANCE_NOT_CONFIGURED]: {
// title: `Instance not configured`,
// message: () => `Instance not configured. Please contact your administrator.`,
// },
// [EAuthErrorCodes.SIGNUP_DISABLED]: {
// title: `Sign up disabled`,
// message: () => `Sign up disabled. Please contact your administrator.`,
// },
// [EAuthErrorCodes.INVALID_PASSWORD]: {
// title: `Invalid password`,
// message: () => `Invalid password. Please try again.`,
// },
// [EAuthErrorCodes.SMTP_NOT_CONFIGURED]: {
// title: `SMTP not configured`,
// message: () => `SMTP not configured. Please contact your administrator.`,
// },
// email check in both sign up and sign in
// [EAuthErrorCodes.INVALID_EMAIL]: {
// title: `Invalid email`,
// message: () => `Invalid email. Please try again.`,
// },
// [EAuthenticationErrorCodes.EMAIL_REQUIRED]: {
// title: `Email required`,
// message: () => `Email required. Please try again.`,
// },
// // sign up
// [EAuthenticationErrorCodes.USER_ALREADY_EXIST]: {
// title: `User already exists`,
// message: (email = undefined) => (
// <div>
// Your account is already registered.&nbsp;
// <Link
// className="underline underline-offset-4 font-medium hover:font-bold transition-all"
// href={`/sign-in${email ? `?email=${encodeURIComponent(email)}` : ``}`}
// >
// Sign In
// </Link>
// &nbsp;now.
// </div>
// ),
// },
// [EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP]: {
// title: `Email and password required`,
// message: () => `Email and password required. Please try again.`,
// },
// [EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP]: {
// title: `Authentication failed`,
// message: () => `Authentication failed. Please try again.`,
// },
// [EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_UP]: {
// title: `Invalid email`,
// message: () => `Invalid email. Please try again.`,
// },
// [EAuthenticationErrorCodes.MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED]: {
// title: `Email and code required`,
// message: () => `Email and code required. Please try again.`,
// },
// [EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP]: {
// title: `Invalid email`,
// message: () => `Invalid email. Please try again.`,
// },
// // sign in
// [EAuthenticationErrorCodes.USER_ACCOUNT_DEACTIVATED]: {
// title: `User account deactivated`,
// message: () => <div>Your account is deactivated. Contact support@plane.so.</div>,
// },
// [EAuthenticationErrorCodes.USER_DOES_NOT_EXIST]: {
// title: `User does not exist`,
// message: (email = undefined) => (
// <div>
// No account found.&nbsp;
// <Link
// className="underline underline-offset-4 font-medium hover:font-bold transition-all"
// href={`/${email ? `?email=${encodeURIComponent(email)}` : ``}`}
// >
// Create one
// </Link>
// &nbsp;to get started.
// </div>
// ),
// },
// [EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN]: {
// title: `Email and password required`,
// message: () => `Email and password required. Please try again.`,
// },
// [EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN]: {
// title: `Authentication failed`,
// message: () => `Authentication failed. Please try again.`,
// },
// [EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN]: {
// title: `Invalid email`,
// message: () => `Invalid email. Please try again.`,
// },
// [EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED]: {
// title: `Email and code required`,
// message: () => `Email and code required. Please try again.`,
// },
// [EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN]: {
// title: `Invalid email`,
// message: () => `Invalid email. Please try again.`,
// },
// // Both Sign in and Sign up
// [EAuthenticationErrorCodes.INVALID_MAGIC_CODE]: {
// title: `Authentication failed`,
// message: () => `Invalid magic code. Please try again.`,
// },
// [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE]: {
// title: `Expired magic code`,
// message: () => `Expired magic code. Please try again.`,
// },
// [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED]: {
// title: `Expired magic code`,
// message: () => `Expired magic code. Please try again.`,
// },
// // Oauth
// [EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED]: {
// title: `Google not configured`,
// message: () => `Google not configured. Please contact your administrator.`,
// },
// [EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED]: {
// title: `GitHub not configured`,
// message: () => `GitHub not configured. Please contact your administrator.`,
// },
// [EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR]: {
// title: `Google OAuth provider error`,
// message: () => `Google OAuth provider error. Please try again.`,
// },
// [EAuthenticationErrorCodes.GITHUB_OAUTH_PROVIDER_ERROR]: {
// title: `GitHub OAuth provider error`,
// message: () => `GitHub OAuth provider error. Please try again.`,
// },
// // Reset Password
// [EAuthenticationErrorCodes.INVALID_PASSWORD_TOKEN]: {
// title: `Invalid password token`,
// message: () => `Invalid password token. Please try again.`,
// },
// [EAuthenticationErrorCodes.EXPIRED_PASSWORD_TOKEN]: {
// title: `Expired password token`,
// message: () => `Expired password token. Please try again.`,
// },
// // Change password
// [EAuthenticationErrorCodes.MISSING_PASSWORD]: {
// title: `Password required`,
// message: () => `Password required. Please try again.`,
// },
// [EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD]: {
// title: `Incorrect old password`,
// message: () => `Incorrect old password. Please try again.`,
// },
// [EAuthenticationErrorCodes.INVALID_NEW_PASSWORD]: {
// title: `Invalid new password`,
// message: () => `Invalid new password. Please try again.`,
// },
// // set password
// [EAuthenticationErrorCodes.PASSWORD_ALREADY_SET]: {
// title: `Password already set`,
// message: () => `Password already set. Please try again.`,
// },
// // 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.&nbsp;
// <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>
// Sign In
// </Link>
// &nbsp;now.
// </div>
// ),
// },
// [EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST]: {
// title: `Admin user does not exist`,
// message: () => (
// <div>
// Admin user does not exist.&nbsp;
// <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>
// Sign In
// </Link>
// &nbsp;now.
// </div>
// ),
// },
// };
// export const authErrorHandler = (
// errorCode: EAuthenticationErrorCodes,
// email?: string | undefined
// ): TAuthErrorInfo | undefined => {
// const bannerAlertErrorCodes = [
// EAuthenticationErrorCodes.INSTANCE_NOT_CONFIGURED,
// EAuthenticationErrorCodes.INVALID_EMAIL,
// EAuthenticationErrorCodes.EMAIL_REQUIRED,
// EAuthenticationErrorCodes.SIGNUP_DISABLED,
// EAuthenticationErrorCodes.INVALID_PASSWORD,
// EAuthenticationErrorCodes.SMTP_NOT_CONFIGURED,
// EAuthenticationErrorCodes.USER_ALREADY_EXIST,
// EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP,
// EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP,
// EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_UP,
// EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP,
// EAuthenticationErrorCodes.MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED,
// EAuthenticationErrorCodes.USER_DOES_NOT_EXIST,
// EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN,
// EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN,
// EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN,
// EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN,
// EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED,
// // EAuthenticationErrorCodes.INVALID_MAGIC_CODE,
// // EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE,
// // EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED,
// EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED,
// EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED,
// EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR,
// EAuthenticationErrorCodes.GITHUB_OAUTH_PROVIDER_ERROR,
// EAuthenticationErrorCodes.INVALID_PASSWORD_TOKEN,
// EAuthenticationErrorCodes.EXPIRED_PASSWORD_TOKEN,
// EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD,
// EAuthenticationErrorCodes.INVALID_NEW_PASSWORD,
// EAuthenticationErrorCodes.PASSWORD_ALREADY_SET,
// 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,
// ];
// 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;
// };

View File

@ -1 +0,0 @@
export * from "./auth";

View File

@ -2,12 +2,13 @@
// @ts-nocheck
import { NodeViewWrapper } from "@tiptap/react";
import { cn } from "src/lib/utils";
import { useRouter } from "next/router";
import { useRouter } from "next/navigation";
import { IMentionHighlight } from "src/types/mention-suggestion";
import { useEffect, useState } from "react";
// eslint-disable-next-line import/no-anonymous-default-export
export const MentionNodeView = (props) => {
// TODO: move it to web app
const router = useRouter();
const [highlightsState, setHighlightsState] = useState<IMentionHighlight[]>();

View File

@ -17,7 +17,6 @@
"@emotion/styled": "^11.11.0",
"@headlessui/react": "^1.7.13",
"@mui/material": "^5.14.1",
"@plane/constants": "*",
"@plane/document-editor": "*",
"@plane/lite-text-editor": "*",
"@plane/rich-text-editor": "*",

View File

@ -5,7 +5,6 @@ import { observer } from "mobx-react";
import { useRouter } from "next/navigation";
import useSWR from "swr";
// types
import { EPageTypes } from "@plane/constants";
import { TOnboardingSteps, TUserProfile } from "@plane/types";
// components
import { LogoSpinner } from "@/components/common";
@ -13,6 +12,8 @@ import { InviteMembers, CreateOrJoinWorkspaces, ProfileSetup } from "@/component
// constants
import { USER_ONBOARDING_COMPLETED } from "@/constants/event-tracker";
import { USER_WORKSPACES_LIST } from "@/constants/fetch-keys";
// helpers
import { EPageTypes } from "@/helpers/authentication.helper";
// hooks
import { useUser, useWorkspace, useUserProfile, useEventTracker } from "@/hooks/store";
// wrappers

View File

@ -29,7 +29,7 @@ export const AppProvider: FC<IAppProvider> = (props) => {
const { resolvedTheme } = useTheme();
return (
<>
<AppProgressBar height="4px" color="#fffd00" options={{ showSpinner: false }} shallowRouting />
<AppProgressBar height="4px" color="#3F76FF" options={{ showSpinner: false }} shallowRouting />
<Toast theme={resolveGeneralTheme(resolvedTheme)} />
<StoreProvider>
<ThemeProvider themes={["light", "dark", "light-contrast", "dark-contrast", "custom"]} defaultTheme="system">

View File

@ -142,7 +142,7 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = observer((props) => {
if (searchParams.has("peekCycle")) {
router.push(`${pathname}?${query}`);
} else {
router.push(`${pathname}?${query}&peekCycle=${cycleId}`);
router.push(`${pathname}?${query && `${query}&`}peekCycle=${cycleId}`);
}
};

View File

@ -72,7 +72,7 @@ export const CyclesListItem: FC<TCyclesListItem> = observer((props) => {
if (searchParams.has("peekCycle")) {
router.push(`${pathname}?${query}`);
} else {
router.push(`${pathname}?${query}&peekCycle=${cycleId}`);
router.push(`${pathname}?${query && `${query}&`}peekCycle=${cycleId}`);
}
};

View File

@ -115,7 +115,7 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
if (searchParams.has("peekModule")) {
router.push(`${pathname}?${query}`);
} else {
router.push(`${pathname}?${query}&peekModule=${moduleId}`);
router.push(`${pathname}?${query && `${query}&`}peekModule=${moduleId}`);
}
};

View File

@ -70,7 +70,7 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
if (searchParams.has("peekModule")) {
router.push(`${pathname}?${query}`);
} else {
router.push(`${pathname}?${query}&peekModule=${moduleId}`);
router.push(`${pathname}?${query && `${query}&`}peekModule=${moduleId}`);
}
};

View File

@ -24,7 +24,6 @@
"@nivo/line": "0.80.0",
"@nivo/pie": "0.80.0",
"@nivo/scatterplot": "0.80.0",
"@plane/constants": "*",
"@plane/document-editor": "*",
"@plane/lite-text-editor": "*",
"@plane/rich-text-editor": "*",

View File

@ -4533,7 +4533,7 @@
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^16.8.0 || ^17.0.0 || ^18.0.0", "@types/react@^18.2.42", "@types/react@^18.2.48":
"@types/react@*", "@types/react@18.2.48", "@types/react@^16.8.0 || ^17.0.0 || ^18.0.0", "@types/react@^18.2.42", "@types/react@^18.2.48":
version "18.2.48"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.48.tgz#11df5664642d0bd879c1f58bc1d37205b064e8f1"
integrity sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w==