From 9d8ae39c77d8e9e45f40e3d64a381bb3eb66582b Mon Sep 17 00:00:00 2001 From: Anish0203 <45678877+Anish0203@users.noreply.github.com> Date: Wed, 23 Oct 2024 00:19:36 +0530 Subject: [PATCH] fix: Make the "create workspace" option more obvious (#4177) --- .../AddToContributorInsightDrawer.tsx | 12 +++- .../AddToContributorInsightModal.tsx | 12 +++- .../Repositories/AddToWorkspaceModal.tsx | 12 +++- components/atoms/Select/single-select.tsx | 56 +++++++++++-------- components/shared/AppSidebar/AppSidebar.tsx | 11 +++- 5 files changed, 76 insertions(+), 27 deletions(-) diff --git a/components/Contributors/AddToContributorInsightDrawer.tsx b/components/Contributors/AddToContributorInsightDrawer.tsx index 829eab5419..1acb2ccf9d 100644 --- a/components/Contributors/AddToContributorInsightDrawer.tsx +++ b/components/Contributors/AddToContributorInsightDrawer.tsx @@ -3,6 +3,7 @@ import { useRouter } from "next/router"; import { BsGithub } from "react-icons/bs"; import { usePostHog } from "posthog-js/react"; import { safeParse } from "valibot"; +import { PlusIcon } from "@heroicons/react/24/outline"; import SingleSelect from "components/atoms/Select/single-select"; import Button from "components/shared/Button/button"; import { fetchApiData } from "helpers/fetchApiData"; @@ -118,7 +119,16 @@ export default function AddToContributorInsightDrawer({ ) : ( + ), + }, ...contributorInsights.map(({ id, name }) => ({ label: name, value: id, diff --git a/components/Contributors/AddToContributorInsightModal.tsx b/components/Contributors/AddToContributorInsightModal.tsx index db3c93c658..a5dc7d82e2 100644 --- a/components/Contributors/AddToContributorInsightModal.tsx +++ b/components/Contributors/AddToContributorInsightModal.tsx @@ -3,6 +3,7 @@ import { useRouter } from "next/router"; import { BsGithub } from "react-icons/bs"; import { usePostHog } from "posthog-js/react"; import { safeParse } from "valibot"; +import { PlusIcon } from "@heroicons/react/24/outline"; import Card from "components/atoms/Card/card"; import SingleSelect from "components/atoms/Select/single-select"; import { Dialog, DialogContent } from "components/molecules/Dialog/dialog"; @@ -119,7 +120,16 @@ export default function AddToContributorInsightModal({ ) : ( + ), + }, ...contributorInsights.map(({ id, name }) => ({ label: name, value: id, diff --git a/components/Repositories/AddToWorkspaceModal.tsx b/components/Repositories/AddToWorkspaceModal.tsx index e786667adc..7c7c2fe794 100644 --- a/components/Repositories/AddToWorkspaceModal.tsx +++ b/components/Repositories/AddToWorkspaceModal.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import { useRouter } from "next/router"; import { BsGithub } from "react-icons/bs"; import { usePostHog } from "posthog-js/react"; +import { PlusIcon } from "@heroicons/react/24/outline"; import Card from "components/atoms/Card/card"; import SingleSelect from "components/atoms/Select/single-select"; import { Dialog, DialogContent } from "components/molecules/Dialog/dialog"; @@ -114,7 +115,16 @@ export default function AddToWorkspaceModal({ repository, isOpen, onCloseModal, ) : ( + ), + }, ...workspaces.map(({ id, name }) => ({ label: name, value: id, diff --git a/components/atoms/Select/single-select.tsx b/components/atoms/Select/single-select.tsx index ee2436d6ec..1672ccdfe5 100644 --- a/components/atoms/Select/single-select.tsx +++ b/components/atoms/Select/single-select.tsx @@ -11,7 +11,7 @@ interface SingleSelectProps { onValueChange: (value: string) => void; placeholder?: string; inputPlaceholder?: string; - options: { label: string; value: string }[]; + options: { label: string; value: string; icon?: React.ReactElement }[]; position?: "popper" | "item-aligned"; isSearchable?: boolean; insetLabel?: string; @@ -90,28 +90,38 @@ const SingleSelect = ({ )} {isOpen && options.length > 0 - ? options.map((option) => ( - { - setInputValue(""); - setIsOpen(false); - onValueChange(option.value); - }} - onMouseDown={(e) => { - e.preventDefault(); - setIsOpen(false); - onValueChange(option.value); - }} - onClick={() => { - setIsOpen(false); - onValueChange(option.value); - }} - className="!z-50 !cursor-pointer flex justify-between min-w-[7rem] items-center !px-3 rounded-md truncate break-words w-full" - > - {option.label} - - )) + ? options.map((option) => { + const Icon = option.icon; + return ( + { + setInputValue(""); + setIsOpen(false); + onValueChange(option.value); + }} + onMouseDown={(e) => { + e.preventDefault(); + setIsOpen(false); + onValueChange(option.value); + }} + onClick={() => { + setIsOpen(false); + onValueChange(option.value); + }} + className="!z-50 !cursor-pointer flex justify-between min-w-[7rem] items-center !px-3 rounded-md truncate break-words w-full" + > + {Icon ? ( +
+ {Icon} + {option.label} +
+ ) : ( + option.label + )} +
+ ); + }) : null}
diff --git a/components/shared/AppSidebar/AppSidebar.tsx b/components/shared/AppSidebar/AppSidebar.tsx index c858955ad4..3eff37d9db 100644 --- a/components/shared/AppSidebar/AppSidebar.tsx +++ b/components/shared/AppSidebar/AppSidebar.tsx @@ -110,7 +110,16 @@ export const AppSideBar = ({ workspaceId, hideSidebar, sidebarCollapsed }: AppSi + ), + }, ...workspaces.map(({ id, name }) => ({ label: name, value: id,