Skip to content

Commit

Permalink
Merge pull request #27827 from rayane-djouah/Update-Task-Report-Syste…
Browse files Browse the repository at this point in the history
…m-Messages-and-LHN-Display-for-Consistency
  • Loading branch information
dangrous authored Sep 28, 2023
2 parents 5cf1904 + a9f75bd commit 365cdbd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function TaskPreview(props) {
disabled={ReportUtils.isCanceledTaskReport(props.taskReport)}
onPress={Session.checkIfActionIsAllowed(() => {
if (isTaskCompleted) {
Task.reopenTask(props.taskReport, taskTitle);
Task.reopenTask(props.taskReport);
} else {
Task.completeTask(props.taskReport, taskTitle);
Task.completeTask(props.taskReport);
}
})}
accessibilityLabel={props.translate('task.task')}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ function TaskView(props) {
<Checkbox
onPress={Session.checkIfActionIsAllowed(() => {
if (isCompleted) {
Task.reopenTask(props.report, taskTitle);
Task.reopenTask(props.report);
} else {
Task.completeTask(props.report, taskTitle);
Task.completeTask(props.report);
}
})}
isChecked={isCompleted}
Expand Down
6 changes: 2 additions & 4 deletions src/components/TaskHeaderActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ function TaskHeaderActionButton(props) {
success
isDisabled={ReportUtils.isCanceledTaskReport(props.report) || !Task.canModifyTask(props.report, props.session.accountID)}
medium
text={props.translate(ReportUtils.isCompletedTaskReport(props.report) ? 'task.markAsIncomplete' : 'task.markAsDone')}
onPress={() =>
ReportUtils.isCompletedTaskReport(props.report) ? Task.reopenTask(props.report, props.report.reportName) : Task.completeTask(props.report, props.report.reportName)
}
text={props.translate(ReportUtils.isCompletedTaskReport(props.report) ? 'task.markAsIncomplete' : 'task.markAsComplete')}
onPress={() => (ReportUtils.isCompletedTaskReport(props.report) ? Task.reopenTask(props.report) : Task.completeTask(props.report))}
style={[styles.flex1]}
/>
</View>
Expand Down
6 changes: 3 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1534,12 +1534,12 @@ export default {
assignee: 'Assignee',
completed: 'Completed',
messages: {
completed: 'completed task',
completed: 'marked as complete',
canceled: 'deleted task',
reopened: 'reopened task',
reopened: 'marked as incomplete',
error: 'You do not have the permission to do the requested action.',
},
markAsDone: 'Mark as done',
markAsComplete: 'Mark as complete',
markAsIncomplete: 'Mark as incomplete',
assigneeError: 'There was an error assigning this task, please try another assignee.',
},
Expand Down
6 changes: 3 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1556,12 +1556,12 @@ export default {
assignee: 'Usuario asignado',
completed: 'Completada',
messages: {
completed: 'tarea completada',
completed: 'marcada como completa',
canceled: 'tarea eliminado',
reopened: 'tarea reabrir',
reopened: 'marcada como incompleta',
error: 'No tiene permiso para realizar la acción solicitada.',
},
markAsDone: 'Marcar como completada',
markAsComplete: 'Marcar como completada',
markAsIncomplete: 'Marcar como incompleta',
assigneeError: 'Hubo un error al asignar esta tarea, inténtalo con otro usuario.',
},
Expand Down
10 changes: 5 additions & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,7 @@ function buildOptimisticCreatedReportAction(emailCreatingAction) {
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'strong',
text: emailCreatingAction === currentUserEmail ? 'You' : emailCreatingAction,
text: emailCreatingAction,
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
Expand Down Expand Up @@ -2590,7 +2590,7 @@ function buildOptimisticEditedTaskReportAction(emailEditingTask) {
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'strong',
text: emailEditingTask === currentUserEmail ? 'You' : emailEditingTask,
text: emailEditingTask,
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
Expand Down Expand Up @@ -2631,7 +2631,7 @@ function buildOptimisticClosedReportAction(emailClosingReport, policyName, reaso
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'strong',
text: emailClosingReport === currentUserEmail ? 'You' : emailClosingReport,
text: emailClosingReport,
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
Expand Down Expand Up @@ -3584,8 +3584,8 @@ function getTaskAssigneeChatOnyxData(accountID, assigneeEmail, assigneeAccountID

// If you're choosing to share the task in the same DM as the assignee then we don't need to create another reportAction indicating that you've been assigned
if (assigneeChatReportID !== parentReportID) {
optimisticAssigneeAddComment = buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeEmail, assigneeAccountID, `Assigned a task to you: ${title}`, parentReportID);

const displayname = lodashGet(allPersonalDetails, [assigneeAccountID, 'displayName']) || lodashGet(allPersonalDetails, [assigneeAccountID, 'login'], '');
optimisticAssigneeAddComment = buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeEmail, assigneeAccountID, `assigned to ${displayname}`, parentReportID);
const lastAssigneeCommentText = formatReportLastMessageText(optimisticAssigneeAddComment.reportAction.message[0].text);
const optimisticAssigneeReport = {
lastVisibleActionCreated: currentTime,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale,
const newName = lodashGet(lastAction, 'originalMessage.newName', '');
result.alternateText = Localize.translate(preferredLocale, 'newRoomPage.roomRenamedTo', {newName});
} else if (lodashGet(lastAction, 'actionName', '') === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED) {
result.alternateText = `${Localize.translate(preferredLocale, 'task.messages.reopened')}: ${report.reportName}`;
result.alternateText = `${Localize.translate(preferredLocale, 'task.messages.reopened')}`;
} else if (lodashGet(lastAction, 'actionName', '') === CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED) {
result.alternateText = `${Localize.translate(preferredLocale, 'task.messages.completed')}: ${report.reportName}`;
result.alternateText = `${Localize.translate(preferredLocale, 'task.messages.completed')}`;
} else if (lodashGet(lastAction, 'actionName', '') !== CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && lastActorDisplayName && lastMessageTextFromReport) {
result.alternateText = `${lastActorDisplayName}: ${lastMessageText}`;
} else {
Expand Down
16 changes: 7 additions & 9 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function createTaskAndNavigate(parentReportID, title, description, assigneeEmail

// Parent ReportAction indicating that a task has been created
const optimisticTaskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmail);
const optimisticAddCommentReport = ReportUtils.buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeEmail, assigneeAccountID, `Created a task: ${title}`, parentReportID);
const optimisticAddCommentReport = ReportUtils.buildOptimisticTaskCommentReportAction(taskReportID, title, assigneeEmail, assigneeAccountID, `task for ${title}`, parentReportID);
optimisticTaskReport.parentReportActionID = optimisticAddCommentReport.reportAction.reportActionID;

const currentTime = DateUtils.getDBTime();
Expand Down Expand Up @@ -219,11 +219,10 @@ function createTaskAndNavigate(parentReportID, title, description, assigneeEmail
/**
* Complete a task
* @param {Object} taskReport task report
* @param {String} taskTitle Title of the task
*/
function completeTask(taskReport, taskTitle) {
function completeTask(taskReport) {
const taskReportID = taskReport.reportID;
const message = `completed task: ${taskTitle}`;
const message = `marked as complete`;
const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED, message);

const optimisticData = [
Expand Down Expand Up @@ -303,11 +302,10 @@ function completeTask(taskReport, taskTitle) {
/**
* Reopen a closed task
* @param {Object} taskReport task report
* @param {String} taskTitle Title of the task
*/
function reopenTask(taskReport, taskTitle) {
function reopenTask(taskReport) {
const taskReportID = taskReport.reportID;
const message = `reopened task: ${taskTitle}`;
const message = `marked as incomplete`;
const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKREOPENED, message);

const optimisticData = [
Expand Down Expand Up @@ -924,7 +922,7 @@ function clearEditTaskErrors(reportID) {
function getTaskReportActionMessage(actionName, reportID, isCreateTaskAction) {
const report = ReportUtils.getReport(reportID);
if (isCreateTaskAction) {
return `Created a task: ${report.reportName}`;
return `task for ${report.reportName}`;
}
let taskStatusText = '';
switch (actionName) {
Expand All @@ -941,7 +939,7 @@ function getTaskReportActionMessage(actionName, reportID, isCreateTaskAction) {
taskStatusText = Localize.translateLocal('task.task');
}

return `${taskStatusText} ${report.reportName}`;
return `${taskStatusText}`;
}

export {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ function HeaderView(props) {
if (ReportUtils.isOpenTaskReport(props.report) && canModifyTask) {
threeDotMenuItems.push({
icon: Expensicons.Checkmark,
text: props.translate('task.markAsDone'),
onSelected: () => Task.completeTask(props.report, title),
text: props.translate('task.markAsComplete'),
onSelected: () => Task.completeTask(props.report),
});
}

Expand All @@ -103,7 +103,7 @@ function HeaderView(props) {
threeDotMenuItems.push({
icon: Expensicons.Checkmark,
text: props.translate('task.markAsIncomplete'),
onSelected: () => Task.reopenTask(props.report, title),
onSelected: () => Task.reopenTask(props.report),
});
}

Expand Down

0 comments on commit 365cdbd

Please sign in to comment.