fix: module and cycle event propagation (#4280)

This commit is contained in:
Anmol Singh Bhatia 2024-04-24 20:20:41 +05:30 committed by GitHub
parent bc2c97b9c3
commit e60ef36bfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 235 additions and 225 deletions

View File

@ -149,7 +149,7 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = observer((props) => {
const daysLeft = findHowManyDaysLeft(cycleDetails.end_date) ?? 0; const daysLeft = findHowManyDaysLeft(cycleDetails.end_date) ?? 0;
return ( return (
<div> <div className="relative">
<Link href={`/${workspaceSlug}/projects/${projectId}/cycles/${cycleDetails.id}`}> <Link href={`/${workspaceSlug}/projects/${projectId}/cycles/${cycleDetails.id}`}>
<div className="flex h-44 w-full flex-col justify-between rounded border border-custom-border-100 bg-custom-background-100 p-4 text-sm hover:shadow-md"> <div className="flex h-44 w-full flex-col justify-between rounded border border-custom-border-100 bg-custom-background-100 p-4 text-sm hover:shadow-md">
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
@ -231,23 +231,23 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = observer((props) => {
) : ( ) : (
<span className="text-xs text-custom-text-400">No due date</span> <span className="text-xs text-custom-text-400">No due date</span>
)} )}
<div className="z-[5] flex items-center gap-1.5">
{isEditingAllowed && (
<FavoriteStar
onClick={(e) => {
if (cycleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e);
}}
selected={!!cycleDetails.is_favorite}
/>
)}
<CycleQuickActions cycleId={cycleId} projectId={projectId} workspaceSlug={workspaceSlug} />
</div>
</div> </div>
</div> </div>
</div> </div>
</Link> </Link>
<div className="absolute right-4 bottom-3.5 z-[5] flex items-center gap-1.5">
{isEditingAllowed && (
<FavoriteStar
onClick={(e) => {
if (cycleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e);
}}
selected={!!cycleDetails.is_favorite}
/>
)}
<CycleQuickActions cycleId={cycleId} projectId={projectId} workspaceSlug={workspaceSlug} />
</div>
</div> </div>
); );
}); });

View File

@ -154,7 +154,7 @@ export const CyclesListItem: FC<TCyclesListItem> = observer((props) => {
const daysLeft = findHowManyDaysLeft(cycleDetails.end_date) ?? 0; const daysLeft = findHowManyDaysLeft(cycleDetails.end_date) ?? 0;
return ( return (
<> <div className="relative">
<Link <Link
href={`/${workspaceSlug}/projects/${projectId}/cycles/${cycleDetails.id}`} href={`/${workspaceSlug}/projects/${projectId}/cycles/${cycleDetails.id}`}
onClick={(e) => { onClick={(e) => {
@ -199,58 +199,61 @@ export const CyclesListItem: FC<TCyclesListItem> = observer((props) => {
{renderDate && `${renderFormattedDate(startDate) ?? `_ _`} - ${renderFormattedDate(endDate) ?? `_ _`}`} {renderDate && `${renderFormattedDate(startDate) ?? `_ _`} - ${renderFormattedDate(endDate) ?? `_ _`}`}
</div> </div>
</div> </div>
<div className="relative flex w-full flex-shrink-0 items-center justify-between gap-2.5 md:w-auto md:flex-shrink-0 md:justify-end"> <span className="h-6 w-52 flex-shrink-0" />
{currentCycle && (
<div
className="relative flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs"
style={{
color: currentCycle.color,
backgroundColor: `${currentCycle.color}20`,
}}
>
{currentCycle.value === "current"
? `${daysLeft} ${daysLeft > 1 ? "days" : "day"} left`
: `${currentCycle.label}`}
</div>
)}
<div className="relative flex flex-shrink-0 items-center gap-3">
<Tooltip tooltipContent={`${cycleDetails.assignee_ids?.length} Members`} isMobile={isMobile}>
<div className="flex w-10 cursor-default items-center justify-center">
{cycleDetails.assignee_ids && cycleDetails.assignee_ids?.length > 0 ? (
<AvatarGroup showTooltip={false}>
{cycleDetails.assignee_ids?.map((assignee_id) => {
const member = getUserDetails(assignee_id);
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>
{isEditingAllowed && !isArchived && (
<FavoriteStar
onClick={(e) => {
if (cycleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e);
}}
selected={!!cycleDetails.is_favorite}
/>
)}
<CycleQuickActions
cycleId={cycleId}
projectId={projectId}
workspaceSlug={workspaceSlug}
isArchived={isArchived}
/>
</div>
</div>
</div> </div>
</Link> </Link>
</> <div className="absolute right-5 bottom-8 z-[5] flex items-center gap-1.5">
<div className="relative flex w-full flex-shrink-0 items-center justify-between gap-2.5 md:w-auto md:flex-shrink-0 md:justify-end">
{currentCycle && (
<div
className="relative flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs"
style={{
color: currentCycle.color,
backgroundColor: `${currentCycle.color}20`,
}}
>
{currentCycle.value === "current"
? `${daysLeft} ${daysLeft > 1 ? "days" : "day"} left`
: `${currentCycle.label}`}
</div>
)}
<div className="relative flex flex-shrink-0 items-center gap-3">
<Tooltip tooltipContent={`${cycleDetails.assignee_ids?.length} Members`} isMobile={isMobile}>
<div className="flex w-10 cursor-default items-center justify-center">
{cycleDetails.assignee_ids && cycleDetails.assignee_ids?.length > 0 ? (
<AvatarGroup showTooltip={false}>
{cycleDetails.assignee_ids?.map((assignee_id) => {
const member = getUserDetails(assignee_id);
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>
{isEditingAllowed && !isArchived && (
<FavoriteStar
onClick={(e) => {
if (cycleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e);
}}
selected={!!cycleDetails.is_favorite}
/>
)}
<CycleQuickActions
cycleId={cycleId}
projectId={projectId}
workspaceSlug={workspaceSlug}
isArchived={isArchived}
/>
</div>
</div>
</div>
</div>
); );
}); });

View File

@ -144,106 +144,107 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
: "0 Issue"; : "0 Issue";
return ( return (
<Link href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}> <div className="relative">
<div className="flex h-44 w-full flex-col justify-between rounded border border-custom-border-100 bg-custom-background-100 p-4 text-sm hover:shadow-md"> <Link href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}>
<div> <div className="flex h-44 w-full flex-col justify-between rounded border border-custom-border-100 bg-custom-background-100 p-4 text-sm hover:shadow-md">
<div className="flex items-center justify-between gap-2"> <div>
<Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}> <div className="flex items-center justify-between gap-2">
<span className="truncate text-base font-medium">{moduleDetails.name}</span> <Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}>
</Tooltip> <span className="truncate text-base font-medium">{moduleDetails.name}</span>
<div className="flex items-center gap-2">
{moduleStatus && (
<span
className="flex h-6 w-20 items-center justify-center rounded-sm text-center text-xs"
style={{
color: moduleStatus.color,
backgroundColor: `${moduleStatus.color}20`,
}}
>
{moduleStatus.label}
</span>
)}
<button onClick={openModuleOverview}>
<Info className="h-4 w-4 text-custom-text-400" />
</button>
</div>
</div>
</div>
<div className="flex flex-col gap-3">
<div className="flex items-center justify-between">
<div className="flex items-center gap-1.5 text-custom-text-200">
<LayersIcon className="h-4 w-4 text-custom-text-300" />
<span className="text-xs text-custom-text-300">{issueCount ?? "0 Issue"}</span>
</div>
{moduleDetails.member_ids?.length > 0 && (
<Tooltip tooltipContent={`${moduleDetails.member_ids.length} Members`} isMobile={isMobile}>
<div className="flex cursor-default items-center gap-1">
<AvatarGroup showTooltip={false}>
{moduleDetails.member_ids.map((member_id) => {
const member = getUserDetails(member_id);
return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
})}
</AvatarGroup>
</div>
</Tooltip> </Tooltip>
)} <div className="flex items-center gap-2">
</div> {moduleStatus && (
<span
<Tooltip className="flex h-6 w-20 items-center justify-center rounded-sm text-center text-xs"
isMobile={isMobile} style={{
tooltipContent={isNaN(completionPercentage) ? "0" : `${completionPercentage.toFixed(0)}%`} color: moduleStatus.color,
position="top-left" backgroundColor: `${moduleStatus.color}20`,
> }}
<div className="flex w-full items-center"> >
<div {moduleStatus.label}
className="bar relative h-1.5 w-full rounded bg-custom-background-90" </span>
style={{ )}
boxShadow: "1px 1px 4px 0px rgba(161, 169, 191, 0.35) inset", <button onClick={openModuleOverview}>
}} <Info className="h-4 w-4 text-custom-text-400" />
> </button>
<div
className="absolute left-0 top-0 h-1.5 rounded bg-blue-600 duration-300"
style={{
width: `${isNaN(completionPercentage) ? 0 : completionPercentage.toFixed(0)}%`,
}}
/>
</div> </div>
</div> </div>
</Tooltip> </div>
<div className="flex items-center justify-between"> <div className="flex flex-col gap-3">
{isDateValid ? ( <div className="flex items-center justify-between">
<> <div className="flex items-center gap-1.5 text-custom-text-200">
<span className="text-xs text-custom-text-300"> <LayersIcon className="h-4 w-4 text-custom-text-300" />
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"} <span className="text-xs text-custom-text-300">{issueCount ?? "0 Issue"}</span>
</span> </div>
</> {moduleDetails.member_ids?.length > 0 && (
) : ( <Tooltip tooltipContent={`${moduleDetails.member_ids.length} Members`} isMobile={isMobile}>
<span className="text-xs text-custom-text-400">No due date</span> <div className="flex cursor-default items-center gap-1">
)} <AvatarGroup showTooltip={false}>
{moduleDetails.member_ids.map((member_id) => {
<div className="z-[5] flex items-center gap-1.5"> const member = getUserDetails(member_id);
{isEditingAllowed && ( return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
<FavoriteStar })}
onClick={(e) => { </AvatarGroup>
if (moduleDetails.is_favorite) handleRemoveFromFavorites(e); </div>
else handleAddToFavorites(e); </Tooltip>
}}
selected={!!moduleDetails.is_favorite}
/>
)} )}
{workspaceSlug && projectId && ( </div>
<ModuleQuickActions
moduleId={moduleId} <Tooltip
projectId={projectId.toString()} isMobile={isMobile}
workspaceSlug={workspaceSlug.toString()} tooltipContent={isNaN(completionPercentage) ? "0" : `${completionPercentage.toFixed(0)}%`}
/> position="top-left"
>
<div className="flex w-full items-center">
<div
className="bar relative h-1.5 w-full rounded bg-custom-background-90"
style={{
boxShadow: "1px 1px 4px 0px rgba(161, 169, 191, 0.35) inset",
}}
>
<div
className="absolute left-0 top-0 h-1.5 rounded bg-blue-600 duration-300"
style={{
width: `${isNaN(completionPercentage) ? 0 : completionPercentage.toFixed(0)}%`,
}}
/>
</div>
</div>
</Tooltip>
<div className="flex items-center justify-between py-0.5">
{isDateValid ? (
<>
<span className="text-xs text-custom-text-300">
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"}
</span>
</>
) : (
<span className="text-xs text-custom-text-400">No due date</span>
)} )}
</div> </div>
</div> </div>
</div> </div>
</Link>
<div className="absolute right-4 bottom-3.5 z-[5] flex items-center gap-1.5">
{isEditingAllowed && (
<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()}
/>
)}
</div> </div>
</Link> </div>
); );
}); });

View File

@ -135,7 +135,7 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
const completedModuleCheck = moduleDetails.status === "completed"; const completedModuleCheck = moduleDetails.status === "completed";
return ( return (
<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"> <div className="relative">
<Link <Link
href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`} href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}
onClick={(e) => { onClick={(e) => {
@ -143,33 +143,39 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
openModuleOverview(e); openModuleOverview(e);
} }
}} }}
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="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">
<div className="flex items-center gap-4 truncate"> <div className="relative flex w-full items-center justify-between gap-3 overflow-hidden">
<span className="flex-shrink-0"> <div className="relative flex w-full items-center gap-3 overflow-hidden">
<CircularProgressIndicator size={38} percentage={progress}> <div className="flex items-center gap-4 truncate">
{completedModuleCheck ? ( <span className="flex-shrink-0">
progress === 100 ? ( <CircularProgressIndicator size={38} percentage={progress}>
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" /> {completedModuleCheck ? (
) : ( progress === 100 ? (
<span className="text-sm text-custom-primary-100">{`!`}</span> <Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
) ) : (
) : progress === 100 ? ( <span className="text-sm text-custom-primary-100">{`!`}</span>
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" /> )
) : ( ) : progress === 100 ? (
<span className="text-xs text-custom-text-300">{`${progress}%`}</span> <Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
)} ) : (
</CircularProgressIndicator> <span className="text-xs text-custom-text-300">{`${progress}%`}</span>
</span> )}
<Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}> </CircularProgressIndicator>
<span className="truncate text-base font-medium">{moduleDetails.name}</span> </span>
</Tooltip> <Tooltip tooltipContent={moduleDetails.name} position="top" isMobile={isMobile}>
<span className="truncate text-base font-medium">{moduleDetails.name}</span>
</Tooltip>
</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> </div>
<button onClick={openModuleOverview} className="z-[5] hidden flex-shrink-0 group-hover:flex"> <span className="h-6 w-52 flex-shrink-0" />
<Info className="h-4 w-4 text-custom-text-400" />
</button>
</div> </div>
</Link>
<div className="absolute right-5 bottom-8 z-[5] flex items-center gap-1.5">
<div className="flex flex-shrink-0 items-center justify-center"> <div className="flex flex-shrink-0 items-center justify-center">
{moduleStatus && ( {moduleStatus && (
<span <span
@ -183,51 +189,51 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
</span> </span>
)} )}
</div> </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="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">
<div className="text-xs text-custom-text-300"> {renderDate && (
{renderDate && ( <span className=" text-xs text-custom-text-300">
<span className=" text-xs text-custom-text-300"> {renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"}
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"} </span>
</span> )}
)} </div>
</div>
<div className="relative flex flex-shrink-0 items-center gap-3"> <div className="relative flex flex-shrink-0 items-center gap-3">
<Tooltip tooltipContent={`${moduleDetails?.member_ids?.length || 0} Members`} isMobile={isMobile}> <Tooltip tooltipContent={`${moduleDetails?.member_ids?.length || 0} Members`} isMobile={isMobile}>
<div className="flex w-10 cursor-default items-center justify-center gap-1"> <div className="flex w-10 cursor-default items-center justify-center gap-1">
{moduleDetails.member_ids.length > 0 ? ( {moduleDetails.member_ids.length > 0 ? (
<AvatarGroup showTooltip={false}> <AvatarGroup showTooltip={false}>
{moduleDetails.member_ids.map((member_id) => { {moduleDetails.member_ids.map((member_id) => {
const member = getUserDetails(member_id); const member = getUserDetails(member_id);
return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />; return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
})} })}
</AvatarGroup> </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"> <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" /> <User2 className="h-4 w-4 text-custom-text-400" />
</span> </span>
)} )}
</div> </div>
</Tooltip> </Tooltip>
{isEditingAllowed && !isArchived && ( {isEditingAllowed && !isArchived && (
<FavoriteStar <FavoriteStar
onClick={(e) => { onClick={(e) => {
if (moduleDetails.is_favorite) handleRemoveFromFavorites(e); if (moduleDetails.is_favorite) handleRemoveFromFavorites(e);
else handleAddToFavorites(e); else handleAddToFavorites(e);
}} }}
selected={moduleDetails.is_favorite} selected={moduleDetails.is_favorite}
/> />
)} )}
{workspaceSlug && projectId && ( {workspaceSlug && projectId && (
<ModuleQuickActions <ModuleQuickActions
moduleId={moduleId} moduleId={moduleId}
projectId={projectId.toString()} projectId={projectId.toString()}
workspaceSlug={workspaceSlug.toString()} workspaceSlug={workspaceSlug.toString()}
isArchived={isArchived} isArchived={isArchived}
/> />
)} )}
</div>
</div> </div>
</div> </div>
</div> </div>