fix: module delete modal outside click event propagation (#4265)

This commit is contained in:
Anmol Singh Bhatia 2024-04-24 15:16:47 +05:30 committed by GitHub
parent d87edede79
commit 6e574515e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -135,103 +135,101 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
const completedModuleCheck = moduleDetails.status === "completed"; const completedModuleCheck = moduleDetails.status === "completed";
return ( return (
<Link <div className="group flex w-full flex-col items-center justify-between gap-5 border-b border-custom-border-100 bg-custom-background-100 px-5 py-6 text-sm hover:bg-custom-background-90 sm:flex-row">
href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`} <Link
onClick={(e) => { href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}
if (isArchived) { onClick={(e) => {
openModuleOverview(e); if (isArchived) {
} openModuleOverview(e);
}} }
> }}
<div className="group flex w-full flex-col items-center justify-between gap-5 border-b border-custom-border-100 bg-custom-background-100 px-5 py-6 text-sm hover:bg-custom-background-90 sm:flex-row"> className="relative flex w-full items-center justify-between gap-3 overflow-hidden"
<div className="relative flex w-full items-center justify-between gap-3 overflow-hidden"> >
<div className="relative flex w-full items-center gap-3 overflow-hidden"> <div className="relative flex w-full items-center gap-3 overflow-hidden">
<div className="flex items-center gap-4 truncate"> <div className="flex items-center gap-4 truncate">
<span className="flex-shrink-0"> <span className="flex-shrink-0">
<CircularProgressIndicator size={38} percentage={progress}> <CircularProgressIndicator size={38} percentage={progress}>
{completedModuleCheck ? ( {completedModuleCheck ? (
progress === 100 ? ( progress === 100 ? (
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
) : (
<span className="text-sm text-custom-primary-100">{`!`}</span>
)
) : progress === 100 ? (
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" /> <Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
) : ( ) : (
<span className="text-xs text-custom-text-300">{`${progress}%`}</span> <span className="text-sm text-custom-primary-100">{`!`}</span>
)} )
</CircularProgressIndicator> ) : progress === 100 ? (
</span> <Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
<Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}> ) : (
<span className="truncate text-base font-medium">{moduleDetails.name}</span> <span className="text-xs text-custom-text-300">{`${progress}%`}</span>
</Tooltip> )}
</div> </CircularProgressIndicator>
<button onClick={openModuleOverview} className="z-[5] hidden flex-shrink-0 group-hover:flex"> </span>
<Info className="h-4 w-4 text-custom-text-400" /> <Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}>
</button> <span className="truncate text-base font-medium">{moduleDetails.name}</span>
</div> </Tooltip>
<div className="flex flex-shrink-0 items-center justify-center">
{moduleStatus && (
<span
className="flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs"
style={{
color: moduleStatus.color,
backgroundColor: `${moduleStatus.color}20`,
}}
>
{moduleStatus.label}
</span>
)}
</div> </div>
<button onClick={openModuleOverview} className="z-[5] hidden flex-shrink-0 group-hover:flex">
<Info className="h-4 w-4 text-custom-text-400" />
</button>
</div>
<div className="flex flex-shrink-0 items-center justify-center">
{moduleStatus && (
<span
className="flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs"
style={{
color: moduleStatus.color,
backgroundColor: `${moduleStatus.color}20`,
}}
>
{moduleStatus.label}
</span>
)}
</div>
</Link>
<div className="relative flex w-full items-center justify-between gap-2.5 sm:w-auto sm:flex-shrink-0 sm:justify-end ">
<div className="text-xs text-custom-text-300">
{renderDate && (
<span className=" text-xs text-custom-text-300">
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"}
</span>
)}
</div> </div>
<div className="relative flex w-full items-center justify-between gap-2.5 sm:w-auto sm:flex-shrink-0 sm:justify-end "> <div className="relative flex flex-shrink-0 items-center gap-3">
<div className="text-xs text-custom-text-300"> <Tooltip tooltipContent={`${moduleDetails?.member_ids?.length || 0} Members`} isMobile={isMobile}>
{renderDate && ( <div className="flex w-10 cursor-default items-center justify-center gap-1">
<span className=" text-xs text-custom-text-300"> {moduleDetails.member_ids.length > 0 ? (
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"} <AvatarGroup showTooltip={false}>
</span> {moduleDetails.member_ids.map((member_id) => {
)} const member = getUserDetails(member_id);
</div> return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
})}
</AvatarGroup>
) : (
<span className="flex h-5 w-5 items-end justify-center rounded-full border border-dashed border-custom-text-400 bg-custom-background-80">
<User2 className="h-4 w-4 text-custom-text-400" />
</span>
)}
</div>
</Tooltip>
<div className="relative flex flex-shrink-0 items-center gap-3"> {isEditingAllowed && !isArchived && (
<Tooltip tooltipContent={`${moduleDetails?.member_ids?.length || 0} Members`} isMobile={isMobile}> <FavoriteStar
<div className="flex w-10 cursor-default items-center justify-center gap-1"> onClick={(e) => {
{moduleDetails.member_ids.length > 0 ? ( if (moduleDetails.is_favorite) handleRemoveFromFavorites(e);
<AvatarGroup showTooltip={false}> else handleAddToFavorites(e);
{moduleDetails.member_ids.map((member_id) => { }}
const member = getUserDetails(member_id); selected={moduleDetails.is_favorite}
return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />; />
})} )}
</AvatarGroup> {workspaceSlug && projectId && (
) : ( <ModuleQuickActions
<span className="flex h-5 w-5 items-end justify-center rounded-full border border-dashed border-custom-text-400 bg-custom-background-80"> moduleId={moduleId}
<User2 className="h-4 w-4 text-custom-text-400" /> projectId={projectId.toString()}
</span> workspaceSlug={workspaceSlug.toString()}
)} isArchived={isArchived}
</div> />
</Tooltip> )}
{isEditingAllowed && !isArchived && (
<FavoriteStar
onClick={(e) => {
if (moduleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e);
}}
selected={moduleDetails.is_favorite}
/>
)}
{workspaceSlug && projectId && (
<ModuleQuickActions
moduleId={moduleId}
projectId={projectId.toString()}
workspaceSlug={workspaceSlug.toString()}
isArchived={isArchived}
/>
)}
</div>
</div> </div>
</div> </div>
</Link> </div>
); );
}); });