-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[NoQA] [HR Import] Initial sync modal, sync action and info on Members page #91315
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 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
de5c54c
[HR Import] Sync now, initial sync modal
mhawryluk 5e693c2
Generalize Members page to work with Merge HR like it does with Gusto
mhawryluk 08076cf
Remove useMergeHRInitialSyncingModal from WorkspaceMembersPage
mhawryluk df31cef
Merge branch 'main' into merge-hr/sync
mhawryluk 0d933d5
Add translations
mhawryluk 86095ba
Adjust the initial syncType onxy data scheme
mhawryluk e573980
Merge branch 'main' into merge-hr/sync
mhawryluk ffbfb77
Update the onyx data structure for initial merge hr sync
mhawryluk 1f148e6
Fix the description not showing up
mhawryluk 897ea31
Remove MERGE_HR_SYNC_TITLE
mhawryluk 2d31562
Don't show Other section too on initial sync
mhawryluk 0a22e99
Add translations for 'syncing'
mhawryluk dbfd1fd
Implement review suggestions
mhawryluk 7d16afb
Fix syncing status for Merge HR in Members page
mhawryluk b6e4c26
Refactor
mhawryluk 158a688
Use TransitionTracker in useMergeHRInitialSyncingModal
mhawryluk 38199e7
Add waitForUpcomingTransition prop to runAfterTransitions
mhawryluk 50e428e
Show the modal only once the app is visible
mhawryluk bbb9810
Add justification comments
mhawryluk ab55e28
Fix initial sync modal not showing up on mobile
mhawryluk ce62021
Add temporary console.logs
mhawryluk 581fea7
Remove console.log
mhawryluk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import {useEffect, useEffectEvent} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import {setMergeHRInitialSyncModalShown} from '@libs/actions/connections/MergeHR'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type Policy from '@src/types/onyx/Policy'; | ||
| import type {PolicyConnectionSyncProgress} from '@src/types/onyx/Policy'; | ||
| import useConfirmModal from './useConfirmModal'; | ||
| import useLocalize from './useLocalize'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| /** | ||
| * Shows a one-time informational modal when the Merge HR connection's first backend-initiated sync starts. | ||
| * The modal is suppressed for subsequent page loads during the same sync by persisting the sync timestamp in Onyx. | ||
| */ | ||
| function useMergeHRInitialSyncingModal(policyID: string, policy: OnyxEntry<Policy>, connectionSyncProgress: OnyxEntry<PolicyConnectionSyncProgress>, isFocused: boolean) { | ||
| const {showConfirmModal} = useConfirmModal(); | ||
| const {translate} = useLocalize(); | ||
| const [shownForTimestamp] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_MERGE_HR_INITIAL_SYNC_MODAL_SHOWN}${policyID}`); | ||
|
|
||
| const showSyncingModal = useEffectEvent((timestamp: string) => { | ||
| if (shownForTimestamp === timestamp) { | ||
| return; | ||
| } | ||
| setMergeHRInitialSyncModalShown(policyID, timestamp); | ||
| showConfirmModal({ | ||
| id: `merge-hr-syncing-${policyID}`, | ||
| title: translate('workspace.hr.syncingModalTitle'), | ||
| prompt: translate('workspace.hr.syncingModalDescription'), | ||
| confirmText: translate('common.buttonConfirm'), | ||
| shouldShowCancelButton: false, | ||
| }); | ||
| }); | ||
|
|
||
| const lastSyncType = policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.MERGE_HR]?.lastSync?.syncType; | ||
|
|
||
| useEffect(() => { | ||
| const isMergeHRInitialSyncStarting = | ||
| connectionSyncProgress?.connectionName === CONST.POLICY.CONNECTIONS.NAME.MERGE_HR && | ||
| connectionSyncProgress?.stageInProgress === CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.MERGE_HR_SYNC_TITLE && | ||
| lastSyncType === CONST.MERGE_HR.SYNC_TYPE.INITIAL; | ||
|
|
||
| if (!isFocused || !isMergeHRInitialSyncStarting || !connectionSyncProgress?.timestamp) { | ||
| return; | ||
| } | ||
|
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. [isInitialSyncInProgress, isFocused] @mhawryluk have you tried passing in isInitialSyncInProgress rather than rerender on both changes? |
||
|
|
||
| showSyncingModal(connectionSyncProgress.timestamp); | ||
| }, [connectionSyncProgress?.connectionName, connectionSyncProgress?.stageInProgress, lastSyncType, connectionSyncProgress?.timestamp, isFocused]); | ||
| } | ||
|
|
||
| export default useMergeHRInitialSyncingModal; | ||
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
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.
SYNC_STATUS: "SYNCING" | "DONE" | "FAILED" | "DISABLED";
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.
SYNC_TYPE: "initial" | "manual" | "auto" | "webhook";
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.
So the loading state is
First sync:
{ ... syncStatus: 'SYNCING', syncType: 'initial' }When done:
{ ... successfulDate: `<idk some date format off top of head>` syncStatus: 'DONE' | 'FAILED' | 'DISABLED', syncType: 'initial' }We only care about initial vs not initial for now, so we can ignore the other syncTypes for the time status