From 855ae52eed1c6f3ce1d62923249041f47821dd35 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 3 Jul 2023 09:28:23 +0700 Subject: [PATCH 1/5] Display error when cannot complete task --- src/languages/en.js | 1 + src/languages/es.js | 1 + src/libs/actions/Task.js | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 14613d52261a..a93c5eeae443 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -1294,6 +1294,7 @@ export default { completed: 'completed task', canceled: 'canceled task', reopened: 'reopened task', + error: 'You do not have the permission to do the requested action.', }, }, statementPage: { diff --git a/src/languages/es.js b/src/languages/es.js index 6deb56b0b15f..389af7b33581 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -1303,6 +1303,7 @@ export default { completed: 'tarea completada', canceled: 'tarea cancelada', reopened: 'tarea reabrir', + error: 'No tiene permiso para realizar la acción solicitada.', }, }, statementPage: { diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 59a84182b803..ec12e57e8597 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -10,6 +10,7 @@ import ROUTES from '../../ROUTES'; import CONST from '../../CONST'; import DateUtils from '../DateUtils'; import * as UserUtils from '../UserUtils'; +import * as ErrorUtils from '../ErrorUtils'; import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; @@ -218,7 +219,11 @@ function completeTask(taskReportID, taskTitle) { { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, - value: {[completedTaskReportAction.reportActionID]: {pendingAction: null}}, + value: { + [completedTaskReportAction.reportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'), + }, + }, }, ]; @@ -275,7 +280,11 @@ function reopenTask(taskReportID, taskTitle) { { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, - value: {[reopenedTaskReportAction.reportActionID]: {pendingAction: null}}, + value: { + [reopenedTaskReportAction.reportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'), + }, + }, }, ]; @@ -611,7 +620,9 @@ function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, value: { - [optimisticReportActionID]: null, + [optimisticReportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'), + }, }, }, ]; From 60747de04f1d8a000cbecd3f95965053318763ba Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 3 Jul 2023 09:38:07 +0700 Subject: [PATCH 2/5] remove error in cancel task --- src/libs/actions/Task.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index ec12e57e8597..12a4a641954f 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -620,9 +620,7 @@ function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, value: { - [optimisticReportActionID]: { - errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'), - }, + [optimisticReportActionID]: null, }, }, ]; From 7afa4bdfa57a322779febb0935d0c8be1eecac5c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 7 Jul 2023 11:43:39 +0700 Subject: [PATCH 3/5] merge main --- src/libs/actions/Task.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index bd0a0f00d024..2e3af58ed76d 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -11,7 +11,6 @@ import CONST from '../../CONST'; import DateUtils from '../DateUtils'; import * as UserUtils from '../UserUtils'; import * as ErrorUtils from '../ErrorUtils'; -import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; let currentUserEmail; From 152362ef66751b61c0142ed4b5f1d01f089dde50 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 11 Jul 2023 11:42:13 +0700 Subject: [PATCH 4/5] fix: flagged as a violation message from the concierge should not be deleted --- src/libs/ReportUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index f7671cdef177..b5c71f307e72 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -245,7 +245,8 @@ function canDeleteReportAction(reportAction, reportID) { reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || reportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || ReportActionsUtils.isCreatedTaskReportAction(reportAction) || - (ReportActionsUtils.isMoneyRequestAction(reportAction) && isSettled(reportAction.originalMessage.IOUReportID)) + (ReportActionsUtils.isMoneyRequestAction(reportAction) && isSettled(reportAction.originalMessage.IOUReportID)) || + reportAction.actorEmail === CONST.EMAIL.CONCIERGE ) { return false; } From a1811814798d2cbc75833f74ff80726cd0280186 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 11 Jul 2023 14:28:18 +0700 Subject: [PATCH 5/5] resolve conflict --- src/libs/ReportUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 65ca93abd3f6..00b8753a405f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -245,8 +245,7 @@ function canDeleteReportAction(reportAction, reportID) { reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || reportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || ReportActionsUtils.isCreatedTaskReportAction(reportAction) || - (ReportActionsUtils.isMoneyRequestAction(reportAction) && isSettled(reportAction.originalMessage.IOUReportID)) || - reportAction.actorEmail === CONST.EMAIL.CONCIERGE + (ReportActionsUtils.isMoneyRequestAction(reportAction) && isSettled(reportAction.originalMessage.IOUReportID)) ) { return false; }