-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
#35715 workspace member details page #37715
Merged
luacmartins
merged 31 commits into
Expensify:main
from
burczu:feature/35715-workspace-member-details-page
Mar 7, 2024
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
35f5618
basic member details page added
burczu be52759
passing personal details, policy members and routes to details page
burczu 69ee8a1
passing backTo parameter to the details route
burczu 210d294
showing member details page title from its personal details
burczu 8e0f762
showing avatar added
burczu 6dc39ce
lint and prettier fixes
burczu 9409582
remove from workspace button added
burczu ec5458b
removing member implementation added
burczu d50d4a4
Merge branch 'main' into feature/35715-workspace-member-details-page
burczu d916cae
after main merge fix
burczu 8000440
role and profile buttons added
burczu e29e0b2
lint and prettier fixes
burczu b37abfe
role selection modal added
burczu f583fd4
role selection list added
burczu f24deca
changing role on the role selection modal added
burczu 27f7917
policy name added as subtitle of the member detail page
burczu 7a91ec8
transform scale helper introduced
burczu 6775986
unnecessary padding removed
burczu 07280c7
back to handled properly
burczu aa11bf3
using value to update workspace member role
burczu de3c302
switched to use correct menu item component
burczu a85b5e7
Merge branch 'main' into feature/35715-workspace-member-details-page
burczu dc7320e
backTo functionality fixed
burczu 86bf243
navigation type issue fixed
burczu 33509bb
state name adjusted
burczu 1159171
event handler name adjusted
burczu f2b95c7
admin and paid policy access constraints added
burczu f78a65e
Merge branch 'main' into feature/35715-workspace-member-details-page
burczu dcd13bb
disabled showing RHN for non paid workspaces
burczu 0140c46
selecting user on item press removed
burczu 18d88ef
lint/prettier
burczu 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
152 changes: 152 additions & 0 deletions
152
src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React, {useCallback} from 'react'; | ||
import {View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Avatar from '@components/Avatar'; | ||
import Button from '@components/Button'; | ||
import ConfirmModal from '@components/ConfirmModal'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import MenuItem from '@components/MenuItem'; | ||
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as UserUtils from '@libs/UserUtils'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {SettingsNavigatorParamList} from '@navigation/types'; | ||
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; | ||
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; | ||
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; | ||
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; | ||
import * as Policy from '@userActions/Policy'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Route} from '@src/ROUTES'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; | ||
|
||
type WorkspacePolicyOnyxProps = { | ||
/** Personal details of all users */ | ||
personalDetails: OnyxEntry<PersonalDetailsList>; | ||
}; | ||
|
||
type WorkspaceMemberDetailsPageProps = WithPolicyAndFullscreenLoadingProps & WorkspacePolicyOnyxProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.MEMBER_DETAILS>; | ||
|
||
function WorkspaceMemberDetailsPage({personalDetails, policyMembers, policy, route}: WorkspaceMemberDetailsPageProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const StyleUtils = useStyleUtils(); | ||
|
||
const [isRemoveMemberConfirmModalVisible, setIsRemoveMemberConfirmModalVisible] = React.useState(false); | ||
|
||
const accountID = Number(route.params.accountID); | ||
const policyID = route.params.policyID; | ||
const backTo = route.params.backTo ?? ('' as Route); | ||
|
||
const member = policyMembers?.[accountID]; | ||
const details = personalDetails?.[accountID] ?? ({} as PersonalDetails); | ||
const avatar = details.avatar ?? UserUtils.getDefaultAvatar(); | ||
const fallbackIcon = details.fallbackIcon ?? ''; | ||
const displayName = details.displayName ?? ''; | ||
|
||
const askForConfirmationToRemove = () => { | ||
setIsRemoveMemberConfirmModalVisible(true); | ||
}; | ||
|
||
const removeUser = useCallback(() => { | ||
Policy.removeMembers([accountID], route.params.policyID); | ||
setIsRemoveMemberConfirmModalVisible(false); | ||
Navigation.goBack(backTo); | ||
}, [accountID, backTo, route.params.policyID]); | ||
|
||
const navigateToProfile = useCallback(() => { | ||
Navigation.navigate(ROUTES.PROFILE.getRoute(accountID, Navigation.getActiveRoute())); | ||
}, [accountID]); | ||
|
||
const openRoleSelectionModal = useCallback(() => { | ||
Navigation.navigate(ROUTES.WORKSPACE_MEMBER_ROLE_SELECTION.getRoute(route.params.policyID, accountID, Navigation.getActiveRoute())); | ||
}, [accountID, route.params.policyID]); | ||
|
||
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. We are not checking if user is workspace member or not, ref: #41492 |
||
return ( | ||
<AdminPolicyAccessOrNotFoundWrapper policyID={policyID}> | ||
<PaidPolicyAccessOrNotFoundWrapper policyID={policyID}> | ||
<ScreenWrapper testID={WorkspaceMemberDetailsPage.displayName}> | ||
<HeaderWithBackButton | ||
title={displayName} | ||
subtitle={policy?.name} | ||
onBackButtonPress={() => Navigation.goBack(backTo)} | ||
/> | ||
<View style={[styles.containerWithSpaceBetween, styles.pointerEventsBoxNone, styles.justifyContentStart]}> | ||
<View style={[styles.avatarSectionWrapper, styles.pb0]}> | ||
<OfflineWithFeedback pendingAction={details.pendingFields?.avatar}> | ||
<Avatar | ||
containerStyles={[styles.avatarXLarge, styles.mv5, styles.noOutline]} | ||
imageStyles={[styles.avatarXLarge]} | ||
source={UserUtils.getAvatar(avatar, accountID)} | ||
size={CONST.AVATAR_SIZE.XLARGE} | ||
fallbackIcon={fallbackIcon} | ||
/> | ||
</OfflineWithFeedback> | ||
{Boolean(details.displayName ?? '') && ( | ||
<Text | ||
style={[styles.textHeadline, styles.pre, styles.mb6, styles.w100, styles.textAlignCenter]} | ||
numberOfLines={1} | ||
> | ||
{displayName} | ||
</Text> | ||
)} | ||
<Button | ||
text={translate('workspace.people.removeMemberButtonTitle')} | ||
onPress={askForConfirmationToRemove} | ||
medium | ||
icon={Expensicons.RemoveMembers} | ||
iconStyles={StyleUtils.getTransformScaleStyle(0.8)} | ||
style={styles.mv5} | ||
/> | ||
<ConfirmModal | ||
danger | ||
title={translate('workspace.people.removeMemberTitle')} | ||
isVisible={isRemoveMemberConfirmModalVisible} | ||
onConfirm={removeUser} | ||
onCancel={() => setIsRemoveMemberConfirmModalVisible(false)} | ||
prompt={translate('workspace.people.removeMemberPrompt', {memberName: displayName})} | ||
confirmText={translate('common.remove')} | ||
cancelText={translate('common.cancel')} | ||
/> | ||
</View> | ||
<View style={styles.w100}> | ||
<MenuItemWithTopDescription | ||
title={member?.role === CONST.POLICY.ROLE.ADMIN ? translate('common.admin') : translate('common.member')} | ||
description={translate('common.role')} | ||
shouldShowRightIcon | ||
onPress={openRoleSelectionModal} | ||
/> | ||
<MenuItem | ||
title={translate('common.profile')} | ||
icon={Expensicons.Info} | ||
onPress={navigateToProfile} | ||
shouldShowRightIcon | ||
/> | ||
</View> | ||
</View> | ||
</ScreenWrapper> | ||
</PaidPolicyAccessOrNotFoundWrapper> | ||
</AdminPolicyAccessOrNotFoundWrapper> | ||
); | ||
} | ||
|
||
WorkspaceMemberDetailsPage.displayName = 'WorkspaceMemberDetailsPage'; | ||
|
||
export default withPolicyAndFullscreenLoading( | ||
withOnyx<WorkspaceMemberDetailsPageProps, WorkspacePolicyOnyxProps>({ | ||
personalDetails: { | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
}, | ||
})(WorkspaceMemberDetailsPage), | ||
); |
Oops, something went wrong.
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.
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.
I think we just wanna navigate to the regular profile here too
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.
I won't block on this, but we should follow up with a fix.