mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: sidebar new issue button validation added (#3706)
This commit is contained in:
parent
cf3b888465
commit
e433a835fd
@ -2,7 +2,7 @@ import { useRef, useState } from "react";
|
|||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ChevronUp, PenSquare, Search } from "lucide-react";
|
import { ChevronUp, PenSquare, Search } from "lucide-react";
|
||||||
// hooks
|
// hooks
|
||||||
import { useApplication, useEventTracker, useUser } from "hooks/store";
|
import { useApplication, useEventTracker, useProject, useUser } from "hooks/store";
|
||||||
import useLocalStorage from "hooks/use-local-storage";
|
import useLocalStorage from "hooks/use-local-storage";
|
||||||
// components
|
// components
|
||||||
import { CreateUpdateDraftIssueModal } from "components/issues";
|
import { CreateUpdateDraftIssueModal } from "components/issues";
|
||||||
@ -16,6 +16,7 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
|
|
||||||
const { theme: themeStore, commandPalette: commandPaletteStore } = useApplication();
|
const { theme: themeStore, commandPalette: commandPaletteStore } = useApplication();
|
||||||
const { setTrackElement } = useEventTracker();
|
const { setTrackElement } = useEventTracker();
|
||||||
|
const { joinedProjectIds } = useProject();
|
||||||
const {
|
const {
|
||||||
membership: { currentWorkspaceRole },
|
membership: { currentWorkspaceRole },
|
||||||
} = useUser();
|
} = useUser();
|
||||||
@ -31,6 +32,8 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
|
|
||||||
const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER;
|
const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
|
const disabled = joinedProjectIds.length === 0;
|
||||||
|
|
||||||
const onMouseEnter = () => {
|
const onMouseEnter = () => {
|
||||||
//if renet before timout clear the timeout
|
//if renet before timout clear the timeout
|
||||||
timeoutRef?.current && clearTimeout(timeoutRef.current);
|
timeoutRef?.current && clearTimeout(timeoutRef.current);
|
||||||
@ -73,17 +76,18 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
type="button"
|
type="button"
|
||||||
className={`relative flex flex-shrink-0 flex-grow items-center gap-2 rounded py-1.5 outline-none ${
|
className={`relative flex flex-shrink-0 flex-grow items-center gap-2 rounded py-1.5 outline-none ${
|
||||||
isSidebarCollapsed ? "justify-center" : ""
|
isSidebarCollapsed ? "justify-center" : ""
|
||||||
}`}
|
} ${disabled ? "cursor-not-allowed opacity-50" : ""}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
|
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
|
||||||
commandPaletteStore.toggleCreateIssueModal(true, EIssuesStoreType.PROJECT);
|
commandPaletteStore.toggleCreateIssueModal(true, EIssuesStoreType.PROJECT);
|
||||||
}}
|
}}
|
||||||
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<PenSquare className="h-4 w-4 text-custom-sidebar-text-300" />
|
<PenSquare className="h-4 w-4 text-custom-sidebar-text-300" />
|
||||||
{!isSidebarCollapsed && <span className="text-sm font-medium">New Issue</span>}
|
{!isSidebarCollapsed && <span className="text-sm font-medium">New Issue</span>}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && (
|
{!disabled && storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className={`h-8 w-0.5 bg-custom-sidebar-background-80 ${isSidebarCollapsed ? "hidden" : "block"}`}
|
className={`h-8 w-0.5 bg-custom-sidebar-background-80 ${isSidebarCollapsed ? "hidden" : "block"}`}
|
||||||
|
Loading…
Reference in New Issue
Block a user