Repository navigation
Add Approve account merge requests task to Home #108297
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
Open
dukenv0307
wants to merge
7
commits into
Expensify:main
Choose a base branch
from
dukenv0307:approve-account-merge-requests-home-task
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+233
−2
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a85984
Add Approve account merge requests task to Home
dukenv0307 1a5fe24
merge main
dukenv0307 8a314ae
drop domainAccountMergeRequestSummary key
dukenv0307 77e6b0b
Merge branch 'main' into approve-account-merge-requests-home-task
dukenv0307 3be126e
lint fix
dukenv0307 08b4aac
merge main + fix reviewer comments
dukenv0307 cba1db7
apply translation
dukenv0307 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
|
|
||
| import navigateToDomainRouteWithSidebarSync from '@libs/Navigation/helpers/navigateToDomainRouteWithSidebarSync'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import {getPendingAccountMergeApprovals} from '@src/selectors/Domain'; | ||
|
|
||
| type ApproveAccountMergeRequests = { | ||
| /** Number of pending account merge requests the current user can approve, used to decide whether to render the approval row */ | ||
| count: number; | ||
|
|
||
| /** accountIDs of the domains that have at least one approvable request, used to count distinct marked domain rows */ | ||
| domainAccountIDs: number[]; | ||
|
|
||
| /** Opens the domain members page for the one domain with pending requests, or the domains list when there are several. */ | ||
| approveAccountMergeRequests: () => void; | ||
| }; | ||
|
|
||
| /** Handles the "Approve X account merge request(s)" row on the "For you" section of the home page. */ | ||
| function useApproveAccountMergeRequests(): ApproveAccountMergeRequests { | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const {isBetaEnabled} = usePermissions(); | ||
| const [reviewableMergeRequestsByDomain] = useOnyx(ONYXKEYS.COLLECTION.DOMAIN_ACCOUNT_MERGE_REQUESTS_TO_REVIEW); | ||
|
|
||
| const {count, domainAccountIDs} = isBetaEnabled(CONST.BETAS.MERGE_DOMAIN_ACCOUNTS) ? getPendingAccountMergeApprovals(reviewableMergeRequestsByDomain) : {count: 0, domainAccountIDs: []}; | ||
|
|
||
| const approveAccountMergeRequests = () => { | ||
| const domainAccountID = domainAccountIDs.at(0); | ||
| if (domainAccountIDs.length === 1 && domainAccountID !== undefined) { | ||
| navigateToDomainRouteWithSidebarSync(ROUTES.DOMAIN_MEMBERS.getRoute(domainAccountID), domainAccountID, shouldUseNarrowLayout); | ||
| return; | ||
| } | ||
| Navigation.navigate(ROUTES.DOMAINS_LIST.getRoute()); | ||
| }; | ||
|
|
||
| return {count, domainAccountIDs, approveAccountMergeRequests}; | ||
| } | ||
|
|
||
| export default useApproveAccountMergeRequests; | ||
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
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type DomainAccountMergeRequest from './DomainAccountMergeRequest'; | ||
|
|
||
| /** The merge requests the current user is authorized to review on one domain, keyed by requestID. */ | ||
| type DomainAccountMergeRequestsToReview = Record<string, DomainAccountMergeRequest>; | ||
|
|
||
| export default DomainAccountMergeRequestsToReview; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.