Skip to content

Commit

Permalink
fix frontend generic paths (OBOFoundry/purl.obolibrary.org#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Jun 17, 2024
1 parent 3e5dfc0 commit 42fece9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import EntityPage from "./pages/ontologies/entities/EntityPage";
import { getEntity } from "./pages/ontologies/ontologiesSlice";
import Search from "./pages/search/Search";
import {Helmet} from "react-helmet";
import LoadingOverlay from "./components/LoadingOverlay";

class App extends React.Component {
render() {
Expand Down Expand Up @@ -100,6 +101,17 @@ export default App;
function RedirectToClasses() {
const params = useParams();
const [search] = useSearchParams();
const entityIri = search.get("iri")
if(entityIri) {
return (
<Navigate
to={{
pathname: `/ontologies/${params.ontologyId}/entities/${encodeURIComponent(encodeURIComponent(entityIri))}`,
search: search.toString(),
}}
/>
);
}
return (
<Navigate
to={{
Expand Down Expand Up @@ -138,14 +150,14 @@ function RedirectToType() {
to={{
pathname: `/ontologies/${
params.ontologyId
}/${entity.getTypePlural()}/${encodeURIComponent(
}/${entity.getTypePlural()}/${
encodeURIComponent(params.entityIri as string)
)}`,
}`,
search: search.toString(),
}}
/>
);
} else {
return <Home />;
return <LoadingOverlay />
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Header({ section }: { section?: string }) {
>
<Helmet>
<meta charSet="utf-8" />
<title>{caps(section)} - Ontology Lookup Service</title>
<title>{caps(section || 'Not Found')} - Ontology Lookup Service</title>
</Helmet>
<div className="container mx-auto px-4 flex flex-col md:flex-row md:gap-10">
<div className="py-6 self-center">
Expand Down

0 comments on commit 42fece9

Please sign in to comment.