-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Show join button in the chat header #33791
Changes from 1 commit
e76361b
2fd6cb1
ec52137
8dbff7c
42d39bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import {withOnyx} from 'react-native-onyx'; | |
import _ from 'underscore'; | ||
import GoogleMeetIcon from '@assets/images/google-meet.svg'; | ||
import ZoomIcon from '@assets/images/zoom-icon.svg'; | ||
import Button from '@components/Button'; | ||
import DisplayNames from '@components/DisplayNames'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
|
@@ -141,25 +142,37 @@ function HeaderView(props) { | |
} | ||
} | ||
|
||
if ((isChatThread && !isEmptyChat) || isUserCreatedPolicyRoom || canLeaveRoom) { | ||
if (!isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.ChatBubbles, | ||
text: translate('common.join'), | ||
onSelected: Session.checkIfActionIsAllowed(() => | ||
Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), | ||
), | ||
}); | ||
} else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) { | ||
const isWorkspaceMemberLeavingWorkspaceRoom = lodashGet(props.report, 'visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED && isPolicyMember; | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.ChatBubbles, | ||
text: translate('common.leave'), | ||
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID, isWorkspaceMemberLeavingWorkspaceRoom)), | ||
}); | ||
} | ||
const canJoinOrLeave = (isChatThread && !isEmptyChat) || isUserCreatedPolicyRoom || canLeaveRoom; | ||
const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; | ||
const canLeave = canJoinOrLeave && ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom); | ||
if (canJoin) { | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.ChatBubbles, | ||
text: translate('common.join'), | ||
onSelected: Session.checkIfActionIsAllowed(() => | ||
Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), | ||
), | ||
}); | ||
} else if (canLeave) { | ||
const isWorkspaceMemberLeavingWorkspaceRoom = lodashGet(props.report, 'visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED && isPolicyMember; | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.ChatBubbles, | ||
text: translate('common.leave'), | ||
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID, isWorkspaceMemberLeavingWorkspaceRoom)), | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need the |
||
|
||
const joinButton = ( | ||
<Button | ||
success | ||
medium | ||
text={translate('common.join')} | ||
onPress={Session.checkIfActionIsAllowed(() => | ||
Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), | ||
bernhardoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
)} | ||
/> | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's worth to create a separate component for join button (like task button), so I just put it here. |
||
|
||
threeDotMenuItems.push(HeaderUtils.getPinMenuItem(props.report)); | ||
|
||
if (isConcierge && props.guideCalendarLink) { | ||
|
@@ -200,103 +213,107 @@ function HeaderView(props) { | |
|
||
return ( | ||
<View | ||
style={[styles.appContentHeader, shouldShowBorderBottom && styles.borderBottom]} | ||
style={[shouldShowBorderBottom && styles.borderBottom]} | ||
dataSet={{dragArea: true}} | ||
> | ||
<View style={[styles.appContentHeaderTitle, !isSmallScreenWidth && !isLoading && styles.pl5]}> | ||
{isLoading ? ( | ||
<ReportHeaderSkeletonView onBackButtonPress={props.onNavigationMenuButtonClicked} /> | ||
) : ( | ||
<> | ||
{isSmallScreenWidth && ( | ||
<PressableWithoutFeedback | ||
onPress={props.onNavigationMenuButtonClicked} | ||
style={[styles.LHNToggle]} | ||
accessibilityHint={translate('accessibilityHints.navigateToChatsList')} | ||
accessibilityLabel={translate('common.back')} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
<Tooltip | ||
text={translate('common.back')} | ||
shiftVertical={4} | ||
<View style={[styles.appContentHeader]}> | ||
<View style={[styles.appContentHeaderTitle, !isSmallScreenWidth && !isLoading && styles.pl5]}> | ||
{isLoading ? ( | ||
<ReportHeaderSkeletonView onBackButtonPress={props.onNavigationMenuButtonClicked} /> | ||
) : ( | ||
<> | ||
{isSmallScreenWidth && ( | ||
<PressableWithoutFeedback | ||
onPress={props.onNavigationMenuButtonClicked} | ||
style={[styles.LHNToggle]} | ||
accessibilityHint={translate('accessibilityHints.navigateToChatsList')} | ||
accessibilityLabel={translate('common.back')} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
<Tooltip | ||
text={translate('common.back')} | ||
shiftVertical={4} | ||
> | ||
<View> | ||
<Icon | ||
src={Expensicons.BackArrow} | ||
fill={theme.icon} | ||
/> | ||
</View> | ||
</Tooltip> | ||
</PressableWithoutFeedback> | ||
)} | ||
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}> | ||
<PressableWithoutFeedback | ||
onPress={() => ReportUtils.navigateToDetailsPage(props.report)} | ||
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]} | ||
disabled={shouldDisableDetailPage} | ||
accessibilityLabel={title} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
<View> | ||
<Icon | ||
src={Expensicons.BackArrow} | ||
fill={theme.icon} | ||
{shouldShowSubscript ? ( | ||
<SubscriptAvatar | ||
mainAvatar={icons[0]} | ||
secondaryAvatar={icons[1]} | ||
size={defaultSubscriptSize} | ||
/> | ||
</View> | ||
</Tooltip> | ||
</PressableWithoutFeedback> | ||
)} | ||
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}> | ||
<PressableWithoutFeedback | ||
onPress={() => ReportUtils.navigateToDetailsPage(props.report)} | ||
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]} | ||
disabled={shouldDisableDetailPage} | ||
accessibilityLabel={title} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
{shouldShowSubscript ? ( | ||
<SubscriptAvatar | ||
mainAvatar={icons[0]} | ||
secondaryAvatar={icons[1]} | ||
size={defaultSubscriptSize} | ||
/> | ||
) : ( | ||
<MultipleAvatars | ||
icons={icons} | ||
shouldShowTooltip={!isChatRoom || isChatThread} | ||
/> | ||
)} | ||
<View style={[styles.flex1, styles.flexColumn]}> | ||
<DisplayNames | ||
fullTitle={title} | ||
displayNamesWithTooltips={displayNamesWithTooltips} | ||
tooltipEnabled | ||
numberOfLines={1} | ||
textStyles={[styles.headerText, styles.pre]} | ||
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport} | ||
/> | ||
{!_.isEmpty(parentNavigationSubtitleData) && ( | ||
<ParentNavigationSubtitle | ||
parentNavigationSubtitleData={parentNavigationSubtitleData} | ||
parentReportID={props.report.parentReportID} | ||
pressableStyles={[styles.alignSelfStart, styles.mw100]} | ||
) : ( | ||
<MultipleAvatars | ||
icons={icons} | ||
shouldShowTooltip={!isChatRoom || isChatThread} | ||
/> | ||
)} | ||
{!_.isEmpty(subtitle) && ( | ||
<Text | ||
style={[styles.sidebarLinkText, styles.optionAlternateText, styles.textLabelSupporting]} | ||
<View style={[styles.flex1, styles.flexColumn]}> | ||
<DisplayNames | ||
fullTitle={title} | ||
displayNamesWithTooltips={displayNamesWithTooltips} | ||
tooltipEnabled | ||
numberOfLines={1} | ||
> | ||
{subtitle} | ||
</Text> | ||
)} | ||
</View> | ||
{brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR && ( | ||
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}> | ||
<Icon | ||
src={Expensicons.DotIndicator} | ||
fill={theme.danger} | ||
textStyles={[styles.headerText, styles.pre]} | ||
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport} | ||
/> | ||
{!_.isEmpty(parentNavigationSubtitleData) && ( | ||
<ParentNavigationSubtitle | ||
parentNavigationSubtitleData={parentNavigationSubtitleData} | ||
parentReportID={props.report.parentReportID} | ||
pressableStyles={[styles.alignSelfStart, styles.mw100]} | ||
/> | ||
)} | ||
{!_.isEmpty(subtitle) && ( | ||
<Text | ||
style={[styles.sidebarLinkText, styles.optionAlternateText, styles.textLabelSupporting]} | ||
numberOfLines={1} | ||
> | ||
{subtitle} | ||
</Text> | ||
)} | ||
</View> | ||
)} | ||
</PressableWithoutFeedback> | ||
<View style={[styles.reportOptions, styles.flexRow, styles.alignItemsCenter]}> | ||
{isTaskReport && !isSmallScreenWidth && ReportUtils.isOpenTaskReport(props.report) && <TaskHeaderActionButton report={props.report} />} | ||
{shouldShowThreeDotsButton && ( | ||
<ThreeDotsMenu | ||
anchorPosition={styles.threeDotsPopoverOffset(windowWidth)} | ||
menuItems={threeDotMenuItems} | ||
shouldSetModalVisibility={false} | ||
/> | ||
)} | ||
{brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR && ( | ||
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}> | ||
<Icon | ||
src={Expensicons.DotIndicator} | ||
fill={theme.danger} | ||
/> | ||
</View> | ||
)} | ||
</PressableWithoutFeedback> | ||
<View style={[styles.reportOptions, styles.flexRow, styles.alignItemsCenter]}> | ||
{isTaskReport && !isSmallScreenWidth && ReportUtils.isOpenTaskReport(props.report) && <TaskHeaderActionButton report={props.report} />} | ||
{canJoin && !isSmallScreenWidth && joinButton} | ||
{shouldShowThreeDotsButton && ( | ||
<ThreeDotsMenu | ||
anchorPosition={styles.threeDotsPopoverOffset(windowWidth)} | ||
menuItems={threeDotMenuItems} | ||
shouldSetModalVisibility={false} | ||
/> | ||
)} | ||
</View> | ||
</View> | ||
</View> | ||
</> | ||
)} | ||
</> | ||
)} | ||
</View> | ||
</View> | ||
{canJoin && isSmallScreenWidth && <View style={[styles.ph5, styles.pb2]}>{joinButton}</View>} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The join button should be displayed only if |
||
</View> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like so many changes, but it just changing from
to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the reference. This seems to better approach than task button which is existing now, since for small screen we render the task button from ReportScreen and non-small screen we render the task button from HeaderView. |
||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add
, props.report.parentReportID, props.report.parentReportActionID)
as the fifth and sixth parameters of updateNotificationPreference so that the bell icon updates optimistically?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done