Skip to content
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

Display error when cannot complete task #22097

Merged
merged 9 commits into from
Jul 11, 2023
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
},
markAsDone: 'Mark as done',
markAsIncomplete: 'Mark as incomplete',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,8 @@ export default {
messages: {
completed: 'tarea completada',
canceled: 'tarea cancelada',
reopened: 'tarea reabierta',
reopened: 'tarea reabrir',
error: 'No tiene permiso para realizar la acción solicitada.',
},
markAsDone: 'Marcar como completada',
markAsIncomplete: 'Marcar como incompleta',
Expand Down
13 changes: 11 additions & 2 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ReportActionsUtils from '../ReportActionsUtils';
import * as Expensicons from '../../components/Icon/Expensicons';

Expand Down Expand Up @@ -225,7 +226,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'),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep the pendingAction: null} maybe it will be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mollfpr We need to keep pendingAction in failureData to check in clearReportActionErrors function.

if (reportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming it; I didn't realize that 😅

},
},
];

Expand Down Expand Up @@ -281,7 +286,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'),
},
},
},
];

Expand Down