Commit 67b1660
authored
fix: navigate to config from the project page (#1424)
# Fix Config Button Navigation to Settings Sidebar
## Problem
Clicking the **Config** button in the project navigation bar resulted in
a 404 error instead of opening the project settings sidebar.
**Steps to Reproduce:**
1. Open the home page (Dashboard)
2. Click on any project to navigate to `/projects/{projectId}/explorer`
3. Click the **Config** button in the top navigation
4. **Expected:** Navigate to `/projects/{projectId}/explorer/settings`
and open settings sidebar
5. **Actual:** Navigate to `/projects/{projectId}/settings` → 404 error,
`projectId` becomes `undefined`
## Root Cause
The navigation issue occurred during the React Router redirect
transition. When navigating from the dashboard to a project:
1. The route initially lands at `/projects/{projectId}` (index route)
2. React Router then redirects to `/projects/{projectId}/explorer`
3. During this transition, if the Config button was clicked, the
`useNavigateWithSettings` hook would capture the base path as
`/projects/{projectId}` (without `/explorer`)
4. This resulted in navigating to `/projects/{projectId}/settings`
instead of `/projects/{projectId}/explorer/settings`
5. Since no route exists for `/projects/{projectId}/settings` directly,
the app returned a 404 error
## Solution
Modified `src/utilities/navigation.ts` in the `useNavigateWithSettings`
function to intelligently detect and handle project index routes:
- **Detection:** Added regex pattern to detect when the base path
matches `/projects/{projectId}` without a specific page
- **Default Behavior:** When navigating to settings from the project
index route (without `/explorer`, `/sessions`, or `/deployments`),
automatically append `/explorer/` before the settings path
- **Result:** Ensures navigation always produces
`/projects/{projectId}/explorer/settings` instead of
`/projects/{projectId}/settings`
## What type of PR is this? (check all applicable)
- [ ] 💡 (feat) - A new feature (non-breaking change which adds
functionality)
- [ ] 🔄 (refactor) - Code Refactoring - A code change that neither fixes
a bug nor adds a feature
- [x] 🐞 (fix) - Bug Fix (non-breaking change which fixes an issue)
- [ ] 🏎 (perf) - Optimization
- [ ] 📄 (docs) - Documentation - Documentation only changes
- [ ] 📄 (test) - Tests - Adding missing tests or correcting existing
tests
- [ ] ⚙️ (ci) - Continuous Integrations - Changes to our CI
configuration files and scripts (example scopes: Travis, Circle,
BrowserStack, SauceLabs)
- [ ] ☑️ (chore) - Chores - Other changes that don't modify src or test
files
- [ ] ↩️ (revert) - Reverts - Reverts a previous commit(s).
<!--
For a timely review/response, please avoid force-pushing additional
commits if your PR already received reviews or comments.
Before submitting a Pull Request, please ensure you've done the
following:
- 👷♀️ Create small PRs. In most cases this will be possible.
- ✅ Provide tests for your changes.
- 📝 Use descriptive commit messages (as described below).
- 📗 Update any related documentation and include any relevant
screenshots.
Commit Message Structure (all lower-case):
<type>(optional ticket number): <description>
[optional body]
-->1 parent bbbc793 commit 67b1660
File tree
4 files changed
+15
-7
lines changed- e2e/project
- triggers
- src
- utilities
4 files changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 93 | | |
98 | 94 | | |
99 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
54 | 65 | | |
55 | 66 | | |
56 | 67 | | |
| |||
0 commit comments