diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index eb1e60461005..438d09e778b4 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -163,32 +163,6 @@ const ContextMenuActions: ContextMenuAction[] = [ ); }, }, - { - isAnonymousAction: true, - textTranslateKey: 'common.download', - icon: Expensicons.Download, - successTextTranslateKey: 'common.download', - successIcon: Expensicons.Download, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat, isOffline): reportAction is ReportAction => { - const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction); - const messageHtml = getActionHtml(reportAction); - return ( - isAttachment && messageHtml !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && !!reportAction?.reportActionID && !ReportActionsUtils.isMessageDeleted(reportAction) && !isOffline - ); - }, - onPress: (closePopover, {reportAction}) => { - const html = getActionHtml(reportAction); - const {originalFileName, sourceURL} = getAttachmentDetails(html); - const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? ''); - const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; - Download.setDownload(sourceID, true); - fileDownload(sourceURLWithAuth, originalFileName ?? '').then(() => Download.setDownload(sourceID, false)); - if (closePopover) { - hideContextMenu(true, ReportActionComposeFocusManager.focus); - } - }, - getDescription: () => {}, - }, { isAnonymousAction: false, textTranslateKey: 'reportActionContextMenu.replyInThread', @@ -216,6 +190,37 @@ const ContextMenuActions: ContextMenuAction[] = [ }, getDescription: () => {}, }, + { + isAnonymousAction: false, + textTranslateKey: 'reportActionContextMenu.markAsUnread', + icon: Expensicons.ChatBubbleUnread, + successIcon: Expensicons.Checkmark, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => + type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION || (type === CONST.CONTEXT_MENU_TYPES.REPORT && !isUnreadChat), + onPress: (closePopover, {reportAction, reportID}) => { + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction) ?? ''; + Report.markCommentAsUnread(originalReportID, reportAction?.created); + if (closePopover) { + hideContextMenu(true, ReportActionComposeFocusManager.focus); + } + }, + getDescription: () => {}, + }, + { + isAnonymousAction: false, + textTranslateKey: 'reportActionContextMenu.markAsRead', + icon: Expensicons.Mail, + successIcon: Expensicons.Checkmark, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => + type === CONST.CONTEXT_MENU_TYPES.REPORT && isUnreadChat, + onPress: (closePopover, {reportID}) => { + Report.readNewestAction(reportID); + if (closePopover) { + hideContextMenu(true, ReportActionComposeFocusManager.focus); + } + }, + getDescription: () => {}, + }, { isAnonymousAction: false, textTranslateKey: 'reportActionContextMenu.editAction', @@ -250,37 +255,6 @@ const ContextMenuActions: ContextMenuAction[] = [ }, getDescription: () => {}, }, - { - isAnonymousAction: false, - textTranslateKey: 'reportActionContextMenu.markAsUnread', - icon: Expensicons.ChatBubbleUnread, - successIcon: Expensicons.Checkmark, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => - type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION || (type === CONST.CONTEXT_MENU_TYPES.REPORT && !isUnreadChat), - onPress: (closePopover, {reportAction, reportID}) => { - const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction) ?? ''; - Report.markCommentAsUnread(originalReportID, reportAction?.created); - if (closePopover) { - hideContextMenu(true, ReportActionComposeFocusManager.focus); - } - }, - getDescription: () => {}, - }, - { - isAnonymousAction: false, - textTranslateKey: 'reportActionContextMenu.markAsRead', - icon: Expensicons.Mail, - successIcon: Expensicons.Checkmark, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => - type === CONST.CONTEXT_MENU_TYPES.REPORT && isUnreadChat, - onPress: (closePopover, {reportID}) => { - Report.readNewestAction(reportID); - if (closePopover) { - hideContextMenu(true, ReportActionComposeFocusManager.focus); - } - }, - getDescription: () => {}, - }, { isAnonymousAction: false, textTranslateKey: 'reportActionContextMenu.joinThread', @@ -430,29 +404,6 @@ const ContextMenuActions: ContextMenuAction[] = [ }, getDescription: () => {}, }, - { - isAnonymousAction: false, - textTranslateKey: 'reportActionContextMenu.deleteAction', - icon: Expensicons.Trashcan, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID) => - // Until deleting parent threads is supported in FE, we will prevent the user from deleting a thread parent - type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION && - ReportUtils.canDeleteReportAction(reportAction, reportID) && - !isArchivedRoom && - !isChronosReport && - !ReportActionsUtils.isMessageDeleted(reportAction), - onPress: (closePopover, {reportID, reportAction}) => { - if (closePopover) { - // Hide popover, then call showDeleteConfirmModal - hideContextMenu(false, () => showDeleteModal(reportID, reportAction)); - return; - } - - // No popover to hide, call showDeleteConfirmModal immediately - showDeleteModal(reportID, reportAction); - }, - getDescription: () => {}, - }, { isAnonymousAction: false, textTranslateKey: 'common.pin', @@ -499,6 +450,55 @@ const ContextMenuActions: ContextMenuAction[] = [ }, getDescription: () => {}, }, + { + isAnonymousAction: true, + textTranslateKey: 'common.download', + icon: Expensicons.Download, + successTextTranslateKey: 'common.download', + successIcon: Expensicons.Download, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat, isOffline): reportAction is ReportAction => { + const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction); + const messageHtml = getActionHtml(reportAction); + return ( + isAttachment && messageHtml !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && !!reportAction?.reportActionID && !ReportActionsUtils.isMessageDeleted(reportAction) && !isOffline + ); + }, + onPress: (closePopover, {reportAction}) => { + const html = getActionHtml(reportAction); + const {originalFileName, sourceURL} = getAttachmentDetails(html); + const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? ''); + const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; + Download.setDownload(sourceID, true); + fileDownload(sourceURLWithAuth, originalFileName ?? '').then(() => Download.setDownload(sourceID, false)); + if (closePopover) { + hideContextMenu(true, ReportActionComposeFocusManager.focus); + } + }, + getDescription: () => {}, + }, + { + isAnonymousAction: false, + textTranslateKey: 'reportActionContextMenu.deleteAction', + icon: Expensicons.Trashcan, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID) => + // Until deleting parent threads is supported in FE, we will prevent the user from deleting a thread parent + type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION && + ReportUtils.canDeleteReportAction(reportAction, reportID) && + !isArchivedRoom && + !isChronosReport && + !ReportActionsUtils.isMessageDeleted(reportAction), + onPress: (closePopover, {reportID, reportAction}) => { + if (closePopover) { + // Hide popover, then call showDeleteConfirmModal + hideContextMenu(false, () => showDeleteModal(reportID, reportAction)); + return; + } + + // No popover to hide, call showDeleteConfirmModal immediately + showDeleteModal(reportID, reportAction); + }, + getDescription: () => {}, + }, { isAnonymousAction: true, textTranslateKey: 'reportActionContextMenu.menu',