-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added isChronosReport prop to prevent edit and delete action for Chro… #12732
Changes from all commits
b4f69a5
34f53dd
408c179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB code style – no need for a line break here: return report.participants && _.contains(report.participants, CONST.EMAIL.CHRONOS); |
||
&& _.contains(report.participants, CONST.EMAIL.CHRONOS); | ||
} | ||
|
||
export { | ||
getReportParticipantsTitle, | ||
isReportMessageAttachment, | ||
|
@@ -1121,4 +1131,5 @@ export { | |
getChatByParticipants, | ||
getIOUReportActionMessage, | ||
getDisplayNameForParticipant, | ||
chatIncludesChronos, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,13 @@ const propTypes = { | |
|
||
/** Target node which is the target of ContentMenu */ | ||
anchor: PropTypes.node, | ||
|
||
/** Flag to check if the chat participant is Chronos */ | ||
isChronosReport: PropTypes.bool, | ||
|
||
/** Whether the provided report is an archived room */ | ||
isArchivedRoom: PropTypes.bool, | ||
|
||
...genericReportActionContextMenuPropTypes, | ||
...withLocalizePropTypes, | ||
...windowDimensionsPropTypes, | ||
|
@@ -28,6 +35,8 @@ const propTypes = { | |
const defaultProps = { | ||
type: CONTEXT_MENU_TYPES.REPORT_ACTION, | ||
anchor: null, | ||
isChronosReport: false, | ||
isArchivedRoom: false, | ||
...GenericReportActionContextMenuDefaultProps, | ||
}; | ||
class BaseReportActionContextMenu extends React.Component { | ||
|
@@ -37,7 +46,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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will you please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sobitneupane Added , Thanks |
||
); | ||
|
||
return this.props.isVisible && ( | ||
<View style={this.wrapperStyle}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,28 @@ import { | |
Dimensions, | ||
} from 'react-native'; | ||
import _ from 'underscore'; | ||
import PropTypes from 'prop-types'; | ||
import * as Report from '../../../../libs/actions/Report'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; | ||
import PopoverWithMeasuredContent from '../../../../components/PopoverWithMeasuredContent'; | ||
import BaseReportActionContextMenu from './BaseReportActionContextMenu'; | ||
import ConfirmModal from '../../../../components/ConfirmModal'; | ||
|
||
const propTypes = { | ||
/** Flag to check if the chat participant is Chronos */ | ||
isChronosReport: PropTypes.bool, | ||
|
||
/** Whether the provided report is an archived room */ | ||
isArchivedRoom: PropTypes.bool, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
isChronosReport: false, | ||
isArchivedRoom: false, | ||
}; | ||
|
||
class PopoverReportActionContextMenu extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
@@ -224,6 +236,7 @@ class PopoverReportActionContextMenu extends React.Component { | |
reportID={this.state.reportID} | ||
reportAction={this.state.reportAction} | ||
isArchivedRoom={this.props.isArchivedRoom} | ||
isChronosReport={this.props.isChronosReport} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will you please add |
||
anchor={this.contextMenuTargetNode} | ||
/> | ||
); | ||
|
@@ -297,6 +310,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> | ||
|
@@ -318,5 +332,6 @@ class PopoverReportActionContextMenu extends React.Component { | |
} | ||
|
||
PopoverReportActionContextMenu.propTypes = propTypes; | ||
PopoverReportActionContextMenu.defaultProps = defaultProps; | ||
|
||
export default withLocalize(PopoverReportActionContextMenu); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB but I think a better name would be
doesChatIncludeChronos
because that makes it a touch more clear that this returns a boolean.