-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: admin can access member details page after member leaves #41492
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e724493
fix: admin can access member details page after member leaves
tienifr e834286
Merge branch 'main' of https://github.com/tienifr/App into fix/40416
tienifr f1d86f0
not found page with wrapper
tienifr fc15f14
Merge branch 'main' of https://github.com/tienifr/App into fix/40416
tienifr 83b9cc7
do not use negated variable name
tienifr f913df5
Revert "do not use negated variable name"
tienifr 59918af
Merge branch 'main' of https://github.com/tienifr/App into fix/40416
tienifr 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,13 @@ import Text from '@components/Text'; | |
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useNetwork from '@hooks/useNetwork'; | ||
import usePrevious from '@hooks/usePrevious'; | ||
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 NotFoundPage from '@pages/ErrorPage/NotFoundPage'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; | ||
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; | ||
|
@@ -56,6 +58,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
|
||
const memberLogin = personalDetails?.[accountID]?.login ?? ''; | ||
const member = policy?.employeeList?.[memberLogin]; | ||
const prevMember = usePrevious(member); | ||
const details = personalDetails?.[accountID] ?? ({} as PersonalDetails); | ||
const avatar = details.avatar ?? UserUtils.getDefaultAvatar(); | ||
const fallbackIcon = details.fallbackIcon ?? ''; | ||
|
@@ -95,14 +98,20 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
} | ||
}, [accountID, policy?.errorFields?.changeOwner, policy?.isChangeOwnerSuccessful, policyID]); | ||
|
||
useEffect(() => { | ||
if (!prevMember || prevMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || member?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { | ||
return; | ||
} | ||
Navigation.goBack(); | ||
}, [member, prevMember]); | ||
|
||
const askForConfirmationToRemove = () => { | ||
setIsRemoveMemberConfirmModalVisible(true); | ||
}; | ||
|
||
const removeUser = useCallback(() => { | ||
Policy.removeMembers([accountID], policyID); | ||
setIsRemoveMemberConfirmModalVisible(false); | ||
Navigation.goBack(); | ||
}, [accountID, policyID]); | ||
|
||
const navigateToProfile = useCallback(() => { | ||
|
@@ -127,6 +136,14 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
Navigation.navigate(ROUTES.WORKSPACE_OWNER_CHANGE_CHECK.getRoute(policyID, accountID, 'amountOwed' as ValueOf<typeof CONST.POLICY.OWNERSHIP_ERRORS>)); | ||
}, [accountID, policyID]); | ||
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
const shouldShowNotFoundPage = | ||
!member || (member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && prevMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); | ||
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. |
||
|
||
if (shouldShowNotFoundPage) { | ||
return <NotFoundPage />; | ||
} | ||
|
||
return ( | ||
<AccessOrNotFoundWrapper | ||
policyID={policyID} | ||
|
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.
Hmm I don't think you should use the lint rule here.
You can just change the conditional
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 the lint rule is a bit too strict, it should only block actual negated variable names like
shouldNotShow
but notshouldShowNotFoundPage
because thenot
here is not really a negated adverb. I think it's fine since we're already using it many places in App.But I still updated as your feedback.
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.
Thanks
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.
Ah ok, that makes sense, I guess that OK
Maybe you can add a comment to explain why the lint exception is appropriate.
I agree that
shouldShowPage
is a confusing name.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.
Reverted!