Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot]
196cd38018 chore: update versions (#3163)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/dashboard@2.17.0

### Minor Changes

-   fd59918: fix: redirect to 404 with nhost cli dashboard

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-27 18:39:50 +01:00
David BM
fd5991845b fix (dashboard): redirect 404 local, revert changes (#3162)
### **User description**
Revert to old `useNotFoundRedirect.ts` changes 

[d43931e](d43931e761)


___

### **PR Type**
Bug fix


___

### **Description**
- Simplified 404 redirect logic in useNotFoundRedirect hook

- Removed platform-specific checks and unused imports

- Updated conditions for redirecting to 404 page

- Added changeset for minor version bump


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>useNotFoundRedirect.ts</strong><dd><code>Simplify
useNotFoundRedirect hook logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>


dashboard/src/features/projects/common/hooks/useNotFoundRedirect/useNotFoundRedirect.ts

<li>Removed unused imports and variables<br> <li> Simplified redirect
conditions<br> <li> Removed platform-specific checks<br> <li> Updated
dependencies in useEffect hook


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/3162/files#diff-837279cf43199053bca09913f62c4af019063a2e8dc7bfb7643ec54b7cecd29d">+10/-39</a>&nbsp;
</td>

</tr>
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>quick-seahorses-draw.md</strong><dd><code>Add changeset
for 404 redirect fix</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

.changeset/quick-seahorses-draw.md

<li>Added changeset file for minor version bump<br> <li> Described fix
for 404 redirect in Nhost CLI dashboard


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/3162/files#diff-df782a89bb7c2193ff124ea1262479d2d492088f1bf865064ead79328913642c">+5/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-01-27 18:36:50 +01:00
3 changed files with 17 additions and 40 deletions

View File

@@ -1,5 +1,11 @@
# @nhost/dashboard
## 2.17.0
### Minor Changes
- fd59918: fix: redirect to 404 with nhost cli dashboard
## 2.16.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "2.16.0",
"version": "2.17.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",

View File

@@ -1,35 +1,17 @@
import { useIsPlatform } from '@/features/orgs/projects/common/hooks/useIsPlatform';
import { useCurrentOrg } from '@/features/orgs/projects/hooks/useCurrentOrg';
import { useProject } from '@/features/orgs/projects/hooks/useProject';
import { useCurrentWorkspaceAndProject } from '@/features/projects/common/hooks/useCurrentWorkspaceAndProject';
import { useRouter } from 'next/router';
import { useEffect } from 'react';
/**
* Redirects to 404 page if either currentWorkspace/currentProject resolves to undefined
* or if the current pathname is not a valid organization/project.
* Not applicable if running dashboard with local Nhost backend.
* Redirects to 404 page if either currentWorkspace/currentProject resolves to undefined.
*/
export default function useNotFoundRedirect() {
const router = useRouter();
const {
query: {
orgSlug: urlOrgSlug,
workspaceSlug: urlWorkspaceSlug,
appSubdomain: urlAppSubdomain,
updating,
appSlug: urlAppSlug,
},
query: { orgSlug, workspaceSlug, appSubdomain, updating, appSlug },
isReady,
} = router;
const { project, loading: projectLoading } = useProject();
const isPlatform = useIsPlatform();
const { org, loading: orgLoading } = useCurrentOrg();
const { subdomain: projectSubdomain } = project || {};
const { slug: currentOrgSlug } = org || {};
const { currentProject, currentWorkspace, loading } =
useCurrentWorkspaceAndProject();
@@ -41,10 +23,6 @@ export default function useNotFoundRedirect() {
!isReady ||
// If the current workspace and project are not loaded, we don't want to redirect to 404
loading ||
// If the project is loading, we don't want to redirect to 404
projectLoading ||
// If the org is loading, we don't want to redirect to 404
orgLoading ||
// If we're already on the 404 page, we don't want to redirect to 404
router.pathname === '/404' ||
router.pathname === '/' ||
@@ -53,14 +31,12 @@ export default function useNotFoundRedirect() {
router.pathname === '/run-one-click-install' ||
router.pathname.includes('/orgs/_') ||
router.pathname.includes('/orgs/_/projects/_') ||
(!isPlatform &&
router.pathname.includes('/orgs/[orgSlug]/projects/[appSubdomain]')) ||
(urlOrgSlug === currentOrgSlug && !urlAppSubdomain) ||
(urlOrgSlug === currentOrgSlug && urlAppSubdomain === projectSubdomain) ||
orgSlug ||
(orgSlug && appSubdomain) ||
// If we are on a valid workspace and project, we don't want to redirect to 404
(urlWorkspaceSlug && currentWorkspace && urlAppSlug && currentProject) ||
(workspaceSlug && currentWorkspace && appSlug && currentProject) ||
// If we are on a valid workspace and no project is selected, we don't want to redirect to 404
(urlWorkspaceSlug && currentWorkspace && !urlAppSlug && !currentProject)
(workspaceSlug && currentWorkspace && !appSlug && !currentProject)
) {
return;
}
@@ -71,16 +47,11 @@ export default function useNotFoundRedirect() {
currentWorkspace,
isReady,
loading,
urlAppSubdomain,
urlAppSlug,
appSubdomain,
appSlug,
router,
updating,
projectLoading,
orgLoading,
currentOrgSlug,
projectSubdomain,
urlWorkspaceSlug,
urlOrgSlug,
isPlatform,
workspaceSlug,
orgSlug,
]);
}