Skip to content

Commit

Permalink
Merge pull request #29725 from Krishna2323/krishna2323/issue/29175
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored Oct 24, 2023
2 parents 66ebf0f + 1608cca commit e9507a0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/DisplayNames/displayNamesPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const propTypes = {
const defaultProps = {
numberOfLines: 1,
tooltipEnabled: false,
titleStyles: [],
textStyles: [],
};

export {propTypes, defaultProps};
19 changes: 18 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 DisplayNames from './DisplayNames';

const propTypes = menuItemPropTypes;

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

Expand Down Expand Up @@ -137,6 +139,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) {
return (
<DisplayNames
fullTitle={props.title}
displayNamesWithTooltips={props.titleWithTooltips}
tooltipEnabled
numberOfLines={1}
/>
);
}

return convertToLTR(props.title);
};

const onPressAction = (e) => {
if (props.disabled || !props.interactive) {
return;
Expand Down Expand Up @@ -266,7 +283,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
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ const propTypes = {
/** Should render component on the right */
shouldShowRightComponent: PropTypes.bool,

/** Array of objects that map display names to their corresponding tooltip */
titleWithTooltips: PropTypes.arrayOf(PropTypes.object),

/** Should check anonymous user in onPress function */
shouldCheckActionAllowedOnPress: PropTypes.bool,
};
Expand Down
8 changes: 8 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,8 @@ function getShareDestination(reportID, reports, personalDetails) {
icons: ReportUtils.getIcons(report, personalDetails, Expensicons.FallbackAvatar),
displayName: ReportUtils.getReportName(report),
subtitle,
displayNamesWithTooltips,
shouldUseFullTitleToDisplay: ReportUtils.shouldUseFullTitleToDisplay(report),
};
}

Expand Down
4 changes: 4 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,7 @@ function NewTaskPage(props) {
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_SHARE_DESTINATION)}
interactive={!props.task.parentReportID}
shouldShowRightIcon={!props.task.parentReportID}
titleWithTooltips={!shareDestination.shouldUseFullTitleToDisplay && shareDestination.displayNamesWithTooltips}
/>
</View>
</View>
Expand Down

0 comments on commit e9507a0

Please sign in to comment.