From 5273b5b734564c44d4b8945a137a68d73131e2fa Mon Sep 17 00:00:00 2001 From: gakshita Date: Mon, 20 Jan 2025 15:02:31 +0530 Subject: [PATCH 1/4] fix: ln support for views constants --- packages/constants/src/index.ts | 1 + packages/constants/src/views.ts | 23 +++++++++ .../i18n/src/locales/en/translations.json | 19 +++++++- .../views/(detail)/[viewId]/header.tsx | 3 +- .../[projectId]/views/(list)/page.tsx | 2 +- web/ce/services/project/view.service.ts | 2 +- web/ce/services/workspace.service.ts | 2 +- .../roots/global-view-root.tsx | 3 +- .../roots/project-view-root.tsx | 3 +- .../stickies/layout/stickies-list.tsx | 2 +- .../views/applied-filters/access.tsx | 3 +- .../components/views/applied-filters/root.tsx | 2 +- .../views/filters/filter-selection.tsx | 2 +- .../components/views/filters/order-by.tsx | 48 +++++++++---------- web/core/components/views/form.tsx | 3 +- .../views/view-list-item-action.tsx | 2 +- web/core/components/workspace/views/form.tsx | 3 +- .../workspace/views/quick-action.tsx | 2 +- web/core/constants/empty-state.tsx | 2 +- web/core/constants/views.ts | 33 ------------- web/core/store/global-view.store.ts | 3 +- web/core/store/project-view.store.ts | 2 +- web/helpers/views.helper.ts | 15 ++++++ 23 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 packages/constants/src/views.ts delete mode 100644 web/core/constants/views.ts create mode 100644 web/helpers/views.helper.ts diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.ts index 2b3964ae9fd..fcefe1855eb 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 "./views"; diff --git a/packages/constants/src/views.ts b/packages/constants/src/views.ts new file mode 100644 index 00000000000..1e80b99ae49 --- /dev/null +++ b/packages/constants/src/views.ts @@ -0,0 +1,23 @@ +export enum EViewAccess { + PRIVATE, + PUBLIC, +} + +export const VIEW_ACCESS_SPECIFIERS: { + key: EViewAccess; + label: string; +}[] = [ + { key: EViewAccess.PUBLIC, label: "project_view.access.public" }, + { key: EViewAccess.PRIVATE, label: "project_view.access.private" }, +]; + +export const VIEW_SORTING_KEY_OPTIONS = [ + { key: "name", label: "project_view.sort_by.name" }, + { key: "created_at", label: "project_view.sort_by.created_at" }, + { key: "updated_at", label: "project_view.sort_by.updated_at" }, +]; + +export const VIEW_SORT_BY_OPTIONS = [ + { key: "asc", label: "common.order_by.asc" }, + { key: "desc", label: "common.order_by.desc" }, +]; diff --git a/packages/i18n/src/locales/en/translations.json b/packages/i18n/src/locales/en/translations.json index 596c3093fa9..46a1496c8be 100644 --- a/packages/i18n/src/locales/en/translations.json +++ b/packages/i18n/src/locales/en/translations.json @@ -316,5 +316,22 @@ "change_parent_issue": "Change parent issue", "remove_parent_issue": "Remove parent issue", "add_parent": "Add parent", - "loading_members": "Loading members..." + "loading_members": "Loading members...", + "project_view": { + "access": { + "public": "Public", + "private": "Private" + }, + "sort_by": { + "created_at": "Created at", + "updated_at": "Updated at", + "name": "Name" + } + }, + "common": { + "order_by": { + "asc": "Ascending", + "desc": "Descending" + } + } } diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx index aaaf5012d9e..1b12d5a3363 100644 --- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx +++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx @@ -6,7 +6,7 @@ import Link from "next/link"; import { useParams } from "next/navigation"; import { Layers, Lock } from "lucide-react"; // plane constants -import { EIssueLayoutTypes, EIssueFilterType, EIssuesStoreType } from "@plane/constants"; +import { EIssueLayoutTypes, EIssueFilterType, EIssuesStoreType, EViewAccess } from "@plane/constants"; // types import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions } from "@plane/types"; // ui @@ -17,7 +17,6 @@ import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelect // constants import { ViewQuickActions } from "@/components/views"; import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "@/constants/issue"; -import { EViewAccess } from "@/constants/views"; // helpers import { isIssueFilterActive } from "@/helpers/filter.helper"; import { truncateText } from "@/helpers/string.helper"; diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(list)/page.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(list)/page.tsx index 387f6e5b423..2da81f1a8fd 100644 --- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(list)/page.tsx +++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(list)/page.tsx @@ -4,6 +4,7 @@ import { useCallback } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // components +import { EViewAccess } from "@plane/constants"; import { TViewFilterProps } from "@plane/types"; import { Header, EHeaderVariant } from "@plane/ui"; import { PageHead } from "@/components/core"; @@ -12,7 +13,6 @@ import { ProjectViewsList } from "@/components/views"; import { ViewAppliedFiltersList } from "@/components/views/applied-filters"; import { EmptyStateType } from "@/constants/empty-state"; // constants -import { EViewAccess } from "@/constants/views"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; // hooks diff --git a/web/ce/services/project/view.service.ts b/web/ce/services/project/view.service.ts index 6cb76222add..9a6ee12a226 100644 --- a/web/ce/services/project/view.service.ts +++ b/web/ce/services/project/view.service.ts @@ -1,5 +1,5 @@ +import { EViewAccess } from "@plane/constants"; import { TPublishViewSettings } from "@plane/types"; -import { EViewAccess } from "@/constants/views"; import { API_BASE_URL } from "@/helpers/common.helper"; import { ViewService as CoreViewService } from "@/services/view.service"; diff --git a/web/ce/services/workspace.service.ts b/web/ce/services/workspace.service.ts index 59fe39c69ce..9dcfb7f6c5e 100644 --- a/web/ce/services/workspace.service.ts +++ b/web/ce/services/workspace.service.ts @@ -1,4 +1,4 @@ -import { EViewAccess } from "@/constants/views"; +import { EViewAccess } from "@plane/constants"; import { API_BASE_URL } from "@/helpers/common.helper"; import { WorkspaceService as CoreWorkspaceService } from "@/services/workspace.service"; diff --git a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx index 7744d48c868..4810d32e1bf 100644 --- a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx +++ b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/global-view-root.tsx @@ -6,7 +6,7 @@ import isEmpty from "lodash/isEmpty"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // types -import { EIssueFilterType, EIssuesStoreType } from "@plane/constants"; +import { EIssueFilterType, EIssuesStoreType, EViewAccess } from "@plane/constants"; import { IIssueFilterOptions, TStaticViewTypes } from "@plane/types"; //ui // components @@ -16,7 +16,6 @@ import { UpdateViewComponent } from "@/components/views/update-view-component"; import { CreateUpdateWorkspaceViewModal } from "@/components/workspace"; // constants import { GLOBAL_VIEW_UPDATED } from "@/constants/event-tracker"; -import { EViewAccess } from "@/constants/views"; import { DEFAULT_GLOBAL_VIEWS_LIST } from "@/constants/workspace"; // helpers import { cn } from "@/helpers/common.helper"; diff --git a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx index 152ebcc2d3f..7945426ece3 100644 --- a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx +++ b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx @@ -6,7 +6,7 @@ import isEmpty from "lodash/isEmpty"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // types -import { EIssueFilterType, EIssuesStoreType } from "@plane/constants"; +import { EIssueFilterType, EIssuesStoreType, EViewAccess } from "@plane/constants"; import { IIssueFilterOptions } from "@plane/types"; // components import { Header, EHeaderVariant } from "@plane/ui"; @@ -14,7 +14,6 @@ import { AppliedFiltersList } from "@/components/issues"; import { CreateUpdateProjectViewModal } from "@/components/views"; import { UpdateViewComponent } from "@/components/views/update-view-component"; // constants -import { EViewAccess } from "@/constants/views"; // hooks import { useIssues, useLabel, useProjectState, useProjectView, useUser, useUserPermissions } from "@/hooks/store"; import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; diff --git a/web/core/components/stickies/layout/stickies-list.tsx b/web/core/components/stickies/layout/stickies-list.tsx index 4da6efe7b03..2a743d0cc02 100644 --- a/web/core/components/stickies/layout/stickies-list.tsx +++ b/web/core/components/stickies/layout/stickies-list.tsx @@ -12,13 +12,13 @@ import { Loader } from "@plane/ui"; // components import { EmptyState } from "@/components/empty-state"; // constants +import { StickiesEmptyState } from "@/components/home/widgets/empty-states/stickies"; import { EmptyStateType } from "@/constants/empty-state"; // hooks import { useSticky } from "@/hooks/use-stickies"; import { useStickyOperations } from "../sticky/use-operations"; import { StickyDNDWrapper } from "./sticky-dnd-wrapper"; import { getInstructionFromPayload } from "./sticky.helpers"; -import { StickiesEmptyState } from "@/components/home/widgets/empty-states/stickies"; type TStickiesLayout = { workspaceSlug: string; diff --git a/web/core/components/views/applied-filters/access.tsx b/web/core/components/views/applied-filters/access.tsx index 8e418daecf9..40616adffc6 100644 --- a/web/core/components/views/applied-filters/access.tsx +++ b/web/core/components/views/applied-filters/access.tsx @@ -2,8 +2,9 @@ import { observer } from "mobx-react"; // icons import { X } from "lucide-react"; // constants -import { EViewAccess, VIEW_ACCESS_SPECIFIERS } from "@/constants/views"; +import { EViewAccess } from "@plane/constants"; // helpers +import { VIEW_ACCESS_SPECIFIERS } from "@/helpers/views.helper"; type Props = { editable: boolean | undefined; diff --git a/web/core/components/views/applied-filters/root.tsx b/web/core/components/views/applied-filters/root.tsx index 391e02bf2b2..85788d6877d 100644 --- a/web/core/components/views/applied-filters/root.tsx +++ b/web/core/components/views/applied-filters/root.tsx @@ -1,10 +1,10 @@ import { X } from "lucide-react"; +import { EViewAccess } from "@plane/constants"; import { TViewFilterProps } from "@plane/types"; // components import { Tag } from "@plane/ui"; import { AppliedDateFilters, AppliedMembersFilters } from "@/components/common/applied-filters"; // constants -import { EViewAccess } from "@/constants/views"; // helpers import { replaceUnderscoreIfSnakeCase } from "@/helpers/string.helper"; import { AppliedAccessFilters } from "./access"; diff --git a/web/core/components/views/filters/filter-selection.tsx b/web/core/components/views/filters/filter-selection.tsx index 00b8ea817e6..d2a32fb79de 100644 --- a/web/core/components/views/filters/filter-selection.tsx +++ b/web/core/components/views/filters/filter-selection.tsx @@ -1,12 +1,12 @@ import { useState } from "react"; import { observer } from "mobx-react"; import { Search, X } from "lucide-react"; +import { EViewAccess } from "@plane/constants"; import { TViewFilterProps, TViewFilters } from "@plane/types"; // components import { FilterCreatedBy, FilterCreatedDate } from "@/components/common/filters"; import { FilterOption } from "@/components/issues"; // constants -import { EViewAccess } from "@/constants/views"; // hooks import { usePlatformOS } from "@/hooks/use-platform-os"; // plane web components diff --git a/web/core/components/views/filters/order-by.tsx b/web/core/components/views/filters/order-by.tsx index 1012700dcde..cce6a7a495c 100644 --- a/web/core/components/views/filters/order-by.tsx +++ b/web/core/components/views/filters/order-by.tsx @@ -2,11 +2,12 @@ import { ArrowDownWideNarrow, ArrowUpWideNarrow, Check, ChevronDown } from "lucide-react"; // types +import { VIEW_SORT_BY_OPTIONS, VIEW_SORTING_KEY_OPTIONS } from "@plane/constants"; +import { useTranslation } from "@plane/i18n"; import { TViewFiltersSortBy, TViewFiltersSortKey } from "@plane/types"; // ui import { CustomMenu, getButtonStyling } from "@plane/ui"; // constants -import { VIEW_SORTING_KEY_OPTIONS } from "@/constants/views"; type Props = { onChange: (value: { key?: TViewFiltersSortKey; order?: TViewFiltersSortBy }) => void; @@ -17,15 +18,11 @@ type Props = { export const ViewOrderByDropdown: React.FC = (props) => { const { onChange, sortBy, sortKey, isMobile = false } = props; + const { t } = useTranslation(); const orderByDetails = VIEW_SORTING_KEY_OPTIONS.find((option) => sortKey === option.key); const isDescending = sortBy === "desc"; - const sortByOptions = [ - { key: "asc", label: "Ascending", isSelected: !isDescending }, - { key: "desc", label: "Descending", isSelected: isDescending }, - ]; - const buttonClassName = isMobile ? "flex items-center text-sm text-custom-text-200 gap-2 w-full" : `${getButtonStyling("neutral-primary", "sm")} px-2 text-custom-text-300`; @@ -39,7 +36,7 @@ export const ViewOrderByDropdown: React.FC = (props) => { customButton={ {!isMobile && icon} - {orderByDetails?.label} + {orderByDetails?.label && t(orderByDetails?.label)} } @@ -54,30 +51,33 @@ export const ViewOrderByDropdown: React.FC = (props) => { className="flex items-center justify-between gap-2" onClick={() => onChange({ - key: option.key, + key: option.key as TViewFiltersSortKey, }) } > - {option.label} + {t(option.label)} {sortKey === option.key && } ))}
- {sortByOptions.map((option) => ( - { - if (!option.isSelected) - onChange({ - order: option.key as TViewFiltersSortBy, - }); - }} - > - {option.label} - {option.isSelected && } - - ))} + {VIEW_SORT_BY_OPTIONS.map((option) => { + const isSelected = (option.key === "asc" && !isDescending) || (option.key === "desc" && isDescending); + return ( + { + if (!isSelected) + onChange({ + order: option.key as TViewFiltersSortBy, + }); + }} + > + {t(option.label)} + {isSelected && } + + ); + })} ); }; diff --git a/web/core/components/views/form.tsx b/web/core/components/views/form.tsx index a39f98fc4e8..fe74e8114cf 100644 --- a/web/core/components/views/form.tsx +++ b/web/core/components/views/form.tsx @@ -5,7 +5,7 @@ import { observer } from "mobx-react"; import { Controller, useForm } from "react-hook-form"; import { Layers } from "lucide-react"; // plane constants -import { EIssueLayoutTypes } from "@plane/constants"; +import { EIssueLayoutTypes, EViewAccess } from "@plane/constants"; // types import { IProjectView, IIssueFilterOptions, IIssueDisplayProperties, IIssueDisplayFilterOptions } from "@plane/types"; // ui @@ -16,7 +16,6 @@ import { AppliedFiltersList, DisplayFiltersSelection, FilterSelection, FiltersDr // constants import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "@/constants/issue"; import { ETabIndices } from "@/constants/tab-indices"; -import { EViewAccess } from "@/constants/views"; // helpers import { convertHexEmojiToDecimal } from "@/helpers/emoji.helper"; import { getComputedDisplayFilters, getComputedDisplayProperties } from "@/helpers/issue.helper"; diff --git a/web/core/components/views/view-list-item-action.tsx b/web/core/components/views/view-list-item-action.tsx index 1868f2e52bf..f9013c07abb 100644 --- a/web/core/components/views/view-list-item-action.tsx +++ b/web/core/components/views/view-list-item-action.tsx @@ -3,13 +3,13 @@ import { observer } from "mobx-react"; import { useParams } from "next/navigation"; import { Earth, Lock } from "lucide-react"; // types +import { EViewAccess } from "@plane/constants"; import { IProjectView } from "@plane/types"; // ui import { Tooltip, FavoriteStar } from "@plane/ui"; // components import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions } from "@/components/views"; // constants -import { EViewAccess } from "@/constants/views"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; import { getPublishViewLink } from "@/helpers/project-views.helpers"; diff --git a/web/core/components/workspace/views/form.tsx b/web/core/components/workspace/views/form.tsx index 9710f093694..f4644bd6a12 100644 --- a/web/core/components/workspace/views/form.tsx +++ b/web/core/components/workspace/views/form.tsx @@ -4,7 +4,7 @@ import { useEffect } from "react"; import { observer } from "mobx-react"; import { Controller, useForm } from "react-hook-form"; // constant -import { EIssueLayoutTypes } from "@plane/constants"; +import { EIssueLayoutTypes, EViewAccess } from "@plane/constants"; // types import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions, IWorkspaceView } from "@plane/types"; // ui @@ -13,7 +13,6 @@ import { Button, Input, TextArea } from "@plane/ui"; import { AppliedFiltersList, DisplayFiltersSelection, FilterSelection, FiltersDropdown } from "@/components/issues"; // constants import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "@/constants/issue"; -import { EViewAccess } from "@/constants/views"; // helpers import { getComputedDisplayFilters, getComputedDisplayProperties } from "@/helpers/issue.helper"; // hooks diff --git a/web/core/components/workspace/views/quick-action.tsx b/web/core/components/workspace/views/quick-action.tsx index c8ee029466b..dd6184cc9d5 100644 --- a/web/core/components/workspace/views/quick-action.tsx +++ b/web/core/components/workspace/views/quick-action.tsx @@ -5,13 +5,13 @@ import { observer } from "mobx-react"; import Link from "next/link"; import { ExternalLink, LinkIcon, Pencil, Trash2, Lock } from "lucide-react"; // types +import { EViewAccess } from "@plane/constants"; import { IWorkspaceView } from "@plane/types"; // ui import { ContextMenu, CustomMenu, TContextMenuItem, TOAST_TYPE, setToast } from "@plane/ui"; // components import { CreateUpdateWorkspaceViewModal, DeleteGlobalViewModal } from "@/components/workspace"; // constants -import { EViewAccess } from "@/constants/views"; // helpers import { cn } from "@/helpers/common.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper"; diff --git a/web/core/constants/empty-state.tsx b/web/core/constants/empty-state.tsx index ef1b9e91829..c2ae08784d7 100644 --- a/web/core/constants/empty-state.tsx +++ b/web/core/constants/empty-state.tsx @@ -1,5 +1,5 @@ -import { EUserPermissions } from "ee/constants/user-permissions"; import { Plus, Shapes } from "lucide-react"; +import { EUserPermissions } from "ee/constants/user-permissions"; export interface EmptyStateDetails { key: EmptyStateType; diff --git a/web/core/constants/views.ts b/web/core/constants/views.ts deleted file mode 100644 index a8e501db459..00000000000 --- a/web/core/constants/views.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Globe2, Lock, LucideIcon } from "lucide-react"; -import { TViewFiltersSortBy, TViewFiltersSortKey } from "@plane/types"; - -export enum EViewAccess { - PRIVATE, - PUBLIC, -} - -export const VIEW_ACCESS_SPECIFIERS: { - key: EViewAccess; - label: string; - icon: LucideIcon; -}[] = [ - { key: EViewAccess.PUBLIC, label: "Public", icon: Globe2 }, - { key: EViewAccess.PRIVATE, label: "Private", icon: Lock }, -]; - -export const VIEW_SORTING_KEY_OPTIONS: { - key: TViewFiltersSortKey; - label: string; -}[] = [ - { key: "name", label: "Name" }, - { key: "created_at", label: "Date created" }, - { key: "updated_at", label: "Date modified" }, -]; - -export const VIEW_SORT_BY_OPTIONS: { - key: TViewFiltersSortBy; - label: string; -}[] = [ - { key: "asc", label: "Ascending" }, - { key: "desc", label: "Descending" }, -]; diff --git a/web/core/store/global-view.store.ts b/web/core/store/global-view.store.ts index ff40a8fd33a..c9840b4c8f0 100644 --- a/web/core/store/global-view.store.ts +++ b/web/core/store/global-view.store.ts @@ -4,10 +4,9 @@ import isEqual from "lodash/isEqual"; import set from "lodash/set"; import { observable, action, makeObservable, runInAction, computed } from "mobx"; import { computedFn } from "mobx-utils"; -import { EIssueFilterType } from "@plane/constants"; +import { EIssueFilterType, EViewAccess } from "@plane/constants"; import { IIssueFilterOptions, IWorkspaceView } from "@plane/types"; // constants -import { EViewAccess } from "@/constants/views"; // services import { WorkspaceService } from "@/plane-web/services"; // store diff --git a/web/core/store/project-view.store.ts b/web/core/store/project-view.store.ts index b9f4e865681..d2e911aa664 100644 --- a/web/core/store/project-view.store.ts +++ b/web/core/store/project-view.store.ts @@ -2,9 +2,9 @@ import { set } from "lodash"; import { observable, action, makeObservable, runInAction, computed } from "mobx"; import { computedFn } from "mobx-utils"; // types +import { EViewAccess } from "@plane/constants"; import { IProjectView, TPublishViewDetails, TPublishViewSettings, TViewFilters } from "@plane/types"; // constants -import { EViewAccess } from "@/constants/views"; // helpers import { getValidatedViewFilters, getViewName, orderViews, shouldFilterView } from "@/helpers/project-views.helpers"; // services diff --git a/web/helpers/views.helper.ts b/web/helpers/views.helper.ts new file mode 100644 index 00000000000..82b1a9c02f4 --- /dev/null +++ b/web/helpers/views.helper.ts @@ -0,0 +1,15 @@ +import { Globe2, Lock, LucideIcon } from "lucide-react"; +import { EViewAccess, VIEW_ACCESS_SPECIFIERS as VIEW_ACCESS_SPECIFIERS_CONSTANTS } from "@plane/constants"; + +const VIEW_ACCESS_ICONS = { + [EViewAccess.PUBLIC]: Globe2, + [EViewAccess.PRIVATE]: Lock, +}; +export const VIEW_ACCESS_SPECIFIERS: { + key: EViewAccess; + label: string; + icon: LucideIcon; +}[] = VIEW_ACCESS_SPECIFIERS_CONSTANTS.map((option) => ({ + ...option, + icon: VIEW_ACCESS_ICONS[option.key as keyof typeof VIEW_ACCESS_ICONS], +})); From b2d2c940c6ae34746e683e40cf1b9bae15c560eb Mon Sep 17 00:00:00 2001 From: gakshita Date: Mon, 20 Jan 2025 15:06:24 +0530 Subject: [PATCH 2/4] fix: added translation --- .../i18n/src/locales/es/translations.json | 19 ++++++++++++++++++- .../i18n/src/locales/fr/translations.json | 19 ++++++++++++++++++- .../i18n/src/locales/ja/translations.json | 19 ++++++++++++++++++- .../i18n/src/locales/zh-CN/translations.json | 19 ++++++++++++++++++- 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/packages/i18n/src/locales/es/translations.json b/packages/i18n/src/locales/es/translations.json index 9f2b98792c2..de4cbfd028d 100644 --- a/packages/i18n/src/locales/es/translations.json +++ b/packages/i18n/src/locales/es/translations.json @@ -316,5 +316,22 @@ "remove_parent_issue": "Eliminar problema padre", "add_parent": "Agregar padre", "loading_members": "Cargando miembros...", - "inbox": "bandeja de entrada" + "inbox": "bandeja de entrada", + "project_view": { + "access": { + "public": "Público", + "private": "Privado" + }, + "sort_by": { + "created_at": "Fecha de creación", + "updated_at": "Fecha de actualización", + "name": "Nombre" + } + }, + "common": { + "order_by": { + "asc": "Ascendente", + "desc": "Descendente" + } + } } diff --git a/packages/i18n/src/locales/fr/translations.json b/packages/i18n/src/locales/fr/translations.json index 0eee868e174..a3fd734cd00 100644 --- a/packages/i18n/src/locales/fr/translations.json +++ b/packages/i18n/src/locales/fr/translations.json @@ -316,5 +316,22 @@ "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", + "project_view": { + "access": { + "public": "Public", + "private": "Privé" + }, + "sort_by": { + "created_at": "Date de création", + "updated_at": "Date de modification", + "name": "Nom" + } + }, + "common": { + "order_by": { + "asc": "Croissant", + "desc": "Décroissant" + } + } } diff --git a/packages/i18n/src/locales/ja/translations.json b/packages/i18n/src/locales/ja/translations.json index fa2b244cc5e..a36f922554c 100644 --- a/packages/i18n/src/locales/ja/translations.json +++ b/packages/i18n/src/locales/ja/translations.json @@ -316,5 +316,22 @@ "remove_parent_issue": "親問題を削除", "add_parent": "親問題を追加", "loading_members": "メンバーを読み込んでいます...", - "inbox": "受信箱" + "inbox": "受信箱", + "project_view": { + "access": { + "public": "公開", + "private": "非公開" + }, + "sort_by": { + "created_at": "作成日時", + "updated_at": "更新日時", + "name": "名前" + } + }, + "common": { + "order_by": { + "asc": "昇順", + "desc": "降順" + } + } } diff --git a/packages/i18n/src/locales/zh-CN/translations.json b/packages/i18n/src/locales/zh-CN/translations.json index 093027c16b1..8f4696fa58a 100644 --- a/packages/i18n/src/locales/zh-CN/translations.json +++ b/packages/i18n/src/locales/zh-CN/translations.json @@ -315,5 +315,22 @@ "remove_parent_issue": "移除父问题", "add_parent": "添加父问题", "loading_members": "正在加载成员...", - "inbox": "收件箱" + "inbox": "收件箱", + "project_view": { + "access": { + "public": "公开", + "private": "私密" + }, + "sort_by": { + "created_at": "创建时间", + "updated_at": "更新时间", + "name": "名称" + } + }, + "common": { + "order_by": { + "asc": "升序", + "desc": "降序" + } + } } From b0f79c137ab1666492ca5a43334cdf848e3c3e62 Mon Sep 17 00:00:00 2001 From: gakshita Date: Wed, 22 Jan 2025 13:56:50 +0530 Subject: [PATCH 3/4] fix: translation keys --- packages/constants/src/views.ts | 16 ++++++++-------- .../components/views/applied-filters/access.tsx | 2 +- web/core/components/views/filters/order-by.tsx | 6 +++--- web/helpers/views.helper.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/constants/src/views.ts b/packages/constants/src/views.ts index 1e80b99ae49..8c051790e9b 100644 --- a/packages/constants/src/views.ts +++ b/packages/constants/src/views.ts @@ -5,19 +5,19 @@ export enum EViewAccess { export const VIEW_ACCESS_SPECIFIERS: { key: EViewAccess; - label: string; + i18n_label: string; }[] = [ - { key: EViewAccess.PUBLIC, label: "project_view.access.public" }, - { key: EViewAccess.PRIVATE, label: "project_view.access.private" }, + { key: EViewAccess.PUBLIC, i18n_label: "project_view.access.public" }, + { key: EViewAccess.PRIVATE, i18n_label: "project_view.access.private" }, ]; export const VIEW_SORTING_KEY_OPTIONS = [ - { key: "name", label: "project_view.sort_by.name" }, - { key: "created_at", label: "project_view.sort_by.created_at" }, - { key: "updated_at", label: "project_view.sort_by.updated_at" }, + { key: "name", i18n_label: "project_view.sort_by.name" }, + { key: "created_at", i18n_label: "project_view.sort_by.created_at" }, + { key: "updated_at", i18n_label: "project_view.sort_by.updated_at" }, ]; export const VIEW_SORT_BY_OPTIONS = [ - { key: "asc", label: "common.order_by.asc" }, - { key: "desc", label: "common.order_by.desc" }, + { key: "asc", i18n_label: "common.order_by.asc" }, + { key: "desc", i18n_label: "common.order_by.desc" }, ]; diff --git a/web/core/components/views/applied-filters/access.tsx b/web/core/components/views/applied-filters/access.tsx index 40616adffc6..5a53f7ca6db 100644 --- a/web/core/components/views/applied-filters/access.tsx +++ b/web/core/components/views/applied-filters/access.tsx @@ -17,7 +17,7 @@ export const AppliedAccessFilters: React.FC = observer((props) => { const getAccessLabel = (val: EViewAccess) => { const value = VIEW_ACCESS_SPECIFIERS.find((option) => option.key === val); - return value?.label; + return value?.i18n_label; }; return ( diff --git a/web/core/components/views/filters/order-by.tsx b/web/core/components/views/filters/order-by.tsx index cce6a7a495c..399bf56d12b 100644 --- a/web/core/components/views/filters/order-by.tsx +++ b/web/core/components/views/filters/order-by.tsx @@ -36,7 +36,7 @@ export const ViewOrderByDropdown: React.FC = (props) => { customButton={ {!isMobile && icon} - {orderByDetails?.label && t(orderByDetails?.label)} + {orderByDetails?.i18n_label && t(orderByDetails?.i18n_label)} } @@ -55,7 +55,7 @@ export const ViewOrderByDropdown: React.FC = (props) => { }) } > - {t(option.label)} + {t(option.i18n_label)} {sortKey === option.key && } ))} @@ -73,7 +73,7 @@ export const ViewOrderByDropdown: React.FC = (props) => { }); }} > - {t(option.label)} + {t(option.i18n_label)} {isSelected && } ); diff --git a/web/helpers/views.helper.ts b/web/helpers/views.helper.ts index 82b1a9c02f4..8ce430aaf6b 100644 --- a/web/helpers/views.helper.ts +++ b/web/helpers/views.helper.ts @@ -7,7 +7,7 @@ const VIEW_ACCESS_ICONS = { }; export const VIEW_ACCESS_SPECIFIERS: { key: EViewAccess; - label: string; + i18n_label: string; icon: LucideIcon; }[] = VIEW_ACCESS_SPECIFIERS_CONSTANTS.map((option) => ({ ...option, From 40d3cafe64150d4e659088fb7e49893b59a2efba Mon Sep 17 00:00:00 2001 From: gakshita Date: Mon, 27 Jan 2025 19:50:29 +0530 Subject: [PATCH 4/4] fix: access --- web/core/components/views/applied-filters/access.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/core/components/views/applied-filters/access.tsx b/web/core/components/views/applied-filters/access.tsx index 5a53f7ca6db..ce46a800ab6 100644 --- a/web/core/components/views/applied-filters/access.tsx +++ b/web/core/components/views/applied-filters/access.tsx @@ -4,6 +4,7 @@ import { X } from "lucide-react"; // constants import { EViewAccess } from "@plane/constants"; // helpers +import { useTranslation } from "@plane/i18n"; import { VIEW_ACCESS_SPECIFIERS } from "@/helpers/views.helper"; type Props = { @@ -14,6 +15,7 @@ type Props = { export const AppliedAccessFilters: React.FC = observer((props) => { const { editable, handleRemove, values } = props; + const { t } = useTranslation(); const getAccessLabel = (val: EViewAccess) => { const value = VIEW_ACCESS_SPECIFIERS.find((option) => option.key === val); @@ -29,7 +31,7 @@ export const AppliedAccessFilters: React.FC = observer((props) => { return (
- {label} + {t(label)} {editable && (