π₯π₯π₯ 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
fix: cycle & module sidebar date range picker (#3127)
Lakhan Baheti1c546e3cc54d
diff --git a/web/components/cycles/sidebar.tsx b/web/components/cycles/sidebar.tsxindex c99ad95199..fa7fef008a 100644--- a/web/components/cycles/sidebar.tsx+++ b/web/components/cycles/sidebar.tsx@@ -273,10 +273,11 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {</Loader>);- const endDate = new Date(cycleDetails.end_date ?? "");- const startDate = new Date(cycleDetails.start_date ?? "");+ const endDate = new Date(watch("end_date") ?? cycleDetails.end_date ?? "");+ const startDate = new Date(watch("start_date") ?? cycleDetails.start_date ?? "");- const areYearsEqual = startDate.getFullYear() === endDate.getFullYear();+ const areYearsEqual =+ startDate.getFullYear() === endDate.getFullYear() || isNaN(startDate.getFullYear()) || isNaN(endDate.getFullYear());const currentCycle = CYCLE_STATUS.find((status) => status.value === cycleStatus);@@ -355,7 +356,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {<Popover className="flex h-full items-center justify-center rounded-lg"><Popover.ButtonclassName={`text-sm font-medium text-custom-text-300 ${- isEditingAllowed ? "cursor-default" : "cursor-not-allowed"+ isEditingAllowed ? "cursor-pointer" : "cursor-not-allowed"}`}disabled={isCompleted || !isEditingAllowed}>@@ -380,10 +381,10 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {handleStartDateChange(val);}}}- startDate={watch("start_date") ? `${watch("start_date")}` : null}- endDate={watch("end_date") ? `${watch("end_date")}` : null}+ startDate={watch("start_date") ?? watch("end_date") ?? null}+ endDate={watch("end_date") ?? watch("start_date") ?? null}maxDate={new Date(`${watch("end_date")}`)}- selectsStart+ selectsStart={watch("end_date") ? true : false}/></Popover.Panel></Transition>@@ -393,9 +394,9 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {<><Popover.ButtonclassName={`text-sm font-medium text-custom-text-300 ${- isEditingAllowed ? "cursor-default" : "cursor-not-allowed"+ isEditingAllowed ? "cursor-pointer" : "cursor-not-allowed"}`}- disabled={isCompleted ?? !isEditingAllowed}+ disabled={isCompleted || !isEditingAllowed}>{areYearsEqual ? renderShortDate(endDate, "_ _") : renderShortMonthDate(endDate, "_ _")}</Popover.Button>@@ -418,10 +419,10 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {handleEndDateChange(val);}}}- startDate={watch("start_date") ? `${watch("start_date")}` : null}- endDate={watch("end_date") ? `${watch("end_date")}` : null}+ startDate={watch("start_date") ?? watch("end_date") ?? null}+ endDate={watch("end_date") ?? watch("start_date") ?? null}minDate={new Date(`${watch("start_date")}`)}- selectsEnd+ selectsEnd={watch("start_date") ? true : false}/></Popover.Panel></Transition>diff --git a/web/components/modules/sidebar-select/select-lead.tsx b/web/components/modules/sidebar-select/select-lead.tsxindex 8729b12f47..f675925c4b 100644--- a/web/components/modules/sidebar-select/select-lead.tsx+++ b/web/components/modules/sidebar-select/select-lead.tsx@@ -13,12 +13,13 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys";type Props = {value: string | null | undefined;onChange: (val: string) => void;+ disabled?: boolean;};const projectMemberService = new ProjectMemberService();export const SidebarLeadSelect: FC<Props> = (props) => {- const { value, onChange } = props;+ const { value, onChange, disabled = false } = props;// routerconst router = useRouter();const { workspaceSlug, projectId } = router.query;@@ -51,6 +52,7 @@ export const SidebarLeadSelect: FC<Props> = (props) => {</div><div className="flex w-1/2 items-center rounded-sm"><CustomSearchSelect+ disabled={disabled}className="w-full rounded-sm"value={value}customButtonClassName="rounded-sm"@@ -63,7 +65,7 @@ export const SidebarLeadSelect: FC<Props> = (props) => {) : (<div className="group flex w-full items-center justify-between gap-2 p-1 text-sm text-custom-text-400"><span>No lead</span>- <ChevronDown className="hidden h-3.5 w-3.5 group-hover:flex" />+ {!disabled && <ChevronDown className="hidden h-3.5 w-3.5 group-hover:flex" />}</div>)}diff --git a/web/components/modules/sidebar-select/select-members.tsx b/web/components/modules/sidebar-select/select-members.tsxindex b1d926d2e8..28b1733886 100644--- a/web/components/modules/sidebar-select/select-members.tsx+++ b/web/components/modules/sidebar-select/select-members.tsx@@ -13,12 +13,13 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys";type Props = {value: string[] | undefined;onChange: (val: string[]) => void;+ disabled?: boolean;};// servicesconst projectMemberService = new ProjectMemberService();-export const SidebarMembersSelect: React.FC<Props> = ({ value, onChange }) => {+export const SidebarMembersSelect: React.FC<Props> = ({ value, onChange, disabled = false }) => {const router = useRouter();const { workspaceSlug, projectId } = router.query;@@ -48,6 +49,7 @@ export const SidebarMembersSelect: React.FC<Props> = ({ value, onChange }) => {</div><div className="flex w-1/2 items-center rounded-sm "><CustomSearchSelect+ disabled={disabled}className="w-full rounded-sm"value={value ?? []}customButtonClassName="rounded-sm"@@ -67,7 +69,7 @@ export const SidebarMembersSelect: React.FC<Props> = ({ value, onChange }) => {) : (<div className="group flex w-full items-center justify-between gap-2 p-1 text-sm text-custom-text-400"><span>No members</span>- <ChevronDown className="hidden h-3.5 w-3.5 group-hover:flex" />+ {!disabled && <ChevronDown className="hidden h-3.5 w-3.5 group-hover:flex" />}</div>)}diff --git a/web/components/modules/sidebar.tsx b/web/components/modules/sidebar.tsxindex ea7acfbaa1..f2db5dbd5e 100644--- a/web/components/modules/sidebar.tsx+++ b/web/components/modules/sidebar.tsx@@ -245,10 +245,11 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {</Loader>);- const startDate = new Date(moduleDetails.start_date ?? "");- const endDate = new Date(moduleDetails.target_date ?? "");+ const startDate = new Date(watch("start_date") ?? moduleDetails.start_date ?? "");+ const endDate = new Date(watch("target_date") ?? moduleDetails.target_date ?? "");- const areYearsEqual = startDate.getFullYear() === endDate.getFullYear();+ const areYearsEqual =+ startDate.getFullYear() === endDate.getFullYear() || isNaN(startDate.getFullYear()) || isNaN(endDate.getFullYear());const moduleStatus = MODULE_STATUS.find((status) => status.value === moduleDetails.status);@@ -316,7 +317,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {customButton={<spanclassName={`flex h-6 w-20 items-center justify-center rounded-sm text-center text-xs ${- isEditingAllowed ? "cursor-default" : "cursor-not-allowed"+ isEditingAllowed ? "cursor-pointer" : "cursor-not-allowed"}`}style={{color: moduleStatus ? moduleStatus.color : "#a3a3a2",@@ -348,7 +349,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {<Popover className="flex h-full items-center justify-center rounded-lg"><Popover.ButtonclassName={`text-sm font-medium text-custom-text-300 ${- isEditingAllowed ? "cursor-default" : "cursor-not-allowed"+ isEditingAllowed ? "cursor-pointer" : "cursor-not-allowed"}`}disabled={!isEditingAllowed}>@@ -372,10 +373,10 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {handleStartDateChange(val);}}}- startDate={watch("start_date") ? `${watch("start_date")}` : null}- endDate={watch("target_date") ? `${watch("target_date")}` : null}+ startDate={watch("start_date") ?? watch("target_date") ?? null}+ endDate={watch("target_date") ?? watch("start_date") ?? null}maxDate={new Date(`${watch("target_date")}`)}- selectsStart+ selectsStart={watch("target_date") ? true : false}/></Popover.Panel></Transition>@@ -385,7 +386,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {<><Popover.ButtonclassName={`text-sm font-medium text-custom-text-300 ${- isEditingAllowed ? "cursor-default" : "cursor-not-allowed"+ isEditingAllowed ? "cursor-pointer" : "cursor-not-allowed"}`}disabled={!isEditingAllowed}>@@ -409,10 +410,10 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {handleEndDateChange(val);}}}- startDate={watch("start_date") ? `${watch("start_date")}` : null}- endDate={watch("target_date") ? `${watch("target_date")}` : null}+ startDate={watch("start_date") ?? watch("target_date") ?? null}+ endDate={watch("target_date") ?? watch("start_date") ?? null}minDate={new Date(`${watch("start_date")}`)}- selectsEnd+ selectsEnd={watch("start_date") ? true : false}/></Popover.Panel></Transition>@@ -434,6 +435,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {name="lead"render={({ field: { value } }) => (<SidebarLeadSelect+ disabled={!isEditingAllowed}value={value}onChange={(val: string) => {submitChanges({ lead: val });@@ -446,6 +448,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {name="members"render={({ field: { value } }) => (<SidebarMembersSelect+ disabled={!isEditingAllowed}value={value}onChange={(val: string[]) => {submitChanges({ members: val });