From 2870968ebf332afeb80300aea90c816b9d4b5bb5 Mon Sep 17 00:00:00 2001 From: gakshita Date: Mon, 26 May 2025 20:30:09 +0530 Subject: [PATCH 1/2] fix: refactor --- .../cycles/analytics-sidebar/issue-progress.tsx | 2 +- .../cycles/dropdowns/estimate-type-dropdown.tsx | 11 +++++++---- web/core/store/estimates/project-estimate.store.ts | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/core/components/cycles/analytics-sidebar/issue-progress.tsx b/web/core/components/cycles/analytics-sidebar/issue-progress.tsx index c0ece831c00..f911b4418ad 100644 --- a/web/core/components/cycles/analytics-sidebar/issue-progress.tsx +++ b/web/core/components/cycles/analytics-sidebar/issue-progress.tsx @@ -32,7 +32,7 @@ type Options = { export const cycleEstimateOptions: Options[] = [ { value: "issues", label: "Work items" }, - { value: "points", label: "Points" }, + { value: "points", label: "Estimates" }, ]; export const cycleChartOptions: Options[] = [ { value: "burndown", label: "Burn-down" }, diff --git a/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx b/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx index 7eba6418d90..c8f66be77c3 100644 --- a/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx +++ b/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx @@ -1,5 +1,7 @@ import React from "react"; +import { observer } from "mobx-react-lite"; import { TCycleEstimateType } from "@plane/types"; +import { EEstimateSystem } from "@plane/types/src/enums"; import { CustomSelect } from "@plane/ui"; import { useCycle, useProjectEstimates } from "@/hooks/store"; import { cycleEstimateOptions } from "../analytics-sidebar"; @@ -12,12 +14,13 @@ type TProps = { cycleId: string; }; -export const EstimateTypeDropdown = (props: TProps) => { +export const EstimateTypeDropdown = observer((props: TProps) => { const { value, onChange, projectId, cycleId, showDefault = false } = props; const { getIsPointsDataAvailable } = useCycle(); - const { areEstimateEnabledByProjectId } = useProjectEstimates(); + const { areEstimateEnabledByProjectId, currentProjectEstimate } = useProjectEstimates(); const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false; - return getIsPointsDataAvailable(cycleId) || isCurrentProjectEstimateEnabled ? ( + return (getIsPointsDataAvailable(cycleId) || isCurrentProjectEstimateEnabled) && + currentProjectEstimate !== EEstimateSystem.CATEGORIES ? (
{ ) : showDefault ? ( {value} ) : null; -}; +}); diff --git a/web/core/store/estimates/project-estimate.store.ts b/web/core/store/estimates/project-estimate.store.ts index 773a7d6dc94..ba7b2f3ca64 100644 --- a/web/core/store/estimates/project-estimate.store.ts +++ b/web/core/store/estimates/project-estimate.store.ts @@ -27,6 +27,7 @@ export interface IProjectEstimateStore { currentActiveEstimateId: string | undefined; currentActiveEstimate: IEstimate | undefined; archivedEstimateIds: string[] | undefined; + currentProjectEstimate: TEstimateSystemKeys | undefined; areEstimateEnabledByProjectId: (projectId: string) => boolean; estimateIdsByProjectId: (projectId: string) => string[] | undefined; currentActiveEstimateIdByProjectId: (projectId: string) => string | undefined; @@ -63,6 +64,7 @@ export class ProjectEstimateStore implements IProjectEstimateStore { currentActiveEstimateId: computed, currentActiveEstimate: computed, archivedEstimateIds: computed, + currentProjectEstimate: computed, // actions getWorkspaceEstimates: action, getProjectEstimates: action, @@ -73,6 +75,11 @@ export class ProjectEstimateStore implements IProjectEstimateStore { } // computed + + get currentProjectEstimate(): TEstimateSystemKeys | undefined { + return this.currentActiveEstimateId ? this.estimates[this.currentActiveEstimateId]?.type : undefined; + } + /** * @description get current active estimate id for a project * @returns { string | undefined } From aef50f9e22235b5e99b9e4e24ca40d004c7f2454 Mon Sep 17 00:00:00 2001 From: gakshita Date: Tue, 27 May 2025 17:19:37 +0530 Subject: [PATCH 2/2] fix: nomenclature --- .../components/cycles/dropdowns/estimate-type-dropdown.tsx | 4 ++-- web/core/store/estimates/project-estimate.store.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx b/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx index c8f66be77c3..2899b7ca3af 100644 --- a/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx +++ b/web/core/components/cycles/dropdowns/estimate-type-dropdown.tsx @@ -17,10 +17,10 @@ type TProps = { export const EstimateTypeDropdown = observer((props: TProps) => { const { value, onChange, projectId, cycleId, showDefault = false } = props; const { getIsPointsDataAvailable } = useCycle(); - const { areEstimateEnabledByProjectId, currentProjectEstimate } = useProjectEstimates(); + const { areEstimateEnabledByProjectId, currentProjectEstimateType } = useProjectEstimates(); const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false; return (getIsPointsDataAvailable(cycleId) || isCurrentProjectEstimateEnabled) && - currentProjectEstimate !== EEstimateSystem.CATEGORIES ? ( + currentProjectEstimateType !== EEstimateSystem.CATEGORIES ? (
boolean; estimateIdsByProjectId: (projectId: string) => string[] | undefined; currentActiveEstimateIdByProjectId: (projectId: string) => string | undefined; @@ -64,7 +64,7 @@ export class ProjectEstimateStore implements IProjectEstimateStore { currentActiveEstimateId: computed, currentActiveEstimate: computed, archivedEstimateIds: computed, - currentProjectEstimate: computed, + currentProjectEstimateType: computed, // actions getWorkspaceEstimates: action, getProjectEstimates: action, @@ -76,7 +76,7 @@ export class ProjectEstimateStore implements IProjectEstimateStore { // computed - get currentProjectEstimate(): TEstimateSystemKeys | undefined { + get currentProjectEstimateType(): TEstimateSystemKeys | undefined { return this.currentActiveEstimateId ? this.estimates[this.currentActiveEstimateId]?.type : undefined; }