diff --git a/.claude/skills/branch-name/SKILL.md b/.claude/skills/branch-name/SKILL.md index a6fc6e55cb6..71793399118 100644 --- a/.claude/skills/branch-name/SKILL.md +++ b/.claude/skills/branch-name/SKILL.md @@ -1,12 +1,12 @@ --- name: branch-name -description: Use when starting a new branch or renaming an existing one — produces a branch name in the format `/-` that's compatible with the create-pr skill's work item ID extraction. +description: Use when starting a new branch or renaming an existing one — produces a branch name in the format `/-` that's compatible with the create-pull-request skill's work item ID extraction. user_invocable: true --- # Branch Naming -Create branch names that follow the convention `/-`, where the work item ID can be cleanly extracted later (e.g., by the create-pr skill). +Create branch names that follow the convention `/-`, where the work item ID can be cleanly extracted later (e.g., by the create-pull-request skill). ## Format @@ -51,7 +51,7 @@ Create branch names that follow the convention `/- **Note on the consolidated row.** CLDR itself only requires `other` for `tr-TR`, `vi-VN`, `id`, `ja`, `ko`, `zh-CN`, `zh-TW` (single-form locales). Emitting both `one` and `other` with identical content is a **project convention** — it keeps tooling and linters consistent across the codebase. It is not a CLDR requirement, and `Intl.PluralRules` will return only `"other"` for these locales at runtime. @@ -336,6 +341,7 @@ Table below covers locales currently in the repo; add a row when you add a local | **cs / sk** | Primary quotes `„…"`. | | **ro** | Primary quotes `„…"`. | | **tr-TR / vi-VN / id** | Straight quotes `"…"`. Vietnamese diacritics are mandatory — never strip (no `bạn` → `ban`). | +| **bg** | Primary quotes `„…“`. No space before punctuation. Preserve Latin brand names and keyboard keys. | | **ru / ua** | Primary `«…»`, nested `„…"`. | | **ja** | Full-width `。、()!?・`. Primary quotes 「」, nested 『』. Ellipsis `…` (U+2026), typically doubled as `……`. | | **ko** | Western `. , ? !`; straight quotes `"…"`. | @@ -346,25 +352,26 @@ Table below covers locales currently in the repo; add a row when you add a local Formality defaults for locales currently in the repo. Add a row for each new locale, consulting the Microsoft Style Guide for that locale as the default authority on product-UI register. -| Locale | Default "you" | Notes | -| ------- | ---------------------------------------------------------------------------- | ------------------------------------------------ | -| fr | **vous** | Never "tu" in product UI | -| es | **usted** + **ustedes** | Neutral Spanish — no "vosotros", no "tú" | -| it | **Lei** (formal third-person) | B2B/enterprise convention | -| de | **Sie** | Use infinitive constructions for system messages | -| pt-BR | **você** | Semi-formal default; never "tu" | -| pl | **Pan/Pani** + 3rd-person, or impersonal | Never "ty" | -| cs / sk | **Vy** (formal, 3rd-person plural) | Never "ty" | -| ro | **dumneavoastră** (formal) | Or impersonal | -| tr-TR | **siz** + `-iniz` endings | Never "sen" | -| vi-VN | **bạn** (safe neutral) | Never "mày/tao"; consistency > variety | -| id | **Anda** (always capitalized) | Never "kamu" in product UI | -| ja | **です・ます体** | Never plain form; avoid 尊敬語・謙譲語 | -| ko | **합니다체** for system/errors; **해요체** acceptable for onboarding | Match surrounding file | -| zh-CN | **您** | B2B convention; never 你 | -| zh-TW | **您** | B2B convention; never 你 | -| ru | **Вы** (cap.) for singular direct address, **вы** (lower) for plural/general | Context-dependent | -| ua | **ви** (lowercase, modern convention) | Capitalized Ви only for very formal | +| Locale | Default "you" | Notes | +| ------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------- | +| fr | **vous** | Never "tu" in product UI | +| es | **usted** + **ustedes** | Neutral Spanish — no "vosotros", no "tú" | +| it | **Lei** (formal third-person) | B2B/enterprise convention | +| de | **Sie** | Use infinitive constructions for system messages | +| pt-BR | **você** | Semi-formal default; never "tu" | +| pl | **Pan/Pani** + 3rd-person, or impersonal | Never "ty" | +| cs / sk | **Vy** (formal, 3rd-person plural) | Never "ty" | +| ro | **dumneavoastră** (formal) | Or impersonal | +| tr-TR | **siz** + `-iniz` endings | Never "sen" | +| vi-VN | **bạn** (safe neutral) | Never "mày/tao"; consistency > variety | +| id | **Anda** (always capitalized) | Never "kamu" in product UI | +| ja | **です・ます体** | Never plain form; avoid 尊敬語・謙譲語 | +| ko | **합니다체** for system/errors; **해요체** acceptable for onboarding | Match surrounding file | +| zh-CN | **您** | B2B convention; never 你 | +| zh-TW | **您** | B2B convention; never 你 | +| ru | **Вы** (cap.) for singular direct address, **вы** (lower) for plural/general | Context-dependent | +| bg | Formal plural verbs with lowercase **вие/вас/ви** | Never informal ти; preserve the existing button and menu verb style. | +| ua | **ви** (lowercase, modern convention) | Capitalized Ви only for very formal | General writing rules (apply across all locales): @@ -380,23 +387,24 @@ General writing rules (apply across all locales): Design strings knowing translations will grow. Typical expansion vs. English for locales currently in the repo; lookup values from Andiamo / Eriksen / W3C tables when adding a locale. -| Locale | Expansion | Implication | -| ------------ | ------------------------------------------------- | ----------------------------------------------- | -| de | +10–35%, single words up to +180% | Reserve generous space on buttons, tabs, labels | -| fr | +15–25% | | -| es | +15–30% | | -| it | +10–25% | | -| pt-BR | +15–30% | | -| pl | +20–30% | | -| cs, sk | +10–20% | | -| ro | +15–25% | | -| ru, ua | +15% typical, spikes to +30% | | -| tr-TR | +10–30% (agglutination) | | -| vi-VN | +30–40% | Diacritic-heavy, many small words | -| id | +10–20% | | -| ja | −10 to −55% character count (similar pixel width) | | -| ko | −10 to −15% | | -| zh-CN, zh-TW | −40% character count (≈2× char width) | | +| Locale | Expansion | Implication | +| ------------ | ----------------------------------------------------------------------------------- | ----------------------------------------------- | +| de | +10–35%, single words up to +180% | Reserve generous space on buttons, tabs, labels | +| fr | +15–25% | | +| es | +15–30% | | +| it | +10–25% | | +| pt-BR | +15–30% | | +| pl | +20–30% | | +| cs, sk | +10–20% | | +| ro | +15–25% | | +| bg | Reserve +35% as the shared UI design budget; actual expansion needs a layout check. | Check narrow buttons, menus, and dialogs. | +| ru, ua | +15% typical, spikes to +30% | | +| tr-TR | +10–30% (agglutination) | | +| vi-VN | +30–40% | Diacritic-heavy, many small words | +| id | +10–20% | | +| ja | −10 to −55% character count (similar pixel width) | | +| ko | −10 to −15% | | +| zh-CN, zh-TW | −40% character count (≈2× char width) | | Rule of thumb: any UI surface must absorb **+35%** without truncation. If a string is length-capped, add a comment or context in the source. @@ -461,7 +469,7 @@ When reviewing a translation — yours or an AI's — score against these catego A "namespace" is a top-level JSON file (e.g. `common.json`, `auth.json`, `epic.json`). The set of valid namespace names is a hard-coded const array — adding a JSON file alone is not enough; the runtime will not load it. 1. Add the new namespace name to the `NAMESPACES` array in `packages/i18n/src/constants/namespaces.ts`. Keep alphabetical order with the existing entries. -2. Create `.json` in **every** locale directory under `packages/i18n/src/locales/` — start with `en/.json` (the source of truth), then create the file in all 18 target locales. An empty `{}` is fine for the targets at this step; `sync-check` will report missing keys as you add them in step 4. +2. Create `.json` in **every** locale directory under `packages/i18n/src/locales/` — start with `en/.json` (the source of truth), then create the file in every target locale (21 today; `ls packages/i18n/src/locales`). An empty `{}` is fine for the targets at this step; `sync-check` will report missing keys as you add them in step 4. 3. Add at least one key in `en/.json` so the namespace has content. 4. Translate every key from `en/.json` into each target locale — apply every rule in this skill. 5. Run `pnpm --filter @plane/i18n run generate:types` to regenerate the `TTranslationKeys` union so component-level `t()` calls type-check. @@ -590,6 +598,8 @@ When you add a language whose script, plural rules, punctuation, or register def 6. **DNT glossary** — Add a column (or row entries) for the new locale across the DNT tables. Specify forbidden literal translations (the words an LLM would produce if uninstructed). Example: if adding Arabic, the forbidden rendering for `Plane` includes `طائرة`; for `Epic` includes `ملحمة`; for `Sticky` includes `ملاحظة`. 7. **Commit this file in the same PR** that introduces the locale. The skill must stay ahead of the codebase — empty per-locale rows guarantee inconsistent translations in future PRs. +Bulgarian references: [Unicode CLDR plural rules](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#bg) and [Microsoft Bulgarian style guide](https://aka.ms/bulgarian-styleguide). + Canonical references to consult: - **Unicode CLDR** — plural categories, number/date formats, collation. diff --git a/.github/ISSUE_TEMPLATE/--bug-report.yaml b/.github/ISSUE_TEMPLATE/--bug-report.yaml index 277a3bdfa89..bfec6986dba 100644 --- a/.github/ISSUE_TEMPLATE/--bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/--bug-report.yaml @@ -1,6 +1,7 @@ name: Bug report description: Create a bug report to help us improve Plane title: "[bug]: " +type: Bug labels: [🐛bug, plane] assignees: [vihar, pushya22] body: @@ -55,19 +56,21 @@ body: - Safari - Other - type: dropdown - id: variant + id: edition attributes: - label: Variant + label: Edition + description: Which edition of Plane are you using? options: + - Community + - Commercial - Cloud - - Self-hosted - - Local validations: required: true - type: input id: version attributes: label: Version + description: Which version of Plane are you using? If Cloud, mention it as latest placeholder: v0.17.0-dev validations: required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/--feature-request.yaml b/.github/ISSUE_TEMPLATE/--feature-request.yaml index c2bd609c047..db154f8972f 100644 --- a/.github/ISSUE_TEMPLATE/--feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/--feature-request.yaml @@ -1,6 +1,7 @@ name: Feature request description: Suggest a feature to improve Plane title: "[feature]: " +type: Feature labels: [✨feature, plane] assignees: [vihar, pushya22] body: diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml index 301080b7590..cf159ef8bd8 100644 --- a/.github/ISSUE_TEMPLATE/config.yaml +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -1,6 +1,7 @@ contact_links: - name: Help and support - about: Reach out to us on our Forum or GitHub discussions. + url: https://forum.plane.so + about: Ask questions and get help from the community on our Forum. - name: Dedicated support url: mailto:support@plane.so about: Write to us if you'd like dedicated support using Plane diff --git a/.github/instructions/bash.instructions.md b/.github/instructions/bash.instructions.md index b14d3c9eda6..892d25e348c 100644 --- a/.github/instructions/bash.instructions.md +++ b/.github/instructions/bash.instructions.md @@ -10,23 +10,32 @@ This document outlines the standard tools and commands used in this monorepo. ## Package Manager We use **pnpm** for package management. + - **Do not use `npm` or `yarn`.** - Lockfile: `pnpm-lock.yaml` - Workspace configuration: `pnpm-workspace.yaml` ### Common Commands + - Install dependencies: `pnpm install` - Run a script in a specific package: `pnpm --filter run - )} - + +
+
+ +
+
+
); } diff --git a/apps/web/app/not-found.tsx b/apps/web/app/not-found.tsx index 13763951ce1..402b0f29b4f 100644 --- a/apps/web/app/not-found.tsx +++ b/apps/web/app/not-found.tsx @@ -6,9 +6,8 @@ import Link from "next/link"; // ui -import { Button } from "@plane/propel/button"; -// images -import Image404 from "@/app/assets/404.svg?url"; +import { Button } from "@makeplane/propel/components/button"; +import { EmptyStateDetailed } from "@plane/blocks/empty-state"; // types import type { Route } from "./+types/not-found"; @@ -19,28 +18,24 @@ export const meta: Route.MetaFunction = () => [ function PageNotFound() { return ( -
-
-
-
- 404- Page not found -
-
-

Oops! Something went wrong.

-

- Sorry, the page you are looking for cannot be found. It may have been removed, had its name changed, or is - temporarily unavailable. -

-
- - - - - -
-
+
+ } + /> + } + />
); } diff --git a/apps/web/app/provider.tsx b/apps/web/app/provider.tsx index 016b66c0e4b..42f54e93ed8 100644 --- a/apps/web/app/provider.tsx +++ b/apps/web/app/provider.tsx @@ -5,14 +5,11 @@ */ import { lazy, Suspense } from "react"; -import { useTheme } from "next-themes"; import { SWRConfig } from "swr"; // Plane Imports import { WEB_SWR_CONFIG } from "@plane/constants"; import { TranslationProvider } from "@plane/i18n"; -import { Toast } from "@plane/propel/toast"; -// helpers -import { resolveGeneralTheme } from "@plane/utils"; +import { PlaneToastProvider } from "@plane/blocks/toast"; // mobx store provider import { StoreProvider } from "@/lib/store-context"; @@ -35,22 +32,23 @@ export interface IAppProvider { export function AppProvider(props: IAppProvider) { const { children } = props; - // themes - const { resolvedTheme } = useTheme(); return ( <> - - - - - {children} - - - + {/* The toast viewport is a provider that calls `useTranslation`, so it sits inside + TranslationProvider and wraps everything that can raise a toast. */} + + + + + {children} + + + + diff --git a/apps/web/app/root.tsx b/apps/web/app/root.tsx index 08a38e632eb..80346247684 100644 --- a/apps/web/app/root.tsx +++ b/apps/web/app/root.tsx @@ -5,13 +5,11 @@ */ import type { ReactNode } from "react"; -import Script from "next/script"; import { Links, Meta, Outlet, Scripts } from "react-router"; import type { LinksFunction } from "react-router"; import { ThemeProvider, useTheme } from "next-themes"; // plane imports import { SITE_DESCRIPTION, SITE_NAME } from "@plane/constants"; -import { cn } from "@plane/utils"; // types // assets import favicon16 from "@/app/assets/favicon/favicon-16x16.png?url"; @@ -28,7 +26,6 @@ import { LogoSpinner } from "@/components/common/logo-spinner"; import { isStaleAssetError, recoverFromStaleAsset } from "@/lib/stale-asset-error"; // local import { CustomErrorComponent } from "./error"; -import { AppProvider } from "./provider"; // fonts import "@fontsource-variable/inter"; import interVariableWoff2 from "@fontsource-variable/inter/files/inter-latin-wght-normal.woff2?url"; @@ -57,8 +54,6 @@ export const links: LinksFunction = () => [ ]; export function Layout({ children }: { children: ReactNode }) { - const isSessionRecorderEnabled = parseInt(process.env.VITE_ENABLE_SESSION_RECORDER || "0"); - return ( @@ -82,15 +77,6 @@ export function Layout({ children }: { children: ReactNode }) { {children} - {!!isSessionRecorderEnabled && process.env.VITE_SESSION_RECORDER_KEY && ( - - )} ); @@ -122,16 +108,11 @@ export const meta: Route.MetaFunction = () => [ { name: "twitter:image:alt", content: "Plane - Modern project management" }, ]; +// Root stays shell-thin: in SPA mode React Router server-builds only the root route, so +// everything imported here is evaluated in Node just to prerender the fallback index.html. +// Providers, the store layer, and app chrome belong in app/layout.tsx — never import them here. export default function Root() { - return ( - -
-
- -
-
-
- ); + return ; } export function HydrateFallback() { diff --git a/apps/web/app/routes.ts b/apps/web/app/routes.ts index cdfea2ea16b..0283958132f 100644 --- a/apps/web/app/routes.ts +++ b/apps/web/app/routes.ts @@ -4,7 +4,7 @@ * See the LICENSE file for details. */ -import { route } from "@react-router/dev/routes"; +import { layout, route } from "@react-router/dev/routes"; import type { RouteConfigEntry } from "@react-router/dev/routes"; import { coreRoutes } from "./routes/core"; import { extendedRoutes } from "./routes/extended"; @@ -13,10 +13,13 @@ import { mergeRoutes } from "./routes/helper"; /** * Main Routes Configuration * This file serves as the entry point for the route configuration. + * + * Every route nests under the pathless app/layout.tsx shell; root.tsx stays + * shell-thin (see the note in app/root.tsx). */ const mergedRoutes: RouteConfigEntry[] = mergeRoutes(coreRoutes, extendedRoutes); // Add catch-all route at the end (404 handler) -const routes: RouteConfigEntry[] = [...mergedRoutes, route("*", "./not-found.tsx")]; +const routes: RouteConfigEntry[] = [layout("./layout.tsx", [...mergedRoutes, route("*", "./not-found.tsx")])]; export default routes; diff --git a/apps/web/caddy/Caddyfile b/apps/web/caddy/Caddyfile new file mode 100644 index 00000000000..fced343528f --- /dev/null +++ b/apps/web/caddy/Caddyfile @@ -0,0 +1,37 @@ +{ + servers { + trusted_proxies static private_ranges + } + + order rate_limit before file_server +} + +:3000 { + root * /usr/share/caddy/html + + # Per-client-IP rate limiting for static asset requests + rate_limit { + zone static { + key {client_ip} + events 300 + window 1m + } + } + + # Security headers (HSTS is set at the TLS terminator) + header { + X-Frame-Options "DENY" + X-Content-Type-Options "nosniff" + X-XSS-Protection "1; mode=block" + } + + # SPA fallback + try_files {path} /index.html + file_server + + # Access logs to stdout (default in Caddy) + log { + output stdout + format console + } +} diff --git a/apps/web/core/components/account/auth-forms/auth-header.tsx b/apps/web/components/account/auth-forms/auth-header.tsx similarity index 93% rename from apps/web/core/components/account/auth-forms/auth-header.tsx rename to apps/web/components/account/auth-forms/auth-header.tsx index 239d6582918..7ffbb45bba0 100644 --- a/apps/web/core/components/account/auth-forms/auth-header.tsx +++ b/apps/web/components/account/auth-forms/auth-header.tsx @@ -6,11 +6,12 @@ import { observer } from "mobx-react"; import useSWR from "swr"; +import { WorkspaceAvatar } from "@makeplane/propel/components/workspace-avatar"; import { useTranslation } from "@plane/i18n"; import type { IWorkspaceMemberInvitation } from "@plane/types"; +import { getFileURL } from "@plane/utils"; // components import { LogoSpinner } from "@/components/common/logo-spinner"; -import { WorkspaceLogo } from "@/components/workspace/logo"; // helpers import { EAuthModes, EAuthSteps } from "@/helpers/authentication.helper"; // services @@ -83,7 +84,7 @@ export const AuthHeader = observer(function AuthHeader(props: TAuthHeader) { header: (
{t("common.join")}{" "} - {" "} + {" "} {workspace.name}
), diff --git a/apps/web/core/components/account/auth-forms/auth-root.tsx b/apps/web/components/account/auth-forms/auth-root.tsx similarity index 92% rename from apps/web/core/components/account/auth-forms/auth-root.tsx rename to apps/web/components/account/auth-forms/auth-root.tsx index 5cba8a178e9..88d3f190879 100644 --- a/apps/web/core/components/account/auth-forms/auth-root.tsx +++ b/apps/web/components/account/auth-forms/auth-root.tsx @@ -8,7 +8,9 @@ import { useEffect, useState } from "react"; import { observer } from "mobx-react"; import { useSearchParams } from "next/navigation"; // plane imports -import { OAuthOptions } from "@plane/ui"; +import { Banner } from "@makeplane/propel/components/banner"; +import { OAuthOptions } from "@plane/blocks/auth"; +import { useTranslation } from "@plane/i18n"; // helpers import type { TAuthErrorInfo } from "@/helpers/authentication.helper"; import { @@ -23,7 +25,6 @@ import { useOAuthConfig } from "@/hooks/oauth"; import { useInstance } from "@/hooks/store/use-instance"; // local imports import { TermsAndConditions } from "../terms-and-conditions"; -import { AuthBanner } from "./auth-banner"; import { AuthHeader, AuthHeaderBase } from "./auth-header"; import { AuthFormRoot } from "./form-root"; @@ -48,6 +49,8 @@ export const AuthRoot = observer(function AuthRoot(props: TAuthRoot) { const [errorInfo, setErrorInfo] = useState(undefined); // store hooks const { config } = useInstance(); + // translation + const { t } = useTranslation(); // derived values const oAuthActionText = authMode === EAuthModes.SIGN_UP ? "Sign up" : "Sign in"; const { isOAuthEnabled, oAuthOptions } = useOAuthConfig(oAuthActionText); @@ -116,7 +119,14 @@ export const AuthRoot = observer(function AuthRoot(props: TAuthRoot) { return ( {errorInfo && errorInfo?.type === EErrorAlertType.BANNER_ALERT && ( - setErrorInfo(value)} /> + setErrorInfo(undefined)} + /> )} + {title} + {description} +
+ ); +} diff --git a/apps/web/components/account/auth-forms/email.tsx b/apps/web/components/account/auth-forms/email.tsx new file mode 100644 index 00000000000..c166cedd253 --- /dev/null +++ b/apps/web/components/account/auth-forms/email.tsx @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { FormEvent } from "react"; +import { useMemo, useRef, useState } from "react"; +import { observer } from "mobx-react"; +// icons +import { CloseCircleOutline, WarningCircleOutline } from "@makeplane/propel/icons"; +// plane imports +import { useTranslation } from "@plane/i18n"; +import { Button } from "@makeplane/propel/components/button"; +import { InputField } from "@makeplane/propel/components/input-field"; +import type { IEmailCheckData } from "@plane/types"; +import { checkEmailValidity } from "@plane/utils"; +// helpers +type TAuthEmailForm = { + defaultEmail: string; + onSubmit: (data: IEmailCheckData) => Promise; +}; + +export const AuthEmailForm = observer(function AuthEmailForm(props: TAuthEmailForm) { + const { onSubmit, defaultEmail } = props; + // states + const [isSubmitting, setIsSubmitting] = useState(false); + const [email, setEmail] = useState(defaultEmail); + // plane hooks + const { t } = useTranslation(); + const emailError = useMemo( + () => (email && !checkEmailValidity(email) ? { email: "auth.common.email.errors.invalid" } : undefined), + [email] + ); + + const handleFormSubmit = async (event: FormEvent) => { + event.preventDefault(); + setIsSubmitting(true); + const payload: IEmailCheckData = { + email: email, + }; + await onSubmit(payload); + setIsSubmitting(false); + }; + + const isButtonDisabled = email.length === 0 || Boolean(emailError?.email) || isSubmitting; + + const [isFocused, setIsFocused] = useState(true); + const inputRef = useRef(null); + + return ( +
+ setEmail(e.target.value)} + onFocus={() => setIsFocused(true)} + onBlur={() => setIsFocused(false)} + placeholder={t("auth.common.email.placeholder")} + autoComplete="off" + autoFocus + ref={inputRef} + endIcon={ + email.length > 0 && ( + + ) + } + error={ + emailError?.email && !isFocused ? ( + + + {t(emailError.email)} + + ) : undefined + } + /> + + )} + {showSmtpError && ( + setShowSmtpError(false)} + /> + )} + + ) : ( + passwordFormData.password.length > 0 && + getPasswordStrength(passwordFormData.password) != E_PASSWORD_STRENGTH.STRENGTH_VALID && ( + + ) + ); + + const isButtonDisabled = useMemo( + () => + !isSubmitting && + !!passwordFormData.password && + (mode === EAuthModes.SIGN_UP ? passwordFormData.password === passwordFormData.confirm_password : true) + ? false + : true, + [isSubmitting, mode, passwordFormData.confirm_password, passwordFormData.password] + ); + + const password = passwordFormData?.password ?? ""; + const confirmPassword = passwordFormData?.confirm_password ?? ""; + const renderPasswordMatchError = !isRetryPasswordInputFocused || confirmPassword.length >= password.length; + + const handleCSRFToken = async () => { + if (!formRef || !formRef.current) return; + const token = await csrfPromise; + if (!token?.csrf_token) return; + const csrfElement = formRef.current.querySelector("input[name=csrfmiddlewaretoken]"); + csrfElement?.setAttribute("value", token?.csrf_token); + }; + + const isPasswordMismatch = !!confirmPassword && password !== confirmPassword && renderPasswordMatchError; + + return ( +
+ {isBannerMessage && mode === EAuthModes.SIGN_UP && ( + } + title={t("auth.sign_up.errors.password.strength")} + dismissLabel={t("close")} + onDismiss={() => setBannerMessage(false)} + /> + )} +
{ + event.preventDefault(); // Prevent form from submitting by default + await handleCSRFToken(); + const isPasswordValid = + mode === EAuthModes.SIGN_UP + ? getPasswordStrength(passwordFormData.password) === E_PASSWORD_STRENGTH.STRENGTH_VALID + : true; + if (isPasswordValid) { + setIsSubmitting(true); + if (formRef.current) formRef.current.submit(); // Manually submit the form if the condition is met + } else { + setBannerMessage(true); + } + }} + onError={() => { + setIsSubmitting(false); + }} + > + + + {nextPath && } + handleFormChange("email", e.target.value)} + placeholder={t("auth.common.email.placeholder")} + disabled + endIcon={ + passwordFormData.email.length > 0 && ( + + ) + } + /> + +
+
+ handleFormChange("password", e.target.value)} + placeholder={t("auth.common.password.placeholder")} + onFocus={() => setIsPasswordInputFocused(true)} + onBlur={() => setIsPasswordInputFocused(false)} + autoComplete="off" + autoFocus + endIcon={ + + } + /> + {mode === EAuthModes.SIGN_UP && passwordSupport &&
{passwordSupport}
} +
+ {mode === EAuthModes.SIGN_IN &&
{passwordSupport}
} +
+ + {mode === EAuthModes.SIGN_UP && ( +
+ handleFormChange("confirm_password", e.target.value)} + placeholder={t("auth.common.password.confirm_password.placeholder")} + onFocus={() => setIsRetryPasswordInputFocused(true)} + onBlur={() => setIsRetryPasswordInputFocused(false)} + autoComplete="off" + endIcon={ + + } + error={isPasswordMismatch ? t("auth.common.password.errors.match") : undefined} + /> +
+ )} + +
+ {mode === EAuthModes.SIGN_IN ? ( + <> +
+ +
+ ); +}); diff --git a/apps/web/components/account/auth-forms/reset-password.tsx b/apps/web/components/account/auth-forms/reset-password.tsx new file mode 100644 index 00000000000..7662dd1e517 --- /dev/null +++ b/apps/web/components/account/auth-forms/reset-password.tsx @@ -0,0 +1,221 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useEffect, useMemo, useState } from "react"; +import { observer } from "mobx-react"; +import { useSearchParams } from "next/navigation"; +// icons +import { HideOutline, ShowOutline } from "@makeplane/propel/icons"; +// ui +import { Banner } from "@makeplane/propel/components/banner"; +import { InputField } from "@makeplane/propel/components/input-field"; +import { API_BASE_URL, E_PASSWORD_STRENGTH } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; +import { Button } from "@makeplane/propel/components/button"; +import { PasswordStrengthIndicator } from "@plane/blocks/auth"; +// components +import { getPasswordStrength } from "@plane/utils"; +// helpers +import type { EAuthenticationErrorCodes, TAuthErrorInfo } from "@/helpers/authentication.helper"; +import { EErrorAlertType, authErrorHandler } from "@/helpers/authentication.helper"; +// services +import { AuthService } from "@/services/auth.service"; +// local imports +import { FormContainer } from "./common/container"; +import { AuthFormHeader } from "./common/header"; + +type TResetPasswordFormValues = { + email: string; + password: string; + confirm_password?: string; +}; + +const defaultValues: TResetPasswordFormValues = { + email: "", + password: "", +}; + +// services +const authService = new AuthService(); + +export const ResetPasswordForm = observer(function ResetPasswordForm() { + // search params + const searchParams = useSearchParams(); + const uidb64 = searchParams.get("uidb64"); + const token = searchParams.get("token"); + const email = searchParams.get("email"); + const error_code = searchParams.get("error_code"); + // states + const [showPassword, setShowPassword] = useState({ + password: false, + retypePassword: false, + }); + const [resetFormData, setResetFormData] = useState({ + ...defaultValues, + email: email ? email.toString() : "", + }); + const [csrfToken, setCsrfToken] = useState(undefined); + const [isPasswordInputFocused, setIsPasswordInputFocused] = useState(false); + const [isRetryPasswordInputFocused, setIsRetryPasswordInputFocused] = useState(false); + const [errorInfo, setErrorInfo] = useState(undefined); + // plane hooks + const { t } = useTranslation(); + + const handleShowPassword = (key: keyof typeof showPassword) => + setShowPassword((prev) => ({ ...prev, [key]: !prev[key] })); + + const handleFormChange = (key: keyof TResetPasswordFormValues, value: string) => + setResetFormData((prev) => ({ ...prev, [key]: value })); + + useEffect(() => { + if (csrfToken === undefined) + authService.requestCSRFToken().then((data) => data?.csrf_token && setCsrfToken(data.csrf_token)); + }, [csrfToken]); + + const isButtonDisabled = useMemo( + () => + !!resetFormData.password && + getPasswordStrength(resetFormData.password) === E_PASSWORD_STRENGTH.STRENGTH_VALID && + resetFormData.password === resetFormData.confirm_password + ? false + : true, + [resetFormData] + ); + + useEffect(() => { + if (error_code) { + const errorhandler = authErrorHandler(error_code?.toString() as EAuthenticationErrorCodes); + if (errorhandler) { + setErrorInfo(errorhandler); + } + } + }, [error_code]); + + const password = resetFormData?.password ?? ""; + const confirmPassword = resetFormData?.confirm_password ?? ""; + const renderPasswordMatchError = !isRetryPasswordInputFocused || confirmPassword.length >= password.length; + + return ( + + + + {errorInfo && errorInfo?.type === EErrorAlertType.BANNER_ALERT && ( + setErrorInfo(undefined)} + /> + )} +
+ + +
+ handleFormChange("password", e.target.value)} + placeholder={t("auth.common.password.placeholder")} + minLength={8} + onFocus={() => setIsPasswordInputFocused(true)} + onBlur={() => setIsPasswordInputFocused(false)} + autoComplete="new-password" + autoFocus + endIcon={ + + } + /> +
+ +
+
+ handleFormChange("confirm_password", e.target.value)} + placeholder={t("auth.common.password.confirm_password.placeholder")} + onFocus={() => setIsRetryPasswordInputFocused(true)} + onBlur={() => setIsRetryPasswordInputFocused(false)} + autoComplete="new-password" + endIcon={ + + } + error={ + !!confirmPassword && password !== confirmPassword && renderPasswordMatchError + ? t("auth.common.password.errors.match") + : undefined + } + /> + + } + /> + + + handleFormChange("confirm_password", e.target.value)} + placeholder={t("auth.common.password.confirm_password.placeholder")} + onFocus={() => setIsRetryPasswordInputFocused(true)} + onBlur={() => setIsRetryPasswordInputFocused(false)} + autoComplete="new-password" + endIcon={ + + } + error={ + !!passwordFormData.confirm_password && + passwordFormData.password !== passwordFormData.confirm_password && + renderPasswordMatchError + ? t("auth.common.password.errors.match") + : undefined + } + /> + + ) + } + /> + +
+ handleFormChange("code", e.target.value)} + placeholder={t("auth.common.unique_code.placeholder")} + autoComplete="off" + autoFocus + /> +
+

+ + {t("auth.common.unique_code.paste_code")} +

+ +
+
+ +
+
+ + ); +} diff --git a/apps/web/components/account/deactivate-account-modal.tsx b/apps/web/components/account/deactivate-account-modal.tsx new file mode 100644 index 00000000000..004ed07245f --- /dev/null +++ b/apps/web/components/account/deactivate-account-modal.tsx @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { useTranslation } from "@plane/i18n"; +// ui +import { ConfirmDialog } from "@plane/blocks/dialog"; +import { setToast } from "@plane/blocks/toast"; +// hooks +import { useUser } from "@/hooks/store/user"; +import { useAppRouter } from "@/hooks/use-app-router"; + +type Props = { + isOpen: boolean; + onClose: () => void; +}; + +export function DeactivateAccountModal(props: Props) { + const router = useAppRouter(); + const { isOpen, onClose } = props; + // hooks + const { t } = useTranslation(); + const { deactivateAccount, signOut } = useUser(); + + // states + const [isDeactivating, setIsDeactivating] = useState(false); + + const handleClose = () => { + setIsDeactivating(false); + onClose(); + }; + + const handleDeleteAccount = async () => { + setIsDeactivating(true); + + await deactivateAccount() + .then(() => { + setToast({ + type: "success", + title: "Success!", + message: "Account deactivated successfully.", + }); + signOut(); + router.push("/"); + handleClose(); + return; + }) + .catch((err: any) => { + setToast({ + type: "error", + title: "Error!", + message: err?.error, + }); + }) + .finally(() => setIsDeactivating(false)); + }; + + return ( + + ); +} diff --git a/apps/web/core/components/account/terms-and-conditions.tsx b/apps/web/components/account/terms-and-conditions.tsx similarity index 89% rename from apps/web/core/components/account/terms-and-conditions.tsx rename to apps/web/components/account/terms-and-conditions.tsx index f6be5963491..ef69141c557 100644 --- a/apps/web/core/components/account/terms-and-conditions.tsx +++ b/apps/web/components/account/terms-and-conditions.tsx @@ -27,7 +27,7 @@ const MESSAGES = { function LegalLink({ href, children }: { href: string; children: React.ReactNode }) { return ( - {children} + {children} ); } @@ -35,7 +35,7 @@ function LegalLink({ href, children }: { href: string; children: React.ReactNode export function TermsAndConditions({ authType = EAuthModes.SIGN_IN }: TermsAndConditionsProps) { return (
-

+

{`${MESSAGES[authType]}, you understand and agree to \n our `} Terms of Service and{" "} Privacy Policy. diff --git a/apps/web/core/components/active-cycles/workspace-active-cycles-upgrade.tsx b/apps/web/components/active-cycles/workspace-active-cycles-upgrade.tsx similarity index 80% rename from apps/web/core/components/active-cycles/workspace-active-cycles-upgrade.tsx rename to apps/web/components/active-cycles/workspace-active-cycles-upgrade.tsx index ff1ee254394..77ade6434f2 100644 --- a/apps/web/core/components/active-cycles/workspace-active-cycles-upgrade.tsx +++ b/apps/web/components/active-cycles/workspace-active-cycles-upgrade.tsx @@ -5,13 +5,19 @@ */ import { observer } from "mobx-react"; -import { AlertOctagon, BarChart4, CircleDashed, Folder, Microscope } from "lucide-react"; +import { + AlertOctagonOutline, + AnalyticsOutline, + BarOutline, + CircleDashedOutline, + FolderOutline, + SearchOutline, +} from "@makeplane/propel/icons"; // plane imports import { MARKETING_PRICING_PAGE_LINK } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; -import { getButtonStyling } from "@plane/propel/button"; -import { SearchIcon } from "@plane/propel/icons"; -import { ContentWrapper } from "@plane/ui"; +import { Button } from "@makeplane/propel/components/button"; +import { ContentWrapper } from "@plane/blocks/layout"; import { cn } from "@plane/utils"; // assets import ctaL1Dark from "@/app/assets/workspace-active-cycles/cta-l-1-dark.webp?url"; @@ -31,40 +37,40 @@ export const WORKSPACE_ACTIVE_CYCLES_DETAILS = [ title: "10,000-feet view of all active cycles.", description: "Zoom out to see running cycles across all your projects at once instead of going from Cycle to Cycle in each project.", - icon: Folder, + icon: FolderOutline, }, { key: "get_snapshot_of_each_active_cycle", title: "Get a snapshot of each active cycle.", description: "Track high-level metrics for all active cycles, see their state of progress, and get a sense of scope against deadlines.", - icon: CircleDashed, + icon: CircleDashedOutline, }, { key: "compare_burndowns", title: "Compare burndowns.", description: "Monitor how each of your teams are performing with a peek into each cycle’s burndown report.", - icon: BarChart4, + icon: BarOutline, }, { key: "quickly_see_make_or_break_issues", title: "Quickly see make-or-break work items. ", description: "Preview high-priority work items for each cycle against due dates. See all of them per cycle in one click.", - icon: AlertOctagon, + icon: AlertOctagonOutline, }, { key: "zoom_into_cycles_that_need_attention", title: "Zoom into cycles that need attention. ", description: "Investigate the state of any cycle that doesn’t conform to expectations in one click.", - icon: SearchIcon, + icon: SearchOutline, }, { key: "stay_ahead_of_blockers", title: "Stay ahead of blockers.", description: "Spot challenges from one project to another and see inter-cycle dependencies that aren’t obvious from any other view.", - icon: Microscope, + icon: AnalyticsOutline, }, ]; @@ -87,19 +93,21 @@ export const WorkspaceActiveCyclesUpgrade = observer(function WorkspaceActiveCyc >

-

{t("on_demand_snapshots_of_all_your_cycles")}

-

{t("active_cycles_description")}

+

{t("on_demand_snapshots_of_all_your_cycles")}

+

{t("active_cycles_description")}

- - - {t("upgrade")} - +
{t(item.key)}
- {t(`${item.key}_description`)} + {t(`${item.key}_description`)}
))} diff --git a/apps/web/core/components/analytics/analytics-filter-actions.tsx b/apps/web/components/analytics/analytics-filter-actions.tsx similarity index 100% rename from apps/web/core/components/analytics/analytics-filter-actions.tsx rename to apps/web/components/analytics/analytics-filter-actions.tsx diff --git a/apps/web/core/components/analytics/analytics-section-wrapper.tsx b/apps/web/components/analytics/analytics-section-wrapper.tsx similarity index 83% rename from apps/web/core/components/analytics/analytics-section-wrapper.tsx rename to apps/web/components/analytics/analytics-section-wrapper.tsx index d46ce74b46b..c78f8eb54c0 100644 --- a/apps/web/core/components/analytics/analytics-section-wrapper.tsx +++ b/apps/web/components/analytics/analytics-section-wrapper.tsx @@ -22,8 +22,8 @@ function AnalyticsSectionWrapper(props: Props) {
{title && (
-

{title}

- {/* {subtitle &&

• {subtitle}

} */} +

{title}

+ {/* {subtitle &&

• {subtitle}

} */}
)} {actions} diff --git a/apps/web/core/components/analytics/analytics-wrapper.tsx b/apps/web/components/analytics/analytics-wrapper.tsx similarity index 82% rename from apps/web/core/components/analytics/analytics-wrapper.tsx rename to apps/web/components/analytics/analytics-wrapper.tsx index 6cd886b0473..4dd42bb50f6 100644 --- a/apps/web/core/components/analytics/analytics-wrapper.tsx +++ b/apps/web/components/analytics/analytics-wrapper.tsx @@ -19,8 +19,8 @@ function AnalyticsWrapper(props: Props) { const { i18nTitle, children, className } = props; const { t } = useTranslation(); return ( -
-

{t(i18nTitle)}

+
+

{t(i18nTitle)}

{children}
); diff --git a/apps/web/components/analytics/constants.ts b/apps/web/components/analytics/constants.ts new file mode 100644 index 00000000000..a4df54e27e1 --- /dev/null +++ b/apps/web/components/analytics/constants.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +// One height for every analytics chart and its loading skeleton, so a section does not jump when +// its chart resolves. +export const ANALYTICS_CHART_HEIGHT_CLASSNAME = "h-[350px]"; diff --git a/apps/web/components/analytics/empty-state.tsx b/apps/web/components/analytics/empty-state.tsx new file mode 100644 index 00000000000..7dac76f3ee3 --- /dev/null +++ b/apps/web/components/analytics/empty-state.tsx @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useTheme } from "next-themes"; +// plane package imports +import { cn } from "@plane/utils"; +// assets +import darkBackgroundAsset from "@/app/assets/empty-state/analytics/empty-grid-background-dark.webp?url"; +import lightBackgroundAsset from "@/app/assets/empty-state/analytics/empty-grid-background-light.webp?url"; + +type Props = { + title: string; + description?: string; + assetPath?: string; + className?: string; +}; + +function AnalyticsEmptyState({ title, description, assetPath, className }: Props) { + // theme hook + const { resolvedTheme } = useTheme(); + const backgroundReolvedPath = resolvedTheme === "light" ? lightBackgroundAsset : darkBackgroundAsset; + + return ( +
+
+ {assetPath && ( +
+ {title} +
+ {title} +
+
+ )} +
+

{title}

+ {description &&

{description}

} +
+
+
+ ); +} + +export default AnalyticsEmptyState; diff --git a/apps/web/core/components/analytics/export.ts b/apps/web/components/analytics/export.ts similarity index 100% rename from apps/web/core/components/analytics/export.ts rename to apps/web/components/analytics/export.ts diff --git a/apps/web/components/analytics/insight-card.tsx b/apps/web/components/analytics/insight-card.tsx new file mode 100644 index 00000000000..855f14be8e2 --- /dev/null +++ b/apps/web/components/analytics/insight-card.tsx @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +// plane package imports +import React from "react"; +import type { IAnalyticsResponseFields } from "@plane/types"; +import { Loader } from "@plane/blocks/skeleton"; +import { cn } from "@plane/utils"; + +export type InsightCardProps = { + data?: IAnalyticsResponseFields; + label: string; + isLoading?: boolean; +}; + +function InsightCard(props: InsightCardProps) { + const { data, label, isLoading = false } = props; + const count = data?.count ?? 0; + + return ( +
+
{label}
+ {/* The count stays mounted (hidden) while loading so the row keeps one height in both states. */} +
+
{count}
+ {isLoading && ( + + + + )} +
+
+ ); +} + +export default InsightCard; diff --git a/apps/web/components/analytics/insight-table/data-table.tsx b/apps/web/components/analytics/insight-table/data-table.tsx new file mode 100644 index 00000000000..e63b029713b --- /dev/null +++ b/apps/web/components/analytics/insight-table/data-table.tsx @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import * as React from "react"; +import type { + ColumnDef, + ColumnFiltersState, + SortingState, + VisibilityState, + Table as TanstackTable, +} from "@tanstack/react-table"; +import { + flexRender, + getCoreRowModel, + getFacetedRowModel, + getFacetedUniqueValues, + getFilteredRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; + +import { useTranslation } from "@plane/i18n"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; +import { SearchOutline } from "@makeplane/propel/icons"; +// plane package imports +import { Icon } from "@makeplane/propel/components/icon"; +import { Input, InputGroup } from "@makeplane/propel/components/input"; +import { Table, TableBody, TableHeader, TableRow } from "@makeplane/propel/components/table"; +import { TableCell, TableHead } from "@makeplane/propel/elements/table"; + +interface DataTableProps { + columns: ColumnDef[]; + data: TData[]; + searchPlaceholder: string; + actions?: (table: TanstackTable) => React.ReactNode; +} + +export function DataTable({ columns, data, searchPlaceholder, actions }: DataTableProps) { + const [rowSelection, _setRowSelection] = React.useState({}); + const [columnVisibility, setColumnVisibility] = React.useState({}); + const [columnFilters, setColumnFilters] = React.useState([]); + const [sorting, _setSorting] = React.useState([]); + const { t } = useTranslation(); + + const table = useReactTable({ + data, + columns, + state: { + sorting, + columnVisibility, + rowSelection, + columnFilters, + }, + onColumnFiltersChange: setColumnFilters, + onColumnVisibilityChange: setColumnVisibility, + getCoreRowModel: getCoreRowModel(), + getFilteredRowModel: getFilteredRowModel(), + getSortedRowModel: getSortedRowModel(), + getFacetedRowModel: getFacetedRowModel(), + getFacetedUniqueValues: getFacetedUniqueValues(), + }); + + // the search filters the first column + const searchColumnId = table.getHeaderGroups()?.[0]?.headers?.[0]?.id; + const searchColumn = searchColumnId ? table.getColumn(searchColumnId) : undefined; + const searchValue = (searchColumn?.getFilterValue() as string | undefined) ?? ""; + + return ( +
+
+
+
+ + + searchColumn?.setFilterValue(e.target.value)} + /> + +
+ {searchColumnId && ( + {searchPlaceholder} + )} +
+ {actions &&
{actions(table)}
} +
+ + {/* a bounded flex column: the table frame shrinks to it, so the table's own viewport scrolls + under its sticky header */} +
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => ( + } + > + {header.isPlaceholder + ? null + : (flexRender(header.column.columnDef.header, header.getContext()) as any)} + + ))} + + ))} + + + {table.getRowModel().rows?.length > 0 ? ( + table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext()) as any} + + ))} + + )) + ) : ( + + + {searchValue.trim() !== "" ? ( + + ) : ( + + )} + + + )} + +
+
+
+ ); +} diff --git a/apps/web/core/components/analytics/insight-table/index.ts b/apps/web/components/analytics/insight-table/index.ts similarity index 100% rename from apps/web/core/components/analytics/insight-table/index.ts rename to apps/web/components/analytics/insight-table/index.ts diff --git a/apps/web/components/analytics/insight-table/loader.tsx b/apps/web/components/analytics/insight-table/loader.tsx new file mode 100644 index 00000000000..c47354c1239 --- /dev/null +++ b/apps/web/components/analytics/insight-table/loader.tsx @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import * as React from "react"; +import type { ColumnDef } from "@tanstack/react-table"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@makeplane/propel/components/table"; +import { Loader } from "@plane/blocks/skeleton"; + +interface TableSkeletonProps { + columns: ColumnDef[]; + rows: number; +} + +const getColumnKey = (column: ColumnDef) => column.id ?? String(column.header ?? ""); + +export function TableLoader({ columns, rows }: TableSkeletonProps) { + const rowKeys = Array.from({ length: rows }, (_, rowIndex) => `skeleton-row-${rowIndex}`); + + return ( + + + + {columns.map((column) => ( + + ))} + + + + {rowKeys.map((rowKey) => ( + + {columns.map((column) => ( + + + + ))} + + ))} + +
+ ); +} diff --git a/apps/web/components/analytics/insight-table/root.tsx b/apps/web/components/analytics/insight-table/root.tsx new file mode 100644 index 00000000000..e317bc2460d --- /dev/null +++ b/apps/web/components/analytics/insight-table/root.tsx @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ColumnDef, Row, Table } from "@tanstack/react-table"; +import { ExportOutline } from "@makeplane/propel/icons"; +import { useTranslation } from "@plane/i18n"; +import { Button } from "@makeplane/propel/components/button"; +import { Icon } from "@makeplane/propel/components/icon"; +import type { AnalyticsTableDataMap, TAnalyticsTabsBase } from "@plane/types"; +import { DataTable } from "./data-table"; +import { TableLoader } from "./loader"; +interface InsightTableProps> { + analyticsType: T; + data?: AnalyticsTableDataMap[T][]; + isLoading?: boolean; + columns: ColumnDef[]; + columnsLabels?: Record; + headerText: string; + onExport?: (rows: Row[]) => void; +} + +export function InsightTable>( + props: InsightTableProps +): React.ReactElement { + const { data, isLoading, columns, headerText, onExport } = props; + const { t } = useTranslation(); + if (isLoading) { + return ; + } + + return ( +
+ ) => ( +
+ ); +} diff --git a/apps/web/components/analytics/loaders.tsx b/apps/web/components/analytics/loaders.tsx new file mode 100644 index 00000000000..205b391c0a2 --- /dev/null +++ b/apps/web/components/analytics/loaders.tsx @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { Loader } from "@plane/blocks/skeleton"; +import { cn } from "@plane/utils"; +// local imports +import { ANALYTICS_CHART_HEIGHT_CLASSNAME } from "./constants"; + +export function ProjectInsightsLoader() { + return ( +
+ + + +
+ + + + + {Array.from({ length: 6 }, (_, index) => ( + // oxlint-disable-next-line react/no-array-index-key + + ))} + +
+
+ ); +} + +export function ChartLoader() { + return ( + + + + ); +} diff --git a/apps/web/components/analytics/overview/active-project-item.tsx b/apps/web/components/analytics/overview/active-project-item.tsx new file mode 100644 index 00000000000..eca6adc72dd --- /dev/null +++ b/apps/web/components/analytics/overview/active-project-item.tsx @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +// plane package imports +import { Logo } from "@plane/blocks/emoji-icon-picker"; +import { ProjectsOutline } from "@makeplane/propel/icons"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import { Badge } from "@makeplane/propel/components/badge"; +// plane web hooks +import { useProject } from "@/hooks/store/use-project"; + +type Props = { + project: { + id: string; + completed_issues?: number; + total_issues?: number; + }; + isLoading?: boolean; +}; + +function CompletionPercentage({ percentage }: { percentage: number }) { + return 50 ? "success" : "danger"} size="sm" label={`${percentage}%`} />; +} + +function ActiveProjectItem(props: Props) { + const { project } = props; + const { getProjectById } = useProject(); + const { id, completed_issues, total_issues } = project; + + const projectDetails = getProjectById(id); + + if (!projectDetails) return null; + + return ( +
+
+
+ + {projectDetails?.logo_props ? ( + + ) : ( + + + + )} + +
+ +

{projectDetails?.name}

+
+
+ +
+ ); +} + +export default ActiveProjectItem; diff --git a/apps/web/core/components/analytics/overview/active-projects.tsx b/apps/web/components/analytics/overview/active-projects.tsx similarity index 83% rename from apps/web/core/components/analytics/overview/active-projects.tsx rename to apps/web/components/analytics/overview/active-projects.tsx index 1ad22dc5423..ab6a427805f 100644 --- a/apps/web/core/components/analytics/overview/active-projects.tsx +++ b/apps/web/components/analytics/overview/active-projects.tsx @@ -10,12 +10,14 @@ import { useParams } from "next/navigation"; import useSWR from "swr"; // plane package imports import { useTranslation } from "@plane/i18n"; -import { Loader } from "@plane/ui"; +import { Loader } from "@plane/blocks/skeleton"; +import { cn } from "@plane/utils"; // plane web hooks import { useAnalytics } from "@/hooks/store/use-analytics"; import { useProject } from "@/hooks/store/use-project"; // plane web components import AnalyticsSectionWrapper from "../analytics-section-wrapper"; +import { ANALYTICS_CHART_HEIGHT_CLASSNAME } from "../constants"; import ActiveProjectItem from "./active-project-item"; const ActiveProjects = observer(function ActiveProjects() { @@ -36,9 +38,14 @@ const ActiveProjects = observer(function ActiveProjects() { -
+
{isProjectAnalyticsCountLoading && Array.from({ length: 5 }).map((_, index) => )} {!isProjectAnalyticsCountLoading && diff --git a/apps/web/core/components/analytics/overview/index.ts b/apps/web/components/analytics/overview/index.ts similarity index 100% rename from apps/web/core/components/analytics/overview/index.ts rename to apps/web/components/analytics/overview/index.ts diff --git a/apps/web/core/components/analytics/overview/project-insights.tsx b/apps/web/components/analytics/overview/project-insights.tsx similarity index 86% rename from apps/web/core/components/analytics/overview/project-insights.tsx rename to apps/web/components/analytics/overview/project-insights.tsx index 6987ce19450..2750137784c 100644 --- a/apps/web/core/components/analytics/overview/project-insights.tsx +++ b/apps/web/components/analytics/overview/project-insights.tsx @@ -10,18 +10,20 @@ import { useParams } from "next/navigation"; import useSWR from "swr"; // plane package imports import { useTranslation } from "@plane/i18n"; -import { EmptyStateCompact } from "@plane/propel/empty-state"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; import type { TChartData } from "@plane/types"; +import { cn } from "@plane/utils"; // hooks import { useAnalytics } from "@/hooks/store/use-analytics"; // services import { AnalyticsService } from "@/services/analytics.service"; // plane web components import AnalyticsSectionWrapper from "../analytics-section-wrapper"; +import { ANALYTICS_CHART_HEIGHT_CLASSNAME } from "../constants"; import { ProjectInsightsLoader } from "../loaders"; const RadarChart = lazy(function RadarChart() { - return import("@plane/propel/charts/radar-chart").then((mod) => ({ + return import("@plane/blocks/charts/radar-chart").then((mod) => ({ default: mod.RadarChart, })); }); @@ -55,7 +57,7 @@ const ProjectInsights = observer(function ProjectInsights() { {isLoadingProjectInsight ? ( @@ -67,11 +69,11 @@ const ProjectInsights = observer(function ProjectInsights() { title={t("workspace_empty_state.analytics_work_items.title")} /> ) : ( -
+
{projectInsightsData && ( }> )} -
-
{t("workspace_analytics.summary_of_projects")}
+
+
{t("workspace_analytics.summary_of_projects")}
{t("workspace_analytics.all_projects")}
-
+
{t("workspace_analytics.trend_on_charts")}
{t("common.work_items")}
{projectInsightsData?.map((item) => ( -
+
{item.name}
{/* */} diff --git a/apps/web/components/analytics/overview/root.tsx b/apps/web/components/analytics/overview/root.tsx new file mode 100644 index 00000000000..3e5b5a0ac46 --- /dev/null +++ b/apps/web/components/analytics/overview/root.tsx @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import React from "react"; +import AnalyticsWrapper from "../analytics-wrapper"; +import TotalInsights from "../total-insights"; +import ActiveProjects from "./active-projects"; +import ProjectInsights from "./project-insights"; + +function Overview() { + return ( + +
+ +
+ + +
+
+
+ ); +} + +export { Overview }; diff --git a/apps/web/core/components/analytics/select/analytics-params.tsx b/apps/web/components/analytics/select/analytics-params.tsx similarity index 93% rename from apps/web/core/components/analytics/select/analytics-params.tsx rename to apps/web/components/analytics/select/analytics-params.tsx index a577002b7c2..0f266fb7af2 100644 --- a/apps/web/core/components/analytics/select/analytics-params.tsx +++ b/apps/web/components/analytics/select/analytics-params.tsx @@ -8,10 +8,9 @@ import { useMemo } from "react"; import { observer } from "mobx-react"; import type { Control, UseFormSetValue } from "react-hook-form"; import { Controller } from "react-hook-form"; -import { SlidersHorizontal } from "lucide-react"; +import { CalendarOutline, PreferencesOutline } from "@makeplane/propel/icons"; // plane package imports import { ANALYTICS_X_AXIS_VALUES, ANALYTICS_Y_AXIS_VALUES } from "@plane/constants"; -import { CalendarLayoutIcon } from "@plane/propel/icons"; import type { IAnalyticsParams } from "@plane/types"; import { ChartYAxisMetric } from "@plane/types"; import { cn } from "@plane/utils"; @@ -70,7 +69,7 @@ export const AnalyticsSelectParams = observer(function AnalyticsSelectParams(pro }} label={
- + {xAxisOptions.find((v) => v.value === value)?.label || "Add Property"} @@ -91,7 +90,7 @@ export const AnalyticsSelectParams = observer(function AnalyticsSelectParams(pro }} label={
- + {groupByOptions.find((v) => v.value === value)?.label || "Add Property"} diff --git a/apps/web/components/analytics/select/duration.tsx b/apps/web/components/analytics/select/duration.tsx new file mode 100644 index 00000000000..8152c3dafd6 --- /dev/null +++ b/apps/web/components/analytics/select/duration.tsx @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +// react +import React from "react"; +import { CalendarOutline } from "@makeplane/propel/icons"; +// plane package imports +import { ANALYTICS_DURATION_FILTER_OPTIONS } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; +import { Select } from "@plane/blocks/select"; + +type TDurationOption = (typeof ANALYTICS_DURATION_FILTER_OPTIONS)[number]; + +type Props = { + value: string | null; + onChange: (val: TDurationOption["value"]) => void; + placeholder?: string; +}; + +const getDurationOption = (value: string | null) => + ANALYTICS_DURATION_FILTER_OPTIONS.find((option) => option.value === value) ?? null; + +function DurationDropdown({ placeholder = "Duration", onChange, value }: Props) { + useTranslation(); + + // derived values + const selectedOption = getDurationOption(value); + + return ( + + getValues={() => [...ANALYTICS_DURATION_FILTER_OPTIONS]} + value={selectedOption} + onChange={(val) => { + const option = getDurationOption(val); + if (option) onChange(option.value); + }} + getOptionValue={(option) => option.value} + getOptionLabel={(option) => option.name} + pinSelected={false} + > + variant="select-md" prependIcon={
diff --git a/apps/web/core/components/analytics/use-analytics-tabs.tsx b/apps/web/components/analytics/use-analytics-tabs.tsx similarity index 100% rename from apps/web/core/components/analytics/use-analytics-tabs.tsx rename to apps/web/components/analytics/use-analytics-tabs.tsx diff --git a/apps/web/core/components/analytics/work-items/created-vs-resolved.tsx b/apps/web/components/analytics/work-items/created-vs-resolved.tsx similarity index 92% rename from apps/web/core/components/analytics/work-items/created-vs-resolved.tsx rename to apps/web/components/analytics/work-items/created-vs-resolved.tsx index c4723c07b39..08d590e7992 100644 --- a/apps/web/core/components/analytics/work-items/created-vs-resolved.tsx +++ b/apps/web/components/analytics/work-items/created-vs-resolved.tsx @@ -10,16 +10,17 @@ import { useParams } from "next/navigation"; import useSWR from "swr"; // plane package imports import { useTranslation } from "@plane/i18n"; -import { AreaChart } from "@plane/propel/charts/area-chart"; -import { EmptyStateCompact } from "@plane/propel/empty-state"; +import { AreaChart } from "@plane/blocks/charts/area-chart"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; import type { IChartResponse, TChartData } from "@plane/types"; -import { renderFormattedDate } from "@plane/utils"; +import { cn, renderFormattedDate } from "@plane/utils"; // hooks import { useAnalytics } from "@/hooks/store/use-analytics"; // services import { AnalyticsService } from "@/services/analytics.service"; // plane web components import AnalyticsSectionWrapper from "../analytics-section-wrapper"; +import { ANALYTICS_CHART_HEIGHT_CLASSNAME } from "../constants"; import { ChartLoader } from "../loaders"; const analyticsService = new AnalyticsService(); @@ -99,7 +100,7 @@ const CreatedVsResolved = observer(function CreatedVsResolved() { ) : parsedData && parsedData.length > 0 ? ( { + updateIsPeekView(true); + + // Handle project selection + if (projectDetails?.id) { + updateSelectedProjects([projectDetails.id]); + } + + // Handle cycle selection + if (cycleDetails?.id) { + updateSelectedCycle(cycleDetails.id); + } + + // Handle module selection + if (moduleDetails?.id) { + updateSelectedModule(moduleDetails.id); + } + setIsModalConfigured(true); + + // Cleanup fields + return () => { + updateSelectedProjects([]); + updateSelectedCycle(""); + updateSelectedModule(""); + updateIsPeekView(false); + }; + }, [ + projectDetails?.id, + cycleDetails?.id, + moduleDetails?.id, + updateSelectedProjects, + updateSelectedCycle, + updateSelectedModule, + updateIsPeekView, + ]); + + if (!isModalConfigured) + return ( +
+ +
+ ); + + return ( +
+ + + + +
+ ); +}); diff --git a/apps/web/components/analytics/work-items/modal/header.tsx b/apps/web/components/analytics/work-items/modal/header.tsx new file mode 100644 index 00000000000..3cec866a49d --- /dev/null +++ b/apps/web/components/analytics/work-items/modal/header.tsx @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane package imports +import { IconButton } from "@makeplane/propel/components/icon-button"; +import { ArrowCollapseOutline, CloseOutline, FullScreenOutline } from "@makeplane/propel/icons"; +import { useTranslation } from "@plane/i18n"; +import type { ICycle, IModule } from "@plane/types"; +// icons + +type Props = { + fullScreen: boolean; + handleClose: () => void; + setFullScreen: React.Dispatch>; + title: string; + cycle?: ICycle; + module?: IModule; +}; + +export const WorkItemsModalHeader = observer(function WorkItemsModalHeader(props: Props) { + const { fullScreen, handleClose, setFullScreen, title, cycle, module } = props; + const { t } = useTranslation(); + + return ( +
+

+ Analytics for {title} {cycle && `in ${cycle.name}`} {module && `in ${module.name}`} +

+
+
+ setFullScreen((prevData) => !prevData)} + icon={ + fullScreen ? ( + + ) : ( + + ) + } + /> +
+ } + /> +
+
+ ); +}); diff --git a/apps/web/components/analytics/work-items/modal/index.tsx b/apps/web/components/analytics/work-items/modal/index.tsx new file mode 100644 index 00000000000..8d9d1ac6782 --- /dev/null +++ b/apps/web/components/analytics/work-items/modal/index.tsx @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import React, { useEffect, useState } from "react"; +import { observer } from "mobx-react"; +// plane package imports +import { ModalPortal } from "@plane/blocks/portal"; +import type { ICycle, IModule, IProject } from "@plane/types"; +import { useAnalytics } from "@/hooks/store/use-analytics"; +// plane web components +import { WorkItemsModalMainContent } from "./content"; +import { WorkItemsModalHeader } from "./header"; + +type Props = { + isOpen: boolean; + onClose: () => void; + projectDetails?: IProject | undefined; + cycleDetails?: ICycle | undefined; + moduleDetails?: IModule | undefined; + isEpic?: boolean; +}; + +export const WorkItemsModal = observer(function WorkItemsModal(props: Props) { + const { isOpen, onClose, projectDetails, moduleDetails, cycleDetails, isEpic } = props; + const { updateIsEpic, isPeekView } = useAnalytics(); + const [fullScreen, setFullScreen] = useState(false); + + const handleClose = () => { + setFullScreen(false); + onClose(); + }; + + useEffect(() => { + updateIsEpic(isPeekView ? (isEpic ?? false) : false); + }, [isEpic, updateIsEpic, isPeekView]); + + return ( + +
+ + +
+
+ ); +}); diff --git a/apps/web/core/components/analytics/work-items/priority-chart.tsx b/apps/web/components/analytics/work-items/priority-chart.tsx similarity index 94% rename from apps/web/core/components/analytics/work-items/priority-chart.tsx rename to apps/web/components/analytics/work-items/priority-chart.tsx index 942285cab20..ad4e446e326 100644 --- a/apps/web/core/components/analytics/work-items/priority-chart.tsx +++ b/apps/web/components/analytics/work-items/priority-chart.tsx @@ -11,13 +11,14 @@ import { useParams } from "next/navigation"; import { useTheme } from "next-themes"; import useSWR from "swr"; // plane package imports -import { Download } from "lucide-react"; +import { ExportOutline } from "@makeplane/propel/icons"; import type { ChartXAxisDateGrouping } from "@plane/constants"; import { ANALYTICS_X_AXIS_VALUES, ANALYTICS_Y_AXIS_VALUES, CHART_COLOR_PALETTES, EChartModels } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; -import { Button } from "@plane/propel/button"; -import { BarChart } from "@plane/propel/charts/bar-chart"; -import { EmptyStateCompact } from "@plane/propel/empty-state"; +import { Button } from "@makeplane/propel/components/button"; +import { Icon } from "@makeplane/propel/components/icon"; +import { BarChart } from "@plane/blocks/charts/bar-chart"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; import type { TBarItem, TChart, TChartDatum, ChartXAxisProperty, ChartYAxisMetric } from "@plane/types"; // plane web components import { generateExtendedColors, parseChartData } from "@/components/chart/utils"; @@ -228,11 +229,13 @@ const PriorityChart = observer(function PriorityChart(props: Props) { actions={(table: Table) => ( + /> )} /> diff --git a/apps/web/core/components/analytics/work-items/root.tsx b/apps/web/components/analytics/work-items/root.tsx similarity index 100% rename from apps/web/core/components/analytics/work-items/root.tsx rename to apps/web/components/analytics/work-items/root.tsx diff --git a/apps/web/core/components/analytics/work-items/utils.ts b/apps/web/components/analytics/work-items/utils.ts similarity index 100% rename from apps/web/core/components/analytics/work-items/utils.ts rename to apps/web/components/analytics/work-items/utils.ts diff --git a/apps/web/core/components/analytics/work-items/workitems-insight-table.tsx b/apps/web/components/analytics/work-items/workitems-insight-table.tsx similarity index 93% rename from apps/web/core/components/analytics/work-items/workitems-insight-table.tsx rename to apps/web/components/analytics/work-items/workitems-insight-table.tsx index 52f3abd66ca..47010d424e6 100644 --- a/apps/web/core/components/analytics/work-items/workitems-insight-table.tsx +++ b/apps/web/components/analytics/work-items/workitems-insight-table.tsx @@ -9,14 +9,14 @@ import type { ColumnDef, Row, RowData } from "@tanstack/react-table"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; import useSWR from "swr"; -import { UserRound } from "lucide-react"; +import { ProjectsOutline, UserOutline } from "@makeplane/propel/icons"; +import { Avatar } from "@makeplane/propel/components/avatar"; import { useTranslation } from "@plane/i18n"; -import { Logo } from "@plane/propel/emoji-icon-picker"; -import { ProjectIcon } from "@plane/propel/icons"; +import { Logo } from "@plane/blocks/emoji-icon-picker"; // plane package imports import type { AnalyticsTableDataMap, WorkItemInsightColumns } from "@plane/types"; // plane web components -import { Avatar } from "@plane/ui"; + import { getFileURL } from "@plane/utils"; // hooks import { useAnalytics } from "@/hooks/store/use-analytics"; @@ -90,7 +90,7 @@ const WorkItemsInsightTable = observer(function WorkItemsInsightTable() { {project?.logo_props ? ( ) : ( - + )} {project?.name}
@@ -111,17 +111,17 @@ const WorkItemsInsightTable = observer(function WorkItemsInsightTable() {
{row.original.avatar_url && row.original.avatar_url !== "" ? ( ) : (
{row.original.display_name ? ( row.original.display_name?.[0] ) : ( - + )}
)} diff --git a/apps/web/core/components/api-token/delete-token-modal.tsx b/apps/web/components/api-token/delete-token-modal.tsx similarity index 91% rename from apps/web/core/components/api-token/delete-token-modal.tsx rename to apps/web/components/api-token/delete-token-modal.tsx index 58a93394c1a..fe418ab0773 100644 --- a/apps/web/core/components/api-token/delete-token-modal.tsx +++ b/apps/web/components/api-token/delete-token-modal.tsx @@ -8,11 +8,11 @@ import { useState } from "react"; import { mutate } from "swr"; // types import { useTranslation } from "@plane/i18n"; -import { TOAST_TYPE, setToast } from "@plane/propel/toast"; +import { setToast } from "@plane/blocks/toast"; import { APITokenService } from "@plane/services"; import type { IApiToken } from "@plane/types"; // ui -import { AlertModalCore } from "@plane/ui"; +import { ConfirmDialog } from "@plane/blocks/dialog"; // fetch-keys import { API_TOKENS_LIST } from "@plane/constants"; @@ -43,7 +43,7 @@ export function DeleteApiTokenModal(props: Props) { .destroy(tokenId) .then(() => { setToast({ - type: TOAST_TYPE.SUCCESS, + type: "success", title: t("workspace_settings.settings.api_tokens.delete.success.title"), message: t("workspace_settings.settings.api_tokens.delete.success.message"), }); @@ -59,7 +59,7 @@ export function DeleteApiTokenModal(props: Props) { }) .catch((err) => { setToast({ - type: TOAST_TYPE.ERROR, + type: "error", title: t("workspace_settings.settings.api_tokens.delete.error.title"), message: err?.message ?? t("workspace_settings.settings.api_tokens.delete.error.message"), }); @@ -68,7 +68,7 @@ export function DeleteApiTokenModal(props: Props) { }; return ( - void; +}; + +export function ApiTokenEmptyState(props: Props) { + const { onClick } = props; + + return ( +
+
+ empty +
No API tokens
+

+ Create API tokens for safe and easy data sharing with external apps, maintaining control and security. +

+
+
+ ); +} diff --git a/apps/web/components/api-token/modal/create-token-modal.tsx b/apps/web/components/api-token/modal/create-token-modal.tsx new file mode 100644 index 00000000000..cf7218d01a3 --- /dev/null +++ b/apps/web/components/api-token/modal/create-token-modal.tsx @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { mutate } from "swr"; +// plane imports +import { Dialog, DialogContent } from "@makeplane/propel/components/dialog"; +import { setToast } from "@plane/blocks/toast"; +import { APITokenService } from "@plane/services"; +import type { IApiToken } from "@plane/types"; +import { renderFormattedDate, csvDownload } from "@plane/utils"; +// constants +import { API_TOKENS_LIST } from "@plane/constants"; +// local imports +import { CreateApiTokenForm } from "./form"; +import { GeneratedTokenDetails } from "./generated-token-details"; + +type Props = { + isOpen: boolean; + onClose: () => void; +}; + +// services +const apiTokenService = new APITokenService(); + +export function CreateApiTokenModal(props: Props) { + const { isOpen, onClose } = props; + // states + const [neverExpires, setNeverExpires] = useState(false); + const [generatedToken, setGeneratedToken] = useState(null); + + const handleClose = () => { + onClose(); + + setTimeout(() => { + setNeverExpires(false); + setGeneratedToken(null); + }, 350); + }; + + const downloadSecretKey = (data: IApiToken) => { + const csvData = { + Title: data.label, + Description: data.description, + Expiry: data.expired_at ? (renderFormattedDate(data.expired_at)?.replace(",", " ") ?? "") : "Never expires", + "Secret key": data.token ?? "", + }; + + csvDownload(csvData, `secret-key-${Date.now()}`); + }; + + const handleCreateToken = async (data: Partial) => { + // make the request to generate the token + await apiTokenService + .create(data) + .then((res) => { + setGeneratedToken(res); + downloadSecretKey(res); + + mutate( + API_TOKENS_LIST, + (prevData) => { + if (!prevData) return; + + return [res, ...prevData]; + }, + false + ); + }) + .catch((err) => { + setToast({ + type: "error", + title: "Error!", + message: err.message || err.detail, + }); + + throw err; + }); + }; + + return ( + /* Dismissed only through its own buttons, matching the modal it replaces, whose `handleClose` + was a no-op. */ + {}}> + + {generatedToken ? ( + + ) : ( + setNeverExpires((prevData) => !prevData)} + onSubmit={handleCreateToken} + /> + )} + + + ); +} diff --git a/apps/web/components/api-token/modal/form.tsx b/apps/web/components/api-token/modal/form.tsx new file mode 100644 index 00000000000..afba9845b89 --- /dev/null +++ b/apps/web/components/api-token/modal/form.tsx @@ -0,0 +1,281 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { add } from "date-fns"; +import { Controller, useForm } from "react-hook-form"; +import { Button } from "@makeplane/propel/components/button"; +import { + DialogActions, + DialogBody, + DialogHeader, + DialogHeading, + DialogInfo, + DialogMain, + DialogTitle, +} from "@makeplane/propel/components/dialog"; +import { InputField } from "@makeplane/propel/components/input-field"; +import { SelectField } from "@makeplane/propel/components/select-field"; +import { Switch } from "@makeplane/propel/components/switch"; +import { TextAreaField } from "@makeplane/propel/components/text-area-field"; +import { CalendarOutline } from "@makeplane/propel/icons"; +import { DateSelect } from "@plane/blocks/property-select"; +import { setToast } from "@plane/blocks/toast"; +import { useTranslation } from "@plane/i18n"; +import type { IApiToken } from "@plane/types"; +import { renderFormattedDate, renderFormattedTime } from "@plane/utils"; +// hooks +import { useUserProfile } from "@/hooks/store/user"; +// helpers +type Props = { + handleClose: () => void; + neverExpires: boolean; + toggleNeverExpires: () => void; + onSubmit: (data: Partial) => Promise; +}; + +const EXPIRY_DATE_OPTIONS = [ + { + key: "1_week", + label: "1 week", + value: { weeks: 1 }, + }, + { + key: "1_month", + label: "1 month", + value: { months: 1 }, + }, + { + key: "3_months", + label: "3 months", + value: { months: 3 }, + }, + { + key: "1_year", + label: "1 year", + value: { years: 1 }, + }, +]; + +/** The expiry picker's rows: the presets plus the "Custom" row that reveals the date picker. */ +const EXPIRY_SELECT_OPTIONS = [ + ...EXPIRY_DATE_OPTIONS.map(({ key, label }) => ({ value: key, label })), + { value: "custom", label: "Custom" }, +]; + +const defaultValues: Partial = { + label: "", + description: "", + expired_at: null, +}; + +const getExpiryDate = (val: string): Date | null | undefined => { + const today = new Date(); + const dateToAdd = EXPIRY_DATE_OPTIONS.find((option) => option.key === val)?.value; + if (dateToAdd) return add(today, dateToAdd); + return null; +}; + +const getFormattedDate = (date: Date): Date => { + const now = new Date(); + const hours = now.getHours(); + const minutes = now.getMinutes(); + const seconds = now.getSeconds(); + return add(date, { hours, minutes, seconds }); +}; + +export function CreateApiTokenForm(props: Props) { + const { handleClose, neverExpires, toggleNeverExpires, onSubmit } = props; + // states + const [customDate, setCustomDate] = useState(null); + // form + const { + control, + formState: { errors, isSubmitting }, + handleSubmit, + reset, + watch, + } = useForm({ defaultValues }); + // hooks + const { t } = useTranslation(); + // store hooks + const { data: userProfile } = useUserProfile(); + + const handleFormSubmit = async (data: IApiToken) => { + // if never expires is toggled off, and the user has not selected a custom date or a predefined date, show an error + if (!neverExpires && (!data.expired_at || (data.expired_at === "custom" && !customDate))) + return setToast({ + type: "error", + title: "Error!", + message: "Please select an expiration date.", + }); + + const payload: Partial = { + label: data.label, + description: data.description, + }; + + // if never expires is toggled on, set expired_at to null + if (neverExpires) payload.expired_at = null; + // if never expires is toggled off, and the user has selected a custom date, set expired_at to the custom date + else if (data.expired_at === "custom") { + payload.expired_at = customDate && getFormattedDate(customDate).toISOString(); + } + // if never expires is toggled off, and the user has selected a predefined date, set expired_at to the predefined date + else { + const expiryDate = getExpiryDate(data.expired_at ?? ""); + if (expiryDate) payload.expired_at = expiryDate.toISOString(); + } + + await onSubmit(payload).then(() => { + reset(defaultValues); + return setCustomDate(null); + }); + }; + + const today = new Date(); + const tomorrow = add(today, { days: 1 }); + const expiredAt = watch("expired_at"); + const expiryDate = getExpiryDate(expiredAt ?? ""); + const customDateFormatted = customDate && getFormattedDate(customDate); + + return ( +
+ + + + {t("workspace_settings.settings.api_tokens.create_token")} + + + +
+ val.trim() !== "" || t("title_is_required"), + }} + render={({ field: { value, onChange, ref } }) => ( + + )} + /> + ( + + )} + /> +
+
+ ( + + name="expired_at" + aria-label="Set expiration date" + size="md" + variant="pill" + value={value ?? null} + onValueChange={(expiry) => { + if (expiry) onChange(expiry); + }} + options={EXPIRY_SELECT_OPTIONS} + itemToStringLabel={(expiry) => + expiry === "custom" + ? "Custom date" + : (EXPIRY_SELECT_OPTIONS.find((option) => option.value === expiry)?.label ?? expiry) + } + icon={} + placeholder="Set expiration date" + disabled={neverExpires} + /> + )} + /> + {expiredAt === "custom" && ( + setCustomDate(date)} + minDate={tomorrow} + icon={} + placeholder="Set date" + disabled={neverExpires} + clearable + weekStartsOn={userProfile?.start_of_the_week} + variant="pill-md" + /> + )} +
+ {!neverExpires && ( + + {expiredAt === "custom" + ? customDate + ? `Expires ${renderFormattedDate(customDateFormatted ?? "")} at ${renderFormattedTime(customDateFormatted ?? "")}` + : null + : expiredAt + ? `Expires ${renderFormattedDate(expiryDate ?? "")} at ${renderFormattedTime(expiryDate ?? "")}` + : null} + + )} +
+
+
+
+ + + + + + + + + + {tokenDetails.expired_at + ? `Expires ${renderFormattedDate(tokenDetails.expired_at)} at ${renderFormattedTime(tokenDetails.expired_at)}` + : "Never expires"} + +
+ ) + } + /> + ); +}); + +type TAuthHeaderBase = { + pageTitle: string; + additionalAction?: React.ReactNode; +}; + +export function AuthHeaderBase(props: TAuthHeaderBase) { + const { pageTitle, additionalAction } = props; + return ( + <> + +
+ + + + {additionalAction} +
+ + ); +} diff --git a/apps/web/components/auth-screens/not-authorized-view.tsx b/apps/web/components/auth-screens/not-authorized-view.tsx new file mode 100644 index 00000000000..6ad3b9079f8 --- /dev/null +++ b/apps/web/components/auth-screens/not-authorized-view.tsx @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import React from "react"; +import { observer } from "mobx-react"; +// plane imports +import { EmptyStateDetailed } from "@plane/blocks/empty-state"; +import { cn } from "@plane/utils"; +// layouts +import DefaultLayout from "@/layouts/default-layout"; + +type Props = { + actionButton?: React.ReactNode; + /** @deprecated Every section now shares the same no-access illustration; kept so callers need no change. */ + section?: "settings" | "general"; + /** @deprecated Every section now shares the same no-access illustration; kept so callers need no change. */ + isProjectView?: boolean; + className?: string; +}; + +export const NotAuthorizedView = observer(function NotAuthorizedView(props: Props) { + const { actionButton, className } = props; + + return ( + + + + ); +}); diff --git a/apps/web/core/components/auth-screens/project/project-access-restriction.tsx b/apps/web/components/auth-screens/project/project-access-restriction.tsx similarity index 97% rename from apps/web/core/components/auth-screens/project/project-access-restriction.tsx rename to apps/web/components/auth-screens/project/project-access-restriction.tsx index 9110f88dca0..1ba0cf279b5 100644 --- a/apps/web/core/components/auth-screens/project/project-access-restriction.tsx +++ b/apps/web/components/auth-screens/project/project-access-restriction.tsx @@ -7,7 +7,7 @@ import { observer } from "mobx-react"; // plane imports import { useTranslation } from "@plane/i18n"; -import { EmptyStateDetailed } from "@plane/propel/empty-state"; +import { EmptyStateDetailed } from "@plane/blocks/empty-state"; type TProps = { isWorkspaceAdmin: boolean; diff --git a/apps/web/components/auth-screens/workspace/not-a-member.tsx b/apps/web/components/auth-screens/workspace/not-a-member.tsx new file mode 100644 index 00000000000..19c1b1e2c33 --- /dev/null +++ b/apps/web/components/auth-screens/workspace/not-a-member.tsx @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import Link from "next/link"; +// ui +import { Button } from "@makeplane/propel/components/button"; +// layouts +import DefaultLayout from "@/layouts/default-layout"; + +export function NotAWorkspaceMember() { + return ( + +
+
+
+

Not Authorized!

+

+ You{"'"}re not a member of this workspace. Please contact the workspace admin to get an invitation or + check your pending invitations. +

+
+
+
+
+
+
+ ); +} diff --git a/apps/web/components/automation/auto-archive-automation.tsx b/apps/web/components/automation/auto-archive-automation.tsx new file mode 100644 index 00000000000..b1d3775677a --- /dev/null +++ b/apps/web/components/automation/auto-archive-automation.tsx @@ -0,0 +1,148 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useMemo, useState } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +// plane imports +import { PROJECT_AUTOMATION_MONTHS, EUserPermissions, EUserPermissionsLevel } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; +import type { IProject } from "@plane/types"; +import { cn } from "@plane/utils"; +import { Switch } from "@makeplane/propel/components/switch"; +import { Select } from "@plane/blocks/select"; +import { Loader } from "@plane/blocks/skeleton"; +// component +import { SelectMonthModal } from "@/components/automation"; +import { SettingsBoxedControlItem } from "@/components/settings/boxed-control-item"; +// hooks +import { useProject } from "@/hooks/store/use-project"; +import { useUserPermissions } from "@/hooks/store/user"; +// local imports +import { AutomationPanel, AutomationPanelRow } from "./automation-panel"; + +type Props = { + handleChange: (formData: Partial) => Promise; +}; + +const initialValues: Partial = { archive_in: 1 }; + +const CUSTOMIZE_TIME_RANGE = "customize-time-range"; + +type TAutomationMonthOption = { + id: string; + label: string; +}; + +export const AutoArchiveAutomation = observer(function AutoArchiveAutomation(props: Props) { + const { handleChange } = props; + // router + const { workspaceSlug } = useParams(); + // states + const [monthModal, setmonthModal] = useState(false); + // store hooks + const { allowPermissions } = useUserPermissions(); + const { t } = useTranslation(); + + const { currentProjectDetails } = useProject(); + + const isAdmin = allowPermissions( + [EUserPermissions.ADMIN], + EUserPermissionsLevel.PROJECT, + workspaceSlug?.toString(), + currentProjectDetails?.id + ); + + const autoArchiveStatus = useMemo(() => { + if (currentProjectDetails?.archive_in === undefined) return false; + return currentProjectDetails.archive_in !== 0; + }, [currentProjectDetails]); + + // `archive_in` is not constrained to the presets — the "Customize time range" modal writes any + // month count — and `Select` names its trigger from the option list, so a value outside the + // presets has to join the list or the trigger reads empty. + const archiveIn = currentProjectDetails?.archive_in; + const monthOptions = useMemo(() => { + const months = PROJECT_AUTOMATION_MONTHS.map((month) => month.value); + if (archiveIn !== undefined && !months.includes(archiveIn)) months.push(archiveIn); + months.sort((a, b) => a - b); + return [ + ...months.map((month) => ({ + id: String(month), + label: t("workspace_projects.common.months_count", { months: month }), + })), + // The last row opens the custom range modal instead of setting a value. + { id: CUSTOMIZE_TIME_RANGE, label: t("common.customize_time_range") }, + ]; + }, [t, archiveIn]); + const selectedMonthOption = monthOptions.find((option) => option.id === String(archiveIn)) ?? null; + + const handleToggleArchive = async () => { + if (currentProjectDetails?.archive_in === 0) { + await handleChange({ archive_in: 1 }); + } else { + await handleChange({ archive_in: 0 }); + } + }; + + return ( + <> + setmonthModal(false)} + handleChange={handleChange} + /> +
+ + } + /> + {currentProjectDetails ? ( + + + + getValues={() => monthOptions} + value={selectedMonthOption} + onChange={(id) => { + if (id === CUSTOMIZE_TIME_RANGE) { + setmonthModal(true); + return; + } + void handleChange({ archive_in: Number(id) }); + }} + getOptionValue={(option) => option.id} + getOptionLabel={(option) => option.label} + showSearch={false} + pinSelected={false} + disabled={!isAdmin} + > + + + + + + + ) : ( + + + + )} +
+ + ); +}); diff --git a/apps/web/components/automation/auto-close-automation.tsx b/apps/web/components/automation/auto-close-automation.tsx new file mode 100644 index 00000000000..63aa62a247b --- /dev/null +++ b/apps/web/components/automation/auto-close-automation.tsx @@ -0,0 +1,193 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useMemo, useState } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +import { StateOutline } from "@makeplane/propel/icons"; +// plane imports +import { PROJECT_AUTOMATION_MONTHS, EUserPermissions, EUserPermissionsLevel, EIconSize } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; +import { StateGroupIcon } from "@plane/blocks/icons"; +import type { IProject, IState } from "@plane/types"; +import { cn } from "@plane/utils"; +import { Switch } from "@makeplane/propel/components/switch"; +import { Select } from "@plane/blocks/select"; +import { Loader } from "@plane/blocks/skeleton"; +import { SelectMonthModal } from "@/components/automation"; +import { SettingsBoxedControlItem } from "@/components/settings/boxed-control-item"; +// hooks +import { useProject } from "@/hooks/store/use-project"; +import { useProjectState } from "@/hooks/store/use-project-state"; +import { useUserPermissions } from "@/hooks/store/user"; +// local imports +import { AutomationPanel, AutomationPanelRow } from "./automation-panel"; + +type Props = { + handleChange: (formData: Partial) => Promise; +}; + +const CUSTOMIZE_TIME_RANGE = "customize-time-range"; + +type TAutomationMonthOption = { + id: string; + label: string; +}; + +export const AutoCloseAutomation = observer(function AutoCloseAutomation(props: Props) { + const { handleChange } = props; + // router + const { workspaceSlug } = useParams(); + // states + const [monthModal, setmonthModal] = useState(false); + // store hooks + const { currentProjectDetails } = useProject(); + const { projectStates } = useProjectState(); + const { allowPermissions } = useUserPermissions(); + const { t } = useTranslation(); + + // const stateGroups = projectStateStore.groupedProjectStates ?? undefined; + + const options = (projectStates ?? []).filter((state) => state.group === "cancelled"); + + const multipleOptions = (options ?? []).length > 1; + + const defaultState = projectStates?.find((s) => s.group === "cancelled")?.id || null; + + const selectedOption = projectStates?.find((s) => s.id === (currentProjectDetails?.default_state ?? defaultState)); + const currentDefaultState = projectStates?.find((s) => s.id === defaultState); + // The trigger falls back to the project's own cancelled state when nothing is stored yet. + const triggerState = selectedOption ?? currentDefaultState; + + // `close_in` is not constrained to the presets — the "Customize time range" modal writes any + // month count — and `Select` names its trigger from the option list, so a value outside the + // presets has to join the list or the trigger reads empty. + const closeIn = currentProjectDetails?.close_in; + const monthOptions = useMemo(() => { + const months = PROJECT_AUTOMATION_MONTHS.map((month) => month.value); + if (closeIn !== undefined && !months.includes(closeIn)) months.push(closeIn); + months.sort((a, b) => a - b); + return [ + ...months.map((month) => ({ + id: String(month), + label: t("workspace_projects.common.months_count", { months: month }), + })), + // The last row opens the custom range modal instead of setting a value. + { id: CUSTOMIZE_TIME_RANGE, label: t("common.customize_time_range") }, + ]; + }, [t, closeIn]); + const selectedMonthOption = monthOptions.find((option) => option.id === String(closeIn)) ?? null; + + const initialValues: Partial = { + close_in: 1, + default_state: defaultState, + }; + + const isAdmin = allowPermissions( + [EUserPermissions.ADMIN], + EUserPermissionsLevel.PROJECT, + workspaceSlug?.toString(), + currentProjectDetails?.id + ); + + const autoCloseStatus = useMemo(() => { + if (currentProjectDetails?.close_in === undefined) return false; + return currentProjectDetails.close_in !== 0; + }, [currentProjectDetails]); + + return ( + <> + setmonthModal(false)} + handleChange={handleChange} + /> +
+ { + if (currentProjectDetails?.close_in === 0) { + void handleChange({ close_in: 1, default_state: defaultState }); + } else { + void handleChange({ close_in: 0, default_state: null }); + } + }} + disabled={!isAdmin} + aria-label={t("project_settings.automations.auto-close.title")} + /> + } + /> + {currentProjectDetails ? ( + + + + getValues={() => monthOptions} + value={selectedMonthOption} + onChange={(id) => { + if (id === CUSTOMIZE_TIME_RANGE) { + setmonthModal(true); + return; + } + void handleChange({ close_in: Number(id) }); + }} + getOptionValue={(option) => option.id} + getOptionLabel={(option) => option.label} + showSearch={false} + pinSelected={false} + disabled={!isAdmin} + > + + + + + + + + getValues={() => options} + value={selectedOption ?? null} + onChange={(val) => void handleChange({ default_state: val })} + disabled={!multipleOptions} + getOptionValue={(state) => state.id} + getOptionLabel={(state) => state.name} + getOptionIcon={(state) => ( + + )} + pinSelected={false} + placeholder={t("state")} + > + + {triggerState ? ( + <> + + {triggerState.name} + + ) : ( + <> + + {t("state")} + + )} + + + + + ) : ( + + + + )} +
+ + ); +}); diff --git a/apps/web/components/automation/automation-panel.tsx b/apps/web/components/automation/automation-panel.tsx new file mode 100644 index 00000000000..f1d7c31a874 --- /dev/null +++ b/apps/web/components/automation/automation-panel.tsx @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +// plane imports +import { cn } from "@plane/utils"; + +type PanelProps = { + isOpen: boolean; + children: ReactNode; +}; + +/** The options panel attached under an automation's toggle row; it slides open while enabled. */ +export function AutomationPanel({ isOpen, children }: PanelProps) { + return ( +
+
+
+ {children} +
+
+
+ ); +} + +type RowProps = { + label: string; + children: ReactNode; +}; + +/** One labelled option inside an automation panel. */ +export function AutomationPanelRow({ label, children }: RowProps) { + return ( +
+
{label}
+
{children}
+
+ ); +} diff --git a/apps/web/core/components/automation/index.ts b/apps/web/components/automation/index.ts similarity index 100% rename from apps/web/core/components/automation/index.ts rename to apps/web/components/automation/index.ts diff --git a/apps/web/components/automation/select-month-modal.tsx b/apps/web/components/automation/select-month-modal.tsx new file mode 100644 index 00000000000..4f23363a327 --- /dev/null +++ b/apps/web/components/automation/select-month-modal.tsx @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useParams } from "next/navigation"; +// react-hook-form +import { Controller, useForm } from "react-hook-form"; +import { Button } from "@makeplane/propel/components/button"; +import { + Dialog, + DialogActions, + DialogBody, + DialogContent, + DialogHeader, + DialogHeading, + DialogMain, + DialogTitle, +} from "@makeplane/propel/components/dialog"; +import { InputField } from "@makeplane/propel/components/input-field"; +import type { IProject } from "@plane/types"; + +// types +type Props = { + isOpen: boolean; + type: "auto-close" | "auto-archive"; + initialValues: Partial; + handleClose: () => void; + handleChange: (formData: Partial) => Promise; +}; + +export function SelectMonthModal({ type, initialValues, isOpen, handleClose, handleChange }: Props) { + const { workspaceSlug, projectId } = useParams(); + + const { + formState: { errors, isSubmitting }, + handleSubmit, + control, + reset, + } = useForm({ + defaultValues: initialValues, + }); + + const onClose = () => { + handleClose(); + reset(initialValues); + }; + + const onSubmit = (formData: Partial) => { + if (!workspaceSlug && !projectId) return; + handleChange(formData); + onClose(); + }; + + const renderMonthField = (name: "close_in" | "archive_in") => ( + ( + Months} + error={errors[name] ? "Select a month between 1 and 12." : undefined} + /> + )} + /> + ); + + return ( + { + if (!open) onClose(); + }} + > + +
+ + + + Customize time range + + + +
+ {type === "auto-close" ? renderMonthField("close_in") : renderMonthField("archive_in")} +
+
+
+ +
+ ); +} diff --git a/apps/web/components/base-layouts/constants.ts b/apps/web/components/base-layouts/constants.ts new file mode 100644 index 00000000000..0ee8c5962d5 --- /dev/null +++ b/apps/web/components/base-layouts/constants.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { BoardOutline, ListOutline, TimelineOutline } from "@makeplane/propel/icons"; +import type { IBaseLayoutConfig } from "@plane/types"; + +export const BASE_LAYOUTS: IBaseLayoutConfig[] = [ + { + key: "list", + icon: ListOutline, + label: "List Layout", + }, + { + key: "kanban", + icon: BoardOutline, + label: "Board Layout", + }, + { + key: "gantt", + icon: TimelineOutline, + label: "Gantt Layout", + }, +]; diff --git a/apps/web/core/components/base-layouts/gantt/index.ts b/apps/web/components/base-layouts/gantt/index.ts similarity index 100% rename from apps/web/core/components/base-layouts/gantt/index.ts rename to apps/web/components/base-layouts/gantt/index.ts diff --git a/apps/web/core/components/base-layouts/gantt/layout.tsx b/apps/web/components/base-layouts/gantt/layout.tsx similarity index 100% rename from apps/web/core/components/base-layouts/gantt/layout.tsx rename to apps/web/components/base-layouts/gantt/layout.tsx diff --git a/apps/web/components/base-layouts/gantt/sidebar.tsx b/apps/web/components/base-layouts/gantt/sidebar.tsx new file mode 100644 index 00000000000..1c1e4ce74ad --- /dev/null +++ b/apps/web/components/base-layouts/gantt/sidebar.tsx @@ -0,0 +1,156 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { RefObject } from "react"; +import { useState } from "react"; +import { observer } from "mobx-react"; +import type { IBaseLayoutsBaseItem, IBlockUpdateData } from "@plane/types"; +import { Loader } from "@plane/blocks/skeleton"; +import { Row } from "@plane/blocks/layout"; +import { cn } from "@plane/utils"; +import RenderIfVisible from "@/components/core/render-if-visible-HOC"; +import { BLOCK_HEIGHT } from "@/components/gantt-chart/constants"; +import { GanttDnDHOC } from "@/components/gantt-chart/sidebar/gantt-dnd-HOC"; +import { handleOrderChange } from "@/components/gantt-chart/sidebar/utils"; +import { GanttLayoutListItemLoader } from "@/components/ui/loader/layouts/gantt-layout-loader"; +import { useIntersectionObserver } from "@/hooks/use-intersection-observer"; +import { useTimeLineChartStore } from "@/hooks/use-timeline-chart"; + +type Props = { + blockUpdateHandler: (block: T, payload: IBlockUpdateData) => void; + canLoadMoreBlocks?: boolean; + loadMoreItems?: (groupId: string) => void; + ganttContainerRef: RefObject; + blockIds: string[]; + enableReorder: boolean; + showAllBlocks?: boolean; + items: Record; + renderItem: (item: T) => React.ReactNode; +}; + +export const BaseGanttSidebar = observer(function BaseGanttSidebar(props: Props) { + const { + blockUpdateHandler, + blockIds, + enableReorder, + loadMoreItems, + canLoadMoreBlocks, + ganttContainerRef, + showAllBlocks = false, + items, + renderItem, + } = props; + + const { getBlockById, updateActiveBlockId, isBlockActive, getNumberOfDaysFromPosition } = useTimeLineChartStore(); + + const [intersectionElement, setIntersectionElement] = useState(null); + + const isPaginating = false; // TODO: Add proper pagination state + + useIntersectionObserver( + ganttContainerRef, + isPaginating ? null : intersectionElement, + loadMoreItems ? () => loadMoreItems("") : undefined, + "100% 0% 100% 0%" + ); + + const handleOnDrop = ( + draggingBlockId: string | undefined, + droppedBlockId: string | undefined, + dropAtEndOfList: boolean + ) => { + handleOrderChange(draggingBlockId, droppedBlockId, dropAtEndOfList, blockIds, getBlockById, blockUpdateHandler); + }; + + return ( +
+ {blockIds ? ( + <> + {blockIds.map((blockId, index) => { + const block = getBlockById(blockId); + const item = items[blockId]; + const isBlockVisibleOnSidebar = block?.start_date && block?.target_date; + + // hide the block if it doesn't have start and target dates and showAllBlocks is false + if (!block || (!showAllBlocks && !isBlockVisibleOnSidebar)) return null; + + if (!item) return null; + + return ( + } + > + + {(isDragging: boolean) => { + const block = getBlockById(blockId); + const isBlockComplete = !!block?.start_date && !!block?.target_date; + const duration = isBlockComplete ? getNumberOfDaysFromPosition(block?.position?.width) : undefined; + const isBlockHoveredOn = isBlockActive(blockId); + + return ( +
updateActiveBlockId(blockId)} + onMouseLeave={() => updateActiveBlockId(null)} + > + +
+
{renderItem(item)}
+ {duration && ( +
+ + {duration} day{duration > 1 ? "s" : ""} + +
+ )} +
+
+
+ ); + }} +
+
+ ); + })} + {canLoadMoreBlocks && ( +
+
+
+ )} + + ) : ( + + + + + + + )} +
+ ); +}); diff --git a/apps/web/core/components/base-layouts/hooks/use-group-drop-target.ts b/apps/web/components/base-layouts/hooks/use-group-drop-target.ts similarity index 100% rename from apps/web/core/components/base-layouts/hooks/use-group-drop-target.ts rename to apps/web/components/base-layouts/hooks/use-group-drop-target.ts diff --git a/apps/web/core/components/base-layouts/hooks/use-layout-state.ts b/apps/web/components/base-layouts/hooks/use-layout-state.ts similarity index 100% rename from apps/web/core/components/base-layouts/hooks/use-layout-state.ts rename to apps/web/components/base-layouts/hooks/use-layout-state.ts diff --git a/apps/web/components/base-layouts/kanban/group-header.tsx b/apps/web/components/base-layouts/kanban/group-header.tsx new file mode 100644 index 00000000000..1d6b9c21501 --- /dev/null +++ b/apps/web/components/base-layouts/kanban/group-header.tsx @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { IGroupHeaderProps } from "@plane/types"; + +export function GroupHeader({ group, itemCount, onToggleGroup }: IGroupHeaderProps) { + return ( + + ); +} diff --git a/apps/web/components/base-layouts/kanban/group.tsx b/apps/web/components/base-layouts/kanban/group.tsx new file mode 100644 index 00000000000..02bc3115c00 --- /dev/null +++ b/apps/web/components/base-layouts/kanban/group.tsx @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import { useTranslation } from "@plane/i18n"; +import type { IBaseLayoutsKanbanItem, IBaseLayoutsKanbanGroupProps } from "@plane/types"; +import { cn } from "@plane/utils"; +import { useGroupDropTarget } from "../hooks/use-group-drop-target"; +import { GroupHeader } from "./group-header"; +import { BaseKanbanItem } from "./item"; + +export const BaseKanbanGroup = observer(function BaseKanbanGroup( + props: IBaseLayoutsKanbanGroupProps +) { + const { + group, + itemIds, + items, + renderItem, + renderGroupHeader, + isCollapsed, + onToggleGroup, + enableDragDrop = false, + onDrop, + canDrag, + groupClassName, + loadMoreItems: _loadMoreItems, + } = props; + + const { t } = useTranslation(); + const { groupRef, isDraggingOver } = useGroupDropTarget({ + groupId: group.id, + enableDragDrop, + onDrop, + }); + + return ( +
+ {/* Group Header */} +
+ {renderGroupHeader ? ( + renderGroupHeader({ group, itemCount: itemIds.length, isCollapsed, onToggleGroup }) + ) : ( + + )} +
+ + {/* Group Items */} + {!isCollapsed && ( +
+ {itemIds.map((itemId, index) => { + const item = items[itemId]; + if (!item) return null; + + return ( + + ); + })} + + {itemIds.length === 0 && ( +
+ {t("common.no_items_in_this_group")} +
+ )} +
+ )} + + {isDraggingOver && enableDragDrop && ( +
+
+ {t("common.drop_here_to_move")} +
+
+ )} +
+ ); +}); diff --git a/apps/web/core/components/base-layouts/kanban/item.tsx b/apps/web/components/base-layouts/kanban/item.tsx similarity index 100% rename from apps/web/core/components/base-layouts/kanban/item.tsx rename to apps/web/components/base-layouts/kanban/item.tsx diff --git a/apps/web/core/components/base-layouts/kanban/layout.tsx b/apps/web/components/base-layouts/kanban/layout.tsx similarity index 100% rename from apps/web/core/components/base-layouts/kanban/layout.tsx rename to apps/web/components/base-layouts/kanban/layout.tsx diff --git a/apps/web/components/base-layouts/layout-switcher.tsx b/apps/web/components/base-layouts/layout-switcher.tsx new file mode 100644 index 00000000000..55579eea5aa --- /dev/null +++ b/apps/web/components/base-layouts/layout-switcher.tsx @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useTranslation } from "@plane/i18n"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import type { TBaseLayoutType } from "@plane/types"; +import { cn } from "@plane/utils"; +import { usePlatformOS } from "@/hooks/use-platform-os"; +import { BASE_LAYOUTS } from "./constants"; + +type Props = { + layouts?: TBaseLayoutType[]; + onChange: (layout: TBaseLayoutType) => void; + selectedLayout: TBaseLayoutType; +}; + +export function LayoutSwitcher(props: Props) { + const { layouts, onChange, selectedLayout } = props; + const { isMobile } = usePlatformOS(); + const { t } = useTranslation(); + + const handleOnChange = (layoutKey: TBaseLayoutType) => { + if (selectedLayout !== layoutKey) { + onChange(layoutKey); + } + }; + + return ( +
+ {BASE_LAYOUTS.map((layout) => { + if (layouts && !layouts.includes(layout.key)) return null; + const Icon = layout.icon; + const isSelected = selectedLayout === layout.key; + return ( + + + + ); + })} +
+ ); +} diff --git a/apps/web/components/base-layouts/list/group-header.tsx b/apps/web/components/base-layouts/list/group-header.tsx new file mode 100644 index 00000000000..1db55420bae --- /dev/null +++ b/apps/web/components/base-layouts/list/group-header.tsx @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { IGroupHeaderProps } from "@plane/types"; + +export function GroupHeader({ group, itemCount, onToggleGroup }: IGroupHeaderProps) { + return ( + + ); +} diff --git a/apps/web/components/base-layouts/list/group.tsx b/apps/web/components/base-layouts/list/group.tsx new file mode 100644 index 00000000000..7b1692d6e61 --- /dev/null +++ b/apps/web/components/base-layouts/list/group.tsx @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import { useTranslation } from "@plane/i18n"; +import type { IBaseLayoutsListItem, IBaseLayoutsListGroupProps } from "@plane/types"; +import { cn } from "@plane/utils"; +import { useGroupDropTarget } from "../hooks/use-group-drop-target"; +import { GroupHeader } from "./group-header"; +import { BaseListItem } from "./item"; + +export const BaseListGroup = observer(function BaseListGroup( + props: IBaseLayoutsListGroupProps +) { + const { + group, + itemIds, + items, + isCollapsed, + onToggleGroup, + renderItem, + renderGroupHeader, + enableDragDrop = false, + onDrop, + canDrag, + loadMoreItems: _loadMoreItems, + } = props; + + const { t } = useTranslation(); + const { groupRef, isDraggingOver } = useGroupDropTarget({ + groupId: group.id, + enableDragDrop, + onDrop, + }); + + return ( +
+ {/* Group Header */} +
+ {renderGroupHeader ? ( + renderGroupHeader({ group, itemCount: itemIds.length, isCollapsed, onToggleGroup }) + ) : ( + + )} +
+ + {/* Group Items */} + {!isCollapsed && ( +
+ {itemIds.map((itemId: string, index: number) => { + const item = items[itemId]; + if (!item) return null; + + return ( + + ); + })} +
+ )} + + {isDraggingOver && enableDragDrop && ( +
+
+ {t("common.drop_here_to_move")} +
+
+ )} +
+ ); +}); diff --git a/apps/web/core/components/base-layouts/list/item.tsx b/apps/web/components/base-layouts/list/item.tsx similarity index 100% rename from apps/web/core/components/base-layouts/list/item.tsx rename to apps/web/components/base-layouts/list/item.tsx diff --git a/apps/web/components/base-layouts/list/layout.tsx b/apps/web/components/base-layouts/list/layout.tsx new file mode 100644 index 00000000000..da7b54789a8 --- /dev/null +++ b/apps/web/components/base-layouts/list/layout.tsx @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import type { IBaseLayoutsListItem, IBaseLayoutsListProps } from "@plane/types"; +import { cn } from "@plane/utils"; +import { useLayoutState } from "../hooks/use-layout-state"; +import { BaseListGroup } from "./group"; + +export const BaseListLayout = observer(function BaseListLayout( + props: IBaseLayoutsListProps +) { + const { + items, + groupedItemIds, + groups, + renderItem, + renderGroupHeader, + enableDragDrop = false, + onDrop, + canDrag, + showEmptyGroups = false, + collapsedGroups: externalCollapsedGroups, + onToggleGroup: externalOnToggleGroup, + loadMoreItems, + className, + } = props; + + const useExternalMode = externalCollapsedGroups !== undefined && externalOnToggleGroup !== undefined; + const { containerRef, collapsedGroups, onToggleGroup } = useLayoutState( + useExternalMode + ? { + mode: "external", + externalCollapsedGroups, + externalOnToggleGroup, + } + : { + mode: "internal", + } + ); + + return ( +
+
+ {groups.map((group) => { + const itemIds = groupedItemIds[group.id] || []; + const isCollapsed = collapsedGroups.includes(group.id); + + if (!showEmptyGroups && itemIds.length === 0) return null; + + return ( + + ); + })} +
+
+ ); +}); diff --git a/apps/web/core/components/base-layouts/loaders/layout-loader.tsx b/apps/web/components/base-layouts/loaders/layout-loader.tsx similarity index 100% rename from apps/web/core/components/base-layouts/loaders/layout-loader.tsx rename to apps/web/components/base-layouts/loaders/layout-loader.tsx diff --git a/apps/web/core/components/breadcrumbs/common.tsx b/apps/web/components/breadcrumbs/common.tsx similarity index 77% rename from apps/web/core/components/breadcrumbs/common.tsx rename to apps/web/components/breadcrumbs/common.tsx index 9040cb21b57..34c47ee55ca 100644 --- a/apps/web/core/components/breadcrumbs/common.tsx +++ b/apps/web/components/breadcrumbs/common.tsx @@ -4,6 +4,8 @@ * See the LICENSE file for details. */ +// plane imports +import type { TCrumbLabelProps } from "@plane/blocks/breadcrumb"; // local components import { useProjectNavigationPreferences } from "@/hooks/use-navigation-preferences"; import { ProjectBreadcrumb } from "./project"; @@ -11,13 +13,13 @@ import { ProjectBreadcrumb } from "./project"; type TCommonProjectBreadcrumbProps = { workspaceSlug: string; projectId: string; -}; +} & TCrumbLabelProps; export function CommonProjectBreadcrumbs(props: TCommonProjectBreadcrumbProps) { - const { workspaceSlug, projectId } = props; + const { workspaceSlug, projectId, ...crumbProps } = props; // preferences const { preferences: projectPreferences } = useProjectNavigationPreferences(); if (projectPreferences.navigationMode === "TABBED") return null; - return ; + return ; } diff --git a/apps/web/components/breadcrumbs/project.tsx b/apps/web/components/breadcrumbs/project.tsx new file mode 100644 index 00000000000..f05a506d1c9 --- /dev/null +++ b/apps/web/components/breadcrumbs/project.tsx @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import { ProjectsOutline } from "@makeplane/propel/icons"; +// plane imports +import type { BreadcrumbNavigationItem, TCrumbLabelProps } from "@plane/blocks/breadcrumb"; +import { Breadcrumbs, BreadcrumbNavigationSelect } from "@plane/blocks/breadcrumb"; +import { Logo } from "@plane/blocks/emoji-icon-picker"; +import { useTranslation } from "@plane/i18n"; +import { SwitcherLabel } from "@/components/common/switcher-label"; +// hooks +import { useProject } from "@/hooks/store/use-project"; +import { useAppRouter } from "@/hooks/use-app-router"; + +type TProjectBreadcrumbProps = { + workspaceSlug: string; + projectId: string; + handleOnClick?: () => void; +} & TCrumbLabelProps; + +export const ProjectBreadcrumb = observer(function ProjectBreadcrumb(props: TProjectBreadcrumbProps) { + const { workspaceSlug, projectId, handleOnClick, ...crumbProps } = props; + // plane hooks + const { t } = useTranslation(); + // router + const router = useAppRouter(); + // store hooks + const { joinedProjectIds, getPartialProjectById } = useProject(); + const currentProjectDetails = getPartialProjectById(projectId); + + if (!currentProjectDetails) return null; + + // derived values + const switcherOptions = joinedProjectIds + .map((id) => { + const project = getPartialProjectById(id); + if (!project) return undefined; + return { + key: id, + label: project.name, + content: ( + + ), + }; + }) + .filter((option) => option !== undefined); + + return ( + { + router.push(`/${workspaceSlug}/projects/${value}/issues`); + }} + label={currentProjectDetails.name} + icon={} + handleOnClick={() => { + if (handleOnClick) handleOnClick(); + else router.push(`/${workspaceSlug}/projects/${currentProjectDetails.id}/issues/`); + }} + placeholder={t("common.project")} + searchPlaceholder={t("common.search.label")} + emptyMessage={t("common.search.no_matches_found")} + /> + } + /> + ); +}); diff --git a/apps/web/components/breadcrumbs/use-project-crumb-props.ts b/apps/web/components/breadcrumbs/use-project-crumb-props.ts new file mode 100644 index 00000000000..3adf95bd026 --- /dev/null +++ b/apps/web/components/breadcrumbs/use-project-crumb-props.ts @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +// plane imports +import type { TCrumbLabelProps } from "@plane/blocks/breadcrumb"; +// hooks +import { useProject } from "@/hooks/store/use-project"; + +/** + * Ruling 39. The project crumb is rendered through `CommonProjectBreadcrumbs` / `ProjectBreadcrumb`, + * whose element props are ids — so the collapsed overflow row below 640px had nothing to read and + * came out blank and inert. The trail reads `crumbLabel` / `crumbHref` off the wrapper element + * itself, which only the call site can set, and only a call site holding the project can name it. + * + * Spread the result onto the wrapper: + * + * ```tsx + * const projectCrumb = useProjectCrumbProps(workspaceSlug, projectId); + * + * ``` + * + * The href matches the crumb's own `handleOnClick` destination, so the collapsed row goes where + * clicking the crumb goes. + */ +export function useProjectCrumbProps( + workspaceSlug: string | undefined, + projectId: string | undefined +): TCrumbLabelProps { + // store hooks + const { getPartialProjectById } = useProject(); + // derived values + const project = projectId ? getPartialProjectById(projectId) : undefined; + + return { + crumbLabel: project?.name, + crumbHref: workspaceSlug && projectId ? `/${workspaceSlug}/projects/${projectId}/issues/` : undefined, + }; +} diff --git a/apps/web/core/components/browse/workItem-detail.tsx b/apps/web/components/browse/workItem-detail.tsx similarity index 100% rename from apps/web/core/components/browse/workItem-detail.tsx rename to apps/web/components/browse/workItem-detail.tsx diff --git a/apps/web/core/components/chart/utils.ts b/apps/web/components/chart/utils.ts similarity index 100% rename from apps/web/core/components/chart/utils.ts rename to apps/web/components/chart/utils.ts diff --git a/apps/web/components/comments/card/display.tsx b/apps/web/components/comments/card/display.tsx new file mode 100644 index 00000000000..fabb6cdf7db --- /dev/null +++ b/apps/web/components/comments/card/display.tsx @@ -0,0 +1,195 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +import { useCallback, useEffect, useState } from "react"; +import { observer } from "mobx-react"; +import { usePathname } from "next/navigation"; +// plane imports +import { Avatar } from "@makeplane/propel/components/avatar"; +import { ActivityCommentCard, ActivityCommentHeader, ActivityTimelineTimestamp } from "@plane/blocks/activity"; +import type { EditorRefApi } from "@plane/editor"; +import { useHashScroll } from "@plane/hooks"; +import { GlobeOutline, LockOutline } from "@makeplane/propel/icons"; +import { EIssueCommentAccessSpecifier } from "@plane/types"; +import type { TCommentsOperations, TIssueComment } from "@plane/types"; +import { calculateTimeAgo, getFileURL, renderFormattedDate, renderFormattedTime } from "@plane/utils"; +// components +import { LiteTextEditor } from "@/components/editor/lite-text"; +// local imports +import { CommentReactions } from "../comment-reaction"; +import { CommentCardEditForm } from "./edit-form"; +import { EmojiReactionButton, EmojiReactionPicker } from "@plane/blocks/emoji-reaction"; +import { useMember } from "@/hooks/store/use-member"; + +export type TCommentCardDisplayProps = { + activityOperations: TCommentsOperations; + comment: TIssueComment; + disabled: boolean; + entityId: string; + projectId?: string; + readOnlyEditorRef: React.RefObject; + showAccessSpecifier: boolean; + workspaceId: string; + workspaceSlug: string; + isEditing?: boolean; + setIsEditing?: (isEditing: boolean) => void; + renderFooter?: (ReactionsComponent: ReactNode | null) => ReactNode; + renderQuickActions?: () => ReactNode; + /** Draw the timeline rail down to the next entry. */ + showConnector?: boolean; +}; + +export const CommentCardDisplay = observer(function CommentCardDisplay(props: TCommentCardDisplayProps) { + const { + activityOperations, + comment, + disabled, + projectId, + readOnlyEditorRef, + showAccessSpecifier, + workspaceId, + workspaceSlug, + isEditing = false, + setIsEditing, + renderFooter, + renderQuickActions, + showConnector = true, + } = props; + // states + const [isHighlighted, setIsHighlighted] = useState(false); + // state + const [isPickerOpen, setIsPickerOpen] = useState(false); + // store hooks + const { getUserDetails } = useMember(); + // derived values + const userDetails = getUserDetails(comment?.actor); + const displayName = comment?.actor_detail?.is_bot + ? comment?.actor_detail?.first_name + `Bot` + : (userDetails?.display_name ?? comment?.actor_detail?.display_name); + const avatarUrl = userDetails?.avatar_url ?? comment?.actor_detail?.avatar_url; + + const userReactions = activityOperations.userReactions(comment.id); + + // navigation + const pathname = usePathname(); + // derived values + const commentBlockId = `comment-${comment?.id}`; + // Check if there are any reactions to determine if we should render the footer + const reactionIds = activityOperations.reactionIds(comment.id); + const hasReactions = reactionIds && Object.keys(reactionIds).some((key) => reactionIds[key]?.length > 0); + + // scroll to comment + const { isHashMatch } = useHashScroll({ + elementId: commentBlockId, + pathname, + }); + + useEffect(() => { + if (!isHashMatch) return; + setIsHighlighted(true); + const timeout = setTimeout(() => { + setIsHighlighted(false); + }, 8000); + + return () => clearTimeout(timeout); + }, [isHashMatch]); + + const handleEmojiSelect = useCallback( + (emoji: string) => { + if (!userReactions) return; + // emoji is already in decimal string format from EmojiReactionPicker + void activityOperations.react(comment.id, emoji, userReactions); + }, + [activityOperations, comment.id, userReactions] + ); + + const shouldRenderReactions = hasReactions && !disabled; + + const reactions = shouldRenderReactions ? ( + + ) : null; + + return ( + + } + header={ + + ) : ( + + ) + ) : undefined + } + timestamp={ + + {calculateTimeAgo(comment.created_at)} + {comment.edited_at && " (edited)"} + + } + actions={ + !disabled ? ( + <> + } + placement="bottom-start" + /> + {renderQuickActions ? renderQuickActions() : null} + + ) : undefined + } + /> + } + footer={!isEditing && reactions ? (renderFooter ? renderFooter(reactions) : reactions) : undefined} + > +
+ {isEditing && setIsEditing ? ( + + ) : ( + + )} +
+
+ ); +}); diff --git a/apps/web/components/comments/card/edit-form.tsx b/apps/web/components/comments/card/edit-form.tsx new file mode 100644 index 00000000000..52400ebb18a --- /dev/null +++ b/apps/web/components/comments/card/edit-form.tsx @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useEffect, useRef, useState } from "react"; +import { observer } from "mobx-react"; +import { useForm } from "react-hook-form"; +// plane imports +import { Button } from "@makeplane/propel/components/button"; +import { CommentBox } from "@plane/blocks/comment-box"; +import type { EditorRefApi } from "@plane/editor"; +import { useTranslation } from "@plane/i18n"; +import type { TCommentsOperations, TIssueComment } from "@plane/types"; +import { isCommentEmpty } from "@plane/utils"; +// components +import { LiteTextEditor } from "@/components/editor/lite-text"; +import { IssueCommentToolbar } from "@/components/editor/lite-text/toolbar"; + +type Props = { + activityOperations: TCommentsOperations; + comment: TIssueComment; + isEditing: boolean; + projectId?: string; + readOnlyEditorRef: EditorRefApi | null; + setIsEditing: (isEditing: boolean) => void; + workspaceId: string; + workspaceSlug: string; +}; + +export const CommentCardEditForm = observer(function CommentCardEditForm(props: Props) { + const { + activityOperations, + comment, + isEditing, + projectId, + readOnlyEditorRef, + setIsEditing, + workspaceId, + workspaceSlug, + } = props; + const { t } = useTranslation(); + // refs + const editorRef = useRef(null); + // states + const [isEditorReady, setIsEditorReady] = useState(false); + // form info + const { + formState: { isSubmitting }, + handleSubmit, + setFocus, + watch, + setValue, + } = useForm>({ + defaultValues: { comment_html: comment?.comment_html }, + }); + const commentHTML = watch("comment_html"); + + const isEmpty = isCommentEmpty(commentHTML); + const isEditorReadyToDiscard = editorRef.current?.isEditorReadyToDiscard(); + const canSubmit = !isEmpty && isEditorReady && !!isEditorReadyToDiscard; + + const onEnter = async (formData: Partial) => { + if (isSubmitting || !comment) return; + + setIsEditing(false); + + await activityOperations.updateComment(comment.id, formData); + + editorRef.current?.setEditorValue(formData?.comment_html ?? "

"); + readOnlyEditorRef?.setEditorValue(formData?.comment_html ?? "

"); + }; + + const handleCancel = () => { + setIsEditing(false); + editorRef.current?.setEditorValue(comment.comment_html ?? "

"); + }; + + useEffect(() => { + if (isEditing) { + setFocus("comment_html"); + } + }, [isEditing, setFocus]); + + return ( + void handleSubmit(onEnter)()} + canSubmit={canSubmit} + isSubmitting={isSubmitting} + toolbar={ +
+
+ { + // TODO: update this while toolbar homogenization + // @ts-expect-error type mismatch here + editorRef.current?.executeMenuItemCommand({ + itemKey: item.itemKey, + ...item.extraProps, + }); + }} + handleSubmit={() => void handleSubmit(onEnter)()} + isCommentEmpty={isEmpty} + isSubmitting={isSubmitting} + showAccessSpecifier={false} + showSubmitButton={false} + editorRef={isEditorReady ? editorRef.current : null} + /> +
+
+ } + editor={ + // Scoped to the editor so Enter on Cancel or a toolbar control activates it instead of saving. +
{ + if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && !isEmpty) handleSubmit(onEnter)(e); + }} + > + setValue("comment_html", comment_html)} + onEnterKeyPress={(e) => { + if (!isEmpty && !isSubmitting) { + handleSubmit(onEnter)(e); + } + }} + showSubmitButton={false} + uploadFile={async (blockId, file) => { + const { asset_id } = await activityOperations.uploadCommentAsset(blockId, file, comment.id); + return asset_id; + }} + duplicateFile={async (assetId: string) => { + const { asset_id } = await activityOperations.duplicateCommentAsset(assetId, comment.id); + return asset_id; + }} + projectId={projectId} + containerClassName="min-h-min max-h-[200px] overflow-y-auto overscroll-contain" + variant="none" + parentClassName="w-full rounded-none border-0 p-0" + displayConfig={{ + fontSize: "small-font", + }} + /> +
+ } + /> + ); +}); diff --git a/apps/web/components/comments/card/root.tsx b/apps/web/components/comments/card/root.tsx new file mode 100644 index 00000000000..6bcbac8b060 --- /dev/null +++ b/apps/web/components/comments/card/root.tsx @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useRef, useState } from "react"; +import { observer } from "mobx-react"; +// plane imports +import type { EditorRefApi } from "@plane/editor"; +import type { TIssueComment, TCommentsOperations } from "@plane/types"; +// local imports +import { CommentQuickActions } from "../quick-actions"; +import { CommentCardDisplay } from "./display"; + +type TCommentCard = { + workspaceSlug: string; + entityId: string; + comment: TIssueComment | undefined; + activityOperations: TCommentsOperations; + ends: "top" | "bottom" | undefined; + showAccessSpecifier: boolean; + showCopyLinkOption: boolean; + enableReplies: boolean; + disabled?: boolean; + projectId?: string; +}; + +export const CommentCard = observer(function CommentCard(props: TCommentCard) { + const { + workspaceSlug, + entityId, + comment, + activityOperations, + ends, + showAccessSpecifier, + showCopyLinkOption, + disabled = false, + projectId, + } = props; + // states + const [isEditing, setIsEditing] = useState(false); + // refs + const readOnlyEditorRef = useRef(null); + // derived values + const workspaceId = comment?.workspace; + + if (!comment || !workspaceId) return null; + + return ( + ( + setIsEditing(true)} + showAccessSpecifier={showAccessSpecifier} + showCopyLinkOption={showCopyLinkOption} + /> + )} + /> + ); +}); diff --git a/apps/web/components/comments/comment-create.tsx b/apps/web/components/comments/comment-create.tsx new file mode 100644 index 00000000000..e0c51898334 --- /dev/null +++ b/apps/web/components/comments/comment-create.tsx @@ -0,0 +1,184 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useRef, useState } from "react"; +import { observer } from "mobx-react"; +import { useForm, Controller } from "react-hook-form"; +// plane imports +import { CommentBox } from "@plane/blocks/comment-box"; +import { EIssueCommentAccessSpecifier } from "@plane/constants"; +import type { EditorRefApi } from "@plane/editor"; +import { useTranslation } from "@plane/i18n"; +import type { TIssueComment, TCommentsOperations } from "@plane/types"; +import { isCommentEmpty } from "@plane/utils"; +// components +import { LiteTextEditor } from "@/components/editor/lite-text"; +import { IssueCommentToolbar } from "@/components/editor/lite-text/toolbar"; +// hooks +import { useWorkspace } from "@/hooks/store/use-workspace"; +// services +import { FileService } from "@/services/file.service"; + +type TCommentCreate = { + entityId: string; + workspaceSlug: string; + activityOperations: TCommentsOperations; + projectId?: string; + onSubmitCallback?: (elementId: string) => void; +}; + +// services +const fileService = new FileService(); + +export const CommentCreate = observer(function CommentCreate(props: TCommentCreate) { + const { workspaceSlug, entityId, activityOperations, projectId, onSubmitCallback } = props; + // translation + const { t } = useTranslation(); + // states + const [uploadedAssetIds, setUploadedAssetIds] = useState([]); + const [isEditorReady, setIsEditorReady] = useState(false); + // refs + const editorRef = useRef(null); + // store hooks + const workspaceStore = useWorkspace(); + // derived values + const workspaceId = workspaceStore.getWorkspaceBySlug(workspaceSlug)?.id as string; + // form info + const { + handleSubmit, + control, + watch, + formState: { isSubmitting }, + reset, + } = useForm>({ + defaultValues: { + comment_html: "

", + }, + }); + + const onSubmit = async (formData: Partial) => { + try { + const comment = await activityOperations.createComment(formData); + if (comment?.id) onSubmitCallback?.(comment.id); + if (uploadedAssetIds.length > 0) { + if (projectId) { + await fileService.updateBulkProjectAssetsUploadStatus(workspaceSlug, projectId.toString(), entityId, { + asset_ids: uploadedAssetIds, + }); + } else { + await fileService.updateBulkWorkspaceAssetsUploadStatus(workspaceSlug, entityId, { + asset_ids: uploadedAssetIds, + }); + } + setUploadedAssetIds([]); + } + } catch (error) { + console.error(error); + } finally { + reset({ + comment_html: "

", + }); + editorRef.current?.clearEditor(); + } + }; + + const commentHTML = watch("comment_html"); + const isEmpty = isCommentEmpty(commentHTML ?? undefined); + const canSubmit = !isEmpty && isEditorReady && !!editorRef.current?.isEditorReadyToDiscard(); + + return ( +
{ + if ( + e.key === "Enter" && + !e.shiftKey && + !e.ctrlKey && + !e.metaKey && + !isEmpty && + !isSubmitting && + editorRef.current?.isEditorReadyToDiscard() + ) + handleSubmit(onSubmit)(e); + }} + > + ( + ( + void handleSubmit(onSubmit)()} + canSubmit={canSubmit} + isSubmitting={isSubmitting} + toolbar={ + { + // TODO: update this while toolbar homogenization + // @ts-expect-error type mismatch here + editorRef.current?.executeMenuItemCommand({ + itemKey: item.itemKey, + ...item.extraProps, + }); + }} + handleSubmit={(e) => void handleSubmit(onSubmit)(e)} + isCommentEmpty={isEmpty} + isSubmitting={isSubmitting} + showAccessSpecifier={false} + showSubmitButton={false} + editorRef={isEditorReady ? editorRef.current : null} + /> + } + editor={ +

"} + workspaceSlug={workspaceSlug} + projectId={projectId} + onEnterKeyPress={(e) => { + if (!isEmpty && !isSubmitting) { + handleSubmit(onSubmit)(e); + } + }} + ref={editorRef} + handleEditorReady={setIsEditorReady} + initialValue={value ?? "

"} + containerClassName="min-h-min max-h-[200px] overflow-y-auto overscroll-contain" + onChange={(comment_json, comment_html) => onChange(comment_html)} + isSubmitting={isSubmitting} + uploadFile={async (blockId, file) => { + const { asset_id } = await activityOperations.uploadCommentAsset(blockId, file); + setUploadedAssetIds((prev) => [...prev, asset_id]); + return asset_id; + }} + duplicateFile={async (assetId: string) => { + const { asset_id } = await activityOperations.duplicateCommentAsset(assetId); + setUploadedAssetIds((prev) => [...prev, asset_id]); + return asset_id; + }} + variant="none" + parentClassName="w-full rounded-none border-0 p-0" + displayConfig={{ + fontSize: "small-font", + }} + /> + } + /> + )} + /> + )} + /> +
+ ); +}); diff --git a/apps/web/core/components/comments/comment-reaction.tsx b/apps/web/components/comments/comment-reaction.tsx similarity index 79% rename from apps/web/core/components/comments/comment-reaction.tsx rename to apps/web/components/comments/comment-reaction.tsx index 709de31e81b..d13c3cc0bdd 100644 --- a/apps/web/core/components/comments/comment-reaction.tsx +++ b/apps/web/components/comments/comment-reaction.tsx @@ -7,9 +7,9 @@ import { useMemo, useState } from "react"; import { observer } from "mobx-react"; // plane imports -import { stringToEmoji } from "@plane/propel/emoji-icon-picker"; -import { EmojiReactionGroup, EmojiReactionPicker } from "@plane/propel/emoji-reaction"; -import type { EmojiReactionType } from "@plane/propel/emoji-reaction"; +import { stringToEmoji } from "@plane/blocks/emoji-icon-picker"; +import { EmojiReactionButton, EmojiReactionGroup, EmojiReactionPicker } from "@plane/blocks/emoji-reaction"; +import type { EmojiReactionType } from "@plane/blocks/emoji-reaction"; import type { TCommentsOperations, TIssueComment } from "@plane/types"; // helpers // local imports @@ -73,20 +73,21 @@ export const CommentReactions = observer(function CommentReactions(props: TProps return (
- setIsPickerOpen(true)} + reactions={reactions} + onReactionClick={handleReactionClick} + showAddButton={showAddButton} + addReactionButton={ + } + placement="bottom-start" /> } - placement="bottom-start" />
); diff --git a/apps/web/core/components/comments/comments.tsx b/apps/web/components/comments/comments.tsx similarity index 96% rename from apps/web/core/components/comments/comments.tsx rename to apps/web/components/comments/comments.tsx index 88befc2de26..4448af621e0 100644 --- a/apps/web/core/components/comments/comments.tsx +++ b/apps/web/components/comments/comments.tsx @@ -76,7 +76,7 @@ export const CommentsWrapper = observer(function CommentsWrapper(props: TComment comment={comment} activityOperations={activityOperations} disabled={!isEditingAllowed} - ends={index === 0 ? "top" : index === comments.length - 1 ? "bottom" : undefined} + ends={index === comments.length - 1 ? "bottom" : index === 0 ? "top" : undefined} projectId={projectId} showAccessSpecifier={showAccessSpecifier} showCopyLinkOption={showCopyLinkOption} diff --git a/apps/web/core/components/comments/index.ts b/apps/web/components/comments/index.ts similarity index 100% rename from apps/web/core/components/comments/index.ts rename to apps/web/components/comments/index.ts diff --git a/apps/web/components/comments/quick-actions.tsx b/apps/web/components/comments/quick-actions.tsx new file mode 100644 index 00000000000..6668d233b37 --- /dev/null +++ b/apps/web/components/comments/quick-actions.tsx @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useMemo } from "react"; +import { observer } from "mobx-react"; +import { + DeleteOutline, + EditOutline, + GlobeOutline, + LinkOutline, + LockOutline, + MoreHorizontalOutline, +} from "@makeplane/propel/icons"; +// plane imports +import { EIssueCommentAccessSpecifier } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; +import { Icon } from "@makeplane/propel/components/icon"; +import { IconButton } from "@makeplane/propel/components/icon-button"; +import { Menu, MenuContent, MenuItem, MenuTrigger } from "@makeplane/propel/components/menu"; +import type { TIssueComment, TCommentsOperations } from "@plane/types"; +import type { TContextMenuItem } from "@plane/blocks/context-menu"; +import { resolveItemVariant } from "@plane/blocks/context-menu"; +// hooks +import { useUser } from "@/hooks/store/user"; + +type TCommentCard = { + activityOperations: TCommentsOperations; + comment: TIssueComment; + setEditMode: () => void; + showAccessSpecifier: boolean; + showCopyLinkOption: boolean; +}; + +export const CommentQuickActions = observer(function CommentQuickActions(props: TCommentCard) { + const { activityOperations, comment, setEditMode, showAccessSpecifier, showCopyLinkOption } = props; + // store hooks + const { data: currentUser } = useUser(); + // derived values + const isAuthor = currentUser?.id === comment.actor; + const canEdit = isAuthor; + const canDelete = isAuthor; + // translation + const { t } = useTranslation(); + + const MENU_ITEMS = useMemo( + function MENU_ITEMS(): TContextMenuItem[] { + return [ + { + key: "edit", + action: setEditMode, + title: t("common.actions.edit"), + icon: EditOutline, + shouldRender: canEdit, + }, + { + key: "copy_link", + action: () => activityOperations.copyCommentLink(comment.id), + title: t("common.actions.copy_link"), + icon: LinkOutline, + shouldRender: showCopyLinkOption, + }, + { + key: "access_specifier", + action: () => + activityOperations.updateComment(comment.id, { + access: + comment.access === EIssueCommentAccessSpecifier.INTERNAL + ? EIssueCommentAccessSpecifier.EXTERNAL + : EIssueCommentAccessSpecifier.INTERNAL, + }), + title: + comment.access === EIssueCommentAccessSpecifier.INTERNAL + ? t("issue.comments.switch.public") + : t("issue.comments.switch.private"), + icon: comment.access === EIssueCommentAccessSpecifier.INTERNAL ? GlobeOutline : LockOutline, + shouldRender: showAccessSpecifier, + }, + { + key: "delete", + action: () => activityOperations.removeComment(comment.id), + title: t("common.actions.delete"), + icon: DeleteOutline, + shouldRender: canDelete, + }, + ].filter((item) => item.shouldRender !== false); + }, + [t, setEditMode, canEdit, showCopyLinkOption, activityOperations, comment, showAccessSpecifier, canDelete] + ); + + if (MENU_ITEMS.length === 0) return null; + + return ( + + } + aria-label={t("common.options")} + variant="ghost" + size="xs" + /> + } + /> + + {MENU_ITEMS.map((item) => ( + : undefined} + disabled={item.disabled} + onClick={() => item.action()} + /> + ))} + + + ); +}); diff --git a/apps/web/core/components/common/access-field.tsx b/apps/web/components/common/access-field.tsx similarity index 76% rename from apps/web/core/components/common/access-field.tsx rename to apps/web/components/common/access-field.tsx index 0df21b1805a..0c7efe4cbbe 100644 --- a/apps/web/core/components/common/access-field.tsx +++ b/apps/web/components/common/access-field.tsx @@ -4,11 +4,11 @@ * See the LICENSE file for details. */ -import type { LucideIcon } from "lucide-react"; +import type { IconGlyph } from "@makeplane/propel/components/icon"; // plane ui import { useTranslation } from "@plane/i18n"; -import type { ISvgIcons } from "@plane/propel/icons"; -import { Tooltip } from "@plane/propel/tooltip"; +import type { ISvgIcons } from "@plane/blocks/icons"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; // plane utils import { cn } from "@plane/utils"; @@ -17,14 +17,12 @@ type Props = { value: number; accessSpecifiers: { key: number; - i18n_label?: string; - label?: string; - icon: LucideIcon | React.FC; + i18n_label: string; + icon: IconGlyph | React.FC; }[]; isMobile?: boolean; }; -// TODO: Remove label once i18n is done export function AccessField(props: Props) { const { onChange, value, accessSpecifiers, isMobile = false } = props; const { t } = useTranslation(); @@ -32,11 +30,12 @@ export function AccessField(props: Props) { return (
{accessSpecifiers.map((access, index) => { - const label = access.i18n_label ? t(access.i18n_label) : access.label; + const label = t(access.i18n_label); return ( - +
+
+
+ ); +} diff --git a/apps/web/core/components/common/extended-app-header.tsx b/apps/web/components/common/extended-app-header.tsx similarity index 100% rename from apps/web/core/components/common/extended-app-header.tsx rename to apps/web/components/common/extended-app-header.tsx diff --git a/apps/web/components/common/filters/created-at.tsx b/apps/web/components/common/filters/created-at.tsx new file mode 100644 index 00000000000..175bb7fc63d --- /dev/null +++ b/apps/web/components/common/filters/created-at.tsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane imports +import { DATE_BEFORE_FILTER_OPTIONS } from "@plane/constants"; +// local imports +import { DateFilterSubmenu, isCustomDateFilterValue } from "./date-filter-submenu"; + +type Props = { + appliedFilters: string[] | null; + handleUpdate: (val: string | string[]) => void; +}; + +export const FilterCreatedDate = observer(function FilterCreatedDate(props: Props) { + const { appliedFilters, handleUpdate } = props; + + return ( + handleUpdate((appliedFilters ?? []).filter(isCustomDateFilterValue))} + /> + ); +}); diff --git a/apps/web/components/common/filters/created-by.tsx b/apps/web/components/common/filters/created-by.tsx new file mode 100644 index 00000000000..41f4dc18f2f --- /dev/null +++ b/apps/web/components/common/filters/created-by.tsx @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// local imports +import { MemberFilterSubmenu } from "./member-filter-submenu"; + +type Props = { + appliedFilters: string[] | null; + handleUpdate: (val: string) => void; + memberIds: string[] | undefined; +}; + +export const FilterCreatedBy = observer(function FilterCreatedBy(props: Props) { + const { appliedFilters, handleUpdate, memberIds } = props; + + return ( + + ); +}); diff --git a/apps/web/components/common/filters/date-filter-modal-context.ts b/apps/web/components/common/filters/date-filter-modal-context.ts new file mode 100644 index 00000000000..b294222faa9 --- /dev/null +++ b/apps/web/components/common/filters/date-filter-modal-context.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { createContext, useContext } from "react"; + +export type TDateFilterModalRequest = { + /** Modal heading — the date property being filtered. */ + title: string; + /** Receives the custom range the user picked, e.g. `["2026-01-01;after", "2026-02-01;before"]`. */ + onSelect: (value: string[]) => void; +}; + +type TDateFilterModalContext = { + openDateFilterModal: (request: TDateFilterModalRequest) => void; +}; + +export const DateFilterModalContext = createContext(null); + +/** + * The custom-range opener of the nearest `DateFilterModalHost`, or `null` when the menu has none — a + * date submenu then simply offers no "Custom" row. + */ +export const useDateFilterModal = () => useContext(DateFilterModalContext); diff --git a/apps/web/components/common/filters/date-filter-modal-host.tsx b/apps/web/components/common/filters/date-filter-modal-host.tsx new file mode 100644 index 00000000000..a4ced8bc11b --- /dev/null +++ b/apps/web/components/common/filters/date-filter-modal-host.tsx @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +import { useCallback, useMemo, useState } from "react"; +// components +import { DateFilterModal } from "@/components/core/filters/date-filter-modal"; +// local imports +import type { TDateFilterModalRequest } from "./date-filter-modal-context"; +import { DateFilterModalContext } from "./date-filter-modal-context"; + +/** + * Renders the custom date-range modal for the date submenus of a filters menu. + * + * Menu popups unmount as soon as the menu closes, so a modal rendered from a submenu row would be + * torn down with it. This host wraps the whole `Menu` instead and the rows only ask it to open. + */ +export function DateFilterModalHost({ children }: { children: ReactNode }) { + const [request, setRequest] = useState(null); + + const openDateFilterModal = useCallback((nextRequest: TDateFilterModalRequest) => setRequest(nextRequest), []); + const contextValue = useMemo(() => ({ openDateFilterModal }), [openDateFilterModal]); + + return ( + + {children} + {request && ( + setRequest(null)} + onSelect={(value) => request.onSelect(value)} + /> + )} + + ); +} diff --git a/apps/web/components/common/filters/date-filter-submenu.tsx b/apps/web/components/common/filters/date-filter-submenu.tsx new file mode 100644 index 00000000000..ba013fc4c65 --- /dev/null +++ b/apps/web/components/common/filters/date-filter-submenu.tsx @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane imports +import { + MenuCheckboxItem, + MenuSubmenu, + MenuSubmenuContent, + MenuSubmenuTrigger, +} from "@makeplane/propel/components/menu"; +import { isInDateFormat } from "@plane/utils"; +// local imports +import { useDateFilterModal } from "./date-filter-modal-context"; +import { FilterSubmenuCount } from "./filter-submenu"; + +type Props = { + /** The date property, shown on the row that opens the submenu and as the custom-range modal title. */ + label: string; + /** Relative presets, e.g. `DATE_AFTER_FILTER_OPTIONS`. */ + options: { name: string; value: string }[]; + appliedFilters: string[] | null | undefined; + /** Toggles one preset. */ + onToggleOption: (value: string) => void; + /** Applies the range picked in the custom-range modal. */ + onSelectCustomRange: (value: string[]) => void; + /** Drops the applied custom range. */ + onClearCustomRange: () => void; +}; + +/** A custom range is stored as literal `YYYY-MM-DD;after|before` values rather than a preset. */ +export const isCustomDateFilterValue = (value: string) => isInDateFormat(value.split(";")[0]); + +/** + * A date property of a filters menu: its relative presets as checkable rows, plus a "Custom" row + * that opens the custom-range modal through the surrounding `DateFilterModalHost`. + */ +export const DateFilterSubmenu = observer(function DateFilterSubmenu(props: Props) { + const { label, options, appliedFilters, onToggleOption, onSelectCustomRange, onClearCustomRange } = props; + // context hooks + const dateFilterModal = useDateFilterModal(); + // derived values + const appliedValues = new Set(appliedFilters ?? []); + const isCustomRangeApplied = (appliedFilters ?? []).some(isCustomDateFilterValue); + + return ( + + } /> + + {options.map((option) => ( + onToggleOption(option.value)} + /> + ))} + {dateFilterModal && ( + { + if (isCustomRangeApplied) onClearCustomRange(); + else dateFilterModal.openDateFilterModal({ title: label, onSelect: onSelectCustomRange }); + }} + /> + )} + + + ); +}); diff --git a/apps/web/components/common/filters/filter-submenu.tsx b/apps/web/components/common/filters/filter-submenu.tsx new file mode 100644 index 00000000000..64f8a7cf9f5 --- /dev/null +++ b/apps/web/components/common/filters/filter-submenu.tsx @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +import { useState } from "react"; +// plane imports +import { + MenuCheckboxItem, + MenuSearch, + MenuSubmenu, + MenuSubmenuContent, + MenuSubmenuTrigger, +} from "@makeplane/propel/components/menu"; +import { useTranslation } from "@plane/i18n"; + +export type TFilterSubmenuOption = { + value: V; + label: string; + icon?: ReactNode; + /** Content pinned at the row's end, e.g. a marker for the current cycle. */ + trailing?: ReactNode; + /** Text the search matches besides `label`, e.g. a member's name on a row labelled "You". */ + searchText?: string; +}; + +type Props = { + /** The filter property, shown on the row that opens the submenu. */ + label: string; + options: TFilterSubmenuOption[]; + appliedFilters: V[] | null | undefined; + onToggle: (value: V) => void; + /** Pins a search field above the options; meant for lists that can grow long (members, labels…). */ + searchable?: boolean; + /** Extra rows rendered after the options, e.g. a date filter's "Custom" row. */ + children?: ReactNode; + onOpenChange?: (open: boolean) => void; +}; + +/** Number of applied values, shown at the end of a filter property's row. */ +export function FilterSubmenuCount({ count }: { count: number }) { + if (count <= 0) return null; + return {count}; +} + +/** + * One property of a filters menu: a row carrying the applied count that opens a submenu of + * checkable values. + */ +export function FilterSubmenu(props: Props) { + const { label, options, appliedFilters, onToggle, searchable = false, children, onOpenChange } = props; + // plane hooks + const { t } = useTranslation(); + // states + const [searchQuery, setSearchQuery] = useState(""); + // derived values + const appliedValues = new Set(appliedFilters ?? []); + const query = searchQuery.trim().toLowerCase(); + const visibleOptions = query + ? options.filter((option) => `${option.label} ${option.searchText ?? ""}`.toLowerCase().includes(query)) + : options; + + return ( + onOpenChange?.(open)}> + } /> + + ) : undefined + } + > + {visibleOptions.length > 0 ? ( + visibleOptions.map((option) => ( + onToggle(option.value)} + /> + )) + ) : ( +

{t("common.search.no_matches_found")}

+ )} + {children} +
+
+ ); +} diff --git a/apps/web/components/common/filters/member-filter-submenu.tsx b/apps/web/components/common/filters/member-filter-submenu.tsx new file mode 100644 index 00000000000..71e7a4a7aa2 --- /dev/null +++ b/apps/web/components/common/filters/member-filter-submenu.tsx @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useMemo, useState } from "react"; +import { sortBy } from "lodash-es"; +import { observer } from "mobx-react"; +// plane imports +import { Avatar } from "@makeplane/propel/components/avatar"; +import { useTranslation } from "@plane/i18n"; +import { getFileURL } from "@plane/utils"; +// hooks +import { useMember } from "@/hooks/store/use-member"; +import { useUser } from "@/hooks/store/user"; +// local imports +import type { TFilterSubmenuOption } from "./filter-submenu"; +import { FilterSubmenu } from "./filter-submenu"; + +type Props = { + /** The member property — "Lead", "Members", "Assignees", "Created by"… */ + label: string; + memberIds: string[] | undefined; + appliedFilters: string[] | null | undefined; + onToggle: (memberId: string) => void; +}; + +/** + * A searchable member submenu for a filters menu. Applied members and then the current user lead the + * list; the order is taken when the submenu opens so rows do not jump while being toggled. + */ +export const MemberFilterSubmenu = observer(function MemberFilterSubmenu(props: Props) { + const { label, memberIds, appliedFilters, onToggle } = props; + // plane hooks + const { t } = useTranslation(); + // store hooks + const { getUserDetails } = useMember(); + const { data: currentUser } = useUser(); + // states + const [pinnedIds, setPinnedIds] = useState(appliedFilters ?? []); + + const options = useMemo(() => { + const pinned = new Set(pinnedIds); + const sortedIds = sortBy(memberIds ?? [], [ + (memberId) => !pinned.has(memberId), + (memberId) => memberId !== currentUser?.id, + (memberId) => getUserDetails(memberId)?.display_name.toLowerCase(), + ]); + + return sortedIds.flatMap((memberId) => { + const member = getUserDetails(memberId); + if (!member) return []; + return [ + { + value: member.id, + label: currentUser?.id === member.id ? t("common.you") : member.display_name, + searchText: member.display_name, + icon: ( + + ), + }, + ]; + }); + }, [memberIds, pinnedIds, currentUser?.id, getUserDetails, t]); + + return ( + { + if (open) setPinnedIds(appliedFilters ?? []); + }} + /> + ); +}); diff --git a/apps/web/core/components/common/latest-feature-block.tsx b/apps/web/components/common/latest-feature-block.tsx similarity index 83% rename from apps/web/core/components/common/latest-feature-block.tsx rename to apps/web/components/common/latest-feature-block.tsx index 7ea1289b2db..8fa87619a28 100644 --- a/apps/web/core/components/common/latest-feature-block.tsx +++ b/apps/web/components/common/latest-feature-block.tsx @@ -7,7 +7,7 @@ import Link from "next/link"; import { useTheme } from "next-themes"; // icons -import { Lightbulb } from "lucide-react"; +import { ThoughtsOutline } from "@makeplane/propel/icons"; // images import latestFeatures from "@/app/assets/onboarding/onboarding-pages.webp?url"; @@ -17,11 +17,11 @@ export function LatestFeatureBlock() { return ( <>
- -

+ +

Pages gets a facelift! Write anything and use Galileo to help you start.{" "} - Learn more + Learn more

diff --git a/apps/web/core/components/common/layout-error-boundary.tsx b/apps/web/components/common/layout-error-boundary.tsx similarity index 79% rename from apps/web/core/components/common/layout-error-boundary.tsx rename to apps/web/components/common/layout-error-boundary.tsx index 74ef8f3fbb8..dd5181887ee 100644 --- a/apps/web/core/components/common/layout-error-boundary.tsx +++ b/apps/web/components/common/layout-error-boundary.tsx @@ -6,9 +6,9 @@ import { Component, Fragment } from "react"; import type { ErrorInfo, ReactNode } from "react"; -import { AlertTriangle } from "lucide-react"; +import { WarningTriangleOutline } from "@makeplane/propel/icons"; import { useTranslation } from "@plane/i18n"; -import { Button } from "@plane/propel/button"; +import { Button } from "@makeplane/propel/components/button"; type Props = { children: ReactNode; @@ -24,11 +24,9 @@ function LayoutErrorFallback({ onRetry }: { onRetry: () => void }) { return (
- -

{t("something_went_wrong")}

- + +

{t("something_went_wrong")}

+
); } diff --git a/apps/web/components/common/layout/sidebar/property-list-item.tsx b/apps/web/components/common/layout/sidebar/property-list-item.tsx new file mode 100644 index 00000000000..da2e52143e5 --- /dev/null +++ b/apps/web/components/common/layout/sidebar/property-list-item.tsx @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import { cn } from "@plane/utils"; + +type TSidebarPropertyListItemProps = { + icon: React.FC<{ className?: string }>; + label: string; + children: ReactNode; + appendElement?: ReactNode; + childrenClassName?: string; +}; + +export function SidebarPropertyListItem(props: TSidebarPropertyListItemProps) { + const { icon: Icon, label, children, appendElement, childrenClassName } = props; + + return ( +
+
+ {/* Top-aligned so the icon stays beside the first line when a long label wraps. */} +
+ + + + + {label} + + {appendElement} +
+
+
{children}
+
+ ); +} diff --git a/apps/web/core/components/common/logo-spinner.tsx b/apps/web/components/common/logo-spinner.tsx similarity index 100% rename from apps/web/core/components/common/logo-spinner.tsx rename to apps/web/components/common/logo-spinner.tsx diff --git a/apps/web/core/components/common/modal/global.tsx b/apps/web/components/common/modal/global.tsx similarity index 100% rename from apps/web/core/components/common/modal/global.tsx rename to apps/web/components/common/modal/global.tsx diff --git a/apps/web/components/common/page-access-icon.tsx b/apps/web/components/common/page-access-icon.tsx new file mode 100644 index 00000000000..1e90b36d4f4 --- /dev/null +++ b/apps/web/components/common/page-access-icon.tsx @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { ArchiveOutline, GlobeOutline, LockOutline } from "@makeplane/propel/icons"; +import { EPageAccess } from "@plane/constants"; +import type { TPage } from "@plane/types"; + +export function PageAccessIcon(page: TPage) { + return ( +
+ {page.archived_at ? ( + + ) : page.access === EPageAccess.PUBLIC ? ( + + ) : ( + + )} +
+ ); +} diff --git a/apps/web/components/common/pro-icon.tsx b/apps/web/components/common/pro-icon.tsx new file mode 100644 index 00000000000..6f7043714d6 --- /dev/null +++ b/apps/web/components/common/pro-icon.tsx @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { UpgradeOutline } from "@makeplane/propel/icons"; +// helpers +import { cn } from "@plane/utils"; + +type TProIcon = { + className?: string; +}; + +export function ProIcon(props: TProIcon) { + const { className } = props; + + return ; +} diff --git a/apps/web/core/components/common/quick-actions-factory.tsx b/apps/web/components/common/quick-actions-factory.tsx similarity index 82% rename from apps/web/core/components/common/quick-actions-factory.tsx rename to apps/web/components/common/quick-actions-factory.tsx index ee7f8fb5f76..d554ae186ee 100644 --- a/apps/web/core/components/common/quick-actions-factory.tsx +++ b/apps/web/components/common/quick-actions-factory.tsx @@ -4,10 +4,16 @@ * See the LICENSE file for details. */ -import { Pencil, ExternalLink, Link, Trash2, ArchiveRestoreIcon } from "lucide-react"; +import { + ArchiveOutline, + DeleteOutline, + EditOutline, + LinkOutline, + NewTabOutline, + RestoreOutline, +} from "@makeplane/propel/icons"; import { useTranslation } from "@plane/i18n"; -import { ArchiveIcon } from "@plane/propel/icons"; -import type { TContextMenuItem } from "@plane/ui"; +import type { TContextMenuItem } from "@plane/blocks/context-menu"; /** * Unified factory for creating menu items across all entities (cycles, modules, views, epics) @@ -20,7 +26,7 @@ export const useQuickActionsFactory = () => { createEditMenuItem: (handler: () => void, shouldRender: boolean = true): TContextMenuItem => ({ key: "edit", title: t("edit"), - icon: Pencil, + icon: EditOutline, action: handler, shouldRender, }), @@ -28,14 +34,14 @@ export const useQuickActionsFactory = () => { createOpenInNewTabMenuItem: (handler: () => void): TContextMenuItem => ({ key: "open-new-tab", title: t("open_in_new_tab"), - icon: ExternalLink, + icon: NewTabOutline, action: handler, }), createCopyLinkMenuItem: (handler: () => void): TContextMenuItem => ({ key: "copy-link", title: t("copy_link"), - icon: Link, + icon: LinkOutline, action: handler, }), @@ -45,10 +51,8 @@ export const useQuickActionsFactory = () => { ): TContextMenuItem => ({ key: "archive", title: t("archive"), - icon: ArchiveIcon, + icon: ArchiveOutline, action: handler, - className: "items-start", - iconClassName: "mt-1", description: opts.description, disabled: opts.disabled, shouldRender: opts.shouldRender, @@ -57,7 +61,7 @@ export const useQuickActionsFactory = () => { createRestoreMenuItem: (handler: () => void, shouldRender: boolean = true): TContextMenuItem => ({ key: "restore", title: t("restore"), - icon: ArchiveRestoreIcon, + icon: RestoreOutline, action: handler, shouldRender, }), @@ -65,7 +69,7 @@ export const useQuickActionsFactory = () => { createDeleteMenuItem: (handler: () => void, shouldRender: boolean = true): TContextMenuItem => ({ key: "delete", title: t("delete"), - icon: Trash2, + icon: DeleteOutline, action: handler, shouldRender, }), @@ -74,14 +78,14 @@ export const useQuickActionsFactory = () => { createOpenInNewTab: (handler: () => void): TContextMenuItem => ({ key: "open-in-new-tab", title: "Open in new tab", - icon: ExternalLink, + icon: NewTabOutline, action: handler, }), createCopyLayoutLinkMenuItem: (handler: () => void): TContextMenuItem => ({ key: "copy-link", title: "Copy link", - icon: Link, + icon: LinkOutline, action: handler, }), }; diff --git a/apps/web/core/components/common/quick-actions-helper.tsx b/apps/web/components/common/quick-actions-helper.tsx similarity index 96% rename from apps/web/core/components/common/quick-actions-helper.tsx rename to apps/web/components/common/quick-actions-helper.tsx index a79b440248e..58754db38cf 100644 --- a/apps/web/core/components/common/quick-actions-helper.tsx +++ b/apps/web/components/common/quick-actions-helper.tsx @@ -4,9 +4,11 @@ * See the LICENSE file for details. */ +// @types/react 19 removed the global JSX namespace; it is imported from react now. +import type { JSX } from "react"; // types import type { ICycle, IModule, IProjectView, IWorkspaceView } from "@plane/types"; -import type { TContextMenuItem } from "@plane/ui"; +import type { TContextMenuItem } from "@plane/blocks/context-menu"; // hooks import { useQuickActionsFactory } from "@/components/common/quick-actions-factory"; diff --git a/apps/web/components/common/removable-chip.tsx b/apps/web/components/common/removable-chip.tsx new file mode 100644 index 00000000000..d9978a75175 --- /dev/null +++ b/apps/web/components/common/removable-chip.tsx @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +// plane imports +import { Icon } from "@makeplane/propel/components/icon"; +import { IconButton } from "@makeplane/propel/components/icon-button"; +import { ComboboxChip } from "@makeplane/propel/elements/combobox"; +import type { ComboboxChipSize } from "@makeplane/propel/elements/combobox"; +import { CloseOutline } from "@makeplane/propel/icons"; +import { useTranslation } from "@plane/i18n"; +import { cn } from "@plane/utils"; + +export type TRemovableChipVariant = "outline" | "soft"; + +// `outline` keeps the chip's own bordered layer-2 surface; `soft` drops the border and sits one +// layer up, for chips nested inside an already bordered layer-2 filter group. +const VARIANT_CLASSNAMES: Record = { + outline: "", + soft: "border-transparent bg-layer-3", +}; + +type Props = { + /** Shown before the label: an avatar, a state or priority icon, a colour dot… */ + icon?: ReactNode; + label: ReactNode; + /** Plain-text name of the value, used to name the remove control. */ + ariaLabel: string; + /** @default "outline" */ + variant?: TRemovableChipVariant; + /** @default "xs" */ + size?: ComboboxChipSize; + /** Leave out for a read-only chip without a remove control. */ + onRemove?: () => void; + className?: string; +}; + +/** + * A selected value shown as a chip, with a remove control unless it is read-only — the chip every + * applied-filters row renders for each of its values. + */ +export function RemovableChip(props: Props) { + const { icon, label, ariaLabel, variant = "outline", size = "xs", onRemove, className } = props; + // plane hooks + const { t } = useTranslation(); + + return ( + ( +
+ )} + > + {icon} + {label} + {onRemove && ( + } + /> + )} + + ); +} + +/** + * The bordered frame one applied filter sits in: the property name, its value chips (the `soft` + * variant) and the control that clears the property. + */ +export const APPLIED_FILTER_GROUP_CLASSNAME = + "my-auto flex min-h-7 flex-wrap items-center gap-1.5 rounded-md border border-subtle-1 bg-layer-2 p-2 py-0.5 text-caption-sm-regular text-tertiary hover:text-secondary"; diff --git a/apps/web/components/common/selection-dialog-layout.tsx b/apps/web/components/common/selection-dialog-layout.tsx new file mode 100644 index 00000000000..d4fcdbf8f89 --- /dev/null +++ b/apps/web/components/common/selection-dialog-layout.tsx @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type { ReactNode } from "react"; +import { Combobox as BaseCombobox } from "@base-ui/react/combobox"; +import { ComboboxSearch, ComboboxSearchInput } from "@makeplane/propel/elements/combobox"; +import { InfoOutline, SearchOutline } from "@makeplane/propel/icons"; +import { cn } from "@plane/utils"; + +/** + * Building blocks for a dialog whose body is an inline `Combobox` picker: a search row, an optional + * row of picked items, the scrolling result list and a status + actions footer. Each section draws + * its own bottom rule so the separators run edge to edge across the dialog. + */ + +type TSelectionDialogSearchProps = { + placeholder: string; + ariaLabel: string; + tabIndex?: number; + /** Extra controls rendered at the end of the search row, e.g. a scope toggle. */ + children?: ReactNode; +}; + +export function SelectionDialogSearch({ placeholder, ariaLabel, tabIndex, children }: TSelectionDialogSearchProps) { + return ( + }> + + } + placeholder={placeholder} + aria-label={ariaLabel} + tabIndex={tabIndex} + className="!text-body-sm-regular" + /> + {children} + + ); +} + +export function SelectionDialogSelected({ children }: { children: ReactNode }) { + return ( +
+
{children}
+
+ ); +} + +export function SelectionDialogList({ children, className }: { children: ReactNode; className?: string }) { + return ( +
+ {children} +
+ ); +} + +export function SelectionDialogFooter({ status, children }: { status?: string; children: ReactNode }) { + return ( +
+
+ {status && ( + <> + + {status} + + )} +
+
{children}
+
+ ); +} diff --git a/apps/web/core/components/common/switcher-label.tsx b/apps/web/components/common/switcher-label.tsx similarity index 88% rename from apps/web/core/components/common/switcher-label.tsx rename to apps/web/components/common/switcher-label.tsx index e19d23278da..4b707deaa1a 100644 --- a/apps/web/core/components/common/switcher-label.tsx +++ b/apps/web/components/common/switcher-label.tsx @@ -5,8 +5,8 @@ */ import type { FC } from "react"; -import { Logo } from "@plane/propel/emoji-icon-picker"; -import type { ISvgIcons } from "@plane/propel/icons"; +import { Logo } from "@plane/blocks/emoji-icon-picker"; +import type { ISvgIcons } from "@plane/blocks/icons"; import type { TLogoProps } from "@plane/types"; import { getFileURL, truncateText } from "@plane/utils"; @@ -33,7 +33,7 @@ export function SwitcherIcon({ logo_props, logo_url, LabelIcon, size = 12, type /> ); } - return ; + return ; } type TSwitcherLabelProps = { diff --git a/apps/web/components/common/trigger-guard.ts b/apps/web/components/common/trigger-guard.ts new file mode 100644 index 00000000000..26a7353e914 --- /dev/null +++ b/apps/web/components/common/trigger-guard.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type * as React from "react"; + +/** + * Trigger guard for a menu trigger that sits inside a clickable ancestor (a card `Link`, a + * collapsible header): keeps the click from reaching the ancestor or its default action. + */ +export const handleTriggerClick = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); +}; + +/** + * Trigger guard for keyboard activation: a `Link` ancestor activates on Enter, so keep Enter and + * Space on the trigger from bubbling out while the menu opens. + */ +export const handleTriggerKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Enter" || e.key === " ") e.stopPropagation(); +}; diff --git a/apps/web/components/core/activity.tsx b/apps/web/components/core/activity.tsx new file mode 100644 index 00000000000..8b3ea3eb5e8 --- /dev/null +++ b/apps/web/components/core/activity.tsx @@ -0,0 +1,772 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useEffect } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +// store hooks +// icons +import { + ArchiveOutline, + AttachOutline, + CalendarOutline, + ChatOutline, + CyclesOutline, + DuplicateOfOutline, + EpicOutline, + EstimateOutline, + GridOutline, + IntakeOutline, + LabelsOutline, + LinkOutline, + MembersOutline, + ModuleOutline, + PriorityMedium, + RelatesToOutline, + WorkItemsOutline, +} from "@makeplane/propel/icons"; +import { BlockedIcon, BlockerIcon } from "@plane/blocks/icons"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import type { IIssueActivity } from "@plane/types"; +import { renderFormattedDate, generateWorkItemLink, capitalizeFirstLetter } from "@plane/utils"; +// helpers +import { useLabel } from "@/hooks/store/use-label"; +import { usePlatformOS } from "@/hooks/use-platform-os"; +// types + +export function IssueLink({ activity }: { activity: IIssueActivity }) { + // router params + const { workspaceSlug } = useParams(); + const { isMobile } = usePlatformOS(); + + const workItemLink = generateWorkItemLink({ + workspaceSlug: workspaceSlug?.toString() ?? activity.workspace_detail?.slug, + projectId: activity?.project, + issueId: activity?.issue, + projectIdentifier: activity?.project_detail?.identifier, + sequenceId: activity?.issue_detail?.sequence_id, + }); + + return ( + + {activity?.issue_detail ? ( + + {`${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}`}{" "} + {activity.issue_detail?.name} + + ) : ( + + {" a work item"}{" "} + + )} + + ); +} + +function UserLink({ activity }: { activity: IIssueActivity }) { + // router params + const { workspaceSlug } = useParams(); + + return ( + + {activity.new_value && activity.new_value !== "" ? activity.new_value : activity.old_value} + + ); +} + +const LabelPill = observer(function LabelPill({ labelId, workspaceSlug }: { labelId: string; workspaceSlug: string }) { + // store hooks + const { workspaceLabels, fetchWorkspaceLabels } = useLabel(); + + useEffect(() => { + if (!workspaceLabels) fetchWorkspaceLabels(workspaceSlug); + }, [fetchWorkspaceLabels, workspaceLabels, workspaceSlug]); + + return ( + l.id === labelId)?.color ?? "#000000", + }} + aria-hidden="true" + /> + ); +}); + +const inboxActivityMessage = { + declined: { + showIssue: "declined work item", + noIssue: "declined this work item from intake.", + }, + snoozed: { + showIssue: "snoozed work item", + noIssue: "snoozed this work item.", + }, + accepted: { + showIssue: "accepted work item", + noIssue: "accepted this work item from intake.", + }, + markedDuplicate: { + showIssue: "declined work item", + noIssue: "declined this work item from intake by marking a duplicate work item.", + }, +}; + +const getInboxUserActivityMessage = (activity: IIssueActivity, showIssue: boolean) => { + switch (activity.verb) { + case "-1": + return showIssue ? inboxActivityMessage.declined.showIssue : inboxActivityMessage.declined.noIssue; + case "0": + return showIssue ? inboxActivityMessage.snoozed.showIssue : inboxActivityMessage.snoozed.noIssue; + case "1": + return showIssue ? inboxActivityMessage.accepted.showIssue : inboxActivityMessage.accepted.noIssue; + case "2": + return showIssue ? inboxActivityMessage.markedDuplicate.showIssue : inboxActivityMessage.markedDuplicate.noIssue; + default: + return "updated intake work item status."; + } +}; + +const activityDetails: { + [key: string]: { + message: (activity: IIssueActivity, showIssue: boolean, workspaceSlug: string) => React.ReactNode; + icon: React.ReactNode; + }; +} = { + assignees: { + message: (activity, showIssue) => { + if (activity.old_value === "") + return ( + <> + added a new assignee + {showIssue && ( + <> + {" "} + to + + )} + + ); + else + return ( + <> + removed the assignee + {showIssue && ( + <> + {" "} + from + + )} + + ); + }, + icon:
+ + + {/* Version description */} + + {activeVersionId && activeVersionDescription ? ( + + ) : ( +
+ + +
+ + +
+
+ + +
+ + +
+ )} +
+ {/* End version description */} +
+ {/* Footer */} + + + + } + aria-label={t("common.actions.copy_markdown")} + /> + + +
+ {unsplashImages ? ( + unsplashImages.length > 0 ? ( +
+ {unsplashImages.map((image) => ( + + ))} +
+ ) : ( +
+

No images found.

+
+ ) + ) : ( + + + + + + + + + + + )} + + )} +
+ + +
+ {Object.values(STATIC_COVER_IMAGES).map((imageUrl, index) => ( + + ))} +
+
+ +
+
+
+
+
+ {image !== null || (value && value !== "") ? ( + <> + image + + ) : ( +
+ + {isDragActive ? "Drop image here to upload" : "Drag & drop image here"} + +
+ )} + + +
+
+ {fileRejections.length > 0 && ( +

+ {fileRejections[0].errors[0].code === "file-too-large" + ? "The image size cannot exceed 5 MB." + : "Please upload a file in a valid format."} +

+ )} + +
+

+ File formats supported- .jpeg, .jpg, .png, .webp +

+
+
+
+
+
+
+ +
+ + + +
+ ); +} + +// observer() erases the generic signature, so restore it with a cast. +export const ImagePickerPopover = observer(ImagePickerPopoverComponent) as typeof ImagePickerPopoverComponent; diff --git a/apps/web/core/components/core/list/index.ts b/apps/web/components/core/list/index.ts similarity index 100% rename from apps/web/core/components/core/list/index.ts rename to apps/web/components/core/list/index.ts diff --git a/apps/web/components/core/list/list-item.tsx b/apps/web/components/core/list/list-item.tsx new file mode 100644 index 00000000000..5c64db62336 --- /dev/null +++ b/apps/web/components/core/list/list-item.tsx @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import React from "react"; +// ui +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import { ControlLink, Row } from "@plane/blocks/layout"; +// helpers +import { cn } from "@plane/utils"; +// hooks +import { useAppRouter } from "@/hooks/use-app-router"; + +interface IListItemProps { + id?: string; + title: string; + itemLink: string; + onItemClick?: (e: React.MouseEvent) => void; + prependTitleElement?: React.ReactNode; + appendTitleElement?: React.ReactNode; + actionableItems?: React.ReactNode; + isMobile?: boolean; + parentRef: React.RefObject; + disableLink?: boolean; + className?: string; + itemClassName?: string; + actionItemContainerClassName?: string; + isSidebarOpen?: boolean; + quickActionElement?: React.ReactNode; + preventDefaultProgress?: boolean; + leftElementClassName?: string; + rightElementClassName?: string; + linkClassName?: string; + titleClassName?: string; +} + +export function ListItem(props: IListItemProps) { + const { + id, + title, + prependTitleElement, + appendTitleElement, + actionableItems, + itemLink, + onItemClick, + isMobile = false, + parentRef, + disableLink = false, + className = "", + actionItemContainerClassName = "", + isSidebarOpen = false, + quickActionElement, + itemClassName = "", + preventDefaultProgress = false, + leftElementClassName = "", + rightElementClassName = "", + linkClassName = "", + titleClassName = "", + } = props; + + // router + const router = useAppRouter(); + + // handlers + const handleControlLinkClick = (e: React.MouseEvent) => { + if (onItemClick) onItemClick(e); + else router.push(itemLink); + }; + + return ( +
+ +
+ +
+ {prependTitleElement && {prependTitleElement}} + + {title} + +
+ {appendTitleElement && ( + {appendTitleElement} + )} +
+ {quickActionElement && quickActionElement} +
+ {actionableItems && ( +
+ {actionableItems} +
+ )} +
+
+ ); +} diff --git a/apps/web/core/components/core/list/list-root.tsx b/apps/web/components/core/list/list-root.tsx similarity index 78% rename from apps/web/core/components/core/list/list-root.tsx rename to apps/web/components/core/list/list-root.tsx index d81f2daeec2..9f9143e8ddb 100644 --- a/apps/web/core/components/core/list/list-root.tsx +++ b/apps/web/components/core/list/list-root.tsx @@ -5,7 +5,7 @@ */ import React from "react"; -import { Row, ERowVariant } from "@plane/ui"; +import { Row, ERowVariant } from "@plane/blocks/layout"; interface IListContainer { children: React.ReactNode; @@ -16,7 +16,7 @@ export function ListLayout(props: IListContainer) { return ( {children} diff --git a/apps/web/components/core/modals/bulk-delete-issues-modal-item.tsx b/apps/web/components/core/modals/bulk-delete-issues-modal-item.tsx new file mode 100644 index 00000000000..41cf19b63b2 --- /dev/null +++ b/apps/web/components/core/modals/bulk-delete-issues-modal-item.tsx @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane imports +import { ComboboxItem } from "@makeplane/propel/components/combobox"; +import type { ISearchIssueResponse } from "@plane/types"; +// components +import { IssueIdentifier } from "@/components/issues/issue-detail/issue-identifier"; + +interface Props { + issue: ISearchIssueResponse; +} + +export const BulkDeleteIssuesModalItem = observer(function BulkDeleteIssuesModalItem(props: Props) { + const { issue } = props; + + const color = issue.state__color; + + return ( + // `selection="checkbox"` draws the multi-select checkbox; Base UI drives it off the root's + // value, so the row no longer needs a hand-placed checkbox or a `checked` prop. + + + + + } + /> + ); +}); diff --git a/apps/web/components/core/modals/bulk-delete-issues-modal.tsx b/apps/web/components/core/modals/bulk-delete-issues-modal.tsx new file mode 100644 index 00000000000..9da293e2f42 --- /dev/null +++ b/apps/web/components/core/modals/bulk-delete-issues-modal.tsx @@ -0,0 +1,224 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useEffect, useState } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +import { useTheme } from "next-themes"; +import type { SubmitHandler } from "react-hook-form"; +import { useForm } from "react-hook-form"; +// plane imports +import { useTranslation } from "@plane/i18n"; +import { Button } from "@makeplane/propel/components/button"; +import { Combobox, ComboboxList, ComboboxSearch } from "@makeplane/propel/components/combobox"; +import { Dialog, DialogActions, DialogContent, DialogMain, DialogTitle } from "@makeplane/propel/components/dialog"; +import { setToast } from "@plane/blocks/toast"; +import type { ISearchIssueResponse, IUser } from "@plane/types"; +import { EIssuesStoreType } from "@plane/types"; +import { Loader } from "@plane/blocks/skeleton"; +// assets +import darkIssuesAsset from "@/app/assets/empty-state/search/issues-dark.webp?url"; +import lightIssuesAsset from "@/app/assets/empty-state/search/issues-light.webp?url"; +import darkSearchAsset from "@/app/assets/empty-state/search/search-dark.webp?url"; +import lightSearchAsset from "@/app/assets/empty-state/search/search-light.webp?url"; +// components +import { SimpleEmptyState } from "@/components/empty-state/simple-empty-state-root"; +// hooks +import { useIssues } from "@/hooks/store/use-issues"; +import useDebounce from "@/hooks/use-debounce"; +// services +import { ProjectService } from "@/services/project"; +// local components +import { BulkDeleteIssuesModalItem } from "./bulk-delete-issues-modal-item"; + +type FormInput = { + delete_issue_ids: string[]; +}; + +type Props = { + isOpen: boolean; + onClose: () => void; + user: IUser | undefined; +}; + +const projectService = new ProjectService(); + +export const BulkDeleteIssuesModal = observer(function BulkDeleteIssuesModal(props: Props) { + const { isOpen, onClose } = props; + // router params + const { workspaceSlug, projectId } = useParams(); + // states + const [query, setQuery] = useState(""); + const [issues, setIssues] = useState([]); + const [isSearching, setIsSearching] = useState(false); + // theme hook + const { resolvedTheme } = useTheme(); + // hooks + const { + issues: { removeBulkIssues }, + } = useIssues(EIssuesStoreType.PROJECT); + const { t } = useTranslation(); + // derived values + const debouncedSearchTerm: string = useDebounce(query, 500); + const searchResolvedPath = resolvedTheme === "light" ? lightSearchAsset : darkSearchAsset; + const issuesResolvedPath = resolvedTheme === "light" ? lightIssuesAsset : darkIssuesAsset; + + useEffect(() => { + if (!isOpen || !workspaceSlug || !projectId) return; + + setIsSearching(true); + projectService + .projectIssuesSearch(workspaceSlug.toString(), projectId.toString(), { + search: debouncedSearchTerm, + workspace_search: false, + }) + .then((res: ISearchIssueResponse[]) => setIssues(res)) + .finally(() => setIsSearching(false)); + }, [debouncedSearchTerm, isOpen, projectId, workspaceSlug]); + + const { + handleSubmit, + watch, + reset, + setValue, + formState: { isSubmitting }, + } = useForm({ + defaultValues: { + delete_issue_ids: [], + }, + }); + + const handleClose = () => { + setQuery(""); + reset(); + onClose(); + }; + + const handleDelete: SubmitHandler = async (data) => { + if (!workspaceSlug || !projectId) return; + + if (!data.delete_issue_ids || data.delete_issue_ids.length === 0) { + setToast({ + type: "error", + title: "Error!", + message: "Please select at least one work item.", + }); + return; + } + + if (!Array.isArray(data.delete_issue_ids)) data.delete_issue_ids = [data.delete_issue_ids]; + + await removeBulkIssues(workspaceSlug, projectId, data.delete_issue_ids) + .then(() => { + setToast({ + type: "success", + title: "Success!", + message: "Work items deleted successfully!", + }); + handleClose(); + }) + .catch(() => + setToast({ + type: "error", + title: "Error!", + message: "Something went wrong. Please try again.", + }) + ); + }; + + const issueList = + issues.length > 0 ? ( +
+ {query === "" && ( +

Select work items to delete

+ )} + + {issues.map((issue) => ( + + ))} + +
+ ) : ( +
+ {query === "" ? ( + + ) : ( + + )} +
+ ); + + return ( + { + if (!open) handleClose(); + }} + > + + {/* The search field is the only visible chrome, so the dialog's accessible name is carried + by a visually hidden title. */} +
+ {t("power_k.actions_commands.bulk_delete_work_items")} +
+
+ {/* `inline` + `open` renders the list in place: the dialog is the surface, so there is no + popup positioner. */} + + inline + multiple + // Bound to the dialog so the combobox resets its transient state when the modal closes. + open={isOpen} + onOpenChange={(open) => { + if (!open) handleClose(); + }} + value={watch("delete_issue_ids")} + onValueChange={(ids) => setValue("delete_issue_ids", ids)} + inputValue={query} + onInputValueChange={(next, details) => { + // Base UI clears the query after every pick in multiple mode; letting that through + // would re-run the debounced server search on each toggle. + if (details.reason === "input-clear") return; + setQuery(next); + }} + > + + +
+ {isSearching ? ( + + + + + + + ) : ( + <>{issueList} + )} +
+
+ + {issues.length > 0 && ( + +
+ ); +}); diff --git a/apps/web/components/core/modals/change-email-modal.tsx b/apps/web/components/core/modals/change-email-modal.tsx new file mode 100644 index 00000000000..90801ef48f6 --- /dev/null +++ b/apps/web/components/core/modals/change-email-modal.tsx @@ -0,0 +1,264 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { observer } from "mobx-react"; +import { Controller, useForm } from "react-hook-form"; +// plane imports +import { Field } from "@makeplane/propel/components/field"; +import { Input, InputGroup } from "@makeplane/propel/components/input"; +import { useTranslation } from "@plane/i18n"; +import { Button } from "@makeplane/propel/components/button"; +import { + Dialog, + DialogActions, + DialogBody, + DialogContent, + DialogDescription, + DialogHeader, + DialogHeading, + DialogMain, + DialogTitle, +} from "@makeplane/propel/components/dialog"; +import { setToast } from "@plane/blocks/toast"; +// helpers +import { authErrorHandler } from "@/helpers/authentication.helper"; +import type { EAuthenticationErrorCodes } from "@/helpers/authentication.helper"; +// hooks +import { useUser } from "@/hooks/store/user"; +// services +import { AuthService } from "@/services/auth.service"; +import userService from "@/services/user.service"; + +type Props = { isOpen: boolean; onClose: () => void }; + +type TModalStep = "EMAIL" | "UNIQUE_CODE"; +type TUniqueCodeValuesForm = { email: string; code: string }; + +const defaultValues: TUniqueCodeValuesForm = { email: "", code: "" }; + +// service initialization +const authService = new AuthService(); + +export const ChangeEmailModal = observer(function ChangeEmailModal(props: Props) { + const { isOpen, onClose } = props; + // states + const [currentStep, setCurrentStep] = useState("EMAIL"); + // store hooks + const { signOut } = useUser(); + const { t } = useTranslation(); + const changeEmailT = (path: string) => t(`account_settings.profile.change_email_modal.${path}`); + // form info + const { + handleSubmit, + control, + setError, + reset, + formState: { errors, isSubmitting }, + } = useForm({ defaultValues }); + + const secondStep = currentStep === "UNIQUE_CODE"; + + const handleClose = () => { + reset({ ...defaultValues }); + setCurrentStep("EMAIL"); + onClose(); + }; + + const handleSignOut = async () => { + await signOut().catch(() => + setToast({ + type: "error", + title: t("auth.sign_out.toast.error.title"), + message: t("auth.sign_out.toast.error.message"), + }) + ); + }; + + const onSubmit = async (formData: TUniqueCodeValuesForm) => { + if (currentStep === "UNIQUE_CODE") { + // Step 2: Verify the code and update email + try { + await userService.verifyEmailCode({ email: formData.email, code: formData.code }); + + setToast({ + type: "success", + title: changeEmailT("toasts.success_title"), + message: changeEmailT("toasts.success_message"), + }); + + // Sign out the user after successful email update + await handleSignOut(); + handleClose(); + } catch (error: unknown) { + const errorMessage = + (error as { error?: string; message?: string })?.error || + (error as { error?: string; message?: string })?.message || + changeEmailT("form.code.errors.invalid"); + setError("code", { type: "custom", message: errorMessage }); + } + return; + } + + // Step 1: Check email and generate verification code + try { + // Get CSRF token + const csrfToken = await authService.requestCSRFToken().then((data) => data?.csrf_token); + if (!csrfToken) throw new Error("CSRF token not found"); + + // Check if email is available + const emailCheckResponse = await userService.checkEmail(csrfToken, formData.email); + + // Check if email already exists + if (emailCheckResponse?.existing === true) { + setError("email", { type: "custom", message: changeEmailT("form.email.errors.exists") }); + return; + } + + // Generate verification code and send to new email + await userService.generateEmailCode({ email: formData.email }); + + // Move to verification code step + setCurrentStep("UNIQUE_CODE"); + } catch (error: unknown) { + // Extract error code and message from backend response + const err = error as { error_code?: number | string; error_message?: string }; + const errorCode = err?.error_code?.toString(); + + // Use authErrorHandler to get user-friendly error message + const errorInfo = errorCode ? authErrorHandler(errorCode as EAuthenticationErrorCodes) : undefined; + + // Get error message from handler or fallback + const errorMessage = errorInfo + ? typeof errorInfo.message === "string" + ? errorInfo.message + : String(errorInfo.message) + : err?.error_message || changeEmailT("form.email.errors.validation_failed"); + + setError("email", { type: "custom", message: errorMessage }); + } + }; + + return ( + { + if (!open) handleClose(); + }} + > + +
+ + + + {changeEmailT("title")} + {changeEmailT("description")} + + + +
+
+ {secondStep && ( +

{changeEmailT("form.email.label")}

+ )} + ( + + + + + + )} + /> + {errors?.email && ( + {errors?.email?.message} + )} +
+ + {secondStep && ( +
+

{changeEmailT("form.code.label")}

+ ( + + + + )} + /> + {errors?.code ? ( + {errors?.code?.message} + ) : ( + + {changeEmailT("form.code.helper_text")} + + )} +
+ )} +
+
+
+ +
+ ); +}); diff --git a/apps/web/components/core/modals/existing-issues-list-modal.tsx b/apps/web/components/core/modals/existing-issues-list-modal.tsx new file mode 100644 index 00000000000..d2c83ee8207 --- /dev/null +++ b/apps/web/components/core/modals/existing-issues-list-modal.tsx @@ -0,0 +1,347 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useEffect, useState, useRef } from "react"; +import { Combobox, ComboboxItem, ComboboxList } from "@makeplane/propel/components/combobox"; +import { Dialog, DialogContent, DialogTitle } from "@makeplane/propel/components/dialog"; +import { CloseOutline, NewTabOutline } from "@makeplane/propel/icons"; +// i18n +import { useTranslation } from "@plane/i18n"; +// types +import { Button } from "@makeplane/propel/components/button"; +import { setToast } from "@plane/blocks/toast"; +import { Tooltip } from "@makeplane/propel/components/tooltip"; +import type { ISearchIssueResponse, TProjectIssuesSearchParams } from "@plane/types"; +// ui +import { Switch } from "@makeplane/propel/components/switch"; +import { Loader } from "@plane/blocks/skeleton"; +import { generateWorkItemLink, getTabIndex } from "@plane/utils"; +// helpers +// hooks +import useDebounce from "@/hooks/use-debounce"; +import { usePlatformOS } from "@/hooks/use-platform-os"; +// services +import { ProjectService } from "@/services/project"; +// components +import { IssueIdentifier } from "@/components/issues/issue-detail/issue-identifier"; +import { + SelectionDialogFooter, + SelectionDialogList, + SelectionDialogSearch, + SelectionDialogSelected, +} from "@/components/common/selection-dialog-layout"; +import { IssueSearchModalEmptyState } from "./issue-search-modal-empty-state"; + +type Props = { + workspaceSlug: string | undefined; + projectId?: string; + isOpen: boolean; + handleClose: () => void; + searchParams: Partial; + handleOnSubmit: (data: ISearchIssueResponse[]) => Promise; + workspaceLevelToggle?: boolean; + shouldHideIssue?: (issue: ISearchIssueResponse) => boolean; + selectedWorkItemIds?: string[]; + workItemSearchServiceCallback?: (params: TProjectIssuesSearchParams) => Promise; +}; + +const projectService = new ProjectService(); + +export function ExistingIssuesListModal(props: Props) { + const { t } = useTranslation(); + + const { + workspaceSlug, + projectId, + isOpen, + handleClose: onClose, + searchParams, + handleOnSubmit, + workspaceLevelToggle = false, + shouldHideIssue, + selectedWorkItemIds, + workItemSearchServiceCallback, + } = props; + // states + const [isLoading, setIsLoading] = useState(false); + const [searchTerm, setSearchTerm] = useState(""); + const [issues, setIssues] = useState([]); + const [selectedIssues, setSelectedIssues] = useState([]); + const [isSearching, setIsSearching] = useState(false); + const [isSubmitting, setIsSubmitting] = useState(false); + const [isWorkspaceLevel, setIsWorkspaceLevel] = useState(false); + const { isMobile } = usePlatformOS(); + const debouncedSearchTerm: string = useDebounce(searchTerm, 500); + const { baseTabIndex } = getTabIndex(undefined, isMobile); + const hasInitializedSelection = useRef(false); + + const handleClose = () => { + onClose(); + setSearchTerm(""); + setSelectedIssues([]); + setIsWorkspaceLevel(false); + hasInitializedSelection.current = false; + }; + + const onSubmit = async () => { + if (selectedIssues.length === 0) { + setToast({ + type: "error", + title: t("toast.error"), + message: t("issue.select.error"), + }); + + return; + } + + setIsSubmitting(true); + + await handleOnSubmit(selectedIssues).finally(() => setIsSubmitting(false)); + + handleClose(); + }; + + const handleSearch = () => { + if (!isOpen || !workspaceSlug) return; + setIsLoading(true); + const searchService = + workItemSearchServiceCallback ?? + (projectId + ? projectService.projectIssuesSearch.bind(projectService, workspaceSlug?.toString(), projectId?.toString()) + : undefined); + if (!searchService) return; + searchService({ + search: debouncedSearchTerm, + ...searchParams, + workspace_search: isWorkspaceLevel, + }) + .then((res) => setIssues(res)) + .finally(() => { + setIsSearching(false); + setIsLoading(false); + }); + }; + + const handleSelectIssues = () => { + setSelectedIssues((prevData) => (prevData.length === filteredIssues.length ? [] : [...filteredIssues])); + }; + + useEffect(() => { + if (isOpen && !hasInitializedSelection.current && selectedWorkItemIds && issues.length > 0) { + setSelectedIssues(issues.filter((issue) => selectedWorkItemIds.includes(issue.id))); + hasInitializedSelection.current = true; + } + }, [isOpen, issues, selectedWorkItemIds]); + + useEffect(() => { + handleSearch(); + }, [debouncedSearchTerm, isOpen, isWorkspaceLevel, projectId, workspaceSlug]); + + const filteredIssues = issues.filter((issue) => !shouldHideIssue?.(issue)); + + return ( + { + if (!open) handleClose(); + }} + > + + {/* The search field is the only visible chrome, so the dialog's accessible name is carried + by a visually hidden title. */} +
+ {t("issue.add.existing")} +
+ {/* `inline` + `open` renders the list in place: the dialog is the surface, so there is no + popup positioner. */} + + inline + multiple + // Bound to the dialog so the combobox resets its transient state when the modal closes. + open={isOpen} + onOpenChange={(open) => { + if (!open) handleClose(); + }} + value={selectedIssues} + onValueChange={(next) => setSelectedIssues(next)} + // Re-searching returns fresh objects, so rows are matched to the selection by id. + isItemEqualToValue={(itemValue, value) => itemValue.id === value.id} + itemToStringLabel={(issue) => issue.name} + inputValue={searchTerm} + onInputValueChange={(next, details) => { + // Base UI clears the query after every pick in multiple mode; letting that through + // would re-run the debounced server search on each toggle. + if (details.reason === "input-clear") return; + setSearchTerm(next); + }} + > + + {workspaceLevelToggle && ( + <> + + +
+ + +
+
+ + )} +
+ {selectedIssues.length > 0 && ( + +
+ {selectedIssues.map((issue) => ( +
+ + +
+ ))} +
+
+ )} + + {/* TODO: Translate here */} + {searchTerm !== "" && ( +
+ Search results for{" "} + + {'"'} + {searchTerm} + {'"'} + {" "} + in project: +
+ )} + + {isSearching || isLoading ? ( + + + + + + + ) : ( + <> + {filteredIssues.length === 0 ? ( + + ) : ( + + {filteredIssues.map((issue) => ( + // `selection="checkbox"` replaces the hand-placed checkbox and the + // `as="label"` wrapper the old row needed to make it clickable. + + + + + } + trailing={ + e.stopPropagation()} + > + + + } + /> + ))} + + )} + + )} +
+ + +
+ ); +} diff --git a/apps/web/components/core/modals/gpt-assistant-popover.tsx b/apps/web/components/core/modals/gpt-assistant-popover.tsx new file mode 100644 index 00000000000..bbbf60aea12 --- /dev/null +++ b/apps/web/components/core/modals/gpt-assistant-popover.tsx @@ -0,0 +1,306 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import type React from "react"; +import { useEffect, useEffectEvent, useState, useRef } from "react"; +import { Controller, useForm } from "react-hook-form"; // services +import { WarningCircleOutline } from "@makeplane/propel/icons"; +// plane imports +import { Input, InputGroup } from "@makeplane/propel/components/input"; +import { Popover, PopoverBody, PopoverContent, PopoverTrigger } from "@makeplane/propel/components/popover"; +import type { EditorRefApi } from "@plane/editor"; +import { Button } from "@makeplane/propel/components/button"; +import { setToast } from "@plane/blocks/toast"; +import { toSideAndAlign } from "@plane/blocks/common"; +import type { TPopoverMenuPlacement } from "@plane/blocks/common"; +import { cn } from "@plane/utils"; + +// components +import { RichTextEditor } from "@/components/editor/rich-text"; +// services +import { AIService } from "@/services/ai.service"; +const aiService = new AIService(); + +type Props = { + isOpen: boolean; + handleClose: () => void; + onResponse: (response: any) => void; + onError?: (error: any) => void; + placement?: TPopoverMenuPlacement; + prompt?: string; + button: React.ReactNode; + className?: string; + workspaceId: string; + workspaceSlug: string; + projectId: string; +}; + +type FormData = { + prompt: string; + task: string; +}; + +export function GptAssistantPopover(props: Props) { + const { + isOpen, + handleClose, + onResponse, + onError, + placement, + prompt, + button, + className = "", + workspaceId, + workspaceSlug, + projectId, + } = props; + // states + const [response, setResponse] = useState(""); + const [invalidResponse, setInvalidResponse] = useState(false); + // refs + const editorRef = useRef(null); + const responseRef = useRef(null); + // derived values + const { side, align } = toSideAndAlign(placement ?? "auto"); + // form + const { + handleSubmit, + control, + reset, + setFocus, + formState: { isSubmitting }, + } = useForm({ + defaultValues: { + prompt: prompt || "", + task: "", + }, + }); + + const onClose = () => { + handleClose(); + setResponse(""); + setInvalidResponse(false); + reset(); + }; + + const handleServiceError = (err: any) => { + const error = err?.data?.error; + const errorMessage = + err?.status === 429 + ? error || "You have reached the maximum number of requests of 50 requests per month per user." + : error || "Some error occurred. Please try again."; + + setToast({ + type: "error", + title: "Error!", + message: errorMessage, + }); + + if (onError) onError(err); + }; + + const callAIService = async (formData: FormData) => { + try { + const res = await aiService.createGptTask(workspaceSlug.toString(), { + prompt: prompt || "", + task: formData.task, + }); + + setResponse(res.response_html); + setFocus("task"); + + setInvalidResponse(res.response === ""); + } catch (err) { + handleServiceError(err); + } + }; + + const handleInvalidTask = () => { + setToast({ + type: "error", + title: "Error!", + message: "Please enter some task to get AI assistance.", + }); + }; + + const handleAIResponse = async (formData: FormData) => { + if (!workspaceSlug) return; + + if (formData.task === "") { + handleInvalidTask(); + return; + } + + await callAIService(formData); + }; + + useEffect(() => { + if (isOpen) setFocus("task"); + }, [isOpen, setFocus]); + + useEffect(() => { + editorRef.current?.setEditorValue(prompt || ""); + }, [editorRef, prompt]); + + useEffect(() => { + responseRef.current?.setEditorValue(`

${response}

`); + }, [response, responseRef]); + + // Read the latest submit handler (it closes over `prompt` and the workspace props) without + // re-subscribing the Enter listener on every render. + const onEnterKey = useEffectEvent(() => void handleSubmit(handleAIResponse)()); + + useEffect(() => { + const handleEnterKeyPress = (event: KeyboardEvent) => { + if (event.key === "Enter" && !event.shiftKey) { + event.preventDefault(); + onEnterKey(); + } + }; + + // Escape is Base UI's now: it closes the popover, which runs `onClose` through `onOpenChange`. + if (isOpen) window.addEventListener("keydown", handleEnterKeyPress); + + return () => { + window.removeEventListener("keydown", handleEnterKeyPress); + }; + }, [isOpen]); + + const responseActionButton = response !== "" && ( +
+
+
+ + +
+ ); +} diff --git a/apps/web/core/components/core/modals/issue-search-modal-empty-state.tsx b/apps/web/components/core/modals/issue-search-modal-empty-state.tsx similarity index 100% rename from apps/web/core/components/core/modals/issue-search-modal-empty-state.tsx rename to apps/web/components/core/modals/issue-search-modal-empty-state.tsx diff --git a/apps/web/components/core/modals/user-image-upload-modal.tsx b/apps/web/components/core/modals/user-image-upload-modal.tsx new file mode 100644 index 00000000000..684bb1e5e64 --- /dev/null +++ b/apps/web/components/core/modals/user-image-upload-modal.tsx @@ -0,0 +1,195 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { observer } from "mobx-react"; +import { useDropzone } from "react-dropzone"; +// plane imports +import { ACCEPTED_AVATAR_IMAGE_MIME_TYPES_FOR_REACT_DROPZONE, MAX_FILE_SIZE } from "@plane/constants"; +import { Button } from "@makeplane/propel/components/button"; +import { + Dialog, + DialogActions, + DialogBody, + DialogContent, + DialogHeader, + DialogHeading, + DialogInfo, + DialogMain, + DialogTitle, +} from "@makeplane/propel/components/dialog"; +import { UserOutline } from "@makeplane/propel/icons"; +import { setToast } from "@plane/blocks/toast"; +import { EFileAssetType } from "@plane/types"; +import { getAssetIdFromUrl, getFileURL, checkURLValidity } from "@plane/utils"; +// services +import { FileService } from "@/services/file.service"; +const fileService = new FileService(); + +type Props = { + handleRemove: () => Promise; + isOpen: boolean; + onClose: () => void; + onSuccess: (url: string) => void; + value: string | null; +}; + +export const UserImageUploadModal = observer(function UserImageUploadModal(props: Props) { + const { handleRemove, isOpen, onClose, onSuccess, value } = props; + // states + const [image, setImage] = useState(null); + const [isRemoving, setIsRemoving] = useState(false); + const [isImageUploading, setIsImageUploading] = useState(false); + + const onDrop = (acceptedFiles: File[]) => setImage(acceptedFiles[0]); + + const { getRootProps, getInputProps, isDragActive, fileRejections } = useDropzone({ + onDrop, + accept: ACCEPTED_AVATAR_IMAGE_MIME_TYPES_FOR_REACT_DROPZONE, + maxSize: MAX_FILE_SIZE, + multiple: false, + }); + + const handleClose = () => { + setImage(null); + setIsImageUploading(false); + onClose(); + }; + + const handleSubmit = async () => { + if (!image) return; + setIsImageUploading(true); + + try { + const { asset_url } = await fileService.uploadUserAsset( + { + entity_identifier: "", + entity_type: EFileAssetType.USER_AVATAR, + }, + image + ); + onSuccess(asset_url); + setImage(null); + } catch (error) { + setToast({ + type: "error", + title: "Error!", + message: error?.toString() ?? "Something went wrong. Please try again.", + }); + throw new Error("Error in uploading file.", { cause: error }); + } finally { + setIsImageUploading(false); + } + }; + + const handleImageRemove = async () => { + if (!value) return; + setIsRemoving(true); + try { + if (checkURLValidity(value)) { + await fileService.deleteOldUserAsset(value); + } else { + const assetId = getAssetIdFromUrl(value); + await fileService.deleteUserAsset(assetId); + } + await handleRemove(); + } catch (error) { + console.log("Error in uploading user asset:", error); + } finally { + setIsRemoving(false); + } + }; + + return ( + { + if (!open) handleClose(); + }} + > + + + + + Upload Image + + + +
+
+
+
+ {image !== null || (value && value !== "") ? ( + <> + + image + + ) : ( +
+ + + {isDragActive ? "Drop image here to upload" : "Drag & drop image here"} + +
+ )} + + +
+
+ {fileRejections.length > 0 && ( +

+ {fileRejections[0].errors[0].code === "file-too-large" + ? "The image size cannot exceed 5 MB." + : "Please upload a file in a valid format."} +

+ )} +
+

File formats supported- .jpeg, .jpg, .png, .webp

+
+
+
+ + +
+ ); +}); diff --git a/apps/web/components/core/modals/workspace-image-upload-modal.tsx b/apps/web/components/core/modals/workspace-image-upload-modal.tsx new file mode 100644 index 00000000000..d023c9ef022 --- /dev/null +++ b/apps/web/components/core/modals/workspace-image-upload-modal.tsx @@ -0,0 +1,206 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { useState } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +import { useDropzone } from "react-dropzone"; +// plane imports +import { ACCEPTED_AVATAR_IMAGE_MIME_TYPES_FOR_REACT_DROPZONE, MAX_FILE_SIZE } from "@plane/constants"; +import { Button } from "@makeplane/propel/components/button"; +import { + Dialog, + DialogActions, + DialogBody, + DialogContent, + DialogHeader, + DialogHeading, + DialogInfo, + DialogMain, + DialogTitle, +} from "@makeplane/propel/components/dialog"; +import { UserOutline } from "@makeplane/propel/icons"; +import { setToast } from "@plane/blocks/toast"; +import { EFileAssetType } from "@plane/types"; +import { getAssetIdFromUrl, getFileURL, checkURLValidity } from "@plane/utils"; +// hooks +import { useWorkspace } from "@/hooks/store/use-workspace"; +// services +import { FileService } from "@/services/file.service"; + +type Props = { + handleRemove: () => Promise; + isOpen: boolean; + onClose: () => void; + onSuccess: (url: string) => void; + value: string | null; +}; + +// services +const fileService = new FileService(); + +export const WorkspaceImageUploadModal = observer(function WorkspaceImageUploadModal(props: Props) { + const { handleRemove, isOpen, onClose, onSuccess, value } = props; + // states + const [image, setImage] = useState(null); + const [isRemoving, setIsRemoving] = useState(false); + const [isImageUploading, setIsImageUploading] = useState(false); + // router + const { workspaceSlug } = useParams(); + // store hooks + const { currentWorkspace, updateWorkspaceLogo } = useWorkspace(); + + const onDrop = (acceptedFiles: File[]) => setImage(acceptedFiles[0]); + + const { getRootProps, getInputProps, isDragActive, fileRejections } = useDropzone({ + onDrop, + accept: ACCEPTED_AVATAR_IMAGE_MIME_TYPES_FOR_REACT_DROPZONE, + maxSize: MAX_FILE_SIZE, + multiple: false, + }); + + const handleClose = () => { + setIsImageUploading(false); + onClose(); + setTimeout(() => { + setImage(null); + }, 300); + }; + + const handleSubmit = async () => { + if (!image || !workspaceSlug || !currentWorkspace) return; + setIsImageUploading(true); + + try { + const { asset_url } = await fileService.uploadWorkspaceAsset( + workspaceSlug.toString(), + { + entity_identifier: currentWorkspace.id, + entity_type: EFileAssetType.WORKSPACE_LOGO, + }, + image + ); + updateWorkspaceLogo(workspaceSlug.toString(), asset_url); + onSuccess(asset_url); + } catch (error: any) { + console.log("error", error); + setToast({ + type: "error", + title: "Error", + message: error.error || "Something went wrong", + }); + } finally { + setIsImageUploading(false); + } + }; + + const handleImageRemove = async () => { + if (!workspaceSlug || !value) return; + setIsRemoving(true); + try { + if (checkURLValidity(value)) { + await fileService.deleteOldWorkspaceAsset(currentWorkspace?.id ?? "", value); + } else { + const assetId = getAssetIdFromUrl(value); + await fileService.deleteWorkspaceAsset(workspaceSlug.toString(), assetId); + } + await handleRemove(); + handleClose(); + } catch (error) { + console.log("Error in removing workspace asset:", error); + } finally { + setIsRemoving(false); + } + }; + + return ( + { + if (!open) handleClose(); + }} + > + + + + + Upload image + + + +
+
+
+
+ {image !== null || (value && value !== "") ? ( + <> +
+
+ image + + ) : ( +
+ + + {isDragActive ? "Drop image here to upload" : "Drag & drop image here"} + +
+ )} + + +
+
+ {fileRejections.length > 0 && ( +

+ {fileRejections[0].errors[0].code === "file-too-large" + ? "The image size cannot exceed 5 MB." + : "Please upload a file in a valid format."} +

+ )} +
+

File formats supported- .jpeg, .jpg, .png, .webp

+
+
+
+ + +
+ ); +}); diff --git a/apps/web/components/core/multiple-select/entity-select-action.tsx b/apps/web/components/core/multiple-select/entity-select-action.tsx new file mode 100644 index 00000000000..d96c7b32ccc --- /dev/null +++ b/apps/web/components/core/multiple-select/entity-select-action.tsx @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import { Checkbox } from "@makeplane/propel/components/checkbox"; +import { cn } from "@plane/utils"; +// hooks +import type { TSelectionHelper } from "@/hooks/use-multiple-select"; + +type Props = { + className?: string; + disabled?: boolean; + groupId: string; + id: string; + selectionHelpers: TSelectionHelper; +}; + +export const MultipleSelectEntityAction = observer(function MultipleSelectEntityAction(props: Props) { + const { className, disabled = false, groupId, id, selectionHelpers } = props; + // derived values + const isSelected = selectionHelpers.getIsEntitySelected(id); + + if (selectionHelpers.isSelectionDisabled) return null; + + return ( + + { + e.stopPropagation(); + selectionHelpers.handleEntityClick(e, id, groupId); + }} + /> + + ); +}); diff --git a/apps/web/components/core/multiple-select/group-select-action.tsx b/apps/web/components/core/multiple-select/group-select-action.tsx new file mode 100644 index 00000000000..de8f0d226c3 --- /dev/null +++ b/apps/web/components/core/multiple-select/group-select-action.tsx @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { Checkbox } from "@makeplane/propel/components/checkbox"; +import { cn } from "@plane/utils"; +// hooks +import type { TSelectionHelper } from "@/hooks/use-multiple-select"; + +type Props = { + className?: string; + disabled?: boolean; + groupID: string; + selectionHelpers: TSelectionHelper; +}; + +export function MultipleSelectGroupAction(props: Props) { + const { className, disabled = false, groupID, selectionHelpers } = props; + // derived values + const groupSelectionStatus = selectionHelpers.isGroupSelected(groupID); + + if (selectionHelpers.isSelectionDisabled) return null; + + return ( + + selectionHelpers.handleGroupClick(groupID)} + /> + + ); +} diff --git a/apps/web/core/components/core/multiple-select/index.ts b/apps/web/components/core/multiple-select/index.ts similarity index 100% rename from apps/web/core/components/core/multiple-select/index.ts rename to apps/web/components/core/multiple-select/index.ts diff --git a/apps/web/core/components/core/multiple-select/select-group.tsx b/apps/web/components/core/multiple-select/select-group.tsx similarity index 100% rename from apps/web/core/components/core/multiple-select/select-group.tsx rename to apps/web/components/core/multiple-select/select-group.tsx diff --git a/apps/web/core/components/core/page-title.tsx b/apps/web/components/core/page-title.tsx similarity index 100% rename from apps/web/core/components/core/page-title.tsx rename to apps/web/components/core/page-title.tsx diff --git a/apps/web/core/components/core/render-if-visible-HOC.tsx b/apps/web/components/core/render-if-visible-HOC.tsx similarity index 96% rename from apps/web/core/components/core/render-if-visible-HOC.tsx rename to apps/web/components/core/render-if-visible-HOC.tsx index 03ba7b52b08..406b24c23de 100644 --- a/apps/web/core/components/core/render-if-visible-HOC.tsx +++ b/apps/web/components/core/render-if-visible-HOC.tsx @@ -15,7 +15,8 @@ type Props = { horizontalOffset?: number; root?: MutableRefObject; children: ReactNode; - as?: keyof JSX.IntrinsicElements; + // @types/react 19 removed the global JSX namespace; it now lives under React. + as?: keyof React.JSX.IntrinsicElements; classNames?: string; placeholderChildren?: ReactNode; defaultValue?: boolean; diff --git a/apps/web/core/components/core/sidebar/progress-chart.tsx b/apps/web/components/core/sidebar/progress-chart.tsx similarity index 97% rename from apps/web/core/components/core/sidebar/progress-chart.tsx rename to apps/web/components/core/sidebar/progress-chart.tsx index a5b99a9cddf..c64b34888c0 100644 --- a/apps/web/core/components/core/sidebar/progress-chart.tsx +++ b/apps/web/components/core/sidebar/progress-chart.tsx @@ -6,7 +6,7 @@ import React from "react"; // plane imports -import { AreaChart } from "@plane/propel/charts/area-chart"; +import { AreaChart } from "@plane/blocks/charts/area-chart"; import type { TChartData, TModuleCompletionChartDistribution } from "@plane/types"; import { renderFormattedDateWithoutYear } from "@plane/utils"; diff --git a/apps/web/components/core/sidebar/progress-stats/assignee.tsx b/apps/web/components/core/sidebar/progress-stats/assignee.tsx new file mode 100644 index 00000000000..ed3b4a3f9a7 --- /dev/null +++ b/apps/web/components/core/sidebar/progress-stats/assignee.tsx @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane imports +import { Avatar } from "@makeplane/propel/components/avatar"; +import { useTranslation } from "@plane/i18n"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; +import { getFileURL } from "@plane/utils"; +// components +import { SingleProgressStats } from "@/components/core/sidebar/single-progress-stats"; + +export type TAssigneeData = { + id: string | undefined; + title: string | undefined; + avatar_url: string | undefined; + completed: number; + total: number; +}[]; + +type TAssigneeStatComponent = { + selectedAssigneeIds: string[]; + handleAssigneeFiltersUpdate: (assigneeId: string | undefined) => void; + distribution: TAssigneeData; + isEditable?: boolean; +}; + +export const AssigneeStatComponent = observer(function AssigneeStatComponent(props: TAssigneeStatComponent) { + const { distribution, isEditable, selectedAssigneeIds, handleAssigneeFiltersUpdate } = props; + const { t } = useTranslation(); + return ( +
+ {distribution && distribution.length > 0 ? ( + distribution.map((assignee, index) => { + if (assignee?.id) + return ( + + + {assignee?.title ?? ""} +
+ } + completed={assignee?.completed ?? 0} + total={assignee?.total ?? 0} + {...(isEditable && { + onClick: () => handleAssigneeFiltersUpdate(assignee.id), + selected: assignee.id ? selectedAssigneeIds.includes(assignee.id) : false, + })} + /> + ); + else + return ( + + + {t("no_assignee")} +
+ } + completed={assignee?.completed ?? 0} + total={assignee?.total ?? 0} + /> + ); + }) + ) : ( + + )} +
+ ); +}); diff --git a/apps/web/components/core/sidebar/progress-stats/label.tsx b/apps/web/components/core/sidebar/progress-stats/label.tsx new file mode 100644 index 00000000000..fdda9702123 --- /dev/null +++ b/apps/web/components/core/sidebar/progress-stats/label.tsx @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +// plane imports +import { useTranslation } from "@plane/i18n"; +import { EmptyStateCompact } from "@plane/blocks/empty-state"; +// components +import { SingleProgressStats } from "@/components/core/sidebar/single-progress-stats"; + +export type TLabelData = { + id: string | undefined; + title: string | undefined; + color: string | undefined; + completed: number; + total: number; +}[]; + +type TLabelStatComponent = { + selectedLabelIds: string[]; + handleLabelFiltersUpdate: (labelId: string | undefined) => void; + distribution: TLabelData; + isEditable?: boolean; +}; + +export const LabelStatComponent = observer(function LabelStatComponent(props: TLabelStatComponent) { + const { distribution, isEditable, selectedLabelIds, handleLabelFiltersUpdate } = props; + const { t } = useTranslation(); + return ( +
+ {distribution && distribution.length > 0 ? ( + distribution.map((label, index) => { + if (label.id) { + return ( + + + + {label.title ?? t("no_labels_yet")} + +
+ } + completed={label.completed} + total={label.total} + {...(isEditable && { + onClick: () => handleLabelFiltersUpdate(label.id), + selected: label.id ? selectedLabelIds.includes(label.id) : false, + })} + /> + ); + } else { + return ( + + + {label.title ?? t("no_labels_yet")} +
+ } + completed={label.completed} + total={label.total} + /> + ); + } + }) + ) : ( + + )} + + ); +}); diff --git a/apps/web/core/components/core/sidebar/progress-stats/shared.ts b/apps/web/components/core/sidebar/progress-stats/shared.ts similarity index 100% rename from apps/web/core/components/core/sidebar/progress-stats/shared.ts rename to apps/web/components/core/sidebar/progress-stats/shared.ts diff --git a/apps/web/core/components/core/sidebar/progress-stats/state_group.tsx b/apps/web/components/core/sidebar/progress-stats/state_group.tsx similarity index 91% rename from apps/web/core/components/core/sidebar/progress-stats/state_group.tsx rename to apps/web/components/core/sidebar/progress-stats/state_group.tsx index bcc4fdb7657..baa9368a38d 100644 --- a/apps/web/core/components/core/sidebar/progress-stats/state_group.tsx +++ b/apps/web/components/core/sidebar/progress-stats/state_group.tsx @@ -6,7 +6,7 @@ import { observer } from "mobx-react"; // plane imports -import { StateGroupIcon } from "@plane/propel/icons"; +import { StateGroupIcon } from "@plane/blocks/icons"; import type { TStateGroups } from "@plane/types"; // components import { SingleProgressStats } from "@/components/core/sidebar/single-progress-stats"; @@ -36,7 +36,7 @@ export const StateGroupStatComponent = observer(function StateGroupStatComponent title={
- {group.state} + {group.state}
} completed={group.completed} diff --git a/apps/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx b/apps/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx new file mode 100644 index 00000000000..75a7c00e285 --- /dev/null +++ b/apps/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { observer } from "mobx-react"; +import { RightSidePaneOutline } from "@makeplane/propel/icons"; +import { useAppTheme } from "@/hooks/store/use-app-theme"; + +export const SidebarHamburgerToggle = observer(function SidebarHamburgerToggle() { + // store hooks + const { toggleSidebar } = useAppTheme(); + + const handleClick = (e: React.MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + toggleSidebar(); + }; + + return ( + + ); +}); diff --git a/apps/web/components/core/sidebar/single-progress-stats.tsx b/apps/web/components/core/sidebar/single-progress-stats.tsx new file mode 100644 index 00000000000..e3ef0fa24c1 --- /dev/null +++ b/apps/web/components/core/sidebar/single-progress-stats.tsx @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import React from "react"; + +type TSingleProgressStatsProps = { + title: any; + completed: number; + total: number; + onClick?: () => void; + selected?: boolean; +}; + +export function SingleProgressStats({ title, completed, total, onClick, selected = false }: TSingleProgressStatsProps) { + return ( +
{ + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + onClick(); + } + } + : undefined + } + > +
{title}
+
+ {isNaN(Math.round((completed / total) * 100)) ? "0" : Math.round((completed / total) * 100)}% + of {total} +
+
+ ); +} diff --git a/apps/web/core/components/core/theme/color-inputs.tsx b/apps/web/components/core/theme/color-inputs.tsx similarity index 98% rename from apps/web/core/components/core/theme/color-inputs.tsx rename to apps/web/components/core/theme/color-inputs.tsx index bb3f7995279..169b6f7cddc 100644 --- a/apps/web/core/components/core/theme/color-inputs.tsx +++ b/apps/web/components/core/theme/color-inputs.tsx @@ -9,7 +9,7 @@ import type { Control } from "react-hook-form"; import { Controller } from "react-hook-form"; // plane imports import type { IUserTheme } from "@plane/types"; -import { InputColorPicker } from "@plane/ui"; +import { InputColorPicker } from "./input-color-picker"; type Props = { control: Control; diff --git a/apps/web/core/components/core/theme/custom-theme-selector.tsx b/apps/web/components/core/theme/custom-theme-selector.tsx similarity index 89% rename from apps/web/core/components/core/theme/custom-theme-selector.tsx rename to apps/web/components/core/theme/custom-theme-selector.tsx index 47307776d85..48063763ccd 100644 --- a/apps/web/core/components/core/theme/custom-theme-selector.tsx +++ b/apps/web/components/core/theme/custom-theme-selector.tsx @@ -9,8 +9,8 @@ import { observer } from "mobx-react"; import { useForm } from "react-hook-form"; // plane imports import { useTranslation } from "@plane/i18n"; -import { Button } from "@plane/propel/button"; -import { TOAST_TYPE, setToast } from "@plane/propel/toast"; +import { Button } from "@makeplane/propel/components/button"; +import { setToast } from "@plane/blocks/toast"; import type { IUserTheme } from "@plane/types"; import { applyCustomTheme } from "@plane/utils"; // components @@ -78,7 +78,7 @@ export const CustomThemeSelector = observer(function CustomThemeSelector() { }); setToast({ - type: TOAST_TYPE.SUCCESS, + type: "success", title: t("success"), message: "Reloading to apply changes...", }); @@ -89,7 +89,7 @@ export const CustomThemeSelector = observer(function CustomThemeSelector() { } catch (error) { console.error("Failed to apply theme:", error); setToast({ - type: TOAST_TYPE.ERROR, + type: "error", title: t("error"), message: t("failed_to_update_the_theme"), }); @@ -116,9 +116,14 @@ export const CustomThemeSelector = observer(function CustomThemeSelector() {
{/* Save Theme Button */} - +
diff --git a/apps/web/core/components/core/theme/download-config-button.tsx b/apps/web/components/core/theme/download-config-button.tsx similarity index 83% rename from apps/web/core/components/core/theme/download-config-button.tsx rename to apps/web/components/core/theme/download-config-button.tsx index c2ffc0bc3d8..668a63029b2 100644 --- a/apps/web/core/components/core/theme/download-config-button.tsx +++ b/apps/web/components/core/theme/download-config-button.tsx @@ -8,8 +8,8 @@ import { observer } from "mobx-react"; import type { UseFormGetValues } from "react-hook-form"; // plane imports import { useTranslation } from "@plane/i18n"; -import { Button } from "@plane/propel/button"; -import { setToast, TOAST_TYPE } from "@plane/propel/toast"; +import { Button } from "@makeplane/propel/components/button"; +import { setToast } from "@plane/blocks/toast"; import type { IUserTheme } from "@plane/types"; type Props = { @@ -43,14 +43,14 @@ export const CustomThemeDownloadConfigButton = observer(function CustomThemeDown URL.revokeObjectURL(url); setToast({ - type: TOAST_TYPE.SUCCESS, + type: "success", title: t("success"), message: "Theme configuration downloaded successfully.", }); } catch (error) { console.error("Failed to download config:", error); setToast({ - type: TOAST_TYPE.ERROR, + type: "error", title: t("error"), message: "Failed to download theme configuration.", }); @@ -58,8 +58,13 @@ export const CustomThemeDownloadConfigButton = observer(function CustomThemeDown }; return ( - + +