From 268d8dc7b38de324fa7ea78113788d9c5dcc78ce Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 14 Jul 2023 01:15:46 +0500 Subject: [PATCH 1/4] fixed assignee --- src/components/ReportActionItem/TaskView.js | 14 ++++++++------ src/libs/ReportUtils.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js index fc890dd37a69..64b892cbcc4b 100644 --- a/src/components/ReportActionItem/TaskView.js +++ b/src/components/ReportActionItem/TaskView.js @@ -17,6 +17,7 @@ import * as PersonalDetailsUtils from '../../libs/PersonalDetailsUtils'; import * as UserUtils from '../../libs/UserUtils'; import * as StyleUtils from '../../styles/StyleUtils'; import * as Task from '../../libs/actions/Task'; +import * as PolicyUtils from '../../libs/PolicyUtils'; import CONST from '../../CONST'; import Checkbox from '../Checkbox'; import convertToLTR from '../../libs/convertToLTR'; @@ -49,7 +50,8 @@ function TaskView(props) { const isOpen = ReportUtils.isOpenTaskReport(props.report); const isCanceled = ReportUtils.isCanceledTaskReport(props.report); const avatarURL = lodashGet(PersonalDetailsUtils.getPersonalDetailsByIDs([props.report.managerID], props.currentUserPersonalDetails.accountID), [0, 'avatar'], ''); - + const policy = ReportUtils.getPolicy(props.report.policyID); + const canEdit = PolicyUtils.isPolicyAdmin(policy) || Task.isTaskAssigneeOrTaskOwner(props.report, props.currentUserPersonalDetails.accountID); return ( [styles.ph5, styles.pv2, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, !isOpen), true)]} ref={props.forwardedRef} - disabled={!isOpen} + disabled={!isOpen || !canEdit} accessibilityLabel={taskTitle || props.translate('task.task')} > {({hovered, pressed}) => ( @@ -77,7 +79,7 @@ function TaskView(props) { containerBorderRadius={8} caretSize={16} accessibilityLabel={taskTitle || props.translate('task.task')} - disabled={isCanceled} + disabled={isCanceled || !canEdit} /> Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen} + disabled={!isOpen || !canEdit} wrapperStyle={[styles.pv2]} numberOfLinesTitle={3} shouldGreyOutWhenDisabled={false} @@ -120,7 +122,7 @@ function TaskView(props) { titleStyle={styles.assigneeTextStyle} onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen} + disabled={!isOpen || !canEdit} wrapperStyle={[styles.pv2]} isSmallAvatarSubscriptMenu shouldGreyOutWhenDisabled={false} @@ -130,7 +132,7 @@ function TaskView(props) { description={props.translate('task.assignee')} onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen} + disabled={!isOpen || !canEdit} wrapperStyle={[styles.pv2]} shouldGreyOutWhenDisabled={false} /> diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 70203539e92e..938039d1ac75 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2488,6 +2488,17 @@ function getOriginalReportID(reportID, reportAction) { return isThreadFirstChat(reportAction, reportID) ? lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, 'parentReportID']) : reportID; } +/** + * Returns policy + * + * @param {String} policyID + * @returns {Object} + */ +function getPolicy(policyID) { + const policy = lodashGet(allPolicies, `${ONYXKEYS.COLLECTION.POLICY}${policyID}`) || {}; + return policy; +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -2591,4 +2602,5 @@ export { shouldHideComposer, getOriginalReportID, canAccessReport, + getPolicy, }; From b92838a7da0a69d5436ed5cc151aadc9eccf0fdb Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 14 Jul 2023 01:59:09 +0500 Subject: [PATCH 2/4] fixed hover state styles --- src/components/ReportActionItem/TaskView.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js index 64b892cbcc4b..ec9dc0548945 100644 --- a/src/components/ReportActionItem/TaskView.js +++ b/src/components/ReportActionItem/TaskView.js @@ -52,6 +52,7 @@ function TaskView(props) { const avatarURL = lodashGet(PersonalDetailsUtils.getPersonalDetailsByIDs([props.report.managerID], props.currentUserPersonalDetails.accountID), [0, 'avatar'], ''); const policy = ReportUtils.getPolicy(props.report.policyID); const canEdit = PolicyUtils.isPolicyAdmin(policy) || Task.isTaskAssigneeOrTaskOwner(props.report, props.currentUserPersonalDetails.accountID); + const disableState = !canEdit || !isOpen; return ( [styles.ph5, styles.pv2, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, !isOpen), true)]} + style={({hovered, pressed}) => [styles.ph5, styles.pv2, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, disableState), true)]} ref={props.forwardedRef} - disabled={!isOpen || !canEdit} + disabled={disableState} accessibilityLabel={taskTitle || props.translate('task.task')} > {({hovered, pressed}) => ( @@ -94,7 +95,7 @@ function TaskView(props) { )} @@ -107,7 +108,7 @@ function TaskView(props) { title={props.report.description || ''} onPress={() => Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen || !canEdit} + disabled={disableState} wrapperStyle={[styles.pv2]} numberOfLinesTitle={3} shouldGreyOutWhenDisabled={false} @@ -122,7 +123,7 @@ function TaskView(props) { titleStyle={styles.assigneeTextStyle} onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen || !canEdit} + disabled={disableState} wrapperStyle={[styles.pv2]} isSmallAvatarSubscriptMenu shouldGreyOutWhenDisabled={false} @@ -132,7 +133,7 @@ function TaskView(props) { description={props.translate('task.assignee')} onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} shouldShowRightIcon={isOpen} - disabled={!isOpen || !canEdit} + disabled={disableState} wrapperStyle={[styles.pv2]} shouldGreyOutWhenDisabled={false} /> From 7df13cebdfa94d82e06aa65f26218a4cb59e23cb Mon Sep 17 00:00:00 2001 From: Anusha Date: Mon, 17 Jul 2023 17:47:51 +0500 Subject: [PATCH 3/4] run prettier --- src/libs/ReportUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ed4a339d6f1a..90041b484d0a 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2527,9 +2527,9 @@ function getOriginalReportID(reportID, reportAction) { function getPolicy(policyID) { const policy = lodashGet(allPolicies, `${ONYXKEYS.COLLECTION.POLICY}${policyID}`) || {}; return policy; +} - - * Return the pendingAction and the errors when we have creating a chat or a workspace room offline +/* Return the pendingAction and the errors when we have creating a chat or a workspace room offline * @param {Object} report * @returns {Object} pending action , errors */ From 0212ad8441f096529c85b9cb76e618a26e2b67ea Mon Sep 17 00:00:00 2001 From: Anusha <93134676+Nodebrute@users.noreply.github.com> Date: Mon, 17 Jul 2023 18:59:59 +0500 Subject: [PATCH 4/4] Update ReportUtils.js --- src/libs/ReportUtils.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 90041b484d0a..6d654a97c6cf 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2518,18 +2518,7 @@ function getOriginalReportID(reportID, reportAction) { } /** - - * Returns policy - * - * @param {String} policyID - * @returns {Object} - */ -function getPolicy(policyID) { - const policy = lodashGet(allPolicies, `${ONYXKEYS.COLLECTION.POLICY}${policyID}`) || {}; - return policy; -} - -/* Return the pendingAction and the errors when we have creating a chat or a workspace room offline + * Return the pendingAction and the errors when we have creating a chat or a workspace room offline * @param {Object} report * @returns {Object} pending action , errors */ @@ -2541,6 +2530,17 @@ function getReportOfflinePendingActionAndErrors(report) { return {addWorkspaceRoomOrChatPendingAction, addWorkspaceRoomOrChatErrors}; } +/** + * Returns policy + * + * @param {String} policyID + * @returns {Object} + */ +function getPolicy(policyID) { + const policy = lodashGet(allPolicies, `${ONYXKEYS.COLLECTION.POLICY}${policyID}`) || {}; + return policy; +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -2645,6 +2645,6 @@ export { shouldHideComposer, getOriginalReportID, canAccessReport, - getPolicy, getReportOfflinePendingActionAndErrors, + getPolicy, };