mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
Route instead of Redirect from empty bug to 404 after a hint from GM #10
This commit is contained in:
parent
ec8a9b2069
commit
46d38aa53f
37
return-404-page.patch
Normal file
37
return-404-page.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
diff --git a/webui/src/App.tsx b/webui/src/App.tsx
|
||||||
|
index 3e8f71e..4fd0993 100644
|
||||||
|
--- a/webui/src/App.tsx
|
||||||
|
+++ b/webui/src/App.tsx
|
||||||
|
@@ -11,7 +11,6 @@ export default function App() {
|
||||||
|
<Layout>
|
||||||
|
<Switch>
|
||||||
|
<Route path="/" exact component={ListPage} />
|
||||||
|
- <Route path="/404bug" exact component={NotFoundPage} />
|
||||||
|
<Route path="/bug/:id" exact component={BugPage} />
|
||||||
|
<Route component={NotFoundPage} />
|
||||||
|
</Switch>
|
||||||
|
diff --git a/webui/src/pages/bug/BugQuery.tsx b/webui/src/pages/bug/BugQuery.tsx
|
||||||
|
index ade64e9..5d459c4 100644
|
||||||
|
--- a/webui/src/pages/bug/BugQuery.tsx
|
||||||
|
+++ b/webui/src/pages/bug/BugQuery.tsx
|
||||||
|
@@ -1,8 +1,10 @@
|
||||||
|
import React from 'react';
|
||||||
|
-import { Redirect, RouteComponentProps } from 'react-router-dom';
|
||||||
|
+import { RouteComponentProps } from 'react-router-dom';
|
||||||
|
|
||||||
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||||
|
|
||||||
|
+import NotFoundPage from '../notfound/NotFoundPage';
|
||||||
|
+
|
||||||
|
import Bug from './Bug';
|
||||||
|
import { useGetBugQuery } from './BugQuery.generated';
|
||||||
|
|
||||||
|
@@ -15,7 +17,7 @@ const BugQuery: React.FC<Props> = ({ match }: Props) => {
|
||||||
|
variables: { id: match.params.id },
|
||||||
|
});
|
||||||
|
if (loading) return <CircularProgress />;
|
||||||
|
- if (!data?.repository?.bug) return <Redirect to="/404bug" />;
|
||||||
|
+ if (!data?.repository?.bug) return <NotFoundPage />;
|
||||||
|
if (error) return <p>Error: {error}</p>;
|
||||||
|
return <Bug bug={data.repository.bug} />;
|
||||||
|
};
|
@ -13,7 +13,6 @@ export default function App() {
|
|||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/" exact component={ListPage} />
|
<Route path="/" exact component={ListPage} />
|
||||||
<Route path="/new" exact component={NewBugPage} />
|
<Route path="/new" exact component={NewBugPage} />
|
||||||
<Route path="/404bug" exact component={NotFoundPage} />
|
|
||||||
<Route path="/bug/:id" exact component={BugPage} />
|
<Route path="/bug/:id" exact component={BugPage} />
|
||||||
<Route component={NotFoundPage} />
|
<Route component={NotFoundPage} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Redirect, RouteComponentProps } from 'react-router-dom';
|
import { RouteComponentProps } from 'react-router-dom';
|
||||||
|
|
||||||
import CircularProgress from '@material-ui/core/CircularProgress';
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||||
|
|
||||||
|
import NotFoundPage from '../notfound/NotFoundPage';
|
||||||
|
|
||||||
import Bug from './Bug';
|
import Bug from './Bug';
|
||||||
import { useGetBugQuery } from './BugQuery.generated';
|
import { useGetBugQuery } from './BugQuery.generated';
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ const BugQuery: React.FC<Props> = ({ match }: Props) => {
|
|||||||
variables: { id: match.params.id },
|
variables: { id: match.params.id },
|
||||||
});
|
});
|
||||||
if (loading) return <CircularProgress />;
|
if (loading) return <CircularProgress />;
|
||||||
if (!data?.repository?.bug) return <Redirect to="/404bug" />;
|
if (!data?.repository?.bug) return <NotFoundPage />;
|
||||||
if (error) return <p>Error: {error}</p>;
|
if (error) return <p>Error: {error}</p>;
|
||||||
return <Bug bug={data.repository.bug} />;
|
return <Bug bug={data.repository.bug} />;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user