-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Workspace Chats for All] Default QAB to primary workspace if no value #51836
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
71e37a5
v1 changes
ishpaul777 62fe24c
fixes
ishpaul777 060c3cc
fixes avatar handling
ishpaul777 32aaff8
resolve review comments
ishpaul777 a00c2e2
merge usememos
ishpaul777 9462bbd
lint
ishpaul777 0b6e497
fix lint
ishpaul777 508065a
remove console
ishpaul777 c80ae45
use isEmptyObject
ishpaul777 92bb507
Update src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPo…
ishpaul777 f4992c7
Update src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPo…
ishpaul777 552885a
Merge branch 'main' into feat/50728
ishpaul777 ccee92f
minor improvements
ishpaul777 4395c5f
Merge branch 'Expensify:main' into feat/50728
ishpaul777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,16 @@ function FloatingActionButtonAndPopover( | |
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${quickActionReport?.reportID ?? -1}`); | ||
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); | ||
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); | ||
const policyChatForActivePolicy = useMemo(() => { | ||
if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) { | ||
return {} as OnyxTypes.Report; | ||
} | ||
const policyChatsForActivePolicy = ReportUtils.getWorkspaceChats(activePolicyID ?? '-1', [session?.accountID ?? -1]); | ||
return policyChatsForActivePolicy.length > 0 ? policyChatsForActivePolicy.at(0) : ({} as OnyxTypes.Report); | ||
}, [activePolicy, activePolicyID, session?.accountID]); | ||
|
||
const [isCreateMenuActive, setIsCreateMenuActive] = useState(false); | ||
const fabRef = useRef<HTMLDivElement>(null); | ||
const {windowHeight} = useWindowDimensions(); | ||
|
@@ -195,10 +205,14 @@ function FloatingActionButtonAndPopover( | |
const avatars = ReportUtils.getIcons(quickActionReport, personalDetails); | ||
return avatars.length <= 1 || ReportUtils.isPolicyExpenseChat(quickActionReport) ? avatars : avatars.filter((avatar) => avatar.id !== session?.accountID); | ||
} | ||
if (!isEmptyObject(policyChatForActivePolicy)) { | ||
const avatars = ReportUtils.getIcons(policyChatForActivePolicy, personalDetails); | ||
return avatars; | ||
ishpaul777 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return []; | ||
// Policy is needed as a dependency in order to update the shortcut details when the workspace changes | ||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
}, [personalDetails, session?.accountID, quickActionReport, quickActionPolicy]); | ||
}, [personalDetails, session?.accountID, quickActionReport, quickActionPolicy, policyChatForActivePolicy]); | ||
|
||
const renderQuickActionTooltip = useCallback( | ||
() => ( | ||
|
@@ -233,16 +247,18 @@ function FloatingActionButtonAndPopover( | |
return quickAction?.action === CONST.QUICK_ACTIONS.SEND_MONEY && displayName.length === 0; | ||
}, [personalDetails, quickActionReport, quickAction?.action, quickActionAvatars]); | ||
|
||
const navigateToQuickAction = () => { | ||
const selectOption = (onSelected: () => void, shouldRestrictAction: boolean) => { | ||
const selectOption = useCallback( | ||
(onSelected: () => void, shouldRestrictAction: boolean) => { | ||
if (shouldRestrictAction && quickActionReport?.policyID && SubscriptionUtils.shouldRestrictUserBillableActions(quickActionReport.policyID)) { | ||
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(quickActionReport.policyID)); | ||
return; | ||
} | ||
|
||
onSelected(); | ||
}; | ||
}, | ||
[quickActionReport?.policyID], | ||
); | ||
|
||
const navigateToQuickAction = useCallback(() => { | ||
const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedRoom(quickActionReport, reportNameValuePairs)); | ||
const quickActionReportID = isValidReport ? quickActionReport?.reportID ?? '-1' : ReportUtils.generateReportID(); | ||
|
||
|
@@ -282,7 +298,7 @@ function FloatingActionButtonAndPopover( | |
break; | ||
default: | ||
} | ||
}; | ||
}, [quickAction, quickActionReport, reportNameValuePairs, selectOption]); | ||
|
||
/** | ||
* Check if LHN status changed from active to inactive. | ||
|
@@ -413,6 +429,77 @@ function FloatingActionButtonAndPopover( | |
]; | ||
}, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline]); | ||
|
||
const quickActionMenuItems = useMemo(() => { | ||
// Define common properties in baseQuickAction | ||
const baseQuickAction = { | ||
label: translate('quickAction.header'), | ||
isLabelHoverable: false, | ||
floatRightAvatars: quickActionAvatars, | ||
floatRightAvatarSize: CONST.AVATAR_SIZE.SMALL, | ||
numberOfLinesDescription: 1, | ||
tooltipAnchorAlignment: { | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
}, | ||
tooltipShiftHorizontal: styles.popoverMenuItem.paddingHorizontal, | ||
tooltipShiftVertical: styles.popoverMenuItem.paddingVertical / 2, | ||
renderTooltipContent: renderQuickActionTooltip, | ||
tooltipWrapperStyle: styles.quickActionTooltipWrapper, | ||
}; | ||
|
||
if (quickAction?.action) { | ||
return [ | ||
{ | ||
...baseQuickAction, | ||
icon: getQuickActionIcon(quickAction?.action), | ||
text: quickActionTitle, | ||
description: !hideQABSubtitle ? ReportUtils.getReportName(quickActionReport) ?? translate('quickAction.updateDestination') : '', | ||
onSelected: () => interceptAnonymousUser(() => navigateToQuickAction()), | ||
shouldShowSubscriptRightAvatar: ReportUtils.isPolicyExpenseChat(quickActionReport), | ||
shouldRenderTooltip: quickAction.isFirstQuickAction, | ||
}, | ||
]; | ||
} | ||
if (!isEmptyObject(policyChatForActivePolicy)) { | ||
return [ | ||
{ | ||
...baseQuickAction, | ||
icon: Expensicons.ReceiptScan, | ||
text: translate('quickAction.scanReceipt'), | ||
description: ReportUtils.getReportName(policyChatForActivePolicy), | ||
onSelected: () => | ||
interceptAnonymousUser(() => { | ||
selectOption(() => { | ||
const isValidReport = !(isEmptyObject(policyChatForActivePolicy) || ReportUtils.isArchivedRoom(policyChatForActivePolicy, reportNameValuePairs)); | ||
const quickActionReportID = isValidReport ? policyChatForActivePolicy?.reportID ?? '-1' : ReportUtils.generateReportID(); | ||
IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickActionReportID ?? '-1', CONST.IOU.REQUEST_TYPE.SCAN, true); | ||
Comment on lines
+456
to
+458
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. Addition of this caused |
||
}, true); | ||
}), | ||
shouldShowSubscriptRightAvatar: true, | ||
shouldRenderTooltip: false, | ||
}, | ||
]; | ||
} | ||
|
||
return []; | ||
}, [ | ||
translate, | ||
quickActionAvatars, | ||
styles.popoverMenuItem.paddingHorizontal, | ||
styles.popoverMenuItem.paddingVertical, | ||
styles.quickActionTooltipWrapper, | ||
renderQuickActionTooltip, | ||
quickAction?.action, | ||
quickAction?.isFirstQuickAction, | ||
policyChatForActivePolicy, | ||
quickActionTitle, | ||
hideQABSubtitle, | ||
quickActionReport, | ||
navigateToQuickAction, | ||
selectOption, | ||
reportNameValuePairs, | ||
]); | ||
|
||
return ( | ||
<View style={styles.flexGrow1}> | ||
<PopoverMenu | ||
|
@@ -468,31 +555,7 @@ function FloatingActionButtonAndPopover( | |
}, | ||
] | ||
: []), | ||
...(quickAction?.action | ||
? [ | ||
{ | ||
icon: getQuickActionIcon(quickAction?.action), | ||
text: quickActionTitle, | ||
label: translate('quickAction.header'), | ||
isLabelHoverable: false, | ||
floatRightAvatars: quickActionAvatars, | ||
floatRightAvatarSize: CONST.AVATAR_SIZE.SMALL, | ||
description: !hideQABSubtitle ? ReportUtils.getReportName(quickActionReport) ?? translate('quickAction.updateDestination') : '', | ||
numberOfLinesDescription: 1, | ||
onSelected: () => interceptAnonymousUser(() => navigateToQuickAction()), | ||
shouldShowSubscriptRightAvatar: ReportUtils.isPolicyExpenseChat(quickActionReport), | ||
shouldRenderTooltip: quickAction.isFirstQuickAction, | ||
tooltipAnchorAlignment: { | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
}, | ||
tooltipShiftHorizontal: styles.popoverMenuItem.paddingHorizontal, | ||
tooltipShiftVertical: styles.popoverMenuItem.paddingVertical / 2, | ||
renderTooltipContent: renderQuickActionTooltip, | ||
tooltipWrapperStyle: styles.quickActionTooltipWrapper, | ||
}, | ||
] | ||
: []), | ||
...quickActionMenuItems, | ||
]} | ||
withoutOverlay | ||
anchorRef={fabRef} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.