From 989d2835533649f70bccfc151af70e10126cc4f3 Mon Sep 17 00:00:00 2001 From: mateusbra Date: Wed, 16 Mar 2022 18:27:50 -0300 Subject: [PATCH 1/8] fix: show Copy e-mail instead of Copy URL when anchor is an e-mail --- .../BaseAnchorForCommentsOnly/index.js | 3 ++- .../BaseAnchorForCommentsOnly/index.native.js | 2 +- src/languages/en.js | 1 + src/languages/es.js | 1 + .../home/report/ContextMenu/ContextMenuActions.js | 12 ++++++++++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js index d2a88849dc34..86124c19449d 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js @@ -9,6 +9,7 @@ import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import fileDownload from '../../../libs/fileDownload'; +import Str from 'expensify-common/lib/str'; /* * This is a default anchor component for regular links. @@ -61,7 +62,7 @@ class BaseAnchorForCommentsOnly extends React.Component { onSecondaryInteraction={ (event) => { ReportActionContextMenu.showContextMenu( - ContextMenuActions.CONTEXT_MENU_TYPES.LINK, + Str.isValidEmail(this.props.fileName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, this.props.href, lodashGet(linkRef, 'current'), diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index c150a300b4ef..802bfbbc6c13 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -64,7 +64,7 @@ class BaseAnchorForCommentsOnly extends React.Component { onSecondaryInteraction={ (event) => { ReportActionContextMenu.showContextMenu( - ContextMenuActions.CONTEXT_MENU_TYPES.LINK, + Str.isValidEmail(this.props.fileName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, this.props.href, lodashGet(linkRef, 'current'), diff --git a/src/languages/en.js b/src/languages/en.js index a17924c1f7dc..c64ae800c8ed 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -165,6 +165,7 @@ export default { copied: 'Copied!', copyLink: 'Copy link', copyURLToClipboard: 'Copy URL to clipboard', + copyEmailToClipboard: 'Copy e-mail to clipboard', markAsUnread: 'Mark as unread', editComment: 'Edit comment', deleteComment: 'Delete comment', diff --git a/src/languages/es.js b/src/languages/es.js index a247568bb3e5..28bd044d92f3 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -165,6 +165,7 @@ export default { copied: '¡Copiado!', copyLink: 'Copiar enlace', copyURLToClipboard: 'Copiar URL al portapapeles', + copyEmailToClipboard: 'Copiar e-mail al portapapeles', markAsUnread: 'Marcar como no leído', editComment: 'Editar commentario', deleteComment: 'Eliminar comentario', diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 34ca78008e41..421184cc1164 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -22,6 +22,7 @@ function getActionText(reportAction) { const CONTEXT_MENU_TYPES = { LINK: 'LINK', REPORT_ACTION: 'REPORT_ACTION', + EMAIL: 'EMAIL', }; // A list of all the context actions in this menu. @@ -37,6 +38,17 @@ export default [ hideContextMenu(true, ReportActionComposeFocusManager.focus); }, }, + { + textTranslateKey:'reportActionContextMenu.copyEmailToClipboard', + icon: Expensicons.Clipboard, + successTextTranslateKey: 'reportActionContextMenu.copied', + successIcon: Expensicons.Checkmark, + shouldShow: type => type === CONTEXT_MENU_TYPES.EMAIL, + onPress: (closePopover, {selection}) => { + Clipboard.setString(selection.replace("mailto:","")); + hideContextMenu(true, ReportActionComposeFocusManager.focus); + }, + }, { textTranslateKey: 'reportActionContextMenu.copyToClipboard', icon: Expensicons.Clipboard, From 367030155ac9bc0bb16c96e309d2a9b3921ee651 Mon Sep 17 00:00:00 2001 From: mateusbra Date: Wed, 16 Mar 2022 18:56:46 -0300 Subject: [PATCH 2/8] add import Str to native applications --- .../BaseAnchorForCommentsOnly/index.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index 802bfbbc6c13..2aacba05dd65 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -10,6 +10,7 @@ import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import styles from '../../../styles/styles'; +import Str from 'expensify-common/lib/str'; /* * This is a default anchor component for regular links. From 29b070100d9a794458524a4fe3dde365c812d76c Mon Sep 17 00:00:00 2001 From: mateusbra Date: Thu, 17 Mar 2022 00:26:33 -0300 Subject: [PATCH 3/8] Fix ESlint problems --- .../AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js | 2 +- .../BaseAnchorForCommentsOnly/index.native.js | 2 +- src/pages/home/report/ContextMenu/ContextMenuActions.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js index 86124c19449d..f635d60c0ed9 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js @@ -2,6 +2,7 @@ import _ from 'underscore'; import React from 'react'; import {Pressable, StyleSheet} from 'react-native'; import lodashGet from 'lodash/get'; +import Str from 'expensify-common/lib/str'; import Text from '../../Text'; import {propTypes, defaultProps} from '../anchorForCommentsOnlyPropTypes'; import PressableWithSecondaryInteraction from '../../PressableWithSecondaryInteraction'; @@ -9,7 +10,6 @@ import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import fileDownload from '../../../libs/fileDownload'; -import Str from 'expensify-common/lib/str'; /* * This is a default anchor component for regular links. diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index 2aacba05dd65..43eb63057610 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -2,6 +2,7 @@ import _ from 'underscore'; import React from 'react'; import lodashGet from 'lodash/get'; import {Linking, StyleSheet, Pressable} from 'react-native'; +import Str from 'expensify-common/lib/str'; import {propTypes, defaultProps} from '../anchorForCommentsOnlyPropTypes'; import fileDownload from '../../../libs/fileDownload'; import Text from '../../Text'; @@ -10,7 +11,6 @@ import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import styles from '../../../styles/styles'; -import Str from 'expensify-common/lib/str'; /* * This is a default anchor component for regular links. diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 421184cc1164..381c9e304f91 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -39,13 +39,13 @@ export default [ }, }, { - textTranslateKey:'reportActionContextMenu.copyEmailToClipboard', + textTranslateKey: 'reportActionContextMenu.copyEmailToClipboard', icon: Expensicons.Clipboard, successTextTranslateKey: 'reportActionContextMenu.copied', successIcon: Expensicons.Checkmark, shouldShow: type => type === CONTEXT_MENU_TYPES.EMAIL, onPress: (closePopover, {selection}) => { - Clipboard.setString(selection.replace("mailto:","")); + Clipboard.setString(selection.replace('mailto:', '')); hideContextMenu(true, ReportActionComposeFocusManager.focus); }, }, From 8956ffab041d7ab0bcfc57a461faad19a72f19bf Mon Sep 17 00:00:00 2001 From: mateusbra Date: Thu, 17 Mar 2022 14:54:23 -0300 Subject: [PATCH 4/8] add EMAIL type to @param --- .../home/report/ContextMenu/PopoverReportActionContextMenu.js | 2 +- src/pages/home/report/ContextMenu/ReportActionContextMenu.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index f94105654eea..bb2668573d70 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -101,7 +101,7 @@ class PopoverReportActionContextMenu extends React.Component { /** * Show the ReportActionContextMenu modal popover. * - * @param {string} type - context menu type [LINK, REPORT_ACTION] + * @param {string} type - context menu type [EMAIL, LINK, REPORT_ACTION] * @param {Object} [event] - A press event. * @param {string} [selection] - A copy text. * @param {Element} contextMenuAnchor - popoverAnchor diff --git a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js index ae82626a0704..8952287fa850 100644 --- a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js @@ -5,7 +5,7 @@ const contextMenuRef = React.createRef(); /** * Show the ReportActionContextMenu modal popover. * - * @param {string} type - the context menu type to display [LINK, REPORT_ACTION] + * @param {string} type - the context menu type to display [EMAIL, LINK, REPORT_ACTION] * @param {Object} [event] - A press event. * @param {string} [selection] - A copy text. * @param {Element} contextMenuAnchor - popoverAnchor From 4076f1b8f7c08433ce598c37b5636ab0d66988ca Mon Sep 17 00:00:00 2001 From: mateusbra Date: Thu, 17 Mar 2022 16:09:08 -0300 Subject: [PATCH 5/8] rename fileName to displayName --- .../BaseAnchorForCommentsOnly/index.js | 12 ++++++------ .../BaseAnchorForCommentsOnly/index.native.js | 12 ++++++------ .../anchorForCommentsOnlyPropTypes.js | 6 +++--- .../HTMLRenderers/AnchorRenderer.js | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js index f635d60c0ed9..4117fee115ac 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js @@ -28,11 +28,11 @@ class BaseAnchorForCommentsOnly extends React.Component { * Initiate file downloading and update downloading flags * * @param {String} href - * @param {String} fileName + * @param {String} displayName */ - processDownload(href, fileName) { + processDownload(href, displayName) { this.setState({isDownloading: true}); - fileDownload(href, fileName).then(() => this.setState({isDownloading: false})); + fileDownload(href, displayName).then(() => this.setState({isDownloading: false})); } render() { @@ -45,12 +45,12 @@ class BaseAnchorForCommentsOnly extends React.Component { if (this.state.isDownloading) { return; } - this.processDownload(this.props.href, this.props.fileName); + this.processDownload(this.props.href, this.props.displayName); }} > @@ -62,7 +62,7 @@ class BaseAnchorForCommentsOnly extends React.Component { onSecondaryInteraction={ (event) => { ReportActionContextMenu.showContextMenu( - Str.isValidEmail(this.props.fileName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, + Str.isValidEmail(this.props.displayName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, this.props.href, lodashGet(linkRef, 'current'), diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index 43eb63057610..fbb9470ed071 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -29,11 +29,11 @@ class BaseAnchorForCommentsOnly extends React.Component { * Initiate file downloading and update downloading flags * * @param {String} href - * @param {String} fileName + * @param {String} displayName */ - processDownload(href, fileName) { + processDownload(href, displayName) { this.setState({isDownloading: true}); - fileDownload(href, fileName).then(() => this.setState({isDownloading: false})); + fileDownload(href, displayName).then(() => this.setState({isDownloading: false})); } render() { @@ -48,12 +48,12 @@ class BaseAnchorForCommentsOnly extends React.Component { if (this.state.isDownloading) { return; } - this.processDownload(this.props.href, this.props.fileName); + this.processDownload(this.props.href, this.props.displayName); }} > @@ -65,7 +65,7 @@ class BaseAnchorForCommentsOnly extends React.Component { onSecondaryInteraction={ (event) => { ReportActionContextMenu.showContextMenu( - Str.isValidEmail(this.props.fileName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, + Str.isValidEmail(this.props.displayName) ? ContextMenuActions.CONTEXT_MENU_TYPES.EMAIL : ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, this.props.href, lodashGet(linkRef, 'current'), diff --git a/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js b/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js index 5beecad66f70..2860ab73fee0 100644 --- a/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js +++ b/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js @@ -21,8 +21,8 @@ const propTypes = { /** Any children to display */ children: PropTypes.node, - /** Display label in case of attachments */ - fileName: PropTypes.string, + /** Display label in case of attachments. Text to display in case of anchors */ + displayName: PropTypes.string, /** Any additional styles to apply */ // eslint-disable-next-line react/forbid-prop-types @@ -37,7 +37,7 @@ const defaultProps = { isAttachment: false, children: null, style: {}, - fileName: '', + displayName: '', }; export {propTypes, defaultProps}; diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index 62362d41b77d..6f53780a4eb4 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -17,7 +17,7 @@ const AnchorRenderer = (props) => { // An auth token is needed to download Expensify chat attachments const isAttachment = Boolean(htmlAttribs['data-expensify-source']); - const fileName = lodashGet(props.tnode, 'domNode.children[0].data', ''); + const displayName = lodashGet(props.tnode, 'domNode.children[0].data', ''); const parentStyle = lodashGet(props.tnode, 'parent.styles.nativeTextRet', {}); const attrHref = htmlAttribs.href || ''; const internalExpensifyPath = (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, '')) @@ -64,7 +64,7 @@ const AnchorRenderer = (props) => { rel={htmlAttribs.rel || 'noopener noreferrer'} style={{...props.style, ...parentStyle}} key={props.key} - fileName={fileName} + displayName={displayName} > From 0b75ee7501286cd696371315003c60752b20bdeb Mon Sep 17 00:00:00 2001 From: mateusbra Date: Thu, 17 Mar 2022 16:26:57 -0300 Subject: [PATCH 6/8] change e-mail to email on translations --- src/languages/en.js | 2 +- src/languages/es.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index c64ae800c8ed..7b0a19ce7841 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -165,7 +165,7 @@ export default { copied: 'Copied!', copyLink: 'Copy link', copyURLToClipboard: 'Copy URL to clipboard', - copyEmailToClipboard: 'Copy e-mail to clipboard', + copyEmailToClipboard: 'Copy email to clipboard', markAsUnread: 'Mark as unread', editComment: 'Edit comment', deleteComment: 'Delete comment', diff --git a/src/languages/es.js b/src/languages/es.js index 28bd044d92f3..5afc9ce79b1c 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -165,7 +165,7 @@ export default { copied: '¡Copiado!', copyLink: 'Copiar enlace', copyURLToClipboard: 'Copiar URL al portapapeles', - copyEmailToClipboard: 'Copiar e-mail al portapapeles', + copyEmailToClipboard: 'Copiar email al portapapeles', markAsUnread: 'Marcar como no leído', editComment: 'Editar commentario', deleteComment: 'Eliminar comentario', From b6a4fd3787fde61a213428611d472b5c265e7580 Mon Sep 17 00:00:00 2001 From: mateusbra Date: Fri, 18 Mar 2022 13:20:45 -0300 Subject: [PATCH 7/8] revert displayName -> fileName in processDownload function --- .../BaseAnchorForCommentsOnly/index.js | 6 +++--- .../BaseAnchorForCommentsOnly/index.native.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js index 4117fee115ac..c673677b73f2 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js @@ -28,11 +28,11 @@ class BaseAnchorForCommentsOnly extends React.Component { * Initiate file downloading and update downloading flags * * @param {String} href - * @param {String} displayName + * @param {String} fileName */ - processDownload(href, displayName) { + processDownload(href, fileName) { this.setState({isDownloading: true}); - fileDownload(href, displayName).then(() => this.setState({isDownloading: false})); + fileDownload(href, fileName).then(() => this.setState({isDownloading: false})); } render() { diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index fbb9470ed071..19e1b28774c2 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -29,11 +29,11 @@ class BaseAnchorForCommentsOnly extends React.Component { * Initiate file downloading and update downloading flags * * @param {String} href - * @param {String} displayName + * @param {String} fileName */ - processDownload(href, displayName) { + processDownload(href, fileName) { this.setState({isDownloading: true}); - fileDownload(href, displayName).then(() => this.setState({isDownloading: false})); + fileDownload(href, fileName).then(() => this.setState({isDownloading: false})); } render() { From 60188588faa89e6cce7c68d637cce3cab0e22fa7 Mon Sep 17 00:00:00 2001 From: mateusbra Date: Fri, 18 Mar 2022 19:43:56 -0300 Subject: [PATCH 8/8] Change comment --- .../AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js b/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js index 2860ab73fee0..fd8b2148a4af 100644 --- a/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js +++ b/src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js @@ -21,7 +21,7 @@ const propTypes = { /** Any children to display */ children: PropTypes.node, - /** Display label in case of attachments. Text to display in case of anchors */ + /** Filename in case of attachments, anchor text in case of URLs or emails. */ displayName: PropTypes.string, /** Any additional styles to apply */