Skip to content

Commit

Permalink
added isChronosReport prop to prevent edit and delete action for Chro…
Browse files Browse the repository at this point in the history
…nos chat
  • Loading branch information
jayeshmangwani committed Nov 15, 2022
1 parent 376c332 commit b4f69a5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,16 @@ function getChatByParticipants(newParticipantList) {
});
}

/**
* Returns true if Chronos is one of the chat participants (1:1)
* @param {Object} report
* @returns {Boolean}
*/
function chatIncludesChronos(report) {
return report.participants
&& _.contains(report.participants, CONST.EMAIL.CHRONOS);
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand Down Expand Up @@ -1121,4 +1131,5 @@ export {
getChatByParticipants,
getIOUReportActionMessage,
getDisplayNameForParticipant,
chatIncludesChronos,
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ class BaseReportActionContextMenu extends React.Component {
}

render() {
const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction, this.props.isArchivedRoom, this.props.betas, this.props.anchor);
const shouldShowFilter = contextAction => contextAction.shouldShow(
this.props.type,
this.props.reportAction,
this.props.isArchivedRoom,
this.props.betas,
this.props.anchor,
this.props.isChronosReport,
);

return this.props.isVisible && (
<View style={this.wrapperStyle}>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ export default [
{
textTranslateKey: 'reportActionContextMenu.editComment',
icon: Expensicons.Pencil,
shouldShow: (type, reportAction, isArchivedRoom) => (
type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom
shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) => (
type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom && !isChronosReport
),
onPress: (closePopover, {reportID, reportAction, draftMessage}) => {
const editAction = () => Report.saveReportActionDraft(
Expand All @@ -187,8 +187,8 @@ export default [
{
textTranslateKey: 'reportActionContextMenu.deleteComment',
icon: Expensicons.Trashcan,
shouldShow: (type, reportAction, isArchivedRoom) => type === CONTEXT_MENU_TYPES.REPORT_ACTION
&& ReportUtils.canDeleteReportAction(reportAction) && !isArchivedRoom,
shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) => type === CONTEXT_MENU_TYPES.REPORT_ACTION
&& ReportUtils.canDeleteReportAction(reportAction) && !isArchivedRoom && !isChronosReport,
onPress: (closePopover, {reportID, reportAction}) => {
if (closePopover) {
// Hide popover, then call showDeleteConfirmModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class PopoverReportActionContextMenu extends React.Component {
reportID={this.state.reportID}
reportAction={this.state.reportAction}
isArchivedRoom={this.props.isArchivedRoom}
isChronosReport={this.props.isChronosReport}
anchor={this.contextMenuTargetNode}
/>
);
Expand Down Expand Up @@ -297,6 +298,7 @@ class PopoverReportActionContextMenu extends React.Component {
reportAction={this.state.reportAction}
draftMessage={this.state.reportActionDraftMessage}
isArchivedRoom={this.props.isArchivedRoom}
isChronosReport={this.props.isChronosReport}
anchor={this.contextMenuTargetNode}
/>
</PopoverWithMeasuredContent>
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class ReportActionItem extends Component {
&& !this.props.draftMessage
}
draftMessage={this.props.draftMessage}
isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)}
/>
</View>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class ReportActionsView extends React.Component {
<PopoverReportActionContextMenu
ref={ReportActionContextMenu.contextMenuRef}
isArchivedRoom={ReportUtils.isArchivedRoom(this.props.report)}
isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)}
/>
</>
)}
Expand Down

0 comments on commit b4f69a5

Please sign in to comment.