Repository navigation
Sort join-workspaces by member count and add Show more #86884
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
Changes from all commits
1791bc1
24354bf
32c673b
1ea95e5
a98a4a3
8fd9d30
14ed7d3
9fb45f3
80cebf4
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import {useFocusEffect} from '@react-navigation/native'; | ||
| import {hasSeenTourSelector} from '@selectors/Onboarding'; | ||
| import React from 'react'; | ||
| import React, {useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Button from '@components/Button'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
|
|
@@ -17,6 +17,7 @@ import useOnboardingStepCounter from '@hooks/useOnboardingStepCounter'; | |
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {navigateAfterOnboardingWithMicrotaskQueue} from '@libs/navigateAfterOnboarding'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
@@ -34,11 +35,13 @@ import type {JoinablePolicy} from '@src/types/onyx/JoinablePolicies'; | |
| import type {BaseOnboardingWorkspacesProps} from './types'; | ||
|
|
||
| function BaseOnboardingWorkspaces({route, shouldUseNativeStyles}: BaseOnboardingWorkspacesProps) { | ||
| const icons = useMemoizedLazyExpensifyIcons(['FallbackWorkspaceAvatar']); | ||
| const icons = useMemoizedLazyExpensifyIcons(['FallbackWorkspaceAvatar', 'DownArrow']); | ||
| const {isOffline} = useNetwork(); | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const {onboardingMessages} = useOnboardingMessages(); | ||
| const [showAll, setShowAll] = useState(false); | ||
|
|
||
| // We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment | ||
| // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth | ||
|
|
@@ -99,33 +102,38 @@ function BaseOnboardingWorkspaces({route, shouldUseNativeStyles}: BaseOnboarding | |
| ); | ||
| }; | ||
|
|
||
| const policyIDItems = Object.values(joinablePolicies ?? {}).map((policyInfo) => ({ | ||
| text: policyInfo.policyName, | ||
| alternateText: translate('onboarding.workspaceMemberList', policyInfo.employeeCount, policyInfo.policyOwner), | ||
| keyForList: policyInfo.policyID, | ||
| isDisabled: true, | ||
| rightElement: ( | ||
| <Button | ||
| isDisabled={isOffline} | ||
| success | ||
| medium | ||
| text={policyInfo.automaticJoiningEnabled ? translate('workspace.workspaceList.joinNow') : translate('workspace.workspaceList.askToJoin')} | ||
| onPress={() => { | ||
| handleJoinWorkspace(policyInfo); | ||
| }} | ||
| sentryLabel={CONST.SENTRY_LABEL.ONBOARDING.JOIN_WORKSPACE} | ||
| /> | ||
| ), | ||
| icons: [ | ||
| { | ||
| id: policyInfo.policyID, | ||
| source: getDefaultWorkspaceAvatar(policyInfo.policyName), | ||
| fallbackIcon: icons.FallbackWorkspaceAvatar, | ||
| name: policyInfo.policyName, | ||
| type: CONST.ICON_TYPE_WORKSPACE, | ||
| }, | ||
| ], | ||
| })); | ||
| const allPolicyIDItems = Object.values(joinablePolicies ?? {}) | ||
| .sort((a, b) => b.employeeCount - a.employeeCount) | ||
| .map((policyInfo) => ({ | ||
| text: policyInfo.policyName, | ||
| alternateText: translate('onboarding.workspaceMemberList', policyInfo.employeeCount, policyInfo.policyOwner), | ||
| keyForList: policyInfo.policyID, | ||
| isDisabled: true, | ||
| rightElement: ( | ||
| <Button | ||
| isDisabled={isOffline} | ||
| success | ||
| medium | ||
| text={policyInfo.automaticJoiningEnabled ? translate('workspace.workspaceList.joinNow') : translate('workspace.workspaceList.askToJoin')} | ||
| onPress={() => { | ||
| handleJoinWorkspace(policyInfo); | ||
| }} | ||
| sentryLabel={CONST.SENTRY_LABEL.ONBOARDING.JOIN_WORKSPACE} | ||
| /> | ||
| ), | ||
| icons: [ | ||
| { | ||
| id: policyInfo.policyID, | ||
| source: getDefaultWorkspaceAvatar(policyInfo.policyName), | ||
| fallbackIcon: icons.FallbackWorkspaceAvatar, | ||
| name: policyInfo.policyName, | ||
| type: CONST.ICON_TYPE_WORKSPACE, | ||
| }, | ||
| ], | ||
| })); | ||
|
|
||
| const hasMoreThanLimit = allPolicyIDItems.length > CONST.ONBOARDING_JOINABLE_WORKSPACES_LIMIT; | ||
| const policyIDItems = !showAll && hasMoreThanLimit ? allPolicyIDItems.slice(0, CONST.ONBOARDING_JOINABLE_WORKSPACES_LIMIT) : allPolicyIDItems; | ||
|
|
||
| const wrapperPadding = onboardingIsMediumOrLargerScreenWidth ? styles.mh8 : styles.mh5; | ||
|
|
||
|
|
@@ -184,11 +192,30 @@ function BaseOnboardingWorkspaces({route, shouldUseNativeStyles}: BaseOnboarding | |
| <Text style={[styles.textSupporting, styles.mt3]}>{translate('onboarding.listOfWorkspaces')}</Text> | ||
| </View> | ||
| } | ||
| listFooterContent={ | ||
| hasMoreThanLimit && !showAll ? ( | ||
| <View style={[wrapperPadding, styles.alignItemsStart]}> | ||
| <Button | ||
| text={translate('common.showMore')} | ||
| onPress={() => setShowAll(true)} | ||
| link | ||
| shouldUseDefaultHover={false} | ||
| medium | ||
| shouldShowRightIcon | ||
| iconRight={icons.DownArrow} | ||
| iconRightFill={theme.link} | ||
| iconRightHoverFill={theme.linkHover} | ||
| innerStyles={styles.ph0} | ||
| textStyles={[styles.fontSizeNormal]} | ||
| /> | ||
|
Comment on lines
+198
to
+210
Contributor
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.
Contributor
Author
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. Fixed — changed "Show more" to use the link style (matching the existing pattern in TransactionGroupListExpanded) and moved it from footerContent to listFooterContent so it renders right after the list items inside the scrollable area. |
||
| </View> | ||
| ) : null | ||
| } | ||
| footerContent={ | ||
| <Button | ||
| success={false} | ||
| large | ||
| text={translate('common.skip')} | ||
| text={translate('onboarding.skipForNow')} | ||
| testID="onboardingWorkSpaceSkipButton" | ||
| onPress={skipJoiningWorkspaces} | ||
| style={[styles.mt5]} | ||
|
|
||

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.
@MelvinBot this button should be left aligned. And there should be dropdown arrow icon next to the text.
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 — left-aligned the Show more button (via alignItemsStart on the wrapper) and added a down arrow icon next to the text (via iconRight).