-
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
Update Canceled task flow #24137
Update Canceled task flow #24137
Changes from all commits
b862234
fffb864
69b6784
f40a5ac
2626fa9
1c887da
b765ae3
c9df9ce
f175265
f640ac2
24fc6c8
26858ed
7998e95
1c9ee15
0665968
b7ba6e9
7ea0e80
84d289b
32d5f1f
e5c898a
52ea600
1796bc8
206669d
61bc6ae
ec7ea0f
1d0064e
52b3f9c
28aa55e
29e5e3e
ca719a0
59e8fff
9440ec2
3de64e1
4bb1b31
b35d758
e80fd05
b4604fb
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 |
---|---|---|
|
@@ -187,23 +187,37 @@ function isTaskReport(report) { | |
} | ||
|
||
/** | ||
* Checks if a report is an open task report. | ||
* Checks if a task has been cancelled | ||
* When a task is deleted, the parentReportAction is updated to have a isDeletedParentAction deleted flag | ||
* This is because when you delete a task, we still allow you to chat on the report itself | ||
* There's another situation where you don't have access to the parentReportAction (because it was created in a chat you don't have access to) | ||
* In this case, we have added the key to the report itself | ||
* | ||
* @param {Object} report | ||
* @param {Object} parentReportAction | ||
* @returns {Boolean} | ||
*/ | ||
function isOpenTaskReport(report) { | ||
return isTaskReport(report) && report.stateNum === CONST.REPORT.STATE_NUM.OPEN && report.statusNum === CONST.REPORT.STATUS.OPEN; | ||
function isCanceledTaskReport(report = {}, parentReportAction = {}) { | ||
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. I don't think this method is specific only for task reports. I just tested deleting request money that has a message and thread; the actions also have 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. Yeah you are correct, a couple different report types can have the isDeletedParentAction. Though I am planning on keeping this name as task reports are slightly different in that the report can have the isDeletedParentAction key as well |
||
if (!_.isEmpty(parentReportAction) && lodashGet(parentReportAction, ['message', 0, 'isDeletedParentAction'], false)) { | ||
return true; | ||
} | ||
|
||
if (!_.isEmpty(report) && report.isDeletedParentAction) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Checks if the current user is assigned to the task report | ||
* Checks if a report is an open task report. | ||
* | ||
* @param {Object} report | ||
* @param {Object} parentReportAction - The parent report action of the report (Used to check if the task has been canceled) | ||
* @returns {Boolean} | ||
*/ | ||
function isCanceledTaskReport(report) { | ||
return isTaskReport(report) && report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && report.statusNum === CONST.REPORT.STATUS.CLOSED; | ||
function isOpenTaskReport(report, parentReportAction = {}) { | ||
return isTaskReport(report) && !isCanceledTaskReport(report, parentReportAction) && report.stateNum === CONST.REPORT.STATE_NUM.OPEN && report.statusNum === CONST.REPORT.STATUS.OPEN; | ||
} | ||
|
||
/** | ||
|
@@ -1600,8 +1614,8 @@ function getParentReport(report) { | |
*/ | ||
function getReportName(report, policy = undefined) { | ||
let formattedName; | ||
const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
if (isChatThread(report)) { | ||
const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
if (ReportActionsUtils.isTransactionThread(parentReportAction)) { | ||
return getTransactionReportName(parentReportAction); | ||
} | ||
|
@@ -1619,6 +1633,11 @@ function getReportName(report, policy = undefined) { | |
} | ||
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage'); | ||
} | ||
|
||
if (isTaskReport(report) && isCanceledTaskReport(report, parentReportAction)) { | ||
return Localize.translateLocal('parentReportAction.deletedTask'); | ||
} | ||
|
||
if (isChatRoom(report) || isTaskReport(report)) { | ||
formattedName = report.reportName; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -755,26 +755,50 @@ function getShareDestination(reportID, reports, personalDetails) { | |
* @param {number} originalStatusNum | ||
*/ | ||
function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum) { | ||
const message = `canceled task: ${taskTitle}`; | ||
const message = `deleted task: ${taskTitle}`; | ||
const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED, message); | ||
const optimisticReportActionID = optimisticCancelReportAction.reportActionID; | ||
const taskReport = ReportUtils.getReport(taskReportID); | ||
const parentReportAction = ReportActionsUtils.getParentReportAction(taskReport); | ||
const parentReport = ReportUtils.getParentReport(taskReport); | ||
|
||
const optimisticReportActions = { | ||
[parentReportAction.reportActionID]: { | ||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
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. Pending action here could be either |
||
previousMessage: parentReportAction.message, | ||
message: [ | ||
{ | ||
translationKey: '', | ||
type: 'COMMENT', | ||
html: '', | ||
text: '', | ||
isEdited: true, | ||
isDeletedParentAction: true, | ||
}, | ||
], | ||
errors: null, | ||
linkMetaData: [], | ||
}, | ||
}; | ||
|
||
const optimisticData = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, | ||
value: { | ||
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, | ||
statusNum: CONST.REPORT.STATUS.CLOSED, | ||
lastVisibleActionCreated: optimisticCancelReportAction.created, | ||
lastMessageText: message, | ||
lastActorAccountID: optimisticCancelReportAction.actorAccountID, | ||
updateReportInLHN: true, | ||
isDeletedParentAction: true, | ||
}, | ||
}, | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${parentReport.reportID}`, | ||
value: { | ||
lastVisibleActionCreated: optimisticCancelReportAction.created, | ||
lastMessageText: message, | ||
lastActorAccountID: optimisticCancelReportAction.actorAccountID, | ||
lastMessageText: ReportActionsUtils.getLastVisibleMessage(parentReport.reportID, {[parentReportAction.reportActionID]: null}).lastMessageText, | ||
lastVisibleActionCreated: ReportActionsUtils.getLastVisibleAction(parentReport.reportID, {[parentReportAction.reportActionID]: null}).created, | ||
}, | ||
}, | ||
{ | ||
|
@@ -784,6 +808,11 @@ function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum | |
[optimisticReportActionID]: optimisticCancelReportAction, | ||
}, | ||
}, | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport.reportID}`, | ||
value: optimisticReportActions, | ||
}, | ||
]; | ||
|
||
const successData = [ | ||
|
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.
@thienlnam I don't know where you got this translation from (I checked slack and could not find it anywhere), but it is wrong. Please make sure you always get confirmation in #espanol-tranlsations
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.
Sending a PR to fix this