(
(state) => state.stateModel.user.logged
);
@@ -731,9 +729,7 @@ function RepositoryPermissionsAlert({
? "connected"
: "not-connected";
- const loginUrl = Url.get(Url.pages.login.link, {
- pathname: location.pathname,
- });
+ const loginUrl = useLoginUrl();
if (error && isNotFound) {
const color = permissions.pull ? "warning" : "danger";
@@ -771,8 +767,8 @@ function RepositoryPermissionsAlert({
{!userLogged ? (
- You need to log in to perform pushes on
- git repositories.
+ You need to log in to perform pushes
+ on git repositories.
) : provider && status === "not-connected" ? (
@@ -798,8 +794,8 @@ function RepositoryPermissionsAlert({
{!userLogged ? (
- You need to log in to perform pushes on
- git repositories.
+ You need to log in to perform pushes
+ on git repositories.
) : provider && status === "not-connected" ? (
diff --git a/client/src/features/session/components/SessionSaveWarning.tsx b/client/src/features/session/components/SessionSaveWarning.tsx
index 1d2dce9a14..f59e829f09 100644
--- a/client/src/features/session/components/SessionSaveWarning.tsx
+++ b/client/src/features/session/components/SessionSaveWarning.tsx
@@ -18,11 +18,10 @@
import cx from "classnames";
import { useCallback, useContext, useState } from "react";
-import { useLocation } from "react-router";
-import { Link } from "react-router-dom";
import { Button, Modal } from "reactstrap";
import { ACCESS_LEVELS } from "../../../api-client";
+import { useLoginUrl } from "../../../authentication/useLoginUrl.hook";
import { InfoAlert } from "../../../components/Alert";
import { ExternalLink } from "../../../components/ExternalLinks";
import { User } from "../../../model/renkuModels.types";
@@ -31,11 +30,8 @@ import { ForkProject } from "../../../project/new";
import { Docs } from "../../../utils/constants/Docs";
import AppContext from "../../../utils/context/appContext";
import useLegacySelector from "../../../utils/customHooks/useLegacySelector.hook";
-import { Url } from "../../../utils/helpers/url";
export default function SessionSaveWarning() {
- const location = useLocation();
-
const logged = useLegacySelector(
(state) => state.stateModel.user.logged
);
@@ -43,11 +39,9 @@ export default function SessionSaveWarning() {
(state) => state.stateModel.project.metadata
);
- if (!logged) {
- const loginUrl = Url.get(Url.pages.login.link, {
- pathname: location.pathname,
- });
+ const loginUrl = useLoginUrl();
+ if (!logged) {
return (
@@ -62,9 +56,12 @@ export default function SessionSaveWarning() {
, but you cannot save your work.
-
+
Log in
- {" "}
+ {" "}
for full access.
diff --git a/client/src/features/session/components/StartNewSession.tsx b/client/src/features/session/components/StartNewSession.tsx
index d21bc219d5..993e7d68d8 100644
--- a/client/src/features/session/components/StartNewSession.tsx
+++ b/client/src/features/session/components/StartNewSession.tsx
@@ -26,10 +26,10 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import cx from "classnames";
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { Redirect, useLocation } from "react-router";
-import { Link } from "react-router-dom";
import { Button, Col, DropdownItem, Form, Modal, Row } from "reactstrap";
import { ACCESS_LEVELS } from "../../../api-client";
+import { useLoginUrl } from "../../../authentication/useLoginUrl.hook";
import { InfoAlert, RenkuAlert, WarnAlert } from "../../../components/Alert";
import { ExternalLink } from "../../../components/ExternalLinks";
import { Loader } from "../../../components/Loader";
@@ -54,8 +54,8 @@ import useAppSelector from "../../../utils/customHooks/useAppSelector.hook";
import useLegacySelector from "../../../utils/customHooks/useLegacySelector.hook";
import { isFetchBaseQueryError } from "../../../utils/helpers/ApiErrors";
import { Url } from "../../../utils/helpers/url";
-import { getProvidedSensitiveFields } from "../../project/utils/projectCloudStorage.utils";
import { useCoreSupport } from "../../project/useProjectCoreSupport";
+import { getProvidedSensitiveFields } from "../../project/utils/projectCloudStorage.utils";
import { useStartSessionMutation } from "../sessions.api";
import startSessionSlice, {
setError,
@@ -542,8 +542,6 @@ function SessionCreateLink() {
}
function SessionSaveWarning() {
- const location = useLocation();
-
const logged = useLegacySelector(
(state) => state.stateModel.user.logged
);
@@ -551,11 +549,9 @@ function SessionSaveWarning() {
(state) => state.stateModel.project.metadata
);
- if (!logged) {
- const loginUrl = Url.get(Url.pages.login.link, {
- pathname: location.pathname,
- });
+ const loginUrl = useLoginUrl();
+ if (!logged) {
return (
@@ -570,9 +566,12 @@ function SessionSaveWarning() {
, but you cannot save your work.
-
+
Log in
- {" "}
+ {" "}
for full access.
diff --git a/client/src/features/usersV2/show/UserRedirect.tsx b/client/src/features/usersV2/show/UserRedirect.tsx
index 1b508d71f7..0377e7f0a9 100644
--- a/client/src/features/usersV2/show/UserRedirect.tsx
+++ b/client/src/features/usersV2/show/UserRedirect.tsx
@@ -20,19 +20,14 @@ import { skipToken } from "@reduxjs/toolkit/query";
import cx from "classnames";
import { useEffect } from "react";
import { ArrowLeft, BoxArrowInRight } from "react-bootstrap-icons";
-import {
- Link,
- generatePath,
- useLocation,
- useNavigate,
-} from "react-router-dom-v5-compat";
+import { Link, generatePath, useNavigate } from "react-router-dom-v5-compat";
import { Col, Row } from "reactstrap";
+import { useLoginUrl } from "../../../authentication/useLoginUrl.hook";
import { Loader } from "../../../components/Loader";
import ContainerWrap from "../../../components/container/ContainerWrap";
import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants";
import useLegacySelector from "../../../utils/customHooks/useLegacySelector.hook";
-import { Url } from "../../../utils/helpers/url";
import UserNotFound from "../../projectsV2/notFound/UserNotFound";
import { useGetUserQuery } from "../../user/dataServicesUser.api";
@@ -72,11 +67,7 @@ export default function UserRedirect() {
}
function NotLoggedIn() {
- const location = useLocation();
-
- const loginUrl = Url.get(Url.pages.login.link, {
- pathname: location.pathname,
- });
+ const loginUrl = useLoginUrl();
return (
@@ -86,10 +77,13 @@ function NotLoggedIn() {
You can only view your own user page if you are logged in.
-
+
Log in
-
+
diff --git a/client/src/landing/HeroLanding/HeroLanding.tsx b/client/src/landing/HeroLanding/HeroLanding.tsx
index b44f1311f2..18d0b8b03b 100644
--- a/client/src/landing/HeroLanding/HeroLanding.tsx
+++ b/client/src/landing/HeroLanding/HeroLanding.tsx
@@ -1,9 +1,11 @@
import cx from "classnames";
-import { Link } from "react-router-dom";
import { Button } from "reactstrap";
+
+import { useLoginUrl } from "../../authentication/useLoginUrl.hook";
import { HomeHeader } from "../AnonymousHome";
import heroGraphic from "../Graphics/hero_graph.svg";
import { AnonymousHomeConfig } from "../anonymousHome.types";
+
import styles from "./HeroLanding.module.scss";
interface HeroLandingProps extends AnonymousHomeConfig {
@@ -12,6 +14,8 @@ interface HeroLandingProps extends AnonymousHomeConfig {
export default function HeroLanding(props: HeroLandingProps) {
const { scrollToGetStarted } = props;
+ const loginUrl = useLoginUrl();
+
return (
@@ -50,14 +54,13 @@ export default function HeroLanding(props: HeroLandingProps) {
>
Try it out
-
Create an account
-
+
diff --git a/client/src/landing/anonymousHomeNav.tsx b/client/src/landing/anonymousHomeNav.tsx
index fc89315bd5..61cc61fc17 100644
--- a/client/src/landing/anonymousHomeNav.tsx
+++ b/client/src/landing/anonymousHomeNav.tsx
@@ -21,6 +21,8 @@ import React from "react";
import { List } from "react-bootstrap-icons";
import { Link } from "react-router-dom";
import { Button, Col, Collapse, Nav, Navbar, NavItem, Row } from "reactstrap";
+
+import { useLoginUrl } from "../authentication/useLoginUrl.hook";
import { ExternalLink } from "../components/ExternalLinks";
import { Docs, Links, RenkuPythonDocs } from "../utils/constants/Docs";
import { Url } from "../utils/helpers/url";
@@ -157,6 +159,9 @@ function TopNavLink({ title, to }: BottomNavLinkProps) {
function TopNav() {
const [isOpen, setIsOpen] = React.useState(false);
const toggleOpen = () => setIsOpen(!isOpen);
+
+ const loginUrl = useLoginUrl();
+
return (
<>
@@ -173,14 +178,13 @@ function TopNav() {
-
Login
-
+