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

fix: Chat - No details tooltip for assignee name on task title. #29725

Merged
merged 18 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
20 changes: 19 additions & 1 deletion src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as Session from '../libs/actions/Session';
import Hoverable from './Hoverable';
import useWindowDimensions from '../hooks/useWindowDimensions';
import RenderHTML from './RenderHTML';
import UserDetailsTooltip from './UserDetailsTooltip';

const propTypes = menuItemPropTypes;

Expand Down Expand Up @@ -79,6 +80,8 @@ const defaultProps = {
shouldRenderAsHTML: false,
rightComponent: undefined,
shouldShowRightComponent: false,
shouldUseFullTitle: false,
titleWithTooltips: [],
shouldCheckActionAllowedOnPress: true,
};

Expand Down Expand Up @@ -137,6 +140,21 @@ const MenuItem = React.forwardRef((props, ref) => {

const hasPressableRightComponent = props.iconRight || (props.rightComponent && props.shouldShowRightComponent);

const renderTitleContent = () => {
if (props.titleWithTooltips && _.isArray(props.titleWithTooltips) && props.titleWithTooltips.length > 0 && !props.shouldUseFullTitle) {
return _.map(props.titleWithTooltips, (accountIdOrUserObject, index) => (
Krishna2323 marked this conversation as resolved.
Show resolved Hide resolved
<Text key={index}>
<UserDetailsTooltip accountID={accountIdOrUserObject.accountID}>
<Text>{convertToLTR(accountIdOrUserObject.displayName)}</Text>
</UserDetailsTooltip>
{index < props.titleWithTooltips.length - 1 && <Text style>,&nbsp;</Text>}
</Text>
));
}

return convertToLTR(props.title);
};

Krishna2323 marked this conversation as resolved.
Show resolved Hide resolved
const onPressAction = (e) => {
if (props.disabled || !props.interactive) {
return;
Expand Down Expand Up @@ -266,7 +284,7 @@ const MenuItem = React.forwardRef((props, ref) => {
numberOfLines={props.numberOfLinesTitle || undefined}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: props.interactive && props.disabled}}
>
{convertToLTR(props.title)}
{renderTitleContent()}
</Text>
)}
{Boolean(props.shouldShowTitleIcon) && (
Expand Down
3 changes: 3 additions & 0 deletions src/components/ReportActionItem/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ function TaskView(props) {
}, [props.report]);

const taskTitle = convertToLTR(props.report.reportName || '');
const assigneeTooltipDetails = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.managerID], props.personalDetails), false);
const isCompleted = ReportUtils.isCompletedTaskReport(props.report);
const isOpen = ReportUtils.isOpenTaskReport(props.report);
const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID);
const disableState = !canModifyTask;
const isDisableInteractive = !canModifyTask || !isOpen;

return (
<View>
<OfflineWithFeedback
Expand Down Expand Up @@ -156,6 +158,7 @@ function TaskView(props) {
isSmallAvatarSubscriptMenu
shouldGreyOutWhenDisabled={false}
interactive={!isDisableInteractive}
titleWithTooltips={assigneeTooltipDetails}
/>
</OfflineWithFeedback>
) : (
Expand Down
6 changes: 6 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ const propTypes = {
/** Should render component on the right */
shouldShowRightComponent: PropTypes.bool,

/** Should render title without tooltip or not, we don't show tooltip on some items like, workspace and few more */
Krishna2323 marked this conversation as resolved.
Show resolved Hide resolved
shouldUseFullTitle: PropTypes.bool,

/** Render title with tooltips for menu items like, asignee & share somewhere menu */
Krishna2323 marked this conversation as resolved.
Show resolved Hide resolved
titleWithTooltips: PropTypes.arrayOf(PropTypes.object),

/** Should check anonymous user in onPress function */
shouldCheckActionAllowedOnPress: PropTypes.bool,
};
Expand Down
13 changes: 13 additions & 0 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Navigation from '../Navigation/Navigation';
import ROUTES from '../../ROUTES';
import CONST from '../../CONST';
import DateUtils from '../DateUtils';
import * as OptionsListUtils from '../OptionsListUtils';
import * as UserUtils from '../UserUtils';
import * as ErrorUtils from '../ErrorUtils';
import * as ReportActionsUtils from '../ReportActionsUtils';
Expand Down Expand Up @@ -708,6 +709,11 @@ function getAssignee(assigneeAccountID, personalDetails) {
* */
function getShareDestination(reportID, reports, personalDetails) {
const report = lodashGet(reports, `report_${reportID}`, {});

const participantAccountIDs = lodashGet(report, 'participantAccountIDs');
const isMultipleParticipant = participantAccountIDs.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);

let subtitle = '';
if (ReportUtils.isChatReport(report) && ReportUtils.isDM(report) && ReportUtils.hasSingleParticipant(report)) {
const participantAccountID = lodashGet(report, 'participantAccountIDs[0]');
Expand All @@ -721,6 +727,13 @@ function getShareDestination(reportID, reports, personalDetails) {
icons: ReportUtils.getIcons(report, personalDetails, Expensicons.FallbackAvatar),
displayName: ReportUtils.getReportName(report),
subtitle,
displayNamesWithTooltips,
shouldShowDestinationTooltip:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain what this is based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to retrieve both the display name and tooltip details for all participants. Our previous code was functioning well when dealing with only assignee. However, tasks can be shared within groups, and given that a single group can comprise multiple users, it's essential to obtain the details for all users within these groups. From our report, we've procured the participant IDs. We then utilize these IDs to fetch the displayNamesWithTooltips.

ReportUtils.isChatThread(report) ||
ReportUtils.isPolicyExpenseChat(report) ||
ReportUtils.isMoneyRequestReport(report) ||
ReportUtils.isThread(report) ||
ReportUtils.isTaskReport(report),
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/pages/tasks/NewTaskPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ROUTES from '../../ROUTES';
import MenuItemWithTopDescription from '../../components/MenuItemWithTopDescription';
import MenuItem from '../../components/MenuItem';
import reportPropTypes from '../reportPropTypes';
import * as OptionsListUtils from '../../libs/OptionsListUtils';
import * as Task from '../../libs/actions/Task';
import * as ReportUtils from '../../libs/ReportUtils';
import FormAlertWithSubmitButton from '../../components/FormAlertWithSubmitButton';
Expand Down Expand Up @@ -64,6 +65,7 @@ const defaultProps = {

function NewTaskPage(props) {
const [assignee, setAssignee] = useState({});
const assigneeTooltipDetails = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs([props.task.assigneeAccountID], props.personalDetails), false);
const [shareDestination, setShareDestination] = useState({});
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
Expand Down Expand Up @@ -185,6 +187,7 @@ function NewTaskPage(props) {
icon={assignee.icons}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_ASSIGNEE)}
shouldShowRightIcon
titleWithTooltips={assigneeTooltipDetails}
/>
<MenuItem
label={shareDestination.displayName ? props.translate('newTaskPage.shareSomewhere') : ''}
Expand All @@ -194,6 +197,8 @@ function NewTaskPage(props) {
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_SHARE_DESTINATION)}
interactive={!props.task.parentReportID}
shouldShowRightIcon={!props.task.parentReportID}
shouldUseFullTitle={shareDestination.shouldShowDestinationTooltip}
Krishna2323 marked this conversation as resolved.
Show resolved Hide resolved
titleWithTooltips={shareDestination.displayNamesWithTooltips}
/>
</View>
</View>
Expand Down
Loading