From 5683d94d0c6f9d4c48e63afbf6c859d901136a24 Mon Sep 17 00:00:00 2001 From: gakshita Date: Tue, 11 Feb 2025 16:09:27 +0530 Subject: [PATCH 1/2] fix: Handled workspace switcher closing on click --- .../workspace/sidebar/dropdown-item.tsx | 5 +++- .../components/workspace/sidebar/dropdown.tsx | 25 +++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/web/core/components/workspace/sidebar/dropdown-item.tsx b/web/core/components/workspace/sidebar/dropdown-item.tsx index 183a8fdb396..7638b657276 100644 --- a/web/core/components/workspace/sidebar/dropdown-item.tsx +++ b/web/core/components/workspace/sidebar/dropdown-item.tsx @@ -19,9 +19,10 @@ type TProps = { activeWorkspace: IWorkspace | null; handleItemClick: () => void; handleWorkspaceNavigation: (workspace: IWorkspace) => void; + handleClose: () => void; }; const SidebarDropdownItem = observer((props: TProps) => { - const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation } = props; + const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation, handleClose } = props; // router const { workspaceSlug } = useParams(); // hooks @@ -89,6 +90,7 @@ const SidebarDropdownItem = observer((props: TProps) => {
@@ -96,6 +98,7 @@ const SidebarDropdownItem = observer((props: TProps) => { diff --git a/web/core/components/workspace/sidebar/dropdown.tsx b/web/core/components/workspace/sidebar/dropdown.tsx index 8d131594840..ac9acf42e5b 100644 --- a/web/core/components/workspace/sidebar/dropdown.tsx +++ b/web/core/components/workspace/sidebar/dropdown.tsx @@ -46,20 +46,10 @@ export const SidebarDropdown = observer(() => { // popper-js init const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: "right", - modifiers: [ - { - name: "preventOverflow", - options: { - padding: 12, - }, - }, - ], + modifiers: [{ name: "preventOverflow", options: { padding: 12 } }], }); - const handleWorkspaceNavigation = (workspace: IWorkspace) => - updateUserProfile({ - last_workspace_id: workspace?.id, - }); + const handleWorkspaceNavigation = (workspace: IWorkspace) => updateUserProfile({ last_workspace_id: workspace?.id }); const handleSignOut = async () => { await signOut().catch(() => @@ -86,14 +76,12 @@ export const SidebarDropdown = observer(() => { "flex-grow-0 justify-center": sidebarCollapsed, })} > - {({ open }) => ( + {({ open, close }) => ( <>
@@ -108,9 +96,7 @@ export const SidebarDropdown = observer(() => {
From 80251e951c939121f4016ce7a02c25a6071c8e9a Mon Sep 17 00:00:00 2001 From: gakshita Date: Mon, 3 Mar 2025 17:18:00 +0530 Subject: [PATCH 2/2] fix: reverted module date picker changes --- web/core/components/dropdowns/date-range.tsx | 4 - .../modules/analytics-sidebar/root.tsx | 91 ++++++++----------- .../components/modules/module-card-item.tsx | 51 ++++------- .../modules/module-list-item-action.tsx | 46 ++++------ 4 files changed, 75 insertions(+), 117 deletions(-) diff --git a/web/core/components/dropdowns/date-range.tsx b/web/core/components/dropdowns/date-range.tsx index 7d73216a42d..f3cede368b2 100644 --- a/web/core/components/dropdowns/date-range.tsx +++ b/web/core/components/dropdowns/date-range.tsx @@ -205,10 +205,6 @@ export const DateRangeDropdown: React.FC = (props) => { selected={dateRange} onSelect={(val) => { onSelect(val); - setDateRange({ - from: val?.from ?? undefined, - to: val?.to ?? undefined, - }); }} mode="range" disabled={disabledDays} diff --git a/web/core/components/modules/analytics-sidebar/root.tsx b/web/core/components/modules/analytics-sidebar/root.tsx index 6489e504b97..aeae69a2c23 100644 --- a/web/core/components/modules/analytics-sidebar/root.tsx +++ b/web/core/components/modules/analytics-sidebar/root.tsx @@ -6,7 +6,6 @@ import { useParams } from "next/navigation"; import { Controller, useForm } from "react-hook-form"; import { ArchiveRestoreIcon, - CalendarCheck2, CalendarClock, ChevronDown, ChevronRight, @@ -43,7 +42,7 @@ import { TextArea, } from "@plane/ui"; // components -import { DateDropdown, MemberDropdown } from "@/components/dropdowns"; +import { DateRangeDropdown, MemberDropdown } from "@/components/dropdowns"; import { ArchiveModuleModal, DeleteModuleModal, @@ -105,7 +104,7 @@ export const ModuleAnalyticsSidebar: React.FC = observer((props) => { const estimateType = areEstimateEnabled && currentActiveEstimateId && estimateById(currentActiveEstimateId); const isEstimatePointValid = estimateType && estimateType?.type == EEstimateSystem.POINTS ? true : false; - const { reset, control, getValues } = useForm({ + const { reset, control } = useForm({ defaultValues, }); @@ -195,8 +194,11 @@ export const ModuleAnalyticsSidebar: React.FC = observer((props) => { }); }; - const handleDateChange = async (data: Partial) => { - submitChanges(data); + const handleDateChange = async (startDate: Date | undefined, targetDate: Date | undefined) => { + submitChanges({ + start_date: startDate ? renderFormattedPayloadDate(startDate) : null, + target_date: targetDate ? renderFormattedPayloadDate(targetDate) : null, + }); setToast({ type: TOAST_TYPE.SUCCESS, title: "Success!", @@ -413,59 +415,40 @@ export const ModuleAnalyticsSidebar: React.FC = observer((props) => {
- Start date -
-
- ( - { - console.log(val); - onChange(renderFormattedPayloadDate(val)); - handleDateChange({ start_date: val ? renderFormattedPayloadDate(val) : null }); - }} - placeholder={t("common.order_by.start_date")} - icon={} - buttonVariant={value ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${!isEditingAllowed || isArchived ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-30" - disabled={!isEditingAllowed || isArchived} - showTooltip - maxDate={getDate(getValues("target_date"))} - /> - )} - /> -
-
-
-
- - Due date + {t("date_range")}
-
+
( - { - onChange(renderFormattedPayloadDate(val)); - handleDateChange({ target_date: val ? renderFormattedPayloadDate(val) : null }); + name="start_date" + render={({ field: { value: startDateValue, onChange: onChangeStartDate } }) => ( + { + const startDate = getDate(startDateValue); + const endDate = getDate(endDateValue); + return ( + { + onChangeStartDate(val?.from ? renderFormattedPayloadDate(val.from) : null); + onChangeEndDate(val?.to ? renderFormattedPayloadDate(val.to) : null); + handleDateChange(val?.from, val?.to); + }} + placeholder={{ + from: t("start_date"), + to: t("target_date"), + }} + disabled={!isEditingAllowed || isArchived} + /> + ); }} - placeholder={t("common.order_by.due_date")} - icon={} - buttonVariant={value ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${!isEditingAllowed || isArchived ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-30" - disabled={!isEditingAllowed || isArchived} - showTooltip - minDate={getDate(getValues("start_date"))} /> )} /> diff --git a/web/core/components/modules/module-card-item.tsx b/web/core/components/modules/module-card-item.tsx index 4fe884b4729..9585755eef3 100644 --- a/web/core/components/modules/module-card-item.tsx +++ b/web/core/components/modules/module-card-item.tsx @@ -4,7 +4,7 @@ import React, { SyntheticEvent, useRef } from "react"; import { observer } from "mobx-react"; import Link from "next/link"; import { useParams, usePathname, useSearchParams } from "next/navigation"; -import { CalendarCheck2, CalendarClock, Info, SquareUser } from "lucide-react"; +import { Info, SquareUser } from "lucide-react"; // plane package imports import { MODULE_STATUS, @@ -14,7 +14,6 @@ import { EUserPermissions, EUserPermissionsLevel, } from "@plane/constants"; -import { useTranslation } from "@plane/i18n"; import { IModule } from "@plane/types"; import { Card, @@ -27,7 +26,7 @@ import { setToast, } from "@plane/ui"; // components -import { DateDropdown } from "@/components/dropdowns"; +import { DateRangeDropdown } from "@/components/dropdowns"; import { ButtonAvatars } from "@/components/dropdowns/member/avatar"; import { ModuleQuickActions } from "@/components/modules"; import { ModuleStatusDropdown } from "@/components/modules/module-status-dropdown"; @@ -59,7 +58,7 @@ export const ModuleCardItem: React.FC = observer((props) => { const { getModuleById, addModuleToFavorites, removeModuleFromFavorites, updateModuleDetails } = useModule(); const { getUserDetails } = useMember(); const { captureEvent } = useEventTracker(); - const { t } = useTranslation(); + // derived values const moduleDetails = getModuleById(moduleId); const isEditingAllowed = allowPermissions( @@ -67,6 +66,7 @@ export const ModuleCardItem: React.FC = observer((props) => { EUserPermissionsLevel.PROJECT ); const isDisabled = !isEditingAllowed || !!moduleDetails?.archived_at; + const renderIcon = Boolean(moduleDetails?.start_date) || Boolean(moduleDetails?.target_date); const { isMobile } = usePlatformOS(); const handleAddToFavorites = (e: React.MouseEvent) => { @@ -236,38 +236,27 @@ export const ModuleCardItem: React.FC = observer((props) => { )}
-
- { - handleModuleDetailsChange({ - start_date: val ? renderFormattedPayloadDate(val) : null, - }); +
+ } - buttonVariant={moduleDetails.start_date ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${isDisabled ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-10" - disabled={isDisabled} - showTooltip - maxDate={getDate(moduleDetails.target_date)} - /> - { + onSelect={(val) => { handleModuleDetailsChange({ - target_date: val ? renderFormattedPayloadDate(val) : null, + start_date: val?.from ? renderFormattedPayloadDate(val.from) : null, + target_date: val?.to ? renderFormattedPayloadDate(val.to) : null, }); }} - placeholder={t("common.order_by.due_date")} - icon={} - buttonVariant={moduleDetails.target_date ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${isDisabled ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-10" + placeholder={{ + from: "Start date", + to: "End date", + }} disabled={isDisabled} - showTooltip - minDate={getDate(moduleDetails.start_date)} + hideIcon={{ from: renderIcon ?? true, to: renderIcon }} />
diff --git a/web/core/components/modules/module-list-item-action.tsx b/web/core/components/modules/module-list-item-action.tsx index e159b119ff0..1f929751dfc 100644 --- a/web/core/components/modules/module-list-item-action.tsx +++ b/web/core/components/modules/module-list-item-action.tsx @@ -4,7 +4,7 @@ import React, { FC } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // icons -import { CalendarCheck2, CalendarClock, SquareUser } from "lucide-react"; +import { SquareUser } from "lucide-react"; // types import { MODULE_STATUS, @@ -18,7 +18,7 @@ import { IModule } from "@plane/types"; // ui import { FavoriteStar, TOAST_TYPE, Tooltip, setPromiseToast, setToast } from "@plane/ui"; // components -import { DateDropdown } from "@/components/dropdowns"; +import { DateRangeDropdown } from "@/components/dropdowns"; import { ModuleQuickActions } from "@/components/modules"; import { ModuleStatusDropdown } from "@/components/modules/module-status-dropdown"; // constants @@ -138,38 +138,28 @@ export const ModuleListItemAction: FC = observer((props) => { return ( <> - { - handleModuleDetailsChange({ - start_date: val ? renderFormattedPayloadDate(val) : null, - }); + } - buttonVariant={moduleDetails.start_date ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${isDisabled ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-10" - disabled={isDisabled} - showTooltip - maxDate={getDate(moduleDetails.target_date)} - /> - { + onSelect={(val) => { handleModuleDetailsChange({ - target_date: val ? renderFormattedPayloadDate(val) : null, + start_date: val?.from ? renderFormattedPayloadDate(val.from) : null, + target_date: val?.to ? renderFormattedPayloadDate(val.to) : null, }); }} - placeholder={t("common.order_by.due_date")} - icon={} - buttonVariant={moduleDetails.target_date ? "border-with-text" : "border-without-text"} - buttonContainerClassName={`h-6 w-full flex ${isDisabled ? "cursor-not-allowed" : "cursor-pointer"} items-center gap-1.5 text-custom-text-300 rounded text-xs`} - optionsClassName="z-10" + placeholder={{ + from: t("start_date"), + to: t("end_date"), + }} disabled={isDisabled} - showTooltip - minDate={getDate(moduleDetails.start_date)} + hideIcon={{ from: renderIcon ?? true, to: renderIcon }} /> + {moduleStatus && (