From 6a8791b9139ec37bd2082497d176a6adbaadd932 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Fri, 14 Feb 2025 18:57:47 +0530 Subject: [PATCH] improvement: minor improvements for workspace switcher --- packages/types/src/workspace.d.ts | 1 - packages/utils/src/index.ts | 1 + packages/utils/src/workspace.ts | 5 +++++ web/ce/components/common/index.ts | 1 + web/ce/components/common/subscription/index.ts | 1 + .../common/{ => subscription}/subscription-pill.tsx | 0 web/core/components/workspace/sidebar/dropdown-item.tsx | 2 +- web/core/components/workspace/sidebar/dropdown.tsx | 8 ++++---- web/ee/components/common/subscription-pill.tsx | 1 - 9 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 packages/utils/src/workspace.ts create mode 100644 web/ce/components/common/index.ts create mode 100644 web/ce/components/common/subscription/index.ts rename web/ce/components/common/{ => subscription}/subscription-pill.tsx (100%) delete mode 100644 web/ee/components/common/subscription-pill.tsx diff --git a/packages/types/src/workspace.d.ts b/packages/types/src/workspace.d.ts index d72dad7cc67..3cec14baa4d 100644 --- a/packages/types/src/workspace.d.ts +++ b/packages/types/src/workspace.d.ts @@ -22,7 +22,6 @@ export interface IWorkspace { readonly updated_by: string; organization_size: string; total_projects?: number; - current_plan?: string; role: number; } diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 510155f6a1e..7ae26931877 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -10,3 +10,4 @@ export * from "./issue"; export * from "./state"; export * from "./string"; export * from "./theme"; +export * from "./workspace"; diff --git a/packages/utils/src/workspace.ts b/packages/utils/src/workspace.ts new file mode 100644 index 00000000000..1fb74e89c2c --- /dev/null +++ b/packages/utils/src/workspace.ts @@ -0,0 +1,5 @@ +// plane imports +import { IWorkspace } from "@plane/types"; + +export const orderWorkspacesList = (workspaces: IWorkspace[]): IWorkspace[] => + workspaces.sort((a, b) => a.name.localeCompare(b.name)); diff --git a/web/ce/components/common/index.ts b/web/ce/components/common/index.ts new file mode 100644 index 00000000000..75c2cf410a8 --- /dev/null +++ b/web/ce/components/common/index.ts @@ -0,0 +1 @@ +export * from "./subscription"; diff --git a/web/ce/components/common/subscription/index.ts b/web/ce/components/common/subscription/index.ts new file mode 100644 index 00000000000..beb26e1d975 --- /dev/null +++ b/web/ce/components/common/subscription/index.ts @@ -0,0 +1 @@ +export * from "./subscription-pill"; \ No newline at end of file diff --git a/web/ce/components/common/subscription-pill.tsx b/web/ce/components/common/subscription/subscription-pill.tsx similarity index 100% rename from web/ce/components/common/subscription-pill.tsx rename to web/ce/components/common/subscription/subscription-pill.tsx diff --git a/web/core/components/workspace/sidebar/dropdown-item.tsx b/web/core/components/workspace/sidebar/dropdown-item.tsx index 7638b657276..2259f95d202 100644 --- a/web/core/components/workspace/sidebar/dropdown-item.tsx +++ b/web/core/components/workspace/sidebar/dropdown-item.tsx @@ -12,7 +12,7 @@ import { cn, getFileURL } from "@plane/utils"; // helpers import { getUserRole } from "@/helpers/user.helper"; // plane web imports -import { SubscriptionPill } from "@/plane-web/components/common/subscription-pill"; +import { SubscriptionPill } from "@/plane-web/components/common/subscription"; type TProps = { workspace: IWorkspace; diff --git a/web/core/components/workspace/sidebar/dropdown.tsx b/web/core/components/workspace/sidebar/dropdown.tsx index ac9acf42e5b..0719d95c0aa 100644 --- a/web/core/components/workspace/sidebar/dropdown.tsx +++ b/web/core/components/workspace/sidebar/dropdown.tsx @@ -8,13 +8,13 @@ import { usePopper } from "react-popper"; import { ChevronDown, CirclePlus, LogOut, Mails, Settings } from "lucide-react"; // ui import { Menu, Transition } from "@headlessui/react"; -// types +// plane imports import { useTranslation } from "@plane/i18n"; import { IWorkspace } from "@plane/types"; -// plane ui import { Avatar, Loader, TOAST_TYPE, setToast } from "@plane/ui"; -import { GOD_MODE_URL, cn } from "@/helpers/common.helper"; +import { orderWorkspacesList } from "@plane/utils"; // helpers +import { GOD_MODE_URL, cn } from "@/helpers/common.helper"; import { getFileURL } from "@/helpers/file.helper"; // hooks import { useAppTheme, useUser, useUserProfile, useWorkspace } from "@/hooks/store"; @@ -66,7 +66,7 @@ export const SidebarDropdown = observer(() => { toggleSidebar(); } }; - const workspacesList = Object.values(workspaces ?? {}); + const workspacesList = orderWorkspacesList(Object.values(workspaces ?? {})); // TODO: fix workspaces list scroll return (
diff --git a/web/ee/components/common/subscription-pill.tsx b/web/ee/components/common/subscription-pill.tsx deleted file mode 100644 index 38bcdebd5ad..00000000000 --- a/web/ee/components/common/subscription-pill.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "ce/components/common/subscription-pill";