From 0fa259888e3586769fb8a287384ea0f8f7a15ee8 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 4 Jul 2024 12:36:17 +0530 Subject: [PATCH] hide disabledActions in main context menu --- src/pages/home/report/ReportActionItem.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 2264feddd67..0c817a350ba 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -325,6 +325,9 @@ function ReportActionItem({ setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); }, [action.reportActionID]); + const isArchivedRoom = ReportUtils.isArchivedRoomWithID(originalReportID); + const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); + const isChronosReport = ReportUtils.chatIncludesChronosWithID(originalReportID); /** * Show the ReportActionContextMenu modal popover. * @@ -350,16 +353,16 @@ function ReportActionItem({ draftMessage ?? '', () => setIsContextMenuActive(true), toggleContextMenuFromActiveReportAction, - ReportUtils.isArchivedRoomWithID(originalReportID), - ReportUtils.chatIncludesChronosWithID(originalReportID), + isArchivedRoom, + isChronosReport, false, false, - [], + disabledActions, false, setIsEmojiPickerActive as () => void, ); }, - [draftMessage, action, report.reportID, toggleContextMenuFromActiveReportAction, originalReportID, shouldDisplayContextMenu], + [draftMessage, action, report.reportID, toggleContextMenuFromActiveReportAction, originalReportID, shouldDisplayContextMenu, disabledActions, isArchivedRoom, isChronosReport], ); // Handles manual scrolling to the bottom of the chat when the last message is an actionable whisper and it's resolved. @@ -889,12 +892,12 @@ function ReportActionItem({ reportActionID={action.reportActionID} anchor={popoverAnchorRef} originalReportID={originalReportID ?? '-1'} - isArchivedRoom={ReportUtils.isArchivedRoom(report)} + isArchivedRoom={isArchivedRoom} displayAsGroup={displayAsGroup} - disabledActions={!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []} + disabledActions={disabledActions} isVisible={hovered && draftMessage === undefined && !hasErrors} draftMessage={draftMessage} - isChronosReport={ReportUtils.chatIncludesChronosWithID(originalReportID)} + isChronosReport={isChronosReport} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} setIsEmojiPickerActive={setIsEmojiPickerActive} />