Skip to content

Commit

Permalink
Merge pull request #53076 from mkzie2/mkzie2-issue/52817
Browse files Browse the repository at this point in the history
add go to workspace shortcut to report details page
  • Loading branch information
youssef-lr authored Dec 5, 2024
2 parents da7252d + ff7dbb2 commit 432fb74
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3178,6 +3178,7 @@ const CONST = {
CANCEL_PAYMENT: 'cancelPayment',
UNAPPROVE: 'unapprove',
DEBUG: 'debug',
GO_TO_WORKSPACE: 'goToWorkspace',
},
EDIT_REQUEST_FIELD: {
AMOUNT: 'amount',
Expand Down
57 changes: 37 additions & 20 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
const shouldShowNotificationPref = !isMoneyRequestReport && ReportUtils.getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const shouldShowWriteCapability = !isMoneyRequestReport;
const shouldShowMenuItem = shouldShowNotificationPref || shouldShowWriteCapability || (!!report?.visibility && report.chatType !== CONST.REPORT.CHAT_TYPE.INVOICE);
const shouldShowGoToWorkspace = policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

const isPayer = ReportUtils.isPayer(session, moneyRequestReport);
const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID ?? '-1');
Expand Down Expand Up @@ -450,23 +451,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
});
}

if (shouldShowLeaveButton) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM,
translationKey: 'common.leave',
icon: Expensicons.Exit,
isAnonymousAction: true,
action: () => {
if (ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true).length === 1 && isRootGroupChat) {
setIsLastMemberLeavingGroupModalVisible(true);
return;
}

leaveChat();
},
});
}

if (isMoneyRequestReport) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.DOWNLOAD,
Expand Down Expand Up @@ -508,6 +492,23 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
});
}

if (shouldShowGoToWorkspace) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.GO_TO_WORKSPACE,
translationKey: 'workspace.common.goToWorkspace',
icon: Expensicons.Building,
action: () => {
if (isSmallScreenWidth) {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID ?? '-1'));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_PROFILE.getRoute(report?.policyID ?? '-1'));
},
isAnonymousAction: false,
shouldShowRightIcon: true,
});
}

if (report?.reportID && isDebugModeEnabled) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.DEBUG,
Expand All @@ -524,7 +525,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
isSelfDM,
isArchivedRoom,
isGroupChat,
isRootGroupChat,
isDefaultRoom,
isChatThread,
isPolicyEmployee,
Expand All @@ -543,14 +543,12 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
shouldShowMenuItem,
isTaskReport,
isCanceledTaskReport,
shouldShowLeaveButton,
activeChatMembers.length,
shouldOpenRoomMembersPage,
shouldShowCancelPaymentButton,
session,
isOffline,
transactionIDList,
leaveChat,
canUnapproveRequest,
isDebugModeEnabled,
unapproveExpenseReportOrShowModal,
Expand All @@ -562,6 +560,8 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
parentReportAction,
moneyRequestReport?.reportID,
isDeletedParentAction,
isSmallScreenWidth,
shouldShowGoToWorkspace,
]);

const displayNamesWithTooltips = useMemo(() => {
Expand Down Expand Up @@ -918,6 +918,23 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
/>
))}

{shouldShowLeaveButton && (
<MenuItem
key={CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM}
icon={Expensicons.Exit}
title={translate('common.leave')}
isAnonymousAction
onPress={() => {
if (ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true).length === 1 && isRootGroupChat) {
setIsLastMemberLeavingGroupModalVisible(true);
return;
}

leaveChat();
}}
/>
)}

{shouldShowDeleteButton && (
<MenuItem
key={CONST.REPORT_DETAILS_MENU_ITEM.DELETE}
Expand Down

0 comments on commit 432fb74

Please sign in to comment.