-
Notifications
You must be signed in to change notification settings - Fork 669
CONSOLE-4990: Replace history object navigation with useNavigate hook #15959
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
base: main
Are you sure you want to change the base?
CONSOLE-4990: Replace history object navigation with useNavigate hook #15959
Conversation
|
Skipping CI for Draft Pull Request. |
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhamilto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
frontend/packages/console-app/src/actions/providers/cronjob-provider.ts
Outdated
Show resolved
Hide resolved
frontend/packages/console-shared/src/components/dynamic-form/index.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/console-shared/src/components/quick-search/QuickSearchContent.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/console-shared/src/components/quick-search/QuickSearchDetails.tsx
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/edit-application/EditApplication.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-items.tsx
Outdated
Show resolved
Hide resolved
fab6845 to
4c78f4b
Compare
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
738897a to
b7a45bf
Compare
|
/assign @yapei |
574af25 to
6f1cc40
Compare
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
1 similar comment
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Update SummaryI've updated this PR to complete the migration of all remaining usage to : Key Changes in This Update:
Commit Organization:Each package now has its own commit for easier review and potential cherry-picking:
All changes follow the same migration patterns used throughout the codebase and are compatible with Ready for review! 🚀 |
6f1cc40 to
1f435ca
Compare
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Replace history object usage with useNavigate hook in console-app package. Changes: - cronjob-factory.ts: Converted to dependency injection pattern - cronjob-provider.ts: Use navigate in action creator - ClusterConfigurationPage.tsx: Replace history.push with navigate - Lightspeed.tsx: Replace history.push with navigate - clone-pvc-modal.tsx: Replace history.push with navigate - restore-pvc-modal.tsx: Replace history.push with navigate - PDBForm.tsx: Replace history.push with navigate - UserPreferencePage.tsx: Replace history.push with navigate - create-volume-snapshot.tsx: Replace history.push with navigate All changes: - Replaced history.push(path) with navigate(path) - Added useNavigate() hook calls - Updated imports to use react-router-dom-v5-compat Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace history object usage with useNavigate hook in console-shared package. Changes: - ActionMenuItem.tsx: Replace history.push with navigate - CatalogTile.tsx: Replace history.push with navigate - CatalogView.tsx: Replace history.push with navigate - catalog-utils.tsx: Accept NavigateFunction as parameter - dynamic-form/index.tsx: Replace history.goBack with navigate(-1) - error-boundary.tsx: Use key prop pattern for location reset - DeleteResourceModal.tsx: Replace history.push with navigate - MultiTabListPage.tsx: Replace history.push with navigate Migration patterns: - Components: Added useNavigate() hook - Utilities: Parameter injection for NavigateFunction - Class components: Key prop for location-based reset Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1f435ca to
6de24c7
Compare
|
Fixed the following issues from review feedback: Must-Fix (Blocking) ⛔
Should-Fix (Non-Blocking)
|
6de24c7 to
52a703f
Compare
Additional FixFound and fixed one more file that was missed:
This deprecated file is still actively used as a fallback form component when structural schemas have errors or no fields, so it needed to be migrated along with the rest of the operator-lifecycle-manager package. All changes have been squashed into the operator-lifecycle-manager commit. |
52a703f to
17b9aba
Compare
Commit Message UpdatedUpdated the operator-lifecycle-manager commit message (082ca63) to include the DEPRECATED_operand-form.tsx file that was added: All other commit messages have been verified to accurately reflect the files they contain. |
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
1 similar comment
|
@rhamilto: This pull request references CONSOLE-4990 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Replace history object usage with useNavigate hook in dev-console package. Changes: - AddCardItem.tsx: Pass navigate to navigateTo utility - EditBuildConfig.tsx: Replace history.push with navigate - EditDeployment.tsx: Replace history.push with navigate - EditApplication.tsx: Replace history.goBack with navigate(-1) - AddHealthChecks.tsx: Replace history.push with navigate - AddHealthChecksForm.tsx: Replace history.goBack with navigate(-1) - HPAFormikForm.tsx: Replace history.goBack with navigate(-1) - DeployImage.tsx: Pass navigate to handleRedirect - ImportForm.tsx: Pass navigate to handleRedirect - ImportSamplePage.tsx: Pass navigate to handleRedirect - import-submit-utils.ts: Accept NavigateFunction parameter - UploadJar.tsx: Replace history.goBack with navigate(-1) - useUploadJarFormToast.ts: Accept navigate as parameter - AddServerlessFunction.tsx: Replace history.goBack with navigate(-1) - jar-file-upload-utils.ts: Accept navigate as parameter - MonitoringPage.tsx: Replace history.push with navigate - ProjectDetailsPage.tsx: Replace history.push with navigate - add-page-utils.ts: Accept navigate as parameter All utility functions updated to use dependency injection pattern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace history object usage with useNavigate hook in knative-plugin package. Changes: - EventSink.tsx: Replace history.goBack with navigate(-1) - EventSource.tsx: Replace history.goBack with navigate(-1) - AddBroker.tsx: Replace history.goBack with navigate(-1) - AddChannel.tsx: Replace history.goBack with navigate(-1) - Subscribe.tsx: Replace history.push with navigate - FunctionDetailsPage.tsx: Replace history.push with navigate - CreateKnatifyPage.tsx: Replace history.goBack with navigate(-1) - create-eventsources-utils.ts: Accept NavigateFunction parameter All components updated to use useNavigate() hook. Utility function updated to use dependency injection pattern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace history object usage with useNavigate hook in helm-plugin package. Changes: - HelmReleaseDetailsPage.tsx: Replace history.push with navigate - CreateHelmChartRepository.tsx: Replace history.goBack with navigate(-1) - CreateHelmChartRepositoryPage.tsx: Replace history.push with navigate - HelmInstallUpgradePage.tsx: Replace history.push/goBack with navigate - HelmReleaseRollbackPage.tsx: Replace history.push/goBack with navigate All components updated to use useNavigate() hook from react-router-dom-v5-compat. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace history object usage with useNavigate hook in operator-lifecycle-manager package. Changes: - create-catalog-source.tsx: Replace history.goBack with navigate(-1) - operator-hub-items.tsx: Replace history.replace with navigate - operator-hub-subscribe.tsx: Replace history.push with navigate - install-plan.tsx: Replace history.push with navigate - uninstall-operator-modal.tsx: Replace history.push with navigate - operand-form.tsx: Replace history.push/replace/goBack with navigate - DEPRECATED_operand-form.tsx: Replace history.push/goBack with navigate - subscription.tsx: Replace history.push with navigate All components updated to use useNavigate() hook from react-router-dom-v5-compat. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace history object usage with useNavigate hook in remaining packages. Changes: - topology/ExportViewLogButton.tsx: Replace history.push with navigate - shipwright-plugin/EditBuild.tsx: Replace history.push/goBack with navigate - metal3-plugin/AddBareMetalHost.tsx: Replace history.push with navigate - metal3-plugin/AddBareMetalHostForm.tsx: Replace history.goBack with navigate(-1) - public/QuickCreate.tsx: Replace history.push with navigate - public/attach-storage.tsx: Remove unused history type definition All components updated to use useNavigate() hook from react-router-dom-v5-compat. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace `LocationDescriptor` and `Location` types from the history package with `To` and `Location` types from react-router-dom-v5-compat. This is part of the migration to programmatic navigation using React Router hooks instead of the history object. Changes: - Replace LocationDescriptor with To in console-types.ts (SDK) - Replace LocationDescriptor with To in delete-modal.tsx - Replace History.LocationDescriptor with To in LinkStatus.tsx - Replace Location import in telemetry.ts Breaking Change: The UseDeleteModal hook's redirectTo parameter type has changed from LocationDescriptor (history) to To (react-router-dom). Plugin developers should update their imports accordingly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
17b9aba to
057efc3
Compare
Test File RemovedRemoved
The test file has been reverted to its original state and is no longer part of this PR. |
|
/retest |
|
@rhamilto: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
It looks like we should not reload everything when switching between resource tabs(this issue is not reproducible on 4.22.0-0.ci-2026-02-09-205844) console-reload-on-switching-tabs.mov |
Summary
This PR completes the migration from the deprecated
historyobject to React Router'suseNavigatehook across all remaining packages in the OpenShift Console frontend.Changes
This PR migrates all remaining instances of the deprecated
historyobject to use theuseNavigatehook fromreact-router-dom-v5-compat, except for:public/components/app.tsx(will be handled in CONSOLE-4392)public/components/factory/modal.tsx(will be handled in CONSOLE-5012)Packages Migrated
console-app
useNavigatehookconsole-shared
useNavigatehookdev-console
ProjectAccess.tsx: Replacehistory.goBackwithnavigate(-1)ProjectAccess.spec.tsx: Updated test mocks (removed obsoletehistorymock, addeduseNavigatemock)knative-plugin
DeleteRevisionModalController.tsx: Replacehistory.push()withnavigate()helm-plugin
useNavigatehookoperator-lifecycle-manager
create-catalog-source.tsx: Replacehistory.goBackwithnavigate(-1)operator-hub-items.tsx: Replacehistory.replacewithnavigateoperator-hub-subscribe.tsx: Replacehistory.pushwithnavigateinstall-plan.tsx: Replacehistory.pushwithnavigateuninstall-operator-modal.tsx: Replacehistory.pushwithnavigateoperand-form.tsx: Replacehistory.push/replace/goBackwith navigate equivalentsDEPRECATED_operand-form.tsx: Replacehistory.push/goBackwith navigate equivalentssubscription.tsx: Replacehistory.pushwithnavigatemetal3-plugin
AddBareMetalHost.tsx: Replacehistory.push()withnavigate()public/components
attach-storage.tsx: Removed unusedhistory: Historytype definitionTest Updates
ProjectAccess.spec.tsxto remove the obsoletehistorymock and add properuseNavigatemockMigration Patterns Used
All migrations follow the established patterns:
history.push(path)→navigate(path)history.replace(path)→navigate(path, { replace: true })history.goBack()→navigate(-1)useNavigate()hook imports fromreact-router-dom-v5-compatCommit Structure
The commits are organized by package for easier review:
CONSOLE-4990: Migrate console-app to useNavigate hookCONSOLE-4990: Migrate console-shared to useNavigate hookCONSOLE-4990: Migrate dev-console to useNavigate hookCONSOLE-4990: Migrate knative-plugin to useNavigate hookCONSOLE-4990: Migrate helm-plugin to useNavigate hookCONSOLE-4990: Migrate operator-lifecycle-manager to useNavigate hookCONSOLE-4990: Migrate remaining packages to useNavigate hookCONSOLE-4990: Replace history types with React Router typesRelated Issues
Testing
useNavigate()hookCo-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com