From a46c507ca146e85fd648b528e1e43b390cbad51c Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Wed, 8 May 2024 13:59:51 +0530 Subject: [PATCH] [WEB-1040] chore: spreadsheet indentation improvement (#4391) * chore: spreadsheet indentation improvement * chore: spreadsheet layout sub issu nesting improvement * chore: sub issue spacing improvement * chore: spreadsheet layout sub issue toggle button improvement --- .../issue-layouts/spreadsheet/issue-row.tsx | 145 +++++++++--------- 1 file changed, 76 insertions(+), 69 deletions(-) diff --git a/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx b/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx index 83dbe57a7..84e2ae485 100644 --- a/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/issue-row.tsx @@ -1,4 +1,4 @@ -import { Dispatch, MutableRefObject, SetStateAction, useRef, useState } from "react"; +import { Dispatch, MouseEvent, MutableRefObject, SetStateAction, useRef, useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // icons @@ -33,6 +33,7 @@ interface Props { containerRef: MutableRefObject; issueIds: string[]; spreadsheetColumnsList: (keyof IIssueDisplayProperties)[]; + spacingLeft?: number; } export const SpreadsheetIssueRow = observer((props: Props) => { @@ -49,6 +50,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => { containerRef, issueIds, spreadsheetColumnsList, + spacingLeft = 14, } = props; const [isExpanded, setExpanded] = useState(false); @@ -72,6 +74,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => { quickActions={quickActions} canEditProperties={canEditProperties} nestingLevel={nestingLevel} + spacingLeft={spacingLeft} isEstimateEnabled={isEstimateEnabled} updateIssue={updateIssue} portalElement={portalElement} @@ -93,6 +96,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => { quickActions={quickActions} canEditProperties={canEditProperties} nestingLevel={nestingLevel + 1} + spacingLeft={spacingLeft + (displayProperties.key ? 16 : 28)} isEstimateEnabled={isEstimateEnabled} updateIssue={updateIssue} portalElement={portalElement} @@ -119,6 +123,7 @@ interface IssueRowDetailsProps { isExpanded: boolean; setExpanded: Dispatch>; spreadsheetColumnsList: (keyof IIssueDisplayProperties)[]; + spacingLeft?: number; } const IssueRowDetails = observer((props: IssueRowDetailsProps) => { @@ -135,6 +140,7 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => { isExpanded, setExpanded, spreadsheetColumnsList, + spacingLeft = 14, } = props; // states const [isMenuActive, setIsMenuActive] = useState(false); @@ -161,22 +167,14 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => { const issueDetail = issue.getIssueById(issueId); - const paddingLeft = `${nestingLevel * 54}px`; + const paddingLeft = `${spacingLeft}px`; useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false)); - const handleToggleExpand = () => { - setExpanded((prevState) => { - if (!prevState && workspaceSlug && issueDetail) - subIssuesStore.fetchSubIssues(workspaceSlug.toString(), issueDetail.project_id, issueDetail.id); - return !prevState; - }); - }; - const customActionButton = (
setIsMenuActive(!isMenuActive)} @@ -186,76 +184,85 @@ const IssueRowDetails = observer((props: IssueRowDetailsProps) => { ); if (!issueDetail) return null; + const handleToggleExpand = (e: MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + if (nestingLevel >= 3) { + handleIssuePeekOverview(issueDetail); + } else { + setExpanded((prevState) => { + if (!prevState && workspaceSlug && issueDetail) + subIssuesStore.fetchSubIssues(workspaceSlug.toString(), issueDetail.project_id, issueDetail.id); + return !prevState; + }); + } + }; + const disableUserActions = !canEditProperties(issueDetail.project_id); return ( <> - - -
-
- - {getProjectIdentifierById(issueDetail.project_id)}-{issueDetail.sequence_id} - - - -
- - {issueDetail.sub_issues_count > 0 && ( -
- -
- )} -
-
+ handleIssuePeekOverview(issueDetail)} - className="clickable w-full line-clamp-1 cursor-pointer text-sm text-custom-text-100" + className={cn( + "group clickable cursor-pointer sticky left-0 h-11 w-[28rem] flex items-center bg-custom-background-100 text-sm after:absolute border-r-[0.5px] z-10 border-custom-border-200", + { + "border-b-[0.5px]": !getIsIssuePeeked(issueDetail.id), + "border border-custom-primary-70 hover:border-custom-primary-70": getIsIssuePeeked(issueDetail.id), + "shadow-[8px_22px_22px_10px_rgba(0,0,0,0.05)]": isScrolled.current, + } + )} disabled={!!issueDetail?.tempId} > -
- -
- {issueDetail.name} +
+
+ {issueDetail.sub_issues_count > 0 && ( + + )} +
+ + +
+

+ {getProjectIdentifierById(issueDetail.project_id)}-{issueDetail.sequence_id} +

- +
+
+ +
+
+
+ +
+ {issueDetail.name} +
+
+
+
+
+ {quickActions({ + issue: issueDetail, + parentRef: cellRef, + customActionButton, + portalElement: portalElement.current, + })} +