π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-3701] fix: use `getCycleById` to ensure null handling for cycle access (#6838)
Prateek Shourya691cbef1f2bb
diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsxindex 381b567dfd..fbe8ed85d5 100644--- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx+++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx@@ -26,7 +26,7 @@ const CycleDetailPage = observer(() => {const { getProjectById } = useProject();// const { issuesFilter } = useIssues(EIssuesStoreType.CYCLE);// hooks- const { setValue, storedValue } = useLocalStorage("cycle_sidebar_collapsed", "false");+ const { setValue, storedValue } = useLocalStorage("cycle_sidebar_collapsed", false);useCyclesDetails({workspaceSlug: workspaceSlug?.toString(),@@ -34,7 +34,7 @@ const CycleDetailPage = observer(() => {cycleId: cycleId.toString(),});// derived values- const isSidebarCollapsed = storedValue ? (storedValue === "true" ? true : false) : false;+ const isSidebarCollapsed = storedValue ? (storedValue === true ? true : false) : false;const cycle = cycleId ? getCycleById(cycleId.toString()) : undefined;const project = projectId ? getProjectById(projectId.toString()) : undefined;const pageTitle = project?.name && cycle?.name ? `${project?.name} - ${cycle?.name}` : undefined;@@ -42,7 +42,7 @@ const CycleDetailPage = observer(() => {/*** Toggles the sidebar*/- const toggleSidebar = () => setValue(`${!isSidebarCollapsed}`);+ const toggleSidebar = () => setValue(!isSidebarCollapsed);// const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout;diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsxindex 508da58a21..106dfa4d2a 100644--- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx+++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx@@ -99,11 +99,11 @@ export const CycleIssuesHeader: React.FC = observer(() => {const activeLayout = issueFilters?.displayFilters?.layout;- const { setValue, storedValue } = useLocalStorage("cycle_sidebar_collapsed", "false");+ const { setValue, storedValue } = useLocalStorage("cycle_sidebar_collapsed", false);- const isSidebarCollapsed = storedValue ? (storedValue === "true" ? true : false) : false;+ const isSidebarCollapsed = storedValue ? (storedValue === true ? true : false) : false;const toggleSidebar = () => {- setValue(`${!isSidebarCollapsed}`);+ setValue(!isSidebarCollapsed);};const handleLayoutChange = useCallback(diff --git a/web/core/store/cycle.store.ts b/web/core/store/cycle.store.tsindex 89221ee7cc..d08d8e935d 100644--- a/web/core/store/cycle.store.ts+++ b/web/core/store/cycle.store.ts@@ -241,10 +241,10 @@ export class CycleStore implements ICycleStore {}getIsPointsDataAvailable = computedFn((cycleId: string) => {- const cycle = this.cycleMap[cycleId];+ const cycle = this.getCycleById(cycleId);if (!cycle) return false;- if (this.cycleMap[cycleId].version === 2) return cycle.progress.some((p) => p.total_estimate_points > 0);- else if (this.cycleMap[cycleId].version === 1) {+ if (cycle.version === 2) return cycle.progress?.some((p) => p.total_estimate_points > 0);+ else if (cycle.version === 1) {const completionChart = cycle.estimate_distribution?.completion_chart || {};return !isEmpty(completionChart) && Object.keys(completionChart).some((p) => completionChart[p]! > 0);} else return false;@@ -560,8 +560,7 @@ export class CycleStore implements ICycleStore {* @returns*/updateCycleDistribution = (distributionUpdates: DistributionUpdates, cycleId: string) => {- const cycle = this.cycleMap[cycleId];-+ const cycle = this.getCycleById(cycleId);if (!cycle) return;runInAction(() => {@@ -644,7 +643,7 @@ export class CycleStore implements ICycleStore {entity_type: "cycle",entity_identifier: cycleId,project_id: projectId,- entity_data: { name: this.cycleMap[cycleId].name || "" },+ entity_data: { name: currentCycle?.name || "" },});return response;} catch (error) {diff --git a/web/core/store/issue/cycle/issue.store.ts b/web/core/store/issue/cycle/issue.store.tsindex 87f5a92127..9bf2c7e16d 100644--- a/web/core/store/issue/cycle/issue.store.ts+++ b/web/core/store/issue/cycle/issue.store.ts@@ -21,6 +21,7 @@ import {// helpersimport { getDistributionPathsPostUpdate } from "@/helpers/distribution-update.helper";//local+import { storage } from "@/lib/local-storage";import { persistence } from "@/local-db/storage.sqlite";import { BaseIssuesStore, IBaseIssuesStore } from "../helpers/base-issues.store";//@@ -142,8 +143,12 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues {projectId && cycleId && this.rootIssueStore.rootStore.cycle.fetchCycleDetails(workspaceSlug, projectId, cycleId);// fetch cycle progress+ const isSidebarCollapsed = storage.get("cycle_sidebar_collapsed");projectId &&cycleId &&+ this.rootIssueStore.rootStore.cycle.getCycleById(cycleId)?.version === 2 &&+ isSidebarCollapsed &&+ JSON.parse(isSidebarCollapsed) === false &&this.rootIssueStore.rootStore.cycle.fetchActiveCycleProgressPro(workspaceSlug, projectId, cycleId);};