Skip to content

Commit

Permalink
move useEnvironment into a component
Browse files Browse the repository at this point in the history
  • Loading branch information
cdOut committed Jul 30, 2024
1 parent f20f537 commit f24cd05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {ContextMenuItemHandle} from '@components/ContextMenuItem';
import ContextMenuItem from '@components/ContextMenuItem';
import FocusTrapForModal from '@components/FocusTrap/FocusTrapForModal';
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
import useEnvironment from '@hooks/useEnvironment';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -126,6 +127,7 @@ function BaseReportActionContextMenu({
const [shouldKeepOpen, setShouldKeepOpen] = useState(false);
const wrapperStyle = StyleUtils.getReportActionContextMenuStyles(isMini, shouldUseNarrowLayout);
const {isOffline} = useNetwork();
const {isProduction} = useEnvironment();
const threedotRef = useRef<View>(null);

const reportAction: OnyxEntry<ReportAction> = useMemo(() => {
Expand All @@ -145,7 +147,7 @@ function BaseReportActionContextMenu({
let filteredContextMenuActions = ContextMenuActions.filter(
(contextAction) =>
!disabledActions.includes(contextAction) &&
contextAction.shouldShow(type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID, isPinnedChat, isUnreadChat, !!isOffline, isMini),
contextAction.shouldShow(type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID, isPinnedChat, isUnreadChat, !!isOffline, isMini, isProduction),
);

if (isMini) {
Expand Down
9 changes: 2 additions & 7 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {Emoji} from '@assets/emojis/types';
import * as Expensicons from '@components/Icon/Expensicons';
import MiniQuickEmojiReactions from '@components/Reactions/MiniQuickEmojiReactions';
import QuickEmojiReactions from '@components/Reactions/QuickEmojiReactions';
import useEnvironment from '@hooks/useEnvironment';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import * as Browser from '@libs/Browser';
import Clipboard from '@libs/Clipboard';
Expand Down Expand Up @@ -67,6 +66,7 @@ type ShouldShow = (
isUnreadChat: boolean,
isOffline: boolean,
isMini: boolean,
isProduction: boolean,
) => boolean;

type ContextMenuActionPayload = {
Expand Down Expand Up @@ -543,12 +543,7 @@ const ContextMenuActions: ContextMenuAction[] = [
icon: Expensicons.Copy,
successTextTranslateKey: 'reportActionContextMenu.copied',
successIcon: Expensicons.Checkmark,
shouldShow: (type) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const {isProduction} = useEnvironment();

return type === CONST.CONTEXT_MENU_TYPES.REPORT && !isProduction;
},
shouldShow: (type, isProduction) => type === CONST.CONTEXT_MENU_TYPES.REPORT && !isProduction,
onPress: (closePopover, {reportID}) => {
const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
Clipboard.setString(JSON.stringify(report, null, 4));
Expand Down

0 comments on commit f24cd05

Please sign in to comment.