From d6413909dc09aed4ba9ebf0f97d7748d61de7048 Mon Sep 17 00:00:00 2001 From: gakshita Date: Fri, 17 Jan 2025 16:50:07 +0530 Subject: [PATCH 1/4] chore: ln support workspace projects constants --- packages/constants/src/index.ts | 1 + .../constants/src}/project.ts | 59 ++++++++++--------- .../i18n/src/locales/en/translations.json | 41 ++++++++++++- .../i18n/src/locales/es/translations.json | 40 ++++++++++++- .../i18n/src/locales/fr/translations.json | 40 ++++++++++++- .../i18n/src/locales/ja/translations.json | 40 ++++++++++++- .../i18n/src/locales/zh-CN/translations.json | 40 ++++++++++++- .../(projects)/profile/[userId]/page.tsx | 8 ++- .../(detail)/[projectId]/settings/page.tsx | 2 - .../components/projects/create/attributes.tsx | 8 +-- web/ce/components/projects/create/root.tsx | 2 +- .../sidebar/sidebar-header.tsx | 6 +- .../automation/auto-archive-automation.tsx | 6 +- .../automation/auto-close-automation.tsx | 6 +- web/core/components/cycles/delete-modal.tsx | 8 ++- .../inbox/modals/delete-issue-modal.tsx | 8 ++- .../components/issues/delete-issue-modal.tsx | 13 ++-- .../issues/workspace-draft/delete-modal.tsx | 14 +++-- .../modules/delete-module-modal.tsx | 8 ++- .../project/applied-filters/access.tsx | 6 +- .../project-display-filters.tsx | 6 +- .../project/dropdowns/filters/access.tsx | 8 ++- .../components/project/dropdowns/order-by.tsx | 10 ++-- web/core/components/project/form.tsx | 7 ++- .../stickies/layout/stickies-list.tsx | 2 +- 25 files changed, 305 insertions(+), 84 deletions(-) rename {web/core/constants => packages/constants/src}/project.ts (71%) diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.ts index 2b3964ae9fd..b100b5864bb 100644 --- a/packages/constants/src/index.ts +++ b/packages/constants/src/index.ts @@ -14,3 +14,4 @@ export * from "./swr"; export * from "./user"; export * from "./workspace"; export * from "./stickies"; +export * from "./project"; diff --git a/web/core/constants/project.ts b/packages/constants/src/project.ts similarity index 71% rename from web/core/constants/project.ts rename to packages/constants/src/project.ts index e984cb968a3..48f8528faa0 100644 --- a/web/core/constants/project.ts +++ b/packages/constants/src/project.ts @@ -1,6 +1,9 @@ // icons import { Globe2, Lock, LucideIcon } from "lucide-react"; -import { TProjectAppliedDisplayFilterKeys, TProjectOrderByOptions } from "@plane/types"; +import { + TProjectAppliedDisplayFilterKeys, + TProjectOrderByOptions, +} from "@plane/types"; export const NETWORK_CHOICES: { key: 0 | 2; @@ -10,32 +13,32 @@ export const NETWORK_CHOICES: { }[] = [ { key: 0, - label: "Private", - description: "Accessible only by invite", + label: "workspace_projects.network.private.title", + description: "workspace_projects.network.private.description", //"Accessible only by invite", icon: Lock, }, { key: 2, - label: "Public", - description: "Anyone in the workspace except Guests can join", + label: "workspace_projects.network.public.title", + description: "workspace_projects.network.public.description", //"Anyone in the workspace except Guests can join", icon: Globe2, }, ]; export const GROUP_CHOICES = { - backlog: "Backlog", - unstarted: "Unstarted", - started: "Started", - completed: "Completed", - cancelled: "Cancelled", + backlog: "workspace_projects.state.backlog", + unstarted: "workspace_projects.state.unstarted", + started: "workspace_projects.state.started", + completed: "workspace_projects.state.completed", + cancelled: "workspace_projects.state.cancelled", }; export const PROJECT_AUTOMATION_MONTHS = [ - { label: "1 month", value: 1 }, - { label: "3 months", value: 3 }, - { label: "6 months", value: 6 }, - { label: "9 months", value: 9 }, - { label: "12 months", value: 12 }, + { label: "common.months_count", value: 1 }, + { label: "common.months_count", value: 3 }, + { label: "common.months_count", value: 6 }, + { label: "common.months_count", value: 9 }, + { label: "common.months_count", value: 12 }, ]; export const PROJECT_UNSPLASH_COVERS = [ @@ -63,19 +66,19 @@ export const PROJECT_ORDER_BY_OPTIONS: { }[] = [ { key: "sort_order", - label: "Manual", + label: "workspace_projects.sort.manual", }, { key: "name", - label: "Name", + label: "workspace_projects.sort.name", }, { key: "created_at", - label: "Created date", + label: "workspace_projects.sort.created_at", }, { key: "members_length", - label: "Number of members", + label: "workspace_projects.sort.members_length", }, ]; @@ -85,29 +88,29 @@ export const PROJECT_DISPLAY_FILTER_OPTIONS: { }[] = [ { key: "my_projects", - label: "My projects", + label: "workspace_projects.scope.my_projects", }, { key: "archived_projects", - label: "Archived", + label: "workspace_projects.scope.archived_projects", }, ]; export const PROJECT_ERROR_MESSAGES = { permissionError: { - title: "You don't have permission to perform this action.", + title: "workspace_projects.error.permission", message: undefined, }, cycleDeleteError: { - title: "Error", - message: "Failed to delete cycle", + title: "error", + message: "workspace_projects.error.cycle_delete", }, moduleDeleteError: { - title: "Error", - message: "Failed to delete module", + title: "error", + message: "workspace_projects.error.module_delete", }, issueDeleteError: { - title: "Error", - message: "Failed to delete issue", + title: "error", + message: "workspace_projects.error.issue_delete", }, }; diff --git a/packages/i18n/src/locales/en/translations.json b/packages/i18n/src/locales/en/translations.json index 596c3093fa9..bd8a0b791fa 100644 --- a/packages/i18n/src/locales/en/translations.json +++ b/packages/i18n/src/locales/en/translations.json @@ -316,5 +316,44 @@ "change_parent_issue": "Change parent issue", "remove_parent_issue": "Remove parent issue", "add_parent": "Add parent", - "loading_members": "Loading members..." + "loading_members": "Loading members...", + + "workspace_projects": { + "network": { + "private": { + "title": "Private", + "description": "Accessible only by invite" + }, + "public": { + "title": "Public", + "description": "Anyone in the workspace except Guests can join" + } + }, + "error": { + "permission": "You don't have permission to perform this action.", + "cycle_delete": "Failed to delete cycle", + "module_delete": "Failed to delete module", + "issue_delete": "Failed to delete issue" + }, + "state": { + "backlog": "Backlog", + "unstarted": "Unstarted", + "started": "Started", + "completed": "Completed", + "cancelled": "Cancelled" + }, + "sort": { + "manual": "Manual", + "name": "Name", + "created_at": "Created date", + "members_length": "Number of members" + }, + "scope": { + "my_projects": "My projects", + "archived_projects": "Archived" + }, + "common": { + "months_count": "{months, plural, one{# month} other{# months}}" + } + } } diff --git a/packages/i18n/src/locales/es/translations.json b/packages/i18n/src/locales/es/translations.json index 9f2b98792c2..1662245e4a5 100644 --- a/packages/i18n/src/locales/es/translations.json +++ b/packages/i18n/src/locales/es/translations.json @@ -316,5 +316,43 @@ "remove_parent_issue": "Eliminar problema padre", "add_parent": "Agregar padre", "loading_members": "Cargando miembros...", - "inbox": "bandeja de entrada" + "inbox": "bandeja de entrada", + "workspace_projects": { + "network": { + "private": { + "title": "Privado", + "description": "Accesible solo por invitación" + }, + "public": { + "title": "Público", + "description": "Cualquiera en el espacio de trabajo excepto invitados puede unirse" + } + }, + "error": { + "permission": "No tienes permiso para realizar esta acción.", + "cycle_delete": "Error al eliminar el ciclo", + "module_delete": "Error al eliminar el módulo", + "issue_delete": "Error al eliminar la incidencia" + }, + "state": { + "backlog": "Pendientes", + "unstarted": "Sin comenzar", + "started": "Iniciado", + "completed": "Completado", + "cancelled": "Cancelado" + }, + "sort": { + "manual": "Manual", + "name": "Nombre", + "created_at": "Fecha de creación", + "members_length": "Número de miembros" + }, + "scope": { + "my_projects": "Mis proyectos", + "archived_projects": "Archivados" + }, + "common": { + "months_count": "{months, plural, one{# mes} other{# meses}}" + } + } } diff --git a/packages/i18n/src/locales/fr/translations.json b/packages/i18n/src/locales/fr/translations.json index 0eee868e174..3b5d57df0e2 100644 --- a/packages/i18n/src/locales/fr/translations.json +++ b/packages/i18n/src/locales/fr/translations.json @@ -316,5 +316,43 @@ "remove_parent_issue": "Supprimer le problème parent", "add_parent": "Ajouter un parent", "loading_members": "Chargement des membres...", - "inbox": "Boîte de réception" + "inbox": "Boîte de réception", + "workspace_projects": { + "network": { + "private": { + "title": "Privé", + "description": "Accessible uniquement sur invitation" + }, + "public": { + "title": "Public", + "description": "Tout le monde dans l'espace de travail sauf les invités peut rejoindre" + } + }, + "error": { + "permission": "Vous n'avez pas la permission d'effectuer cette action.", + "cycle_delete": "Échec de la suppression du cycle", + "module_delete": "Échec de la suppression du module", + "issue_delete": "Échec de la suppression du problème" + }, + "state": { + "backlog": "Backlog", + "unstarted": "Non démarré", + "started": "Démarré", + "completed": "Terminé", + "cancelled": "Annulé" + }, + "sort": { + "manual": "Manuel", + "name": "Nom", + "created_at": "Date de création", + "members_length": "Nombre de membres" + }, + "scope": { + "my_projects": "Mes projets", + "archived_projects": "Archivés" + }, + "common": { + "months_count": "{months, plural, one{# mois} other{# mois}}" + } + } } diff --git a/packages/i18n/src/locales/ja/translations.json b/packages/i18n/src/locales/ja/translations.json index fa2b244cc5e..5830acaf808 100644 --- a/packages/i18n/src/locales/ja/translations.json +++ b/packages/i18n/src/locales/ja/translations.json @@ -316,5 +316,43 @@ "remove_parent_issue": "親問題を削除", "add_parent": "親問題を追加", "loading_members": "メンバーを読み込んでいます...", - "inbox": "受信箱" + "inbox": "受信箱", + "workspace_projects": { + "network": { + "private": { + "title": "プライベート", + "description": "招待のみでアクセス可能" + }, + "public": { + "title": "パブリック", + "description": "ゲスト以外のワークスペースのメンバーが参加可能" + } + }, + "error": { + "permission": "この操作を実行する権限がありません。", + "cycle_delete": "サイクルの削除に失敗しました", + "module_delete": "モジュールの削除に失敗しました", + "issue_delete": "課題の削除に失敗しました" + }, + "state": { + "backlog": "バックログ", + "unstarted": "未着手", + "started": "開始済み", + "completed": "完了", + "cancelled": "キャンセル" + }, + "sort": { + "manual": "手動", + "name": "名前", + "created_at": "作成日", + "members_length": "メンバー数" + }, + "scope": { + "my_projects": "自分のプロジェクト", + "archived_projects": "アーカイブ済み" + }, + "common": { + "months_count": "{months, plural, other{#ヶ月}}" + } + } } diff --git a/packages/i18n/src/locales/zh-CN/translations.json b/packages/i18n/src/locales/zh-CN/translations.json index 093027c16b1..3ea7a305295 100644 --- a/packages/i18n/src/locales/zh-CN/translations.json +++ b/packages/i18n/src/locales/zh-CN/translations.json @@ -315,5 +315,43 @@ "remove_parent_issue": "移除父问题", "add_parent": "添加父问题", "loading_members": "正在加载成员...", - "inbox": "收件箱" + "inbox": "收件箱", + "workspace_projects": { + "network": { + "private": { + "title": "私有", + "description": "仅限邀请访问" + }, + "public": { + "title": "公开", + "description": "除访客外的工作区所有成员都可加入" + } + }, + "error": { + "permission": "您没有执行此操作的权限。", + "cycle_delete": "删除周期失败", + "module_delete": "删除模块失败", + "issue_delete": "删除问题失败" + }, + "state": { + "backlog": "待办", + "unstarted": "未开始", + "started": "进行中", + "completed": "已完成", + "cancelled": "已取消" + }, + "sort": { + "manual": "手动", + "name": "名称", + "created_at": "创建日期", + "members_length": "成员数量" + }, + "scope": { + "my_projects": "我的项目", + "archived_projects": "已归档" + }, + "common": { + "months_count": "{months, plural, one{#个月} other{#个月}}" + } + } } diff --git a/web/app/[workspaceSlug]/(projects)/profile/[userId]/page.tsx b/web/app/[workspaceSlug]/(projects)/profile/[userId]/page.tsx index 480e30aed37..dab2e5100d0 100644 --- a/web/app/[workspaceSlug]/(projects)/profile/[userId]/page.tsx +++ b/web/app/[workspaceSlug]/(projects)/profile/[userId]/page.tsx @@ -3,6 +3,8 @@ import { useParams } from "next/navigation"; import useSWR from "swr"; // types +import { GROUP_CHOICES } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; import { IUserStateDistribution, TStateGroups } from "@plane/types"; // components import { ContentWrapper } from "@plane/ui"; @@ -16,7 +18,6 @@ import { } from "@/components/profile"; // constants import { USER_PROFILE_DATA } from "@/constants/fetch-keys"; -import { GROUP_CHOICES } from "@/constants/project"; // services import { UserService } from "@/services/user.service"; @@ -25,6 +26,7 @@ const userService = new UserService(); export default function ProfileOverviewPage() { const { workspaceSlug, userId } = useParams(); + const { t } = useTranslation(); const { data: userProfile } = useSWR( workspaceSlug && userId ? USER_PROFILE_DATA(workspaceSlug.toString(), userId.toString()) : null, @@ -32,10 +34,10 @@ export default function ProfileOverviewPage() { ); const stateDistribution: IUserStateDistribution[] = Object.keys(GROUP_CHOICES).map((key) => { - const group = userProfile?.state_distribution.find((g) => g.state_group === key); + const group = userProfile?.state_distribution.find((g) => g.state_group === t(key)); if (group) return group; - else return { state_group: key as TStateGroups, state_count: 0 }; + else return { state_group: t(key) as TStateGroups, state_count: 0 }; }); return ( diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/page.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/page.tsx index e21532c643a..49b09693203 100644 --- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/page.tsx +++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/page.tsx @@ -43,8 +43,6 @@ const GeneralSettingsPage = observer(() => { ); const pageTitle = currentProjectDetails?.name ? `${currentProjectDetails?.name} - General Settings` : undefined; - // const currentNetwork = NETWORK_CHOICES.find((n) => n.key === projectDetails?.network); - // const selectedNetwork = NETWORK_CHOICES.find((n) => n.key === watch("network")); return ( <> diff --git a/web/ce/components/projects/create/attributes.tsx b/web/ce/components/projects/create/attributes.tsx index 38247188d96..c757c35ba44 100644 --- a/web/ce/components/projects/create/attributes.tsx +++ b/web/ce/components/projects/create/attributes.tsx @@ -1,6 +1,7 @@ "use client"; import { FC } from "react"; import { Controller, useFormContext } from "react-hook-form"; +import { NETWORK_CHOICES } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { IProject } from "@plane/types"; // ui @@ -8,7 +9,6 @@ import { CustomSelect } from "@plane/ui"; // components import { MemberDropdown } from "@/components/dropdowns"; // constants -import { NETWORK_CHOICES } from "@/constants/project"; import { ETabIndices } from "@/constants/tab-indices"; // helpers import { getTabIndex } from "@/helpers/tab-indices.helper"; @@ -40,7 +40,7 @@ const ProjectAttributes: FC = (props) => { {currentNetwork ? ( <> - {currentNetwork.label} + {t(currentNetwork.label)} ) : ( {t("select_network")} @@ -58,8 +58,8 @@ const ProjectAttributes: FC = (props) => {
-

{network.label}

-

{network.description}

+

{t(network.label)}

+

{t(network.description)}

diff --git a/web/ce/components/projects/create/root.tsx b/web/ce/components/projects/create/root.tsx index 8d77d2c0150..95c509a4f7f 100644 --- a/web/ce/components/projects/create/root.tsx +++ b/web/ce/components/projects/create/root.tsx @@ -3,6 +3,7 @@ import { useState, FC } from "react"; import { observer } from "mobx-react"; import { FormProvider, useForm } from "react-hook-form"; +import { PROJECT_UNSPLASH_COVERS } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; // ui import { setToast, TOAST_TYPE } from "@plane/ui"; @@ -11,7 +12,6 @@ import ProjectCommonAttributes from "@/components/project/create/common-attribut import ProjectCreateHeader from "@/components/project/create/header"; import ProjectCreateButtons from "@/components/project/create/project-create-buttons"; import { PROJECT_CREATED } from "@/constants/event-tracker"; -import { PROJECT_UNSPLASH_COVERS } from "@/constants/project"; // helpers import { getRandomEmoji } from "@/helpers/emoji.helper"; // hooks diff --git a/web/core/components/analytics/custom-analytics/sidebar/sidebar-header.tsx b/web/core/components/analytics/custom-analytics/sidebar/sidebar-header.tsx index 9873d08a879..dd070c53c12 100644 --- a/web/core/components/analytics/custom-analytics/sidebar/sidebar-header.tsx +++ b/web/core/components/analytics/custom-analytics/sidebar/sidebar-header.tsx @@ -1,9 +1,10 @@ import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // components +import { NETWORK_CHOICES } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; import { Logo } from "@/components/common"; // constants -import { NETWORK_CHOICES } from "@/constants/project"; // helpers import { renderFormattedDate } from "@/helpers/date-time.helper"; // hooks @@ -16,6 +17,7 @@ export const CustomAnalyticsSidebarHeader = observer(() => { const { getCycleById } = useCycle(); const { getModuleById } = useModule(); const { getUserDetails } = useMember(); + const { t } = useTranslation(); const cycleDetails = cycleId ? getCycleById(cycleId.toString()) : undefined; const moduleDetails = moduleId ? getModuleById(moduleId.toString()) : undefined; @@ -91,7 +93,7 @@ export const CustomAnalyticsSidebarHeader = observer(() => {
Network
- {NETWORK_CHOICES.find((n) => n.key === projectDetails?.network)?.label ?? ""} + {t(NETWORK_CHOICES.find((n) => n.key === projectDetails?.network)?.label ?? "")}
diff --git a/web/core/components/automation/auto-archive-automation.tsx b/web/core/components/automation/auto-archive-automation.tsx index 8ef488da599..a4afe5d29f2 100644 --- a/web/core/components/automation/auto-archive-automation.tsx +++ b/web/core/components/automation/auto-archive-automation.tsx @@ -4,13 +4,14 @@ import React, { useState } from "react"; import { observer } from "mobx-react"; import { ArchiveRestore } from "lucide-react"; // types +import { PROJECT_AUTOMATION_MONTHS } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; import { IProject } from "@plane/types"; // ui import { CustomSelect, Loader, ToggleSwitch } from "@plane/ui"; // component import { SelectMonthModal } from "@/components/automation"; // constants -import { PROJECT_AUTOMATION_MONTHS } from "@/constants/project"; // hooks import { useProject, useUserPermissions } from "@/hooks/store"; import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; @@ -27,6 +28,7 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { const [monthModal, setmonthModal] = useState(false); // store hooks const { allowPermissions } = useUserPermissions(); + const { t } = useTranslation(); const { currentProjectDetails } = useProject(); @@ -91,7 +93,7 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( - {month.label} + {t(month.label, { month: month.value })} ))} diff --git a/web/core/components/automation/auto-close-automation.tsx b/web/core/components/automation/auto-close-automation.tsx index dce5764d420..18e3be6722a 100644 --- a/web/core/components/automation/auto-close-automation.tsx +++ b/web/core/components/automation/auto-close-automation.tsx @@ -5,13 +5,14 @@ import { observer } from "mobx-react"; // icons import { ArchiveX } from "lucide-react"; // types +import { PROJECT_AUTOMATION_MONTHS } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; import { IProject } from "@plane/types"; // ui import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui"; // component import { SelectMonthModal } from "@/components/automation"; // constants -import { PROJECT_AUTOMATION_MONTHS } from "@/constants/project"; // hooks import { useProject, useProjectState, useUserPermissions } from "@/hooks/store"; import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; @@ -28,6 +29,7 @@ export const AutoCloseAutomation: React.FC = observer((props) => { const { currentProjectDetails } = useProject(); const { projectStates } = useProjectState(); const { allowPermissions } = useUserPermissions(); + const { t } = useTranslation(); // const stateGroups = projectStateStore.groupedProjectStates ?? undefined; @@ -118,7 +120,7 @@ export const AutoCloseAutomation: React.FC = observer((props) => { <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( - {month.label} + {t(month.label, { month: month.value })} ))}