Skip to content

Commit

Permalink
Merge pull request #53520 from twilight2294/patch-13
Browse files Browse the repository at this point in the history
Fix: App back button returns to the same page after clicking back button on Import RHP
  • Loading branch information
arosiclair authored Dec 31, 2024
2 parents c4b3297 + 900cb38 commit d89be5f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/ImportSpreadsheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Text from './Text';

type ImportSpreedsheetProps = {
// The route to navigate to when the back button is pressed.
backTo: Routes;
backTo?: Routes;

// The route to navigate to after the file import is completed.
goTo: Routes;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/categories/ImportCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function ImportCategoriesPage({route}: ImportCategoriesPageProps) {
fullPageNotFoundViewProps={{subtitleKey: isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized', onLinkPress: PolicyUtils.goBackFromInvalidPolicy}}
>
<ImportSpreadsheet
backTo={isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyID, backTo) : ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)}
backTo={backTo}
goTo={isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_IMPORTED.getRoute(policyID, backTo) : ROUTES.WORKSPACE_CATEGORIES_IMPORTED.getRoute(policyID)}
/>
</AccessOrNotFoundWrapper>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
Modal.close(() => setIsOfflineModalVisible(true));
return;
}
Navigation.navigate(isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_IMPORT.getRoute(policyId, backTo) : ROUTES.WORKSPACE_CATEGORIES_IMPORT.getRoute(policyId));
Navigation.navigate(
isQuickSettingsFlow
? ROUTES.SETTINGS_CATEGORIES_IMPORT.getRoute(policyId, ROUTES.SETTINGS_CATEGORIES_ROOT.getRoute(policyId, backTo))
: ROUTES.WORKSPACE_CATEGORIES_IMPORT.getRoute(policyId),
);
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/ImportTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function ImportTagsPage({route}: ImportTagsPageProps) {
fullPageNotFoundViewProps={{subtitleKey: isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized', onLinkPress: PolicyUtils.goBackFromInvalidPolicy}}
>
<ImportSpreadsheet
backTo={isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID, backTo) : ROUTES.WORKSPACE_TAGS.getRoute(policyID)}
backTo={backTo}
goTo={isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_IMPORTED.getRoute(policyID, backTo) : ROUTES.WORKSPACE_TAGS_IMPORTED.getRoute(policyID)}
/>
</AccessOrNotFoundWrapper>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
const [isDownloadFailureModalVisible, setIsDownloadFailureModalVisible] = useState(false);
const [isDeleteTagsConfirmModalVisible, setIsDeleteTagsConfirmModalVisible] = useState(false);
const [isOfflineModalVisible, setIsOfflineModalVisible] = useState(false);
const policyID = route.params.policyID;
const isFocused = useIsFocused();
const policyID = route.params.policyID ?? '-1';
const backTo = route.params.backTo;
const policy = usePolicy(policyID);
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`);
Expand Down Expand Up @@ -302,7 +302,11 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
Modal.close(() => setIsOfflineModalVisible(true));
return;
}
Navigation.navigate(isQuickSettingsFlow ? ROUTES.SETTINGS_TAGS_IMPORT.getRoute(policyID, backTo) : ROUTES.WORKSPACE_TAGS_IMPORT.getRoute(policyID));
Navigation.navigate(
isQuickSettingsFlow
? ROUTES.SETTINGS_TAGS_IMPORT.getRoute(policyID, ROUTES.SETTINGS_TAGS_ROOT.getRoute(policyID, backTo))
: ROUTES.WORKSPACE_TAGS_IMPORT.getRoute(policyID),
);
},
},
];
Expand Down

0 comments on commit d89be5f

Please sign in to comment.