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

Fixes for redesign thread ancestry feature #39343

Merged
merged 23 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
454c178
Fix: Gray Replies does not disappear together with reply when reply i…
rayane-djouah Mar 31, 2024
ccbd4f6
Thread - Invited thread member can click on Thread when they are not …
rayane-djouah Apr 1, 2024
2fc36ea
Fix: Thread-Cursor is hand cursor instead of text cursor when hoverin…
rayane-djouah Apr 1, 2024
80078c3
prettier
rayane-djouah Apr 1, 2024
92fd58a
fix lint error
rayane-djouah Apr 1, 2024
f38039d
added explanation comment
rayane-djouah Apr 2, 2024
928b10f
make the thread link look gray when it's disabled
rayane-djouah Apr 2, 2024
2c4a34a
prevent Thread and Replies words from being copied
rayane-djouah Apr 2, 2024
4860d79
prevent Thread and Replies words from being selected and copied
rayane-djouah Apr 2, 2024
eecb694
make isDisabled prop optional
rayane-djouah Apr 2, 2024
85c4923
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 2, 2024
63bdd3d
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 4, 2024
bc4b365
Remove not allowed cursor on hover for the top-most message when the …
rayane-djouah Apr 4, 2024
ec3761e
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 4, 2024
623345d
Remove not allowed cursor on hover for the 'Thread' link for when it …
rayane-djouah Apr 4, 2024
0f7ecdb
remove comment
rayane-djouah Apr 8, 2024
c660f42
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 8, 2024
3f72d26
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 9, 2024
bf2beab
Merge branch 'Expensify:main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 9, 2024
2a38baa
Fix lint error
rayane-djouah Apr 9, 2024
92def9a
Merge branch 'main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 30, 2024
ad21911
Merge branch 'main' into Feat-Redesign-thread-ancestry
rayane-djouah Apr 30, 2024
278ad0c
Merge branch 'main' into Feat-Redesign-thread-ancestry
rayane-djouah May 2, 2024
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
5 changes: 5 additions & 0 deletions src/components/ParentNavigationSubtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct
const {isOffline} = useNetwork();
const {translate} = useLocalize();

// We should not display the parent navigation subtitle if the user does not have access to the parent chat (the reportName is empty in this case)
if (!reportName) {
rayane-djouah marked this conversation as resolved.
Show resolved Hide resolved
return;
}

return (
<PressableWithoutFeedback
onPress={() => {
Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5965,6 +5965,13 @@ function isReportParticipant(accountID: number, report: OnyxEntry<Report>): bool
return possibleAccountIDs.includes(accountID);
}

/**
* Check to see if the current user has access to view the report.
*/
function canCurrentUserOpenReport(report: OnyxEntry<Report>): boolean {
return (isReportParticipant(currentUserAccountID ?? 0, report) || isPublicRoom(report)) && canAccessReport(report, allPolicies, allBetas);
}

function shouldUseFullTitleToDisplay(report: OnyxEntry<Report>): boolean {
return (
isMoneyRequestReport(report) || isPolicyExpenseChat(report) || isChatRoom(report) || isChatThread(report) || isTaskReport(report) || isGroupChat(report) || isInvoiceReport(report)
Expand Down Expand Up @@ -6493,6 +6500,7 @@ export {
canBeAutoReimbursed,
canCreateRequest,
canCreateTaskInReport,
canCurrentUserOpenReport,
canDeleteReportAction,
canEditFieldOfMoneyRequest,
canEditMoneyRequest,
Expand Down
8 changes: 6 additions & 2 deletions src/pages/home/report/RepliesDivider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import CONST from '@src/CONST';

type RepliesDividerProps = {
/** Whether we should hide thread divider line */
Expand All @@ -19,14 +20,17 @@ function RepliesDivider({shouldHideThreadDividerLine}: RepliesDividerProps) {
const {translate} = useLocalize();

return (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1]}>
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<Icon
src={Expensicons.Thread}
fill={theme.icon}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1]}>{translate('threads.replies')}</Text>
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1, styles.userSelectNone]}>{translate('threads.replies')}</Text>
{!shouldHideThreadDividerLine && <View style={[styles.threadDividerLine]} />}
</View>
);
Expand Down
7 changes: 6 additions & 1 deletion src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,12 @@ function ReportActionItem({
checkIfContextMenuActive={toggleContextMenuFromActiveReportAction}
setIsEmojiPickerActive={setIsEmojiPickerActive}
/>
<View style={StyleUtils.getReportActionItemStyle(hovered || isWhisper || isContextMenuActive || !!isEmojiPickerActive || draftMessage !== undefined, !!onPress)}>
<View
style={StyleUtils.getReportActionItemStyle(
hovered || isWhisper || isContextMenuActive || !!isEmojiPickerActive || draftMessage !== undefined,
draftMessage === undefined && !!onPress,
)}
>
<OfflineWithFeedback
onClose={() => ReportActions.clearAllRelatedReportActionErrors(report.reportID, action)}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand Down
27 changes: 17 additions & 10 deletions src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,24 @@ function ReportActionItemParentAction({
errorRowStyles={[styles.ml10, styles.mr2]}
onClose={() => Report.navigateToConciergeChatAndDeleteReport(ancestor.report.reportID)}
>
<ThreadDivider ancestor={ancestor} />
<ThreadDivider
ancestor={ancestor}
isLinkDisabled={!ReportUtils.canCurrentUserOpenReport(ReportUtils.getReport(ancestor?.report?.parentReportID))}
/>
<ReportActionItem
onPress={() => {
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
if (isVisibleAction && !isOffline) {
// Pop the chat report screen before navigating to the linked report action.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
}
}}
onPress={
ReportUtils.canCurrentUserOpenReport(ReportUtils.getReport(ancestor?.report?.parentReportID))
? () => {
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
if (isVisibleAction && !isOffline) {
// Pop the chat report screen before navigating to the linked report action.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
}
}
: undefined
}
parentReportAction={parentReportAction}
report={ancestor.report}
reportActions={reportActions}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ function ReportActionsList({
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)}
shouldDisplayReplyDivider={sortedReportActions.length > 1}
shouldDisplayReplyDivider={sortedVisibleReportActions.length > 1}
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
/>
Expand All @@ -564,7 +564,6 @@ function ReportActionsList({
report,
linkedReportActionID,
sortedVisibleReportActions,
sortedReportActions.length,
mostRecentIOUReportActionID,
shouldHideThreadDividerLine,
shouldDisplayNewMarker,
Expand Down
66 changes: 42 additions & 24 deletions src/pages/home/report/ThreadDivider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,56 @@ import ROUTES from '@src/ROUTES';
type ThreadDividerProps = {
/** Thread ancestor */
ancestor: Ancestor;

/** Whether the link is disabled */
isLinkDisabled?: boolean;
};

function ThreadDivider({ancestor}: ThreadDividerProps) {
function ThreadDivider({ancestor, isLinkDisabled = false}: ThreadDividerProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const {isOffline} = useNetwork();

return (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1]}>
<PressableWithoutFeedback
onPress={() => {
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
if (isVisibleAction && !isOffline) {
// Pop the chat report screen before navigating to the linked report action.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
}
}}
accessibilityLabel={translate('threads.thread')}
role={CONST.ROLE.BUTTON}
style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}
>
<Icon
src={Expensicons.Thread}
fill={theme.link}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.threadDividerText, styles.link]}>{translate('threads.thread')}</Text>
</PressableWithoutFeedback>
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml5, styles.mt3, styles.mb1, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{isLinkDisabled ? (
<>
<Icon
src={Expensicons.Thread}
fill={theme.icon}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.threadDividerText, styles.textSupporting, styles.ml1, styles.userSelectNone]}>{translate('threads.thread')}</Text>
</>
) : (
<PressableWithoutFeedback
onPress={() => {
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '');
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''));
if (isVisibleAction && !isOffline) {
// Pop the chat report screen before navigating to the linked report action.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID));
}
}}
accessibilityLabel={translate('threads.thread')}
role={CONST.ROLE.BUTTON}
style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}
>
<Icon
src={Expensicons.Thread}
fill={theme.link}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.threadDividerText, styles.link]}>{translate('threads.thread')}</Text>
</PressableWithoutFeedback>
)}
{!ancestor.shouldDisplayNewMarker && <View style={[styles.threadDividerLine]} />}
</View>
);
Expand Down
Loading