From e433a835fdf9c8af9316b1cdbbc16752b0daf66d Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:40:48 +0530 Subject: [PATCH] chore: sidebar new issue button validation added (#3706) --- web/components/workspace/sidebar-quick-action.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/components/workspace/sidebar-quick-action.tsx b/web/components/workspace/sidebar-quick-action.tsx index 6b3782a625..28b57f0f5e 100644 --- a/web/components/workspace/sidebar-quick-action.tsx +++ b/web/components/workspace/sidebar-quick-action.tsx @@ -2,7 +2,7 @@ import { useRef, useState } from "react"; import { observer } from "mobx-react-lite"; import { ChevronUp, PenSquare, Search } from "lucide-react"; // hooks -import { useApplication, useEventTracker, useUser } from "hooks/store"; +import { useApplication, useEventTracker, useProject, useUser } from "hooks/store"; import useLocalStorage from "hooks/use-local-storage"; // components import { CreateUpdateDraftIssueModal } from "components/issues"; @@ -16,6 +16,7 @@ export const WorkspaceSidebarQuickAction = observer(() => { const { theme: themeStore, commandPalette: commandPaletteStore } = useApplication(); const { setTrackElement } = useEventTracker(); + const { joinedProjectIds } = useProject(); const { membership: { currentWorkspaceRole }, } = useUser(); @@ -31,6 +32,8 @@ export const WorkspaceSidebarQuickAction = observer(() => { const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER; + const disabled = joinedProjectIds.length === 0; + const onMouseEnter = () => { //if renet before timout clear the timeout timeoutRef?.current && clearTimeout(timeoutRef.current); @@ -73,17 +76,18 @@ export const WorkspaceSidebarQuickAction = observer(() => { type="button" className={`relative flex flex-shrink-0 flex-grow items-center gap-2 rounded py-1.5 outline-none ${ isSidebarCollapsed ? "justify-center" : "" - }`} + } ${disabled ? "cursor-not-allowed opacity-50" : ""}`} onClick={() => { setTrackElement("APP_SIDEBAR_QUICK_ACTIONS"); commandPaletteStore.toggleCreateIssueModal(true, EIssuesStoreType.PROJECT); }} + disabled={disabled} > {!isSidebarCollapsed && New Issue} - {storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && ( + {!disabled && storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && ( <>