Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const defaultProps = {
shouldRenderAsHTML: false,
rightComponent: undefined,
shouldShowRightComponent: false,
shouldCheckActionAllowedOnPress: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propType def is missing in menuItemPropTypes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated.

};

const MenuItem = React.forwardRef((props, ref) => {
Expand Down Expand Up @@ -135,21 +136,23 @@ const MenuItem = React.forwardRef((props, ref) => {

const hasPressableRightComponent = props.iconRight || (props.rightComponent && props.shouldShowRightComponent);

const onPressAction = (e) => {
if (props.disabled || !props.interactive) {
return;
}

if (e && e.type === 'click') {
e.currentTarget.blur();
}

props.onPress(e);
};

return (
<Hoverable>
{(isHovered) => (
<PressableWithSecondaryInteraction
onPress={Session.checkIfActionIsAllowed((e) => {
if (props.disabled || !props.interactive) {
return;
}

if (e && e.type === 'click') {
e.currentTarget.blur();
}

props.onPress(e);
}, props.isAnonymousAction)}
onPress={props.shouldCheckActionAllowedOnPress ? Session.checkIfActionIsAllowed(onPressAction, props.isAnonymousAction) : onPressAction}
onPressIn={() => props.shouldBlockSelection && isSmallScreenWidth && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={ControlSelection.unblock}
onSecondaryInteraction={props.onSecondaryInteraction}
Expand Down
1 change: 1 addition & 0 deletions src/components/PopoverMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function PopoverMenu(props) {
iconHeight={item.iconHeight}
iconFill={item.iconFill}
title={item.text}
shouldCheckActionAllowedOnPress={false}
description={item.description}
onPress={() => selectItem(menuIndex)}
focused={focusedIndex === menuIndex}
Expand Down
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ const propTypes = {

/** Should render component on the right */
shouldShowRightComponent: PropTypes.bool,

/** Should check anonymous user in onPress function */
shouldCheckActionAllowedOnPress: PropTypes.bool,
};

export default propTypes;
23 changes: 13 additions & 10 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as Link from '../../libs/actions/Link';
import * as Report from '../../libs/actions/Report';
import * as Task from '../../libs/actions/Task';
import compose from '../../libs/compose';
import * as Session from '../../libs/actions/Session';
import styles from '../../styles/styles';
import themeColors from '../../styles/themes/default';
import reportPropTypes from '../reportPropTypes';
Expand Down Expand Up @@ -102,7 +103,7 @@ function HeaderView(props) {
icon: Expensicons.Checkmark,
iconFill: themeColors.icon,
text: props.translate('task.markAsIncomplete'),
onSelected: () => Task.reopenTask(props.report),
onSelected: Session.checkIfActionIsAllowed(() => Task.reopenTask(props.report)),
});
}

Expand All @@ -112,7 +113,7 @@ function HeaderView(props) {
icon: Expensicons.Trashcan,
iconFill: themeColors.icon,
text: props.translate('common.cancel'),
onSelected: () => Task.cancelTask(props.report.reportID, props.report.reportName, props.report.stateNum, props.report.statusNum),
onSelected: Session.checkIfActionIsAllowed(() => Task.cancelTask(props.report.reportID, props.report.reportName, props.report.stateNum, props.report.statusNum)),
});
}
}
Expand All @@ -123,14 +124,16 @@ function HeaderView(props) {
icon: Expensicons.ChatBubbles,
iconFill: themeColors.icon,
text: props.translate('common.joinThread'),
onSelected: () => Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false),
onSelected: Session.checkIfActionIsAllowed(() =>
Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false),
),
});
} else if (props.report.notificationPreference.length) {
threeDotMenuItems.push({
icon: Expensicons.ChatBubbles,
iconFill: themeColors.icon,
text: props.translate('common.leaveThread'),
onSelected: () => Report.leaveRoom(props.report.reportID),
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID)),
});
}
}
Expand All @@ -142,26 +145,26 @@ function HeaderView(props) {
icon: Expensicons.Phone,
iconFill: themeColors.icon,
text: props.translate('videoChatButtonAndMenu.tooltip'),
onSelected: () => {
onSelected: Session.checkIfActionIsAllowed(() => {
Link.openExternalLink(props.guideCalendarLink);
},
}),
});
} else if (!isAutomatedExpensifyAccount && !isTaskReport && !isArchivedRoom) {
threeDotMenuItems.push({
icon: ZoomIcon,
iconFill: themeColors.icon,
text: props.translate('videoChatButtonAndMenu.zoom'),
onSelected: () => {
onSelected: Session.checkIfActionIsAllowed(() => {
Link.openExternalLink(CONST.NEW_ZOOM_MEETING_URL);
},
}),
});
threeDotMenuItems.push({
icon: GoogleMeetIcon,
iconFill: themeColors.icon,
text: props.translate('videoChatButtonAndMenu.googleMeet'),
onSelected: () => {
onSelected: Session.checkIfActionIsAllowed(() => {
Link.openExternalLink(CONST.NEW_GOOGLE_MEET_MEETING_URL);
},
}),
});
}

Expand Down