Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: gitlab comment card in activity

zaralX81231122ccd1
diff --git a/apps/web/src/components/activity/comment-card.tsx b/apps/web/src/components/activity/comment-card.tsx
index efc764744..9e7cb6342 100644
--- a/apps/web/src/components/activity/comment-card.tsx
+++ b/apps/web/src/components/activity/comment-card.tsx
@@ -1,9 +1,10 @@
import { useQueryClient } from "@tanstack/react-query";
-import { ExternalLink, Pencil, Trash2 } from "lucide-react";
+import { ExternalLink, FolderGit, Pencil, Trash2 } from "lucide-react";
import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import CommentEditor from "@/components/activity/comment-editor";
import { GithubIcon } from "@/components/icons/github-icon";
+import { GitlabIcon } from "@/components/icons/gitlab-icon";
import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
@@ -24,6 +25,21 @@ import { formatDateTime, formatRelativeTime } from "@/lib/format";
import { getInitials } from "@/lib/get-initials";
import { toast } from "@/lib/toast";
+// A comment can arrive from any of the linked forges, so the icon and the name
+// follow the source rather than always reading GitHub.
+const forges = {
+ github: { name: "GitHub", Icon: GithubIcon },
+ gitea: { name: "Gitea", Icon: FolderGit },
+ gitlab: { name: "GitLab", Icon: GitlabIcon },
+} as const;
+
+function forgeOf(externalSource: string | null | undefined) {
+ if (!externalSource) {
+ return null;
+ }
+ return forges[externalSource as keyof typeof forges] ?? null;
+}
+
type CommentCardProps = {
commentId: string;
taskId: string;
@@ -58,9 +74,13 @@ export default function CommentCard({
const queryClient = useQueryClient();
const canEdit = currentUser?.id === user?.id;
- const isFromGitHub = externalSource === "github";
+ const forge = forgeOf(externalSource);
+ // Only GitHub has a profile URL that can be derived from a username alone; a
+ // Gitea or GitLab profile lives on whichever instance the comment came from.
const githubProfileUrl =
- isFromGitHub && user?.name ? `https://github.com/${user.name}` : null;
+ forge?.name === "GitHub" && user?.name
+ ? `https://github.com/${user.name}`
+ : null;
const commentUrl = externalUrl || null;
const fullTimestamp = formatDateTime(createdAt);
@@ -143,11 +163,11 @@ export default function CommentCard({
{user.email}
</p>
)}
- {isFromGitHub && (
+ {forge && (
<div className="mt-1.5 flex items-center gap-1">
- <GithubIcon className="size-3 text-muted-foreground" />
+ <forge.Icon className="size-3 text-muted-foreground" />
<span className="text-xs text-muted-foreground">
- {t("activity:comment.github")}
+ {forge.name}
</span>
</div>
)}
@@ -185,7 +205,7 @@ export default function CommentCard({
</TooltipContent>
</Tooltip>
- {commentUrl && (
+ {commentUrl && forge && (
<>
<span className="text-xs text-muted-foreground/40">·</span>
<a
@@ -194,8 +214,8 @@ export default function CommentCard({
rel="noopener noreferrer"
className="flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"
>
- <GithubIcon className="size-3" />
- {t("activity:comment.commentedOnGithub")}
+ <forge.Icon className="size-3" />
+ {t("activity:comment.commentedOnForge", { forge: forge.name })}
</a>
</>
)}