From 230d1a4b08a28e578640ac7d44e7658dfdf457e5 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Fri, 15 Dec 2023 19:18:10 +0530 Subject: [PATCH] issue properties optimization --- .../issues/issue-layouts/kanban/block.tsx | 12 ++-- .../all-properties.tsx} | 56 ++++++------------- .../with-display-properties-HOC.tsx | 12 ++-- 3 files changed, 28 insertions(+), 52 deletions(-) rename web/components/issues/issue-layouts/{kanban/properties.tsx => properties/all-properties.tsx} (75%) diff --git a/web/components/issues/issue-layouts/kanban/block.tsx b/web/components/issues/issue-layouts/kanban/block.tsx index 31456e33c..24d102723 100644 --- a/web/components/issues/issue-layouts/kanban/block.tsx +++ b/web/components/issues/issue-layouts/kanban/block.tsx @@ -1,7 +1,7 @@ import { memo } from "react"; import { Draggable } from "@hello-pangea/dnd"; // components -import { KanBanProperties } from "./properties"; +import { IssueProperties } from "../properties/all-properties"; // ui import { Tooltip } from "@plane/ui"; // types @@ -15,7 +15,6 @@ import { IProjectIssuesFilterStore, IViewIssuesFilterStore, } from "store_legacy/issues"; -import { IssuesFilter } from "store/issue/base-issue-filter.store"; import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC"; interface IssueBlockProps { @@ -70,10 +69,7 @@ const KanbanIssueDetailsBlock: React.FC = (props) => { return ( <> - displayProperties?.key} - > +
{issue.project_detail.identifier}-{issue.sequence_id} @@ -87,11 +83,11 @@ const KanbanIssueDetailsBlock: React.FC = (props) => {
-
diff --git a/web/components/issues/issue-layouts/kanban/properties.tsx b/web/components/issues/issue-layouts/properties/all-properties.tsx similarity index 75% rename from web/components/issues/issue-layouts/kanban/properties.tsx rename to web/components/issues/issue-layouts/properties/all-properties.tsx index 0463269ff..5f06f337a 100644 --- a/web/components/issues/issue-layouts/kanban/properties.tsx +++ b/web/components/issues/issue-layouts/properties/all-properties.tsx @@ -20,7 +20,7 @@ import { } from "store_legacy/issues"; import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC"; -export interface IKanBanProperties { +export interface IIssueProperties { issue: IIssue; handleIssues: (issue: IIssue) => void; issuesFilter: @@ -29,12 +29,12 @@ export interface IKanBanProperties { | ICycleIssuesFilterStore | IViewIssuesFilterStore | IProfileIssuesFilterStore; - showEmptyGroup: boolean; isReadOnly: boolean; + className: string; } -export const KanBanProperties: React.FC = observer((props) => { - const { issue, handleIssues, issuesFilter, isReadOnly } = props; +export const IssueProperties: React.FC = observer((props) => { + const { issue, handleIssues, issuesFilter, isReadOnly, className } = props; const handleState = (state: IState) => { handleIssues({ ...issue, state: state.id }); @@ -65,13 +65,10 @@ export const KanBanProperties: React.FC = observer((props) => }; return ( -
+
{/* basic properties */} {/* state */} - displayProperties && displayProperties?.state} - > + = observer((props) => {/* priority */} - displayProperties && displayProperties?.priority} - > + = observer((props) => {/* label */} - displayProperties && displayProperties?.labels} - > + = observer((props) => {/* start date */} - displayProperties?.start_date} - > + handleStartDate(date)} @@ -125,10 +113,7 @@ export const KanBanProperties: React.FC = observer((props) => {/* target/due date */} - displayProperties?.due_date} - > + handleTargetDate(date)} @@ -138,10 +123,7 @@ export const KanBanProperties: React.FC = observer((props) => {/* assignee */} - displayProperties?.assignee} - > + = observer((props) => {/* estimates */} - displayProperties?.estimate} - > + = observer((props) => {/* sub-issues */} displayProperties?.sub_issue_count && !!issue?.sub_issues_count} + displayPropertyKey="sub_issue_count" + shouldRenderProperty={!!issue?.sub_issues_count} >
@@ -184,9 +164,8 @@ export const KanBanProperties: React.FC = observer((props) => {/* attachments */} - displayProperties?.attachment_count && !!issue?.attachment_count - } + displayPropertyKey="attachment_count" + shouldRenderProperty={!!issue?.attachment_count} >
@@ -199,7 +178,8 @@ export const KanBanProperties: React.FC = observer((props) => {/* link */} displayProperties?.link && !!issue?.link_count} + displayPropertyKey="link" + shouldRenderProperty={!!issue?.link_count} >
diff --git a/web/components/issues/issue-layouts/properties/with-display-properties-HOC.tsx b/web/components/issues/issue-layouts/properties/with-display-properties-HOC.tsx index e32b25728..0bf380bd5 100644 --- a/web/components/issues/issue-layouts/properties/with-display-properties-HOC.tsx +++ b/web/components/issues/issue-layouts/properties/with-display-properties-HOC.tsx @@ -7,7 +7,6 @@ import { IProjectIssuesFilterStore, IViewIssuesFilterStore, } from "store_legacy/issues"; -import { IIssueDisplayProperties } from "types"; interface IWithDisplayPropertiesHOC { issuesFilter: @@ -16,16 +15,17 @@ interface IWithDisplayPropertiesHOC { | ICycleIssuesFilterStore | IViewIssuesFilterStore | IProfileIssuesFilterStore; - getShouldRenderProperty: (displayProperties: IIssueDisplayProperties) => boolean; + shouldRenderProperty?: boolean; + displayPropertyKey: string; children: ReactNode; } export const WithDisplayPropertiesHOC = observer( - ({ issuesFilter, getShouldRenderProperty, children }: IWithDisplayPropertiesHOC) => { - const displayProperties = issuesFilter.issueFilters.displayProperties; + ({ issuesFilter, shouldRenderProperty = true, displayPropertyKey, children }: IWithDisplayPropertiesHOC) => { + const shouldDisplayPropertyFromFilters = issuesFilter.issueFilters.displayProperties[displayPropertyKey]; - const shouldRenderProperty = getShouldRenderProperty(displayProperties); + const renderProperty = shouldDisplayPropertyFromFilters && shouldRenderProperty; - if (!shouldRenderProperty) return null; + if (!renderProperty) return null; return <>{children}; }