-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix empty assignee in TaskHeader and update permission to mark Task complete/incomplete/cancel in Task report #20689
Conversation
@@ -106,7 +116,7 @@ const HeaderView = (props) => { | |||
} | |||
|
|||
// Task is not closed | |||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED) { | |||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED && isTaskAssigneeOrTaskOwner) { |
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'm not sure this one. Should we allow assignee to cancel the task?
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 so. If this is a flow we do not want in the future we can create another issue for it. But I believe an assignee should be able to cancel a task.
@joelbettner @mollfpr One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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.
Just a question posted for you so I can make sure I am clear on what is happening...
src/components/TaskHeader.js
Outdated
const isOpen = props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN; | ||
const isCompleted = props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED; | ||
|
||
useEffect(() => { | ||
TaskUtils.setTaskReport(props.report); | ||
Task.setTaskReport(props.report); |
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.
Not that it is wrong, but can you please explain to me why we are switching from using the TaskUtils
method and using the Task
method instead?
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 observe from what we did for other features, basically we will have 2 libs:
- an action lib (for example libs/actions/Report.js, libs/actions/ReportActions.js) => we usually put all the function that need to update to Onyx or make API call
- a utils lib (for example libs/ReportUtils.js, libs/ReportActionsUtils.js) => a shared utils like get/set/check
In this PR, I'm going to introduce new module called TaskUtils (and put some new get/set function into there). So I replaced old TaskUtils
name (It's actually actions/Task) to Task
to avoid confusing in this TaskHeader component.
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.
btw, I just wanna correct the imported name here
It's importing Task
action but named it as TaskUtils
. By introducing TaskUtils
, I would like to correct it.
If we think it's not correct. I can revert the change (combine new utils TaskUtils
into exiting Task
action lib)
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.
@hoangzinh I think we can use actions/Task.js
for the new method you introduce; not necessary to create a new utils file for the task. We already have a couple of utils methods in actions/Task.js
and we don't want to confuse anyone what the different methods in actions/Task.js
and libs/TaskUtils.js
.
I believe a method unrelated to API action should be in the utils file, but the damage is already done.
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.
@mollfpr okay. Let me move into the actions/Task
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 moved all my new methods to actions/Task
. Please help me to review this PR again. Thanks ❤️
@@ -106,7 +116,7 @@ const HeaderView = (props) => { | |||
} | |||
|
|||
// Task is not closed | |||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED) { | |||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED && isTaskAssigneeOrTaskOwner) { |
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 so. If this is a flow we do not want in the future we can create another issue for it. But I believe an assignee should be able to cancel a task.
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 LGTM 👍
@mollfpr all yours.
Reviewer Checklist
Screenshots/VideosWeb20689.Web.movMobile Web - Chrome20689.mWeb.Chrome.movMobile Web - Safari20689.mWeb.Safari.movDesktop20689.Desktop.moviOS20689.iOS.movAndroid20689.Android.mov |
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.
LGTM 👍
@hoangzinh there are some conflicts. |
src/libs/actions/Task.js
Outdated
} | ||
|
||
const reportAction = ReportActionsUtils.getParentReportAction(taskReport); | ||
return lodashGet(reportAction, 'childManagerEmail', null); |
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.
@mollfpr @joelbettner I just merged latest main to this PR and I realize that we're going to change from "email" -> "accountID" a lot of place.
For "childManagerEmail", do you know when will the BE return "childManagerAccountID"? for reportAction of taskReport? (as we optimistic build from FE side)?
Lines 1239 to 1240 in 7b00c47
reportAction.reportAction.childManagerEmail = taskAssignee; | |
reportAction.reportAction.childManagerAccountID = taskAssigneeAccountID; |
Currently, I have a blocker that most of utils (get avatar/display name) is changed to accountID
Line 861 in 7b00c47
function getDisplayNameForParticipant(accountID, shouldUseShortForm = false) { |
So if we only have email, we can not get the display name/avatar.
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.
nvm, I found a way to get accountID for given login.
@mollfpr @joelbettner I merged latest |
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.
LGTM 👍
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/joelbettner in version: 1.3.30-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.30-5 🚀
|
src/components/TaskHeader.js
Outdated
@@ -74,7 +73,7 @@ function TaskHeader(props) { | |||
> | |||
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, styles.pv3]}> | |||
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}> | |||
{!_.isEmpty(assigneeEmail) && ( | |||
{assigneeEmail && assigneeEmail > 0 && ( |
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.
While merging main, this could have been avoided. String && View is anti-pattern and already in checklist.
verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />
.
@@ -59,7 +73,7 @@ function TaskHeader(props) { | |||
> | |||
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, styles.pv3]}> | |||
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}> | |||
{props.report.managerID && props.report.managerID > 0 && ( | |||
{assigneeAccountID && assigneeAccountID > 0 && ( |
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.
Coming from #22398:
I understand this logic already existed but we should avoid this pattern and it's already in checklist.
This could have been fixed earlier while merging main.
I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />
.
Details
Fixed Issues
$ #19631
PROPOSAL: #19631 (comment)
Tests
Offline tests
Could not test when offline because B&C won't receive new task
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-06-13.at.23.13.27.-.web.mp4
Mobile Web - Chrome
Screen.Recording.2023-06-13.at.23.38.26.-.android.chrome.mp4
Mobile Web - Safari
Screen.Recording.2023-06-14.at.00.08.26.-.ios.safari.mov
Desktop
Screen.Recording.2023-06-13.at.23.25.41.-.desktop.mp4
iOS
Screen.Recording.2023-06-14.at.00.06.17.-.ios.mp4
Android
Screen.Recording.2023-06-13.at.23.49.50.-.android.mp4