Skip to content

Commit c114938

Browse files
improve error messages and explicitly mention loggin in to anonymous users
1 parent fc03256 commit c114938

File tree

1 file changed

+82
-49
lines changed

1 file changed

+82
-49
lines changed

client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx

Lines changed: 82 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { CommandCopy } from "~/components/commandCopy/CommandCopy";
5353
import RenkuBadge from "~/components/renkuBadge/RenkuBadge";
5454
import RepositoryGitLabWarnBadge from "~/features/legacy/RepositoryGitLabWarnBadge";
5555
import { useGetRepositoriesQuery } from "~/features/repositories/api/repositories.api";
56+
import { useGetUserQueryState } from "~/features/usersV2/api/users.api";
5657
import { ABSOLUTE_ROUTES } from "~/routing/routes.constants";
5758
import { ButtonWithMenuV2 } from "../../../../components/buttons/Button";
5859
import { RtkOrNotebooksError } from "../../../../components/errors/RtkErrorAlert";
@@ -503,7 +504,7 @@ export function RepositoryPermissionsBadge({
503504
? "Integration required"
504505
: !data?.metadata?.pull_permission &&
505506
data?.connection?.status === "connected"
506-
? "No access"
507+
? "Inaccessible"
507508
: !data?.metadata?.push_permission && !data?.provider?.id && hasWriteAccess
508509
? "Request integration"
509510
: !data?.metadata?.push_permission && !data?.provider?.id && !hasWriteAccess
@@ -713,6 +714,15 @@ function RepositoryView({
713714
);
714715
}
715716

717+
function LogInWarning() {
718+
return (
719+
<p className="mb-0">
720+
You need to be logged in to activate integrations and access private
721+
repositories.
722+
</p>
723+
);
724+
}
725+
716726
interface RepositoryCallToActionAlertProps {
717727
hasWriteAccess: boolean;
718728
repositoryUrl: string;
@@ -726,6 +736,11 @@ export function RepositoryCallToActionAlert({
726736
url: repositoryUrl,
727737
});
728738

739+
const { data: userInfo } = useGetUserQueryState();
740+
const anonymousUser = useMemo(() => {
741+
return userInfo && !userInfo?.isLoggedIn;
742+
}, [userInfo]);
743+
729744
const search = useMemo(() => {
730745
return `?${new URLSearchParams({
731746
targetProvider: data?.provider?.id ?? "",
@@ -750,50 +765,64 @@ export function RepositoryCallToActionAlert({
750765
Either the repository does not exist, or you do not have access to
751766
it.
752767
</p>
753-
<p className="mb-2">
754-
If you think you should have access, check your integration{" "}
755-
<span className="fst-italic">{data.provider.name}</span>.
756-
</p>
757-
<Link
758-
className={cx("btn", "btn-primary", "btn-sm")}
759-
to={{
760-
pathname: ABSOLUTE_ROUTES.v2.integrations,
761-
search,
762-
}}
763-
>
764-
<Plugin className={cx("bi", "me-1")} />
765-
View integration
766-
</Link>
768+
{anonymousUser ? (
769+
<LogInWarning />
770+
) : (
771+
<>
772+
<p className="mb-2">
773+
If you think you should have access, check your integration{" "}
774+
<span className="fst-italic">{data.provider.name}</span>.
775+
</p>
776+
<Link
777+
className={cx("btn", "btn-primary", "btn-sm")}
778+
to={{
779+
pathname: ABSOLUTE_ROUTES.v2.integrations,
780+
search,
781+
}}
782+
>
783+
<Plugin className={cx("bi", "me-1")} />
784+
View integration
785+
</Link>
786+
</>
787+
)}
767788
</>
768789
) : (
769790
<>
770-
<p>
791+
<p className={cx(!hasWriteAccess && "mb-0")}>
771792
The repository URL is invalid or points to a version control
772-
platform we currently do not support. Please verify the URL and
773-
check if the platform is in the currently supported{" "}
774-
<Link
775-
to={{
776-
pathname: ABSOLUTE_ROUTES.v2.integrations,
777-
search,
778-
}}
779-
>
780-
<Plugin className={cx("bi", "me-1")} />
781-
integrations list.
782-
</Link>
793+
platform we currently do not support.
794+
{hasWriteAccess && (
795+
<>
796+
{" "}
797+
Please verify the URL and check if the platform is in the
798+
currently supported{" "}
799+
<Link
800+
to={{
801+
pathname: ABSOLUTE_ROUTES.v2.integrations,
802+
search,
803+
}}
804+
>
805+
<Plugin className={cx("bi", "me-1")} />
806+
integrations list.
807+
</Link>
808+
</>
809+
)}
783810
</p>
784811

785-
<p className="mb-0">
786-
If you&apos;re certain the URL is correct,{" "}
787-
<a
788-
target="_blank"
789-
rel="noreferrer noopener"
790-
href="mailto:[email protected]"
791-
>
792-
<Send className={cx("bi", "me-1")} />
793-
contact us
794-
</a>{" "}
795-
about adding an integration.
796-
</p>
812+
{hasWriteAccess && (
813+
<p className="mb-0">
814+
If you&apos;re certain the URL is correct,{" "}
815+
<a
816+
target="_blank"
817+
rel="noreferrer noopener"
818+
href="mailto:[email protected]"
819+
>
820+
<Send className={cx("bi", "me-1")} />
821+
contact us
822+
</a>{" "}
823+
about adding an integration.
824+
</p>
825+
)}
797826
</>
798827
)}
799828
</ErrorAlert>
@@ -882,16 +911,20 @@ export function RepositoryCallToActionAlert({
882911
permissions, you can log in through the integration{" "}
883912
<span className="fst-italic">{data.provider.name}</span>.
884913
</p>
885-
<Link
886-
className={cx("btn", "btn-primary", "btn-sm")}
887-
to={{
888-
pathname: ABSOLUTE_ROUTES.v2.integrations,
889-
search,
890-
}}
891-
>
892-
<Plugin className={cx("bi", "me-1")} />
893-
View integration
894-
</Link>
914+
{anonymousUser ? (
915+
<LogInWarning />
916+
) : (
917+
<Link
918+
className={cx("btn", "btn-primary", "btn-sm")}
919+
to={{
920+
pathname: ABSOLUTE_ROUTES.v2.integrations,
921+
search,
922+
}}
923+
>
924+
<Plugin className={cx("bi", "me-1")} />
925+
View integration
926+
</Link>
927+
)}
895928
</InfoAlert>
896929
);
897930
}

0 commit comments

Comments
 (0)