Skip to content

Commit

Permalink
refactor: adopt v2-centric URL scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
ciyer committed Jan 30, 2025
1 parent 3dbc386 commit b522811
Show file tree
Hide file tree
Showing 27 changed files with 209 additions and 402 deletions.
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
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
8 changes: 5 additions & 3 deletions client/src/features/dashboardV2/DashboardV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,17 @@ 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={`${searchUrl}?page=1&perPage=12&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={`${searchUrl}?page=1&perPage=12&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 +587,7 @@ function ViewAllLink({
}

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

const url = "renkulab.io/v2/groups/";
const url = "renkulab.io/g/";

const resetUrl = useCallback(() => {
setValue("slug", slugFromTitle(currentName, true, true), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default function GroupMetadataForm({ group }: GroupMetadataFormProps) {
errors={errors}
name={"slug"}
resetFunction={resetUrl}
url="renkulab.io/v2/groups/"
url="renkulab.io/g/"
/>
{errors.slug && dirtyFields.slug && (
<div className={cx("d-block", "invalid-feedback")}>
Expand Down
5 changes: 1 addition & 4 deletions client/src/features/platform/components/StatusBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ function StatusPageMaintenance({
);

const location = useLocation();
const isDashboard =
(userLogged && location.pathname === "/") ||
location.pathname === "/v2" ||
location.pathname === "/v2/";
const isDashboard = userLogged && location.pathname === "/";

// 1. There is a scheduled maintenance in < 48 hours: show it on all pages except the landing page
// 2. There is a scheduled maintenance in < 7 days: show it on the v1 Dashboard and the v2 Dashboard
Expand Down
12 changes: 10 additions & 2 deletions client/src/features/projectsV2/list/ProjectV2ListDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import { Badge, Card, CardBody, CardHeader, ListGroup } from "reactstrap";
import { Loader } from "../../../components/Loader";
import Pagination from "../../../components/Pagination";
import { RtkOrNotebooksError } from "../../../components/errors/RtkErrorAlert";
import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants";
import useGroupPermissions from "../../groupsV2/utils/useGroupPermissions.hook";
import PermissionsGuard from "../../permissionsV2/PermissionsGuard";
import { useGetUserQuery } from "../../usersV2/api/users.api";
import { NamespaceKind } from "../api/namespace.api";
import { useGetProjectsQuery } from "../api/projectV2.enhanced-api";
import { PROJECT_CREATION_HASH } from "../new/createProjectV2.constants";
import ProjectShortHandDisplay from "../show/ProjectShortHandDisplay";

const DEFAULT_PER_PAGE = 5;
Expand Down Expand Up @@ -221,7 +223,10 @@ function AddButtonForGroupNamespace({ namespace }: { namespace: string }) {
"ms-auto",
"my-auto"
)}
to="/v2/projects/new"
to={{
pathname: ABSOLUTE_ROUTES.v2.root,
hash: PROJECT_CREATION_HASH,
}}
>
<PlusLg className="bi" id="createPlus" />
</Link>
Expand All @@ -245,7 +250,10 @@ function AddButtonForUserNamespace({ namespace }: { namespace: string }) {
"ms-auto",
"my-auto"
)}
to="/v2/projects/new"
to={{
pathname: ABSOLUTE_ROUTES.v2.root,
hash: PROJECT_CREATION_HASH,
}}
>
<PlusLg className="bi" id="createPlus" />
</Link>
Expand Down
2 changes: 1 addition & 1 deletion client/src/features/projectsV2/new/ProjectV2New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function ProjectV2CreationDetails() {
});
}, [setValue, currentName]);

const url = `renkulab.io/v2/projects/${currentNamespace ?? "<Owner>"}/`;
const url = `renkulab.io/p/${currentNamespace ?? "<Owner>"}/`;

return (
<>
Expand Down
Loading

0 comments on commit b522811

Please sign in to comment.