Skip to content

Commit 74ad8c8

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 29cee0d commit 74ad8c8

36 files changed

+297
-413
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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ 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";
@@ -46,7 +45,6 @@ import {
4645
FooterNavbar,
4746
RenkuNavBar,
4847
} from "./features/landing/components/NavBar/NavBar";
49-
import LazyNotFound from "./not-found/LazyNotFound";
5048
import NotificationsManager from "./notifications/NotificationsManager";
5149
import Cookie from "./privacy/Cookie";
5250
import LazyProjectView from "./project/LazyProjectView";
@@ -83,7 +81,7 @@ function CentralContentContainer({ user }) {
8381
element={
8482
user.logged ? (
8583
<ContainerWrap fullSize={true}>
86-
<LazyDashboardV2 />
84+
<LazyRootV2 />
8785
</ContainerWrap>
8886
) : (
8987
<div className="w-100">
@@ -116,10 +114,14 @@ function CentralContentContainer({ user }) {
116114
/>
117115
<Route
118116
path="/datasets"
119-
element={<Navigate to={`${ABSOLUTE_ROUTES.v1.search}?type=dataset`} replace />}
117+
element={
118+
<Navigate
119+
to={`${ABSOLUTE_ROUTES.v1.search}?type=dataset`}
120+
replace
121+
/>
122+
}
120123
/>
121124
<Route path="/v1/*" element={<LazyRootV1 />} />
122-
<Route path="/v2/*" element={<LazyRootV2 />} />
123125
{userInfo?.isLoggedIn && userInfo.is_admin && (
124126
<Route
125127
path="/admin"
@@ -130,7 +132,7 @@ function CentralContentContainer({ user }) {
130132
}
131133
/>
132134
)}
133-
<Route path="*" element={<LazyNotFound />} />
135+
<Route path="/*" element={<LazyRootV2 />} />
134136
</Routes>
135137
</div>
136138
);

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";
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
@@ -575,16 +575,20 @@ function ViewAllLink({
575575
noItems: boolean;
576576
total: number;
577577
}) {
578+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
578579
return noItems ? (
579580
<Link
580-
to={`/v2/search?page=1&perPage=12&q=type:${type}`}
581+
to={{ pathname: searchUrl, search: "q=type:${type}" }}
581582
data-cy={`view-other-${type}s-btn`}
582583
>
583584
View other {type === "project" ? "projects" : "groups"}
584585
</Link>
585586
) : (
586587
<Link
587-
to={`/v2/search?page=1&perPage=12&q=role:owner,editor,viewer+type:${type}+sort:created-desc`}
588+
to={{
589+
pathname: searchUrl,
590+
search: `q=role:owner,editor,viewer+type:${type}+sort:created-desc`,
591+
}}
588592
data-cy={`view-my-${type}s-btn`}
589593
>
590594
View all my {total > 5 ? total : ""}{" "}
@@ -594,6 +598,7 @@ function ViewAllLink({
594598
}
595599

596600
function EmptyProjectsButtons() {
601+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
597602
return (
598603
<div className={cx("d-flex", "gap-3")}>
599604
<Link
@@ -604,7 +609,7 @@ function EmptyProjectsButtons() {
604609
Create my first project
605610
</Link>
606611
<Link
607-
to={"/v2/search?page=1&perPage=12&q=type:project"}
612+
to={{ pathname: searchUrl, search: "q=type:project" }}
608613
className={cx("btn", "btn-outline-primary")}
609614
>
610615
<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)