Skip to content

Commit cc5a777

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 9b32170 commit cc5a777

34 files changed

+281
-418
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: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ import LazyDatasetAddToProject from "./dataset/addtoproject/LazyDatasetAddToProj
3737
import { DatasetCoordinator } from "./dataset/Dataset.state";
3838
import LazyShowDataset from "./dataset/LazyShowDataset";
3939
import LazyAdminPage from "./features/admin/LazyAdminPage";
40-
import LazyDashboardV2 from "./features/dashboardV2/LazyDashboardV2";
4140
import { Favicon } from "./features/favicon/Favicon";
4241
import { Unavailable } from "./features/maintenance/Maintenance";
4342
import LazyRootV1 from "./features/rootV1/LazyRootV1";
4443
import LazyRootV2 from "./features/rootV2/LazyRootV2";
4544
import { useGetUserQuery } from "./features/usersV2/api/users.api";
4645
import LazyAnonymousHome from "./landing/LazyAnonymousHome";
4746
import { FooterNavbar, RenkuNavBar } from "./landing/NavBar";
48-
import LazyNotFound from "./not-found/LazyNotFound";
4947
import NotificationsManager from "./notifications/NotificationsManager";
5048
import Cookie from "./privacy/Cookie";
5149
import LazyProjectView from "./project/LazyProjectView";
@@ -83,7 +81,7 @@ function CentralContentContainer({ user, socket }) {
8381
<CompatRoute exact path="/">
8482
{user.logged ? (
8583
<ContainerWrap fullSize={true}>
86-
<LazyDashboardV2 />
84+
<LazyRootV2 />
8785
</ContainerWrap>
8886
) : (
8987
<div className="w-100">
@@ -123,9 +121,6 @@ function CentralContentContainer({ user, socket }) {
123121
<CompatRoute path="/v1">
124122
<LazyRootV1 user={user} />
125123
</CompatRoute>
126-
<CompatRoute path="/v2">
127-
<LazyRootV2 />
128-
</CompatRoute>
129124
{userInfo?.isLoggedIn && userInfo.is_admin && (
130125
<CompatRoute path="/admin">
131126
<ContainerWrap>
@@ -134,7 +129,7 @@ function CentralContentContainer({ user, socket }) {
134129
</CompatRoute>
135130
)}
136131
<Route path="/*">
137-
<LazyNotFound />
132+
<LazyRootV2 />
138133
</Route>
139134
</Switch>
140135
</div>

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 & 154 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
@@ -792,7 +792,7 @@ function RepositoryPermissionsAlert({
792792
<p className={cx("mt-1", "mb-0", "fst-italic")}>
793793
Your user account is not currently connected to{" "}
794794
{provider.display_name}. See{" "}
795-
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
795+
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
796796
connected services
797797
</Link>
798798
.
@@ -819,7 +819,7 @@ function RepositoryPermissionsAlert({
819819
<p className={cx("mt-1", "mb-0", "fst-italic")}>
820820
Your user account is not currently connected to{" "}
821821
{provider.display_name}. See{" "}
822-
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
822+
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
823823
connected services
824824
</Link>
825825
.

client/src/features/dashboardV2/DashboardV2.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,20 @@ function ViewAllLink({
567567
noItems: boolean;
568568
total: number;
569569
}) {
570+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
570571
return noItems ? (
571572
<Link
572-
to={`/v2/search?page=1&perPage=12&q=type:${type}`}
573+
to={{ pathname: searchUrl, search: "q=type:${type}" }}
573574
data-cy={`view-other-${type}s-btn`}
574575
>
575576
View other {type === "project" ? "projects" : "groups"}
576577
</Link>
577578
) : (
578579
<Link
579-
to={`/v2/search?page=1&perPage=12&q=role:owner,editor,viewer+type:${type}+sort:created-desc`}
580+
to={{
581+
pathname: searchUrl,
582+
search: `q=role:owner,editor,viewer+type:${type}+sort:created-desc`,
583+
}}
580584
data-cy={`view-my-${type}s-btn`}
581585
>
582586
View all my {total > 5 ? total : ""}{" "}
@@ -586,6 +590,7 @@ function ViewAllLink({
586590
}
587591

588592
function EmptyProjectsButtons() {
593+
const searchUrl = ABSOLUTE_ROUTES.v2.search;
589594
return (
590595
<div className={cx("d-flex", "gap-3")}>
591596
<Link
@@ -596,7 +601,7 @@ function EmptyProjectsButtons() {
596601
Create my first project
597602
</Link>
598603
<Link
599-
to={"/v2/search?page=1&perPage=12&q=type:project"}
604+
to={{ pathname: searchUrl, search: "q=type:project" }}
600605
className={cx("btn", "btn-outline-primary")}
601606
>
602607
<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
@@ -159,7 +159,10 @@ function GroupV2CreationDetails() {
159159
}
160160
}, [result, navigate]);
161161

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

164167
const resetUrl = useCallback(() => {
165168
setValue("slug", slugFromTitle(currentName, true, true), {
@@ -188,7 +191,7 @@ function GroupV2CreationDetails() {
188191
errors={errors}
189192
name="slug"
190193
resetFunction={resetUrl}
191-
url={url}
194+
parentPath={parentPath}
192195
slug={currentSlug}
193196
dirtyFields={dirtyFields}
194197
label="Group URL"

0 commit comments

Comments
 (0)