Skip to content
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: view your subscription link does not navigate to subscription page #48673

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) {
const canPerformUpgrade = !!feature && !!policy && PolicyUtils.isPolicyAdmin(policy);
const isUpgraded = React.useMemo(() => PolicyUtils.isControlPolicy(policy), [policy]);

const goBack = useCallback(() => {
if (!feature) {
return;
}
switch (feature.id) {
case CONST.UPGRADE_FEATURE_INTRO_MAPPING.reportFields.id:
case CONST.UPGRADE_FEATURE_INTRO_MAPPING.rules.id:
return Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID));
default:
return route.params.backTo ? Navigation.navigate(route.params.backTo) : Navigation.goBack();
}
}, [feature, policyID, route.params.backTo]);
Comment on lines +35 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #50924, I was only able to track this PR to origanting this minor bug, we did not handled CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id: here properly which caused selected approver to resetted when going back, more details in #50924 (comment)


const upgradeToCorporate = () => {
if (!canPerformUpgrade) {
return;
Expand All @@ -47,14 +60,13 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) {
switch (feature.id) {
case CONST.UPGRADE_FEATURE_INTRO_MAPPING.reportFields.id:
Policy.enablePolicyReportFields(policyID, true, true);
return Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID));
break;
case CONST.UPGRADE_FEATURE_INTRO_MAPPING.rules.id:
Policy.enablePolicyRules(policyID, true, true);
return Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID));
break;
default:
return route.params.backTo ? Navigation.navigate(route.params.backTo) : Navigation.goBack();
}
}, [feature, policyID, route.params.backTo]);
}, [feature, policyID]);

useEffect(() => {
const unsubscribeListener = navigation.addListener('blur', () => {
Expand All @@ -79,11 +91,21 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) {
>
<HeaderWithBackButton
title={translate('common.upgrade')}
onBackButtonPress={() => (isUpgraded ? Navigation.dismissModal() : Navigation.goBack())}
onBackButtonPress={() => {
if (isUpgraded) {
Navigation.dismissModal();
} else {
Navigation.goBack();
}
goBack();
}}
/>
{isUpgraded && (
<UpgradeConfirmation
onConfirmUpgrade={() => Navigation.dismissModal()}
onConfirmUpgrade={() => {
Navigation.dismissModal();
goBack();
}}
policyName={policy.name}
/>
)}
Expand Down
Loading