Skip to content

Commit

Permalink
refactor: move search, help, secrets, connected services URLs to top …
Browse files Browse the repository at this point in the history
…level
  • Loading branch information
ciyer committed Jan 30, 2025
1 parent 378869c commit 10d3e35
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 61 deletions.
6 changes: 1 addition & 5 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ 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 @@ -122,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 @@ -133,7 +129,7 @@ function CentralContentContainer({ user, socket }) {
</CompatRoute>
)}
<Route path="/*">
<LazyNotFound />
<LazyRootV2 />
</Route>
</Switch>
</div>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/navbar/NavBarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export function RenkuToolbarItemUser({
}

const userSecretsUrl = isV2
? ABSOLUTE_ROUTES.v2.secrets
? ABSOLUTE_ROUTES.secrets
: ABSOLUTE_ROUTES.v1.secrets;

return (
Expand Down Expand Up @@ -345,7 +345,7 @@ export function RenkuToolbarItemUser({
{isV2 && (
<>
<Link
to={ABSOLUTE_ROUTES.v2.connectedServices}
to={ABSOLUTE_ROUTES.connectedServices}
className="dropdown-item"
>
Integrations
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.connectedServices}>
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.connectedServices}>
connected services
</Link>
.
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.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.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
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
8 changes: 2 additions & 6 deletions client/src/features/rootV2/NavbarV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function NavbarItemHelp() {
<Link
data-cy="help-link"
className="dropdown-item"
to={ABSOLUTE_ROUTES.v2.help.root}
to={ABSOLUTE_ROUTES.v2.root}
>
Help
</Link>
Expand Down Expand Up @@ -187,11 +187,7 @@ export default function NavbarV2() {
navbar
>
<NavItem>
<RenkuNavLinkV2
end
to={ABSOLUTE_ROUTES.v2.search}
title="Search"
>
<RenkuNavLinkV2 end to={ABSOLUTE_ROUTES.search} title="Search">
<Search className="bi" /> Search
</RenkuNavLinkV2>
</NavItem>
Expand Down
8 changes: 4 additions & 4 deletions client/src/features/rootV2/RootV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ export default function RootV2() {
element={<ProjectsV2Routes />}
/>
<Route
path={RELATIVE_ROUTES.v2.help.root}
path={RELATIVE_ROUTES.help.root}
element={
<ContainerWrap>
<HelpV2Routes />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v2.search}
path={RELATIVE_ROUTES.search}
element={
<ContainerWrap>
<LazySearchV2 />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v2.connectedServices}
path={RELATIVE_ROUTES.connectedServices}
element={
<ContainerWrap>
<LazyConnectedServicesPage />
</ContainerWrap>
}
/>
<Route
path={RELATIVE_ROUTES.v2.secrets}
path={RELATIVE_ROUTES.secrets}
element={
<ContainerWrap>
<LazySecretsV2 />
Expand Down
4 changes: 2 additions & 2 deletions client/src/features/searchV2/components/SearchV2Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function SearchV2Bar() {
const { searchBarQuery } = useAppSelector(({ searchV2 }) => searchV2);
const navigate = useNavigate();
const location = useLocation();
const isSearchPage = location.pathname === ABSOLUTE_ROUTES.v2.search;
const isSearchPage = location.pathname === ABSOLUTE_ROUTES.search;

const { register, handleSubmit, setFocus, setValue } = useForm<SearchBarForm>(
{
Expand All @@ -50,7 +50,7 @@ export default function SearchV2Bar() {
q: `type:project ${data.searchBarQuery}`,
});
navigate({
pathname: ABSOLUTE_ROUTES.v2.search,
pathname: ABSOLUTE_ROUTES.search,
search: search.toString(),
});
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/landing/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function FooterNavbarAnonymousLinks() {
function FooterNavbarLoggedInLinks({ location, privacyLink }) {
const helpLocation =
location && location.pathname.startsWith("/v2")
? ABSOLUTE_ROUTES.v2.help.root
? ABSOLUTE_ROUTES.help.root
: Url.pages.help.base;
return (
<>
Expand Down Expand Up @@ -157,7 +157,7 @@ function FooterNavbarInner({ location }) {
const isRenkuV1 = isRenkuLegacy(location.pathname);
const releaseLocation = isRenkuV1
? ABSOLUTE_ROUTES.v1.help.release
: ABSOLUTE_ROUTES.v2.help.release;
: ABSOLUTE_ROUTES.help.release;

const footer = (
<footer className={cx("text-body", "bg-body")} data-bs-theme="navy">
Expand Down
44 changes: 22 additions & 22 deletions client/src/routing/routes.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

export const ABSOLUTE_ROUTES = {
root: "/",
help: {
root: "/help",
contact: "/help/contact",
status: "/help/status",
release: "/help/release",
tos: "/help/tos",
privacy: "/help/privacy",
},
search: "/search",
connectedServices: "/connected-services",
secrets: "/secrets",
v2: {
root: "/v2",
user: "/v2/user",
Expand All @@ -42,17 +53,6 @@ export const ABSOLUTE_ROUTES = {
},
showById: "/v2/p/:id",
},
help: {
root: "/v2/help",
contact: "/v2/help/contact",
status: "/v2/help/status",
release: "/v2/help/release",
tos: "/v2/help/tos",
privacy: "/v2/help/privacy",
},
search: "/v2/search",
connectedServices: "/v2/connected-services",
secrets: "/v2/secrets",
},
v1: {
root: "/v1",
Expand Down Expand Up @@ -81,6 +81,17 @@ export const RELATIVE_ROUTES = {
root: "/",
datasets: "/datasets",
projects: "/projects",
help: {
root: "help/*",
contact: "contact",
status: "status",
release: "release",
tos: "tos",
privacy: "privacy",
},
search: "search",
connectedServices: "connected-services",
secrets: "secrets",
v1: {
root: "v1/*",
projects: {
Expand Down Expand Up @@ -125,16 +136,5 @@ export const RELATIVE_ROUTES = {
},
showById: ":id",
},
help: {
root: "help/*",
contact: "contact",
status: "status",
release: "release",
tos: "tos",
privacy: "privacy",
},
search: "search",
connectedServices: "connected-services",
secrets: "secrets",
},
} as const;
8 changes: 4 additions & 4 deletions tests/cypress/e2e/connectedServicesV2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Interact with Connected services", () => {
});

it("Shows an empty page when no services are available", () => {
cy.visit("/v2/connected-services");
cy.visit("/connected-services");
cy.getDataCy("connected-services-page").should(
"contain.text",
"There are currently no external services"
Expand All @@ -36,7 +36,7 @@ describe("Interact with Connected services", () => {

it("Connect GitHub user", () => {
fixtures.listConnectedServicesProviders();
cy.visit("/v2/connected-services");
cy.visit("/connected-services");
cy.getDataCy("connected-services-card").should("have.length", 2);
cy.getDataCy("connected-services-card").contains("GitHub.com");
cy.getDataCy("connected-services-card")
Expand All @@ -49,7 +49,7 @@ describe("Interact with Connected services", () => {
// ? Instead of clicking the Connect link, we just load the connection.
fixtures.listConnectedServicesConnections();
cy.reload();
cy.visit("/v2/connected-services");
cy.visit("/connected-services");
cy.getDataCy("connected-services-card")
.filter(`:contains("GitHub.com")`)
.contains("Connected");
Expand All @@ -64,7 +64,7 @@ describe("Interact with Connected services", () => {
.listConnectedServicesConnections()
.listConnectedServicesAccount()
.listConnectedServicesInstallations({ empty: true });
cy.visit("/v2/connected-services");
cy.visit("/connected-services");

cy.getDataCy("connected-services-card")
.should("contain", "@my-github-user")
Expand Down
4 changes: 2 additions & 2 deletions tests/cypress/e2e/dashboardV2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("View v2 landing page", () => {
.listManyGroupV2()
.listManyProjectV2()
.readProjectV2ById();
cy.visit("/v2");
cy.visit("/");
});

it("view dashboard", () => {
Expand Down Expand Up @@ -100,7 +100,7 @@ describe("View v2 landing page empty", () => {
beforeEach(() => {
fixtures.config().versions().userTest().namespaces();
fixtures.projects().landingUserProjects().readProjectV2ById();
cy.visit("/v2");
cy.visit("/");
});

it("view dashboard", () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/cypress/e2e/searchV2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Search V2", () => {

it("Load the page and search", () => {
fixtures.searchV2ListProjects({ numberOfProjects: 5, numberOfUsers: 0 });
cy.visit("/v2/search");
cy.visit("/search");

cy.getDataCy("search-input").type("test{enter}");
cy.getDataCy("search-header").contains("5 results for");
Expand All @@ -34,7 +34,7 @@ describe("Search V2", () => {

it("Updates the search parameters", () => {
fixtures.searchV2ListProjects({ numberOfProjects: 5, numberOfUsers: 2 });
cy.visit("/v2/search");
cy.visit("/search");
cy.getDataCy("search-input").type("type:project test{enter}");

cy.getDataCy("search-filter-type-project")
Expand All @@ -54,7 +54,7 @@ describe("Search V2", () => {

it("Updates the search sorting", () => {
fixtures.searchV2ListProjects();
cy.visit("/v2/search");
cy.visit("/search");
cy.getDataCy("search-input").type("sort:name-asc test{enter}");
cy.getDataCy("search-header").contains("sort:name-asc");

Expand Down

0 comments on commit 10d3e35

Please sign in to comment.