mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 04:45:19 +00:00
move to link
This commit is contained in:
parent
1810a773a7
commit
943b914818
1 changed files with 14 additions and 17 deletions
|
|
@ -11,7 +11,9 @@ import Image from "next/image";
|
|||
import { FileIcon } from "@radix-ui/react-icons";
|
||||
import clsx from "clsx";
|
||||
import { RepositoryQuery } from "@/lib/types";
|
||||
import { useBrowseNavigation } from "../../browse/hooks/useBrowseNavigation";
|
||||
import { getBrowsePath } from "../../browse/hooks/useBrowseNavigation";
|
||||
import Link from "next/link";
|
||||
import { useDomain } from "@/hooks/useDomain";
|
||||
|
||||
interface RepositoryCarouselProps {
|
||||
repos: RepositoryQuery[];
|
||||
|
|
@ -57,9 +59,8 @@ interface RepositoryBadgeProps {
|
|||
const RepositoryBadge = ({
|
||||
repo
|
||||
}: RepositoryBadgeProps) => {
|
||||
const { navigateToPath } = useBrowseNavigation();
|
||||
|
||||
const { repoIcon, displayName, repoLink } = (() => {
|
||||
const domain = useDomain();
|
||||
const { repoIcon, displayName } = (() => {
|
||||
const info = getCodeHostInfoForRepo({
|
||||
codeHostType: repo.codeHostType,
|
||||
name: repo.repoName,
|
||||
|
|
@ -75,34 +76,30 @@ const RepositoryBadge = ({
|
|||
className={`w-4 h-4 ${info.iconClassName}`}
|
||||
/>,
|
||||
displayName: info.displayName,
|
||||
repoLink: info.repoLink,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
repoIcon: <FileIcon className="w-4 h-4" />,
|
||||
displayName: repo.repoName,
|
||||
repoLink: undefined,
|
||||
}
|
||||
})();
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
navigateToPath({
|
||||
repoName: repo.repoName,
|
||||
path: '/',
|
||||
pathType: 'tree',
|
||||
});
|
||||
}}
|
||||
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip", {
|
||||
"cursor-pointer": repoLink !== undefined,
|
||||
<Link
|
||||
href={getBrowsePath({
|
||||
repoName: repo.repoName,
|
||||
path: '/',
|
||||
pathType: 'tree',
|
||||
domain
|
||||
})}
|
||||
|
||||
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip")}
|
||||
>
|
||||
{repoIcon}
|
||||
<span className="text-sm font-mono">
|
||||
{displayName}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue