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

Assignee selector #22851

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/components/ReportActionItem/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,7 +50,9 @@ 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);
const disableState = !canEdit || !isOpen;
return (
<View>
<PressableWithSecondaryInteraction
Expand All @@ -60,9 +63,9 @@ function TaskView(props) {

Navigation.navigate(ROUTES.getTaskReportTitleRoute(props.report.reportID));
})}
style={({hovered, pressed}) => [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}
disabled={disableState}
accessibilityLabel={taskTitle || props.translate('task.task')}
>
{({hovered, pressed}) => (
Expand All @@ -77,7 +80,7 @@ function TaskView(props) {
containerBorderRadius={8}
caretSize={16}
accessibilityLabel={taskTitle || props.translate('task.task')}
disabled={isCanceled}
disabled={isCanceled || !canEdit}
/>
<View style={[styles.flexRow, styles.flex1]}>
<Text
Expand All @@ -92,7 +95,7 @@ function TaskView(props) {
<Icon
additionalStyles={[styles.alignItemsCenter]}
src={Expensicons.ArrowRight}
fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed, false, !isOpen))}
fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed, false, disableState))}
/>
</View>
)}
Expand All @@ -105,7 +108,7 @@ function TaskView(props) {
title={props.report.description || ''}
onPress={() => Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))}
shouldShowRightIcon={isOpen}
disabled={!isOpen}
disabled={disableState}
wrapperStyle={[styles.pv2]}
numberOfLinesTitle={3}
shouldGreyOutWhenDisabled={false}
Expand All @@ -120,7 +123,7 @@ function TaskView(props) {
titleStyle={styles.assigneeTextStyle}
onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))}
shouldShowRightIcon={isOpen}
disabled={!isOpen}
disabled={disableState}
wrapperStyle={[styles.pv2]}
isSmallAvatarSubscriptMenu
shouldGreyOutWhenDisabled={false}
Expand All @@ -130,7 +133,7 @@ function TaskView(props) {
description={props.translate('task.assignee')}
onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))}
shouldShowRightIcon={isOpen}
disabled={!isOpen}
disabled={disableState}
wrapperStyle={[styles.pv2]}
shouldGreyOutWhenDisabled={false}
/>
Expand Down
12 changes: 12 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,17 @@ function getOriginalReportID(reportID, reportAction) {
}

/**

Nodebrute marked this conversation as resolved.
Show resolved Hide resolved
Nodebrute marked this conversation as resolved.
Show resolved Hide resolved
* 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
Nodebrute marked this conversation as resolved.
Show resolved Hide resolved
* @param {Object} report
* @returns {Object} pending action , errors
Expand Down Expand Up @@ -2634,5 +2645,6 @@ export {
shouldHideComposer,
getOriginalReportID,
canAccessReport,
getPolicy,
getReportOfflinePendingActionAndErrors,
};