Skip to content

Commit

Permalink
refactor: adopt typed v2-centric URL scheme (#3504)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciyer authored Feb 5, 2025
1 parent 9b32170 commit d5dd04b
Show file tree
Hide file tree
Showing 34 changed files with 281 additions and 418 deletions.
6 changes: 0 additions & 6 deletions client/scripts/generate_sitemap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ tee > "${OUTPUT_FILE}" << EOF
<url>
<loc>${BASE_URL}/help</loc>
</url>
<url>
<loc>${BASE_URL}/help/docs</loc>
</url>
<url>
<loc>${BASE_URL}/help/features</loc>
</url>
<url>
<loc>${BASE_URL}/help/status</loc>
</url>
Expand Down
9 changes: 2 additions & 7 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ import LazyDatasetAddToProject from "./dataset/addtoproject/LazyDatasetAddToProj
import { DatasetCoordinator } from "./dataset/Dataset.state";
import LazyShowDataset from "./dataset/LazyShowDataset";
import LazyAdminPage from "./features/admin/LazyAdminPage";
import LazyDashboardV2 from "./features/dashboardV2/LazyDashboardV2";
import { Favicon } from "./features/favicon/Favicon";
import { Unavailable } from "./features/maintenance/Maintenance";
import LazyRootV1 from "./features/rootV1/LazyRootV1";
import LazyRootV2 from "./features/rootV2/LazyRootV2";
import { useGetUserQuery } from "./features/usersV2/api/users.api";
import LazyAnonymousHome from "./landing/LazyAnonymousHome";
import { FooterNavbar, RenkuNavBar } from "./landing/NavBar";
import LazyNotFound from "./not-found/LazyNotFound";
import NotificationsManager from "./notifications/NotificationsManager";
import Cookie from "./privacy/Cookie";
import LazyProjectView from "./project/LazyProjectView";
Expand Down Expand Up @@ -83,7 +81,7 @@ function CentralContentContainer({ user, socket }) {
<CompatRoute exact path="/">
{user.logged ? (
<ContainerWrap fullSize={true}>
<LazyDashboardV2 />
<LazyRootV2 />
</ContainerWrap>
) : (
<div className="w-100">
Expand Down Expand Up @@ -123,9 +121,6 @@ function CentralContentContainer({ user, socket }) {
<CompatRoute path="/v1">
<LazyRootV1 user={user} />
</CompatRoute>
<CompatRoute path="/v2">
<LazyRootV2 />
</CompatRoute>
{userInfo?.isLoggedIn && userInfo.is_admin && (
<CompatRoute path="/admin">
<ContainerWrap>
Expand All @@ -134,7 +129,7 @@ function CentralContentContainer({ user, socket }) {
</CompatRoute>
)}
<Route path="/*">
<LazyNotFound />
<LazyRootV2 />
</Route>
</Switch>
</div>
Expand Down

This file was deleted.

154 changes: 0 additions & 154 deletions client/src/components/earlyAccessBanner/EarlyAccessBanner.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/components/navbar/AnonymousNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
RenkuToolbarItemUser,
RenkuToolbarNotifications,
} from "./NavBarItems";
import { RENKU_LOGO } from "./navbar.constans";
import { RENKU_LOGO } from "./navbar.constants";

export default function AnonymousNavBar() {
const { params, model, notifications } = useContext(AppContext);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/navbar/LoggedInNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
RenkuToolbarItemUser,
RenkuToolbarNotifications,
} from "./NavBarItems";
import { RENKU_LOGO } from "./navbar.constans";
import { RENKU_LOGO } from "./navbar.constants";

export default function LoggedInNavBar() {
const { params, model, notifications } = useContext(AppContext);
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 @@ -345,7 +345,7 @@ export function RenkuToolbarItemUser({
{isV2 && (
<>
<Link
to={ABSOLUTE_ROUTES.v2.connectedServices}
to={ABSOLUTE_ROUTES.v2.integrations}
className="dropdown-item"
>
Integrations
Expand Down
13 changes: 8 additions & 5 deletions client/src/error-boundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import * as Sentry from "@sentry/react";
import cx from "classnames";
import { ReactNode, useCallback } from "react";
import { useLocation } from "react-router-dom-v5-compat";
import { ArrowLeft } from "react-bootstrap-icons";
import { StyleHandler } from "../index";
import rkOopsImg from "../styles/assets/oops.svg";
import rkOopsV2Img from "../styles/assets/oopsV2.svg";
import useLegacySelector from "../utils/customHooks/useLegacySelector.hook";
import { isRenkuLegacy } from "../utils/helpers/HelperFunctionsV2";

interface AppErrorBoundaryProps {
children?: ReactNode;
Expand Down Expand Up @@ -52,7 +54,8 @@ export function AppErrorBoundary({ children }: AppErrorBoundaryProps) {
}

function ErrorPage() {
const isV2 = location.pathname.startsWith("/v2");
const location = useLocation();
const isLegacy = isRenkuLegacy(location.pathname);
const logged = useLegacySelector((state) => state.stateModel.user.logged);
return (
<>
Expand All @@ -61,10 +64,10 @@ function ErrorPage() {
className={cx("d-flex", "flex-column", "align-items-center", "mt-5")}
>
<div className={cx("p-4")}>
<img src={isV2 ? rkOopsV2Img : rkOopsImg} />
<img src={isLegacy ? rkOopsImg : rkOopsV2Img} />
<h3
className={cx(
isV2 ? "text-primary" : "text-rk-green",
isLegacy ? "text-rk-green" : "text-primary",
"fw-bold",
"mt-3"
)}
Expand All @@ -77,7 +80,7 @@ function ErrorPage() {
<a
className={cx(
"btn",
isV2 ? "btn-outline-primary" : "btn-outline-rk-green",
isLegacy ? "btn-outline-rk-green" : "btn-outline-primary",
"m-2"
)}
href={window.location.href}
Expand All @@ -89,7 +92,7 @@ function ErrorPage() {
<a
className={cx(
"btn",
isV2 ? "btn-primary" : "btn-rk-green",
isLegacy ? "btn-rk-green" : "btn-primary",
"m-2"
)}
href="/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ function RepositoryPermissionsAlert({
<p className={cx("mt-1", "mb-0", "fst-italic")}>
Your user account is not currently connected to{" "}
{provider.display_name}. See{" "}
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
connected services
</Link>
.
Expand All @@ -819,7 +819,7 @@ function RepositoryPermissionsAlert({
<p className={cx("mt-1", "mb-0", "fst-italic")}>
Your user account is not currently connected to{" "}
{provider.display_name}. See{" "}
<Link to={ABSOLUTE_ROUTES.v2.connectedServices}>
<Link to={ABSOLUTE_ROUTES.v2.integrations}>
connected services
</Link>
.
Expand Down
11 changes: 8 additions & 3 deletions client/src/features/dashboardV2/DashboardV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,20 @@ function ViewAllLink({
noItems: boolean;
total: number;
}) {
const searchUrl = ABSOLUTE_ROUTES.v2.search;
return noItems ? (
<Link
to={`/v2/search?page=1&perPage=12&q=type:${type}`}
to={{ pathname: searchUrl, search: "q=type:${type}" }}
data-cy={`view-other-${type}s-btn`}
>
View other {type === "project" ? "projects" : "groups"}
</Link>
) : (
<Link
to={`/v2/search?page=1&perPage=12&q=role:owner,editor,viewer+type:${type}+sort:created-desc`}
to={{
pathname: searchUrl,
search: `q=role:owner,editor,viewer+type:${type}+sort:created-desc`,
}}
data-cy={`view-my-${type}s-btn`}
>
View all my {total > 5 ? total : ""}{" "}
Expand All @@ -586,6 +590,7 @@ function ViewAllLink({
}

function EmptyProjectsButtons() {
const searchUrl = ABSOLUTE_ROUTES.v2.search;
return (
<div className={cx("d-flex", "gap-3")}>
<Link
Expand All @@ -596,7 +601,7 @@ function EmptyProjectsButtons() {
Create my first project
</Link>
<Link
to={"/v2/search?page=1&perPage=12&q=type:project"}
to={{ pathname: searchUrl, search: "q=type:project" }}
className={cx("btn", "btn-outline-primary")}
>
<Eye className={cx("bi", "me-1")} />
Expand Down
7 changes: 5 additions & 2 deletions client/src/features/groupsV2/new/GroupNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ function GroupV2CreationDetails() {
}
}, [result, navigate]);

const url = "renkulab.io/v2/groups/";
const groupPath = generatePath(ABSOLUTE_ROUTES.v2.groups.show.root, {
slug: "",
});
const parentPath = `${groupPath}/`;

const resetUrl = useCallback(() => {
setValue("slug", slugFromTitle(currentName, true, true), {
Expand Down Expand Up @@ -188,7 +191,7 @@ function GroupV2CreationDetails() {
errors={errors}
name="slug"
resetFunction={resetUrl}
url={url}
parentPath={parentPath}
slug={currentSlug}
dirtyFields={dirtyFields}
label="Group URL"
Expand Down
Loading

0 comments on commit d5dd04b

Please sign in to comment.