diff --git a/src/CONST.js b/src/CONST.js index f8fbc930c9a3..d31fb95bb043 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -106,6 +106,7 @@ const CONST = { FREE_PLAN: 'freePlan', DEFAULT_ROOMS: 'defaultRooms', BETA_EXPENSIFY_WALLET: 'expensifyWallet', + BETA_COMMENT_LINKING: 'commentLinking', INTERNATIONALIZATION: 'internationalization', IOU_SEND: 'sendMoney', POLICY_ROOMS: 'policyRooms', diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index 2f61c5ecde68..5de388f8f605 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -67,6 +67,14 @@ function canUseWallet(betas) { return _.contains(betas, CONST.BETAS.BETA_EXPENSIFY_WALLET) || canUseAllBetas(betas); } +/** + * @param {Array} betas + * @returns {Boolean} + */ +function canUseCommentLinking(betas) { + return _.contains(betas, CONST.BETAS.BETA_COMMENT_LINKING) || canUseAllBetas(betas); +} + /** * We're requiring you to be added to the policy rooms beta on dev, * since contributors have been reporting a number of false issues related to the feature being under development. @@ -94,6 +102,7 @@ export default { canUseInternationalization, canUseIOUSend, canUseWallet, + canUseCommentLinking, canUsePolicyRooms, canUsePolicyExpenseChat, }; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index ea0b478aaf63..f4db994ad0cd 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -1,5 +1,6 @@ import React from 'react'; import {View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import PropTypes from 'prop-types'; import getReportActionContextMenuStyles from '../../../../styles/getReportActionContextMenuStyles'; @@ -12,6 +13,7 @@ import withLocalize, {withLocalizePropTypes} from '../../../../components/withLo import ContextMenuActions, {CONTEXT_MENU_TYPES} from './ContextMenuActions'; import compose from '../../../../libs/compose'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions'; +import ONYXKEYS from '../../../../ONYXKEYS'; const propTypes = { /** String representing the context menu type [LINK, REPORT_ACTION] which controls context menu choices */ @@ -32,7 +34,7 @@ class BaseReportActionContextMenu extends React.Component { } render() { - const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction); + const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction, this.props.betas); return this.props.isVisible && ( @@ -65,5 +67,10 @@ BaseReportActionContextMenu.defaultProps = defaultProps; export default compose( withLocalize, + withOnyx({ + betas: { + key: ONYXKEYS.BETAS, + }, + }), withWindowDimensions, )(BaseReportActionContextMenu); diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 575e2ff1686d..635721245c4a 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -13,6 +13,7 @@ import fileDownload from '../../../../libs/fileDownload'; import addEncryptedAuthTokenToURL from '../../../../libs/addEncryptedAuthTokenToURL'; import * as ContextMenuUtils from './ContextMenuUtils'; import * as Environment from '../../../../libs/Environment/Environment'; +import Permissions from '../../../../libs/Permissions'; /** * Gets the HTML version of the message in an action. @@ -121,7 +122,7 @@ export default [ { textTranslateKey: 'reportActionContextMenu.copyLink', icon: Expensicons.LinkCopy, - shouldShow: () => true, + shouldShow: (type, reportAction, betas) => Permissions.canUseCommentLinking(betas), onPress: (closePopover, {reportAction, reportID}) => { Environment.getEnvironmentURL() .then((environmentURL) => {