Skip to content

Commit

Permalink
refactor: move legacy URLs to new locations (#3505)
Browse files Browse the repository at this point in the history
* /help -> /v1/help
* /inactive-kg-projects -> /v1/inactive-kg-projects
* /notifications -> /v1/notifications
* /projects/new/ -> /v1/projects/new
* /projects -> /v1/projects/ (project listing/GitLab search, urls for project pages are unchanged)
* /projects/all -> /v1/projects/all
* /projects/starred -> /v1/projects/starred
* /search -> /v1/search
  • Loading branch information
ciyer authored Jan 31, 2025
1 parent 814ef0f commit 75b525d
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 95 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,21 @@ flowchart LR
subgraph L1
A(/)-->DA(/datasets)
A-->HE(/help)
A-->LOOUT(/logout)
A-->LOGOUT(/logout)
A-->PR(/projects)
A-->SEA(/search)
A-->SE(/sessions)
A-->V1(/v1)
end
subgraph L2
PR-->PR1(/new)
PR-->PRID(/:id)
DA-->DAID(/:id)
HE-->HE1(/changes)
HE-->HE2(/docs)
HE-->HE3(/features)
HE-->HE4(/status)
V1-->V1_HE(/help)
V1-->V1_PR_NEW(/projects/new)
end
subgraph L3
PRID-->PRID1(/overview)
Expand Down
17 changes: 2 additions & 15 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ import LazyNotFound from "./not-found/LazyNotFound";
import NotificationsManager from "./notifications/NotificationsManager";
import Cookie from "./privacy/Cookie";
import LazyProjectView from "./project/LazyProjectView";
import LazyProjectList from "./project/list/LazyProjectList";
import LazyNewProject from "./project/new/LazyNewProject";
import { ABSOLUTE_ROUTES } from "./routing/routes.constants";
import AppContext from "./utils/context/appContext";
import useLegacySelector from "./utils/customHooks/useLegacySelector.hook";
import { setupWebSocket } from "./websocket";
Expand Down Expand Up @@ -92,18 +91,6 @@ function CentralContentContainer({ user, socket }) {
</div>
)}
</CompatRoute>
{["/projects", "/projects/starred", "/projects/all"].map((path) => (
<CompatRoute key={path} exact path={path}>
<ContainerWrap>
<LazyProjectList />
</ContainerWrap>
</CompatRoute>
))}
<CompatRoute exact path="/projects/new">
<ContainerWrap>
<LazyNewProject />
</ContainerWrap>
</CompatRoute>
<Route path="/projects/:subUrl+">
<LazyProjectView
client={client}
Expand Down Expand Up @@ -131,7 +118,7 @@ function CentralContentContainer({ user, socket }) {
/>
</CompatRoute>
<CompatRoute path="/datasets">
<Redirect to="/search?type=dataset" />
<Redirect to={`${ABSOLUTE_ROUTES.v1.search}?type=dataset`} />
</CompatRoute>
<CompatRoute path="/v1">
<LazyRootV1 user={user} />
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/navbar/NavBarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function RenkuToolbarItemPlus() {
<Link
className="dropdown-item"
id="navbar-project-new"
to="/projects/new"
to={ABSOLUTE_ROUTES.v1.projects.new}
>
Project
</Link>
Expand Down
14 changes: 7 additions & 7 deletions client/src/components/quicknav/QuickNav.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export const defaultSuggestionQuickBar = {
type: "fixed",
path: "",
id: "link-projects",
url: "/search",
url: "/v1/search",
label: "My Projects",
icon: "/project-icon.svg",
},
{
type: "fixed",
path: "",
id: "link-datasets",
url: "/search",
url: "/v1/search",
label: "My datasets",
icon: "/dataset-icon.svg",
},
Expand All @@ -57,15 +57,15 @@ export const defaultAnonymousSuggestionQuickBar = {
type: "fixed",
path: "",
id: "link-projects",
url: "/search",
url: "/v1/search",
label: "Projects",
icon: "/project-icon.svg",
},
{
type: "fixed",
path: "",
id: "link-datasets",
url: "/search",
url: "/v1/search",
label: "Datasets",
icon: "/dataset-icon.svg",
},
Expand Down Expand Up @@ -98,7 +98,7 @@ export function QuickNavContainer({ user }) {
type: "last-queries",
path: "",
id: "last-queries",
url: "/search",
url: "/v1/search",
label: query,
query,
});
Expand Down Expand Up @@ -132,8 +132,8 @@ export function QuickNavContainer({ user }) {
e.preventDefault();
setPhrase(currentPhrase);
refetchLastQueries(e.currentTarget);
if (location.pathname === "/search") return;
navigate("/search");
if (location.pathname === "/v1/search") return;
navigate("/v1/search");
};

const onSuggestionsFetchRequested = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { Link } from "react-router-dom";

import { WarnAlert } from "../../../components/Alert";
import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants";
import useAppSelector from "../../../utils/customHooks/useAppSelector.hook";
import useLegacySelector from "../../../utils/customHooks/useLegacySelector.hook";
import { useGetInactiveKgProjectsQuery } from "../../inactiveKgProjects/InactiveKgProjectsApi";
Expand All @@ -38,7 +39,7 @@ function InactiveProjectsWarning({
<WarnAlert>
<div data-cy="inactive-kg-project-alert">
Metadata indexing is not activated on {totalProjectsText}.{" "}
<Link to="/inactive-kg-projects">
<Link to={ABSOLUTE_ROUTES.v1.inactiveKGProjects}>
Activate indexing on your projects
</Link>{" "}
to properly integrate them with Renku.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ function ProjectAlert({ total }: ProjectAlertProps) {
<ExternalLink
role="text"
title="create a new project"
url="/projects/new"
url="/v1/projects/new"
className="fw-bold"
/>
,{" "}
<ExternalLink
role="text"
title="explore other projects"
url="/search"
url="/v1/search"
className="fw-bold"
/>{" "}
or{" "}
<ExternalLink
role="text"
title="search"
url="/search"
url="/v1/search"
className="fw-bold"
/>{" "}
for a specific project or dataset.
Expand Down
71 changes: 71 additions & 0 deletions client/src/features/rootV1/ProjectRootV1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*!
* Copyright 2025 - Swiss Data Science Center (SDSC)
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
* Eidgenössische Technische Hochschule Zürich (ETHZ).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

import { Route, Routes } from "react-router-dom-v5-compat";
import ContainerWrap from "../../components/container/ContainerWrap";
import LazyNotFound from "../../not-found/LazyNotFound";
import LazyProjectList from "../../project/list/LazyProjectList";
import LazyNewProject from "../../project/new/LazyNewProject";
import { RELATIVE_ROUTES } from "../../routing/routes.constants";

export default function RootV1() {
return (
<Routes>
<Route
index
element={
<ContainerWrap>
<LazyProjectList />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v1.projects.starred}
element={
<ContainerWrap>
<LazyProjectList />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v1.projects.all}
element={
<ContainerWrap>
<LazyProjectList />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v1.projects.new}
element={
<ContainerWrap>
<LazyNewProject />
</ContainerWrap>
}
/>
<Route
path="*"
element={
<ContainerWrap>
<LazyNotFound />
</ContainerWrap>
}
/>
</Routes>
);
}
10 changes: 10 additions & 0 deletions client/src/features/rootV1/RootV1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import LazySearchPage from "../kgSearch/LazySearchPage";
import LazySecrets from "../secrets/LazySecrets";
import LazyAnonymousSessionsList from "../session/components/LazyAnonymousSessionsList";

import ProjectRootV1 from "./ProjectRootV1";

export default function RootV1({
user,
}: {
Expand Down Expand Up @@ -101,6 +103,14 @@ export default function RootV1({
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v1.projects.root}
element={
<ContainerWrap>
<ProjectRootV1 />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v1.sessions}
element={
Expand Down
23 changes: 14 additions & 9 deletions client/src/landing/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

import cx from "classnames";
import { useContext } from "react";
import { Link, Route, Switch, useLocation } from "react-router-dom";
import { Switch } from "react-router-dom";
import { Link, Route, useLocation } from "react-router-dom-v5-compat";

import { ExternalDocsLink } from "../components/ExternalLinks";
import AnonymousNavBar from "../components/navbar/AnonymousNavBar";
Expand Down Expand Up @@ -94,9 +95,11 @@ function FooterNavbarAnonymousLinks() {
}

function FooterNavbarLoggedInLinks({ privacyLink }) {
const helpLocation = location.pathname.startsWith("/v2")
? ABSOLUTE_ROUTES.v2.help.root
: Url.pages.help;
const location = useLocation();
const helpLocation =
location && location.pathname.startsWith("/v2")
? ABSOLUTE_ROUTES.v2.help.root
: Url.pages.help.base;
return (
<>
<RenkuNavLink to={helpLocation} title="Help" />
Expand All @@ -121,12 +124,11 @@ function FooterNavbarLoggedInLinks({ privacyLink }) {
}

function FooterNavbar() {
const location = useLocation();

return <FooterNavbarInner location={location} />;
return <FooterNavbarInner />;
}

function FooterNavbarInner({ location }) {
function FooterNavbarInner() {
const location = useLocation();
const projectMetadata = useLegacySelector(
(state) => state.stateModel.project?.metadata
);
Expand Down Expand Up @@ -190,7 +192,10 @@ function FooterNavbarInner({ location }) {
location.pathname === Url.get(Url.pages.landing) ? (
<FooterNavbarAnonymousLinks />
) : (
<FooterNavbarLoggedInLinks privacyLink={privacyLink} />
<FooterNavbarLoggedInLinks
location={location}
privacyLink={privacyLink}
/>
)}
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions client/src/namespace/Namespace.present.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ import cx from "classnames";
import { ExternalLink } from "../components/ExternalLinks";
import { Loader } from "../components/Loader";
import NotFound from "../not-found/NotFound";
import { ABSOLUTE_ROUTES } from "../routing/routes.constants";

const fakeHistory = createMemoryHistory({
initialEntries: ["/"],
initialIndex: 0,
});
fakeHistory.push({
pathname: "/projects",
pathname: ABSOLUTE_ROUTES.v1.projects.root,
search: "?page=1",
});

const NamespaceProjects = (props) => {
const { namespace } = props;
// TODO: I should get the URLs from the redux store: #779
const searchUrl = "/projects/all";
const searchUrl = ABSOLUTE_ROUTES.v1.projects.all;
const searchProjectUrl = (project) => {
return `${searchUrl}?q=${project}`;
};
Expand Down
3 changes: 2 additions & 1 deletion client/src/not-found/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import cx from "classnames";
import { ReactNode } from "react";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom-v5-compat";

import { ArrowLeft } from "react-bootstrap-icons";
import ContainerWrap from "../components/container/ContainerWrap";
Expand All @@ -44,6 +44,7 @@ export default function NotFound({
description: description_,
children,
}: NotFoundProps) {
const location = useLocation();
const isV2 = !isRenkuLegacy(location.pathname);
const title = title_ ?? "Page not found";
const description =
Expand Down
Loading

0 comments on commit 75b525d

Please sign in to comment.