-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Delete Comments #2046
Delete Comments #2046
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
# Conflicts: # src/libs/API.js # src/pages/home/report/ReportActionContextMenu.js # src/pages/home/report/ReportActionContextMenuItem.js # src/pages/home/report/ReportActionsView.js
but I'm going to try use ``` javascript import Onyx, {withOnyx} from 'react-native-onyx'; ``` instead
# Conflicts: # src/pages/home/report/ReportActionContextMenu.js # src/pages/home/report/ReportActionItem.js
@@ -112,9 +120,10 @@ class ReportActionContextMenu extends React.Component { | |||
{ | |||
text: this.props.translate('reportActionContextMenu.editComment'), | |||
icon: Pencil, | |||
shouldShow: this.props.reportAction.actorEmail === this.props.session.email | |||
shouldShow: () => ( | |||
this.canEdit |
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.
this.canEdit | |
this.canEdit() |
# Conflicts: # src/languages/en.js
/** | ||
* A list of all the context actions in this menu. | ||
*/ | ||
this.contextActions = [ |
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.
sooooo, heh, sorry to keep commenting here, but are these going to be moved outside the class?
} | ||
|
||
/** | ||
Confirms the deletion of the comment and hides the confirmation modal. |
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.
Don't need this method doc (or the one below) at all (like PHP, they are only needed if the method is non-obvious)
@@ -248,7 +248,13 @@ class ReportActionsView extends React.Component { | |||
updateSortedReportActions(reportActions) { | |||
this.sortedReportActions = _.chain(reportActions) | |||
.sortBy('sequenceNumber') | |||
.filter(action => action.actionName === 'ADDCOMMENT' || action.actionName === 'IOU') | |||
.filter((action) => { | |||
// Only show non-empty ADDCOMMENT actions or IOU actions |
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.
This comment does a good job of explaining "what" the code is doing, but not "why" it's doing it. The comment could be improved to explain why it's not showing any other actions.
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.
OK, thanks for moving that. After seeing it, I agree with you that it can be reverted. I didn't realize we would have to pass more than props
and seeing all this stuff being passed around is worse than just keeping it in the constructor. There are probably some ways around all this, but let's just revert this last change and get this out.
This reverts commit f10de2e.
I just tested this quickly and found an interesting bug.
|
* @return {Boolean} | ||
*/ | ||
canEdit() { | ||
return this.props.reportAction.actorEmail === this.props.session.email |
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.
@sketchydroide we also shouldn't be able to edit/delete IOU actions, or any other type of report action (not yet, anyways). So let's add a check for that here:
canEditReportAction() {
return this.props.reportAction.actionName === 'ADDCOMMENT' // Bonus: make a constant for report action names
&& this.props.reportAction.actorEmail === this.props.session.email
&& this.props.reportAction.reportActionID;
}
While I completly agree this is a bug, I would suggest creating a GH for it, this PR is already a bit complex, and fixing that bug would add further complexity. Not sure if that makes sense. |
OK, I'm fine with opening a separate GH to handle that. |
Ok @tgolen created a GH https://github.com/Expensify/Expensify/issues/165320 |
src/libs/actions/Report.js
Outdated
...reportAction, | ||
message: [ | ||
{ | ||
type: 'COMMENT', |
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.
Looks like this should be moved to a constant to be consistent with the other actions having constants too?
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.
I think that is just the type of the message not the action, but I'm happy with adding those to constants as well
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.
Okay, I think this is looking good 👍
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.
Looks good! In some future improvement, we probably could allow editing the optimistic comment. In that case, it would just fire off a second edit comment request to the API and things would probably work fine.
and that would allow you to edit comments while offline, which would be kinda cool... |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
<If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit.>
Details
Fixed Issues
Fixes https://github.com/Expensify/Expensify/issues/147483
Fixes #2966
Tests / QA Steps (web/desktop)
Edit Comment
orDelete Comment
actions as options in theReportActionContextMenu
Edit Comment
orDelete Comment
actions as options in theReportActionContextMenu
Edit Comment
Save Changes
.Edit Comment
Save Changes
.Delete Comment
Delete Comment
Delete Comment
Edit Comment
Save Changes
.Tests / QA Steps (iOS/Android/mWeb)
Edit Comment
orDelete Comment
actions as options in theReportActionContextMenu
Edit Comment
.Save Changes
Delete Comment
Delete Comment
Edit Comment
Save Changes
Tested On