-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[No QA][HR Import] Final approver page #91297
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 4 commits
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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import React from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import WorkspaceMembersSelectionList from '@components/WorkspaceMembersSelectionList'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import usePolicy from '@hooks/usePolicy'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type Beta from '@src/types/onyx/Beta'; | ||
| import type {PolicyConnectionSyncProgress} from '@src/types/onyx/Policy'; | ||
| import type Policy from '@src/types/onyx/Policy'; | ||
|
|
||
| type HRFinalApproverProviderConfig = { | ||
| testID: string; | ||
| beta: Beta; | ||
| isConnected: (policy: OnyxEntry<Policy>) => boolean; | ||
| getCurrentFinalApprover: (policy: OnyxEntry<Policy>) => string | null; | ||
| getHeaderTitle: (providerName: string) => string; | ||
| getProviderName: (policy: OnyxEntry<Policy>) => string; | ||
| handleSave: (params: {policyID: string; email: string; currentFinalApprover: string | null; connectionSyncProgress?: OnyxEntry<PolicyConnectionSyncProgress>}) => void; | ||
| }; | ||
|
|
||
| type HRFinalApproverPageBaseProps = { | ||
| policyID: string; | ||
| config: HRFinalApproverProviderConfig; | ||
| }; | ||
|
|
||
| function HRFinalApproverPageBase({policyID, config}: HRFinalApproverPageBaseProps) { | ||
| const styles = useThemeStyles(); | ||
| const {isBetaEnabled} = usePermissions(); | ||
| const policy = usePolicy(policyID); | ||
| const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`); | ||
| const finalApprover = config.getCurrentFinalApprover(policy); | ||
| const providerName = config.getProviderName(policy); | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.CONTROL]} | ||
| policyID={policyID} | ||
| featureName={CONST.POLICY.MORE_FEATURES.IS_HR_ENABLED} | ||
| shouldBeBlocked={!isBetaEnabled(config.beta) || (!!policy && !config.isConnected(policy))} | ||
| > | ||
| <ScreenWrapper | ||
| enableEdgeToEdgeBottomSafeAreaPadding | ||
| style={[styles.defaultModalContainer]} | ||
| testID={config.testID} | ||
| shouldEnableMaxHeight | ||
| > | ||
| <HeaderWithBackButton | ||
| title={config.getHeaderTitle(providerName)} | ||
| onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_HR.getRoute(policyID))} | ||
| /> | ||
| <WorkspaceMembersSelectionList | ||
| policyID={policyID} | ||
| selectedApprover={finalApprover ?? ''} | ||
| setApprover={(email) => { | ||
| config.handleSave({policyID, email, currentFinalApprover: finalApprover, connectionSyncProgress}); | ||
| Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(ROUTES.WORKSPACE_HR.getRoute(policyID))); | ||
| }} | ||
| /> | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| ); | ||
| } | ||
|
|
||
| export type {HRFinalApproverProviderConfig}; | ||
| export default HRFinalApproverPageBase; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| import React from 'react'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {updateMergeHRFinalApprover} from '@libs/actions/connections/MergeHR'; | ||
| import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import {getConnectedHRProvider, isMergeHRConnected} from '@libs/PolicyUtils'; | ||
| import HRFinalApproverPageBase from '@pages/workspace/hr/HRFinalApproverPageBase'; | ||
| import type {HRFinalApproverProviderConfig} from '@pages/workspace/hr/HRFinalApproverPageBase'; | ||
| import CONST from '@src/CONST'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
|
|
||
|
|
@@ -18,22 +17,22 @@ function MergeHRFinalApproverPage({ | |
| }, | ||
| }: MergeHRFinalApproverPageProps) { | ||
| const {translate} = useLocalize(); | ||
| const {isBetaEnabled} = usePermissions(); | ||
|
|
||
| const config: HRFinalApproverProviderConfig = { | ||
| testID: 'MergeHRFinalApproverPage', | ||
| beta: CONST.BETAS.MERGE_HR, | ||
| isConnected: isMergeHRConnected, | ||
| getCurrentFinalApprover: (policy) => policy?.connections?.merge_hris?.config?.finalApprover ?? null, | ||
| getProviderName: (policy) => getConnectedHRProvider(policy)?.displayName ?? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY.merge_hris, | ||
|
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.
Using Useful? React with 👍 / 👎.
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. a user should only have one HR integration connected
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. wondering about the case when a policy deletes one connection and adds a second, do we have both objects |
||
| getHeaderTitle: (providerName) => translate('workspace.hr.providerFinalApprover', providerName), | ||
| handleSave: ({policyID: id, email, currentFinalApprover}) => updateMergeHRFinalApprover(id, email, currentFinalApprover), | ||
| }; | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.CONTROL]} | ||
| <HRFinalApproverPageBase | ||
| policyID={policyID} | ||
| featureName={CONST.POLICY.MORE_FEATURES.IS_HR_ENABLED} | ||
| shouldBeBlocked={!isBetaEnabled(CONST.BETAS.MERGE_HR)} | ||
| > | ||
| <ScreenWrapper testID="MergeHRFinalApproverPage"> | ||
| <HeaderWithBackButton | ||
| title={translate('workspace.hr.finalApprover')} | ||
| onBackButtonPress={() => Navigation.goBack()} | ||
| /> | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| config={config} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
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.
should the error be
.finalApprovertooThere 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.
fixed