Skip to content

Commit ccabf15

Browse files
committed
refactor: adopt typed v2-centric URL scheme (#3504)
* /v2/help -> /help * /v2/connected-services -> /integrations * /v2/groups -> /g * /v2/projects -> /p * /v2/search -> /search * /v2/secrets -> /secrets * /v2/user -> /user * /v2/users -> /u
1 parent 03ebde3 commit ccabf15

34 files changed

+289
-408
lines changed

client/scripts/generate_sitemap.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ tee > "${OUTPUT_FILE}" << EOF
3939
<url>
4040
<loc>${BASE_URL}/help</loc>
4141
</url>
42-
<url>
43-
<loc>${BASE_URL}/help/docs</loc>
44-
</url>
45-
<url>
46-
<loc>${BASE_URL}/help/features</loc>
47-
</url>
4842
<url>
4943
<loc>${BASE_URL}/help/status</loc>
5044
</url>

client/src/App.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ import LazyDatasetAddToProject from "./dataset/addtoproject/LazyDatasetAddToProj
3535
import { DatasetCoordinator } from "./dataset/Dataset.state";
3636
import LazyShowDataset from "./dataset/LazyShowDataset";
3737
import LazyAdminPage from "./features/admin/LazyAdminPage";
38-
import LazyDashboardV2 from "./features/dashboardV2/LazyDashboardV2";
3938
import { Favicon } from "./features/favicon/Favicon";
4039
import { Unavailable } from "./features/maintenance/Maintenance";
4140
import LazyRootV1 from "./features/rootV1/LazyRootV1";
4241
import LazyRootV2 from "./features/rootV2/LazyRootV2";
4342
import { useGetUserQuery } from "./features/usersV2/api/users.api";
4443
import LazyAnonymousHome from "./landing/LazyAnonymousHome";
4544
import { FooterNavbar, RenkuNavBar } from "./landing/NavBar";
46-
import LazyNotFound from "./not-found/LazyNotFound";
4745
import NotificationsManager from "./notifications/NotificationsManager";
4846
import Cookie from "./privacy/Cookie";
4947
import LazyProjectView from "./project/LazyProjectView";
@@ -84,7 +82,7 @@ function CentralContentContainer({ user, socket }) {
8482
element={
8583
props.user.logged ? (
8684
<ContainerWrap fullSize={true}>
87-
<LazyDashboardV2 />
85+
<LazyRootV2 />
8886
</ContainerWrap>
8987
) : (
9088
<div className="w-100">
@@ -124,7 +122,6 @@ function CentralContentContainer({ user, socket }) {
124122
element={<Navigate to={`${ABSOLUTE_ROUTES.v1.search}?type=dataset`} replace />}
125123
/>
126124
<Route path="/v1/*" element={<LazyRootV1 />} />
127-
<Route path="/v2/*" element={<LazyRootV2 />} />
128125
{userInfo?.isLoggedIn && userInfo.is_admin && (
129126
<Route
130127
path="/admin"
@@ -135,9 +132,10 @@ function CentralContentContainer({ user, socket }) {
135132
}
136133
/>
137134
)}
138-
<Route path="*" element={<LazyNotFound />} />
139-
</Routes>
140-
</AppContext.Provider>
135+
<Route path="/*">
136+
<LazyRootV2 />
137+
</Route>
138+
</Switch>
141139
</div>
142140
);
143141
}

client/src/components/earlyAccessBanner/EarlyAccessBanner.module.scss

Lines changed: 0 additions & 9 deletions
This file was deleted.

client/src/components/earlyAccessBanner/EarlyAccessBanner.tsx

Lines changed: 0 additions & 153 deletions
This file was deleted.

client/src/components/navbar/AnonymousNavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
RenkuToolbarItemUser,
3434
RenkuToolbarNotifications,
3535
} from "./NavBarItems";
36-
import { RENKU_LOGO } from "./navbar.constans";
36+
import { RENKU_LOGO } from "./navbar.constants";
3737

3838
export default function AnonymousNavBar() {
3939
const { params, model, notifications } = useContext(AppContext);

client/src/components/navbar/LoggedInNavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
RenkuToolbarItemUser,
3434
RenkuToolbarNotifications,
3535
} from "./NavBarItems";
36-
import { RENKU_LOGO } from "./navbar.constans";
36+
import { RENKU_LOGO } from "./navbar.constants";
3737

3838
export default function LoggedInNavBar() {
3939
const { params, model, notifications } = useContext(AppContext);

client/src/components/navbar/NavBarItems.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export function RenkuToolbarItemUser({
345345
{isV2 && (
346346
<>
347347
<Link
348-
to={ABSOLUTE_ROUTES.v2.connectedServices}
348+
to={ABSOLUTE_ROUTES.v2.integrations}
349349
className="dropdown-item"
350350
>
351351
Integrations

client/src/error-boundary/ErrorBoundary.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import * as Sentry from "@sentry/react";
2020
import cx from "classnames";
2121
import { ReactNode, useCallback } from "react";
22+
import { useLocation } from "react-router-dom-v5-compat";
2223
import { ArrowLeft } from "react-bootstrap-icons";
2324
import { StyleHandler } from "../index";
2425
import rkOopsImg from "../styles/assets/oops.svg";
2526
import rkOopsV2Img from "../styles/assets/oopsV2.svg";
2627
import useLegacySelector from "../utils/customHooks/useLegacySelector.hook";
28+
import { isRenkuLegacy } from "../utils/helpers/HelperFunctionsV2";
2729

2830
interface AppErrorBoundaryProps {
2931
children?: ReactNode;
@@ -52,7 +54,8 @@ export function AppErrorBoundary({ children }: AppErrorBoundaryProps) {
5254
}
5355

5456
function ErrorPage() {
55-
const isV2 = location.pathname.startsWith("/v2");
57+
const location = useLocation();
58+
const isLegacy = isRenkuLegacy(location.pathname);
5659
const logged = useLegacySelector((state) => state.stateModel.user.logged);
5760
return (
5861
<>
@@ -61,10 +64,10 @@ function ErrorPage() {
6164
className={cx("d-flex", "flex-column", "align-items-center", "mt-5")}
6265
>
6366
<div className={cx("p-4")}>
64-
<img src={isV2 ? rkOopsV2Img : rkOopsImg} />
67+
<img src={isLegacy ? rkOopsImg : rkOopsV2Img} />
6568
<h3
6669
className={cx(
67-
isV2 ? "text-primary" : "text-rk-green",
70+
isLegacy ? "text-rk-green" : "text-primary",
6871
"fw-bold",
6972
"mt-3"
7073
)}
@@ -77,7 +80,7 @@ function ErrorPage() {
7780
<a
7881
className={cx(
7982
"btn",
80-
isV2 ? "btn-outline-primary" : "btn-outline-rk-green",
83+
isLegacy ? "btn-outline-rk-green" : "btn-outline-primary",
8184
"m-2"
8285
)}
8386
href={window.location.href}
@@ -89,7 +92,7 @@ function ErrorPage() {
8992
<a
9093
className={cx(
9194
"btn",
92-
isV2 ? "btn-primary" : "btn-rk-green",
95+
isLegacy ? "btn-rk-green" : "btn-primary",
9396
"m-2"
9497
)}
9598
href="/"

client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ function RepositoryPermissionsAlert({
816816
<p className={cx("mt-1", "mb-0", "fst-italic")}>
817817
Your user account is not currently connected to{" "}
818818
{provider.display_name}. See{" "}
819-
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
819+
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
820820
connected services
821821
</Link>
822822
.
@@ -843,7 +843,7 @@ function RepositoryPermissionsAlert({
843843
<p className={cx("mt-1", "mb-0", "fst-italic")}>
844844
Your user account is not currently connected to{" "}
845845
{provider.display_name}. See{" "}
846-
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
846+
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
847847
connected services
848848
</Link>
849849
.

client/src/features/dashboardV2/DashboardV2.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,20 @@ function ViewAllLink({
569569
noItems: boolean;
570570
total: number;
571571
}) {
572+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
572573
return noItems ? (
573574
<Link
574-
to={`/v2/search?page=1&perPage=12&q=type:${type}`}
575+
to={{ pathname: searchUrl, search: "q=type:${type}" }}
575576
data-cy={`view-other-${type}s-btn`}
576577
>
577578
View other {type === "project" ? "projects" : "groups"}
578579
</Link>
579580
) : (
580581
<Link
581-
to={`/v2/search?page=1&perPage=12&q=role:owner,editor,viewer+type:${type}+sort:created-desc`}
582+
to={{
583+
pathname: searchUrl,
584+
search: `q=role:owner,editor,viewer+type:${type}+sort:created-desc`,
585+
}}
582586
data-cy={`view-my-${type}s-btn`}
583587
>
584588
View all my {total > 5 ? total : ""}{" "}
@@ -588,6 +592,7 @@ function ViewAllLink({
588592
}
589593

590594
function EmptyProjectsButtons() {
595+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
591596
return (
592597
<div className={cx("d-flex", "gap-3")}>
593598
<Link
@@ -598,7 +603,7 @@ function EmptyProjectsButtons() {
598603
Create my first project
599604
</Link>
600605
<Link
601-
to={"/v2/search?page=1&perPage=12&q=type:project"}
606+
to={{ pathname: searchUrl, search: "q=type:project" }}
602607
className={cx("btn", "btn-outline-primary")}
603608
>
604609
<Eye className={cx("bi", "me-1")} />

client/src/features/groupsV2/new/GroupNew.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ function GroupV2CreationDetails() {
160160
}
161161
}, [result, navigate]);
162162

163-
const url = "renkulab.io/v2/groups/";
163+
const groupPath = generatePath(ABSOLUTE_ROUTES.v2.groups.show.root, {
164+
slug: "",
165+
});
166+
const parentPath = `${groupPath}/`;
164167

165168
const resetUrl = useCallback(() => {
166169
setValue("slug", slugFromTitle(currentName, true, true), {
@@ -193,7 +196,7 @@ function GroupV2CreationDetails() {
193196
errors={errors}
194197
name="slug"
195198
resetFunction={resetUrl}
196-
url={url}
199+
parentPath={parentPath}
197200
slug={currentSlug}
198201
dirtyFields={dirtyFields}
199202
label="Group URL"

0 commit comments

Comments
 (0)