⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat(web): add Gitea integration settings and workflow UI
Tinf1362d9fcda4
diff --git a/apps/web/src/components/project/gitea-integration-settings.tsx b/apps/web/src/components/project/gitea-integration-settings.tsxnew file mode 100644index 000000000..c7abbb746--- /dev/null+++ b/apps/web/src/components/project/gitea-integration-settings.tsx@@ -0,0 +1,727 @@+import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";+import {+ AlertTriangle,+ CheckCircle,+ ExternalLink,+ GitBranch,+ Import,+ Link,+ RefreshCw,+ Unlink,+ XCircle,+} from "lucide-react";+import React from "react";+import { useForm } from "react-hook-form";+import { useTranslation } from "react-i18next";+import { z } from "zod/v4";+import { GiteaRepositoryBrowserModal } from "@/components/project/gitea-repository-browser-modal";+import { Badge } from "@/components/ui/badge";+import { Button } from "@/components/ui/button";+import {+ Form,+ FormControl,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";+import { Input } from "@/components/ui/input";+import { Separator } from "@/components/ui/separator";+import { Switch } from "@/components/ui/switch";+import type { VerifyGiteaAccessResponse } from "@/fetchers/gitea-integration/verify-gitea-access";+import {+ useCreateGiteaIntegration,+ useDeleteGiteaIntegration,+ useVerifyGiteaAccess,+} from "@/hooks/mutations/gitea-integration/use-create-gitea-integration";+import useImportGiteaIssues from "@/hooks/mutations/gitea-integration/use-import-gitea-issues";+import { useUpdateGiteaIntegration } from "@/hooks/mutations/gitea-integration/use-update-gitea-integration";+import useGetGiteaIntegration from "@/hooks/queries/gitea-integration/use-get-gitea-integration";+import { cn } from "@/lib/cn";+import { toast } from "@/lib/toast";++type GiteaIntegrationFormValues = {+ baseUrl: string;+ accessToken: string;+ repositoryOwner: string;+ repositoryName: string;+};++export function GiteaIntegrationSettings({ projectId }: { projectId: string }) {+ const { t } = useTranslation();++ const giteaIntegrationSchema = React.useMemo(+ () =>+ z.object({+ baseUrl: z+ .string()+ .min(1, t("settings:giteaIntegration.validation.baseUrlRequired"))+ .refine((s) => {+ try {+ new URL(s);+ return true;+ } catch {+ return false;+ }+ }, t("settings:giteaIntegration.validation.baseUrlInvalid")),+ accessToken: z.string(),+ repositoryOwner: z+ .string()+ .min(1, t("settings:giteaIntegration.validation.ownerRequired"))+ .regex(+ /^[a-zA-Z0-9_.-]+$/,+ t("settings:giteaIntegration.validation.ownerInvalid"),+ ),+ repositoryName: z+ .string()+ .min(1, t("settings:giteaIntegration.validation.nameRequired"))+ .regex(+ /^[a-zA-Z0-9._-]+$/,+ t("settings:giteaIntegration.validation.nameInvalid"),+ ),+ }),+ [t],+ );++ const { data: integration, isLoading } = useGetGiteaIntegration(projectId);+ const { mutateAsync: createIntegration, isPending: isCreating } =+ useCreateGiteaIntegration();+ const { mutateAsync: deleteIntegration, isPending: isDeleting } =+ useDeleteGiteaIntegration();+ const { mutateAsync: verifyAccess, isPending: isVerifying } =+ useVerifyGiteaAccess();+ const { mutateAsync: importIssues, isPending: isImporting } =+ useImportGiteaIssues();+ const { mutateAsync: updateGiteaSettings, isPending: isUpdatingSettings } =+ useUpdateGiteaIntegration();++ const [verificationResult, setVerificationResult] =+ React.useState<VerifyGiteaAccessResponse | null>(null);+ const [showRepositoryBrowser, setShowRepositoryBrowser] =+ React.useState(false);++ const form = useForm<GiteaIntegrationFormValues>({+ resolver: standardSchemaResolver(giteaIntegrationSchema),+ defaultValues: {+ baseUrl: "",+ accessToken: "",+ repositoryOwner: "",+ repositoryName: "",+ },+ });++ React.useEffect(() => {+ if (integration?.baseUrl) {+ form.reset({+ baseUrl: integration.baseUrl,+ accessToken: "",+ repositoryOwner: integration.repositoryOwner,+ repositoryName: integration.repositoryName,+ });+ }+ }, [integration, form]);++ const runVerify = React.useCallback(+ async (data: GiteaIntegrationFormValues, showToast = true) => {+ const token = data.accessToken.trim();+ if (!token && integration) {+ return;+ }+ if (!token && !integration) {+ if (showToast) {+ toast.error(t("settings:giteaIntegration.toast.tokenRequiredVerify"));+ }+ setVerificationResult(null);+ return;+ }+ try {+ const result = await verifyAccess({+ baseUrl: data.baseUrl,+ accessToken: token,+ repositoryOwner: data.repositoryOwner,+ repositoryName: data.repositoryName,+ });+ setVerificationResult(result);+ if (showToast) {+ if (result.isInstalled && result.hasRequiredPermissions) {+ toast.success(t("settings:giteaIntegration.toast.verifyOk"));+ } else if (!result.repositoryExists) {+ toast.error(t("settings:giteaIntegration.toast.repoNotFound"));+ } else {+ toast.warning(t("settings:giteaIntegration.toast.verifyWarning"));+ }+ }+ } catch (error) {+ if (showToast) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:giteaIntegration.toast.verifyError"),+ );+ }+ setVerificationResult(null);+ }+ },+ [verifyAccess, integration, t],+ );++ const baseUrl = form.watch("baseUrl");+ const accessToken = form.watch("accessToken");+ const repositoryOwner = form.watch("repositoryOwner");+ const repositoryName = form.watch("repositoryName");++ React.useEffect(() => {+ if (+ !baseUrl ||+ !repositoryOwner ||+ !repositoryName ||+ !form.formState.isValid+ ) {+ return;+ }+ if (!accessToken.trim()) {+ return;+ }+ runVerify(form.getValues(), false);+ }, [+ baseUrl,+ repositoryOwner,+ repositoryName,+ accessToken,+ form.formState.isValid,+ runVerify,+ form,+ ]);++ const onSubmit = async (data: GiteaIntegrationFormValues) => {+ try {+ if (!data.accessToken.trim() && !integration) {+ toast.error(t("settings:giteaIntegration.toast.tokenRequired"));+ return;+ }++ if (data.accessToken.trim()) {+ const verification = await verifyAccess({+ baseUrl: data.baseUrl,+ accessToken: data.accessToken.trim(),+ repositoryOwner: data.repositoryOwner,+ repositoryName: data.repositoryName,+ });++ if (!verification.isInstalled || !verification.hasRequiredPermissions) {+ toast.error(t("settings:giteaIntegration.toast.verifyFirst"));+ return;+ }+ }++ await createIntegration({+ projectId,+ data: {+ baseUrl: data.baseUrl,+ ...(data.accessToken.trim()+ ? { accessToken: data.accessToken.trim() }+ : {}),+ repositoryOwner: data.repositoryOwner,+ repositoryName: data.repositoryName,+ },+ });+ form.setValue("accessToken", "");+ toast.success(t("settings:giteaIntegration.toast.updated"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:giteaIntegration.toast.updateError"),+ );+ }+ };++ const handleDelete = async () => {+ try {+ await deleteIntegration(projectId);+ form.reset({+ baseUrl: "",+ accessToken: "",+ repositoryOwner: "",+ repositoryName: "",+ });+ setVerificationResult(null);+ toast.success(t("settings:giteaIntegration.toast.removed"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:giteaIntegration.toast.removeError"),+ );+ }+ };++ const handleImportIssues = async () => {+ try {+ await importIssues(projectId);+ toast.success(t("settings:giteaIntegration.toast.issuesImported"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:giteaIntegration.toast.importError"),+ );+ }+ };++ const handleRepositorySelect = (repository: {+ owner: string;+ name: string;+ }) => {+ form.setValue("repositoryOwner", repository.owner, {+ shouldValidate: true,+ shouldDirty: true,+ shouldTouch: true,+ });+ form.setValue("repositoryName", repository.name, {+ shouldValidate: true,+ shouldDirty: true,+ shouldTouch: true,+ });+ setShowRepositoryBrowser(false);+ setVerificationResult(null);+ };++ if (isLoading) {+ return (+ <div className="space-y-4">+ <div className="h-10 bg-muted rounded animate-pulse w-full" />+ </div>+ );+ }++ const isConnected = !!integration && integration.isActive;+ const canImport =+ isConnected &&+ verificationResult?.isInstalled &&+ verificationResult?.hasRequiredPermissions;++ const repoUrl =+ integration?.baseUrl && integration.repositoryOwner+ ? `${integration.baseUrl.replace(/\/$/, "")}/${integration.repositoryOwner}/${integration.repositoryName}`+ : null;++ return (+ <div className="space-y-4">+ <div className="space-y-4 border border-border rounded-md p-4 bg-sidebar">+ <div className="flex items-center justify-between">+ <div className="space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:giteaIntegration.connectionStatus")}+ </p>+ {isConnected ? (+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.connectedActive")}+ </p>+ ) : (+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.notConnectedHint")}+ </p>+ )}+ </div>+ {isConnected ? (+ <Badge variant="secondary" className="gap-1">+ <CheckCircle className="w-3 h-3" />+ {t("settings:giteaIntegration.badgeConnected")}+ </Badge>+ ) : (+ <Badge variant="outline" className="gap-1">+ <XCircle className="w-3 h-3" />+ {t("settings:giteaIntegration.badgeNotConnected")}+ </Badge>+ )}+ </div>++ {isConnected && integration && (+ <>+ <Separator />+ <div className="flex items-center justify-between">+ <div className="space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:giteaIntegration.repository")}+ </p>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.repositoryHint")}+ </p>+ </div>+ <div className="flex items-center gap-2 text-sm">+ <span className="font-medium">+ {integration.repositoryOwner}/{integration.repositoryName}+ </span>+ {repoUrl && (+ <a+ href={repoUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary hover:text-primary/80 transition-colors"+ >+ <ExternalLink className="w-3 h-3" />+ </a>+ )}+ </div>+ </div>++ <Separator />+ <div className="flex items-center justify-between gap-4">+ <div className="min-w-0 flex-1 space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:giteaIntegration.commentTaskLinkTitle")}+ </p>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.commentTaskLinkHint")}+ </p>+ </div>+ <Switch+ checked={integration.commentTaskLinkOnGiteaIssue !== false}+ onCheckedChange={async (checked) => {+ try {+ await updateGiteaSettings({+ projectId,+ json: { commentTaskLinkOnGiteaIssue: checked },+ });+ toast.success(+ checked+ ? t("settings:giteaIntegration.toast.commentOnEnabled")+ : t(+ "settings:giteaIntegration.toast.commentOnDisabled",+ ),+ );+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t(+ "settings:giteaIntegration.toast.settingsUpdateError",+ ),+ );+ }+ }}+ disabled={isUpdatingSettings}+ />+ </div>++ {integration.webhookUrl && (+ <>+ <Separator />+ <div className="space-y-2 text-xs">+ <p className="font-medium text-sm">+ {t("settings:giteaIntegration.webhookTitle")}+ </p>+ <p className="text-muted-foreground">+ {t("settings:giteaIntegration.webhookHint")}+ </p>+ <code className="block break-all rounded bg-muted px-2 py-1 text-[11px]">+ {integration.webhookUrl}+ </code>+ <p className="text-muted-foreground mt-2">+ {t("settings:giteaIntegration.webhookSecretLabel")}+ </p>+ <code className="block break-all rounded bg-muted px-2 py-1 text-[11px]">+ {integration.webhookSecret}+ </code>+ </div>+ </>+ )}+ </>+ )}+ </div>++ <div className="space-y-4 border border-border rounded-md p-4 bg-sidebar">+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">+ <FormField+ control={form.control}+ name="baseUrl"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center justify-between gap-4">+ <div className="space-y-0.5">+ <FormLabel className="text-sm font-medium">+ {t("settings:giteaIntegration.baseUrlLabel")}+ </FormLabel>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.baseUrlHint")}+ </p>+ </div>+ <FormControl>+ <Input+ className="w-72"+ placeholder="https://gitea.example.com"+ {...field}+ disabled={isCreating || isDeleting}+ />+ </FormControl>+ </div>+ <FormMessage />+ </FormItem>+ )}+ />++ <Separator />++ <FormField+ control={form.control}+ name="accessToken"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center justify-between gap-4">+ <div className="space-y-0.5">+ <FormLabel className="text-sm font-medium">+ {t("settings:giteaIntegration.tokenLabel")}+ </FormLabel>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.tokenHint")}+ {integration?.maskedAccessToken+ ? ` (${t("settings:giteaIntegration.currentToken")}: ${integration.maskedAccessToken})`+ : null}+ </p>+ </div>+ <FormControl>+ <Input+ className="w-72"+ type="password"+ autoComplete="off"+ placeholder={+ integration+ ? t(+ "settings:giteaIntegration.tokenPlaceholderUpdate",+ )+ : t("settings:giteaIntegration.tokenPlaceholder")+ }+ {...field}+ disabled={isCreating || isDeleting}+ />+ </FormControl>+ </div>+ <FormMessage />+ </FormItem>+ )}+ />++ <Separator />++ <FormField+ control={form.control}+ name="repositoryOwner"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center justify-between gap-4">+ <div className="space-y-0.5">+ <FormLabel className="text-sm font-medium">+ {t("settings:giteaIntegration.ownerLabel")}+ </FormLabel>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.ownerHint")}+ </p>+ </div>+ <FormControl>+ <Input+ className="w-64"+ {...field}+ disabled={isCreating || isDeleting}+ />+ </FormControl>+ </div>+ <FormMessage />+ </FormItem>+ )}+ />++ <Separator />++ <FormField+ control={form.control}+ name="repositoryName"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center justify-between gap-4">+ <div className="space-y-0.5">+ <FormLabel className="text-sm font-medium">+ {t("settings:giteaIntegration.repoNameLabel")}+ </FormLabel>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.repoNameHint")}+ </p>+ </div>+ <FormControl>+ <Input+ className="w-64"+ {...field}+ disabled={isCreating || isDeleting}+ />+ </FormControl>+ </div>+ <FormMessage />+ </FormItem>+ )}+ />++ <Separator />++ <div className="flex items-center justify-between">+ <div className="space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:giteaIntegration.actionsTitle")}+ </p>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.actionsHint")}+ </p>+ </div>+ <div className="flex flex-wrap gap-2">+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => setShowRepositoryBrowser(true)}+ className="gap-2"+ disabled={!baseUrl || !accessToken.trim()}+ >+ <GitBranch className="size-3" />+ {t("settings:giteaIntegration.browse")}+ </Button>++ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => runVerify(form.getValues())}+ disabled={+ isVerifying ||+ !form.formState.isValid ||+ (!accessToken.trim() && !integration)+ }+ className="gap-2"+ >+ <RefreshCw+ className={cn("size-3", isVerifying && "animate-spin")}+ />+ {t("settings:giteaIntegration.verify")}+ </Button>++ <Button+ type="submit"+ size="sm"+ disabled={+ isCreating ||+ isDeleting ||+ !form.formState.isValid ||+ (verificationResult+ ? !verificationResult.isInstalled ||+ !verificationResult.hasRequiredPermissions+ : false)+ }+ className="gap-2"+ >+ <Link className="size-3" />+ {isConnected+ ? t("settings:giteaIntegration.update")+ : t("settings:giteaIntegration.connect")}+ </Button>++ {isConnected && (+ <Button+ type="button"+ variant="destructive"+ size="sm"+ onClick={handleDelete}+ disabled={isCreating || isDeleting}+ className="gap-2"+ >+ <Unlink className="size-3" />+ {t("settings:giteaIntegration.disconnect")}+ </Button>+ )}+ </div>+ </div>+ </form>+ </Form>++ {verificationResult && (+ <>+ <Separator />+ <div+ className={cn(+ "flex items-start gap-3 p-3 border rounded-md text-sm",+ verificationResult.isInstalled &&+ verificationResult.hasRequiredPermissions+ ? "border-success/25 bg-success/10"+ : verificationResult.repositoryExists+ ? "border-warning/25 bg-warning/10"+ : "border-destructive/25 bg-destructive/10",+ )}+ >+ {verificationResult.isInstalled &&+ verificationResult.hasRequiredPermissions ? (+ <CheckCircle className="mt-0.5 h-4 w-4 flex-shrink-0 text-success-foreground" />+ ) : verificationResult.repositoryExists ? (+ <AlertTriangle className="mt-0.5 h-4 w-4 flex-shrink-0 text-warning-foreground" />+ ) : (+ <XCircle className="mt-0.5 h-4 w-4 flex-shrink-0 text-destructive-foreground" />+ )}+ <div className="flex-1">+ <p className="font-medium">{verificationResult.message}</p>+ </div>+ </div>+ </>+ )}+ </div>++ {isConnected && (+ <div className="space-y-4 border border-border rounded-md p-4 bg-sidebar">+ <div className="flex items-center justify-between">+ <div className="space-y-0.5">+ <p className="text-sm font-medium">+ {t("settings:giteaIntegration.importSectionTitle")}+ </p>+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.importSectionHint")}+ </p>+ </div>+ <Button+ onClick={handleImportIssues}+ disabled={isImporting || !canImport}+ className="gap-2"+ size="sm"+ variant="outline"+ >+ {isImporting ? (+ <RefreshCw className="size-3 animate-spin" />+ ) : (+ <Import className="size-3" />+ )}+ {isImporting+ ? t("settings:giteaIntegration.importing")+ : t("settings:giteaIntegration.importIssues")}+ </Button>+ </div>+ {!canImport && (+ <>+ <Separator />+ <p className="text-xs text-muted-foreground">+ {t("settings:giteaIntegration.importDisabledHint")}+ </p>+ </>+ )}+ </div>+ )}++ <GiteaRepositoryBrowserModal+ open={showRepositoryBrowser}+ onOpenChange={setShowRepositoryBrowser}+ onSelectRepository={handleRepositorySelect}+ selectedRepository={+ repositoryOwner && repositoryName+ ? `${repositoryOwner}/${repositoryName}`+ : undefined+ }+ baseUrl={baseUrl}+ accessToken={accessToken}+ />+ </div>+ );+}diff --git a/apps/web/src/components/project/gitea-repository-browser-modal.tsx b/apps/web/src/components/project/gitea-repository-browser-modal.tsxnew file mode 100644index 000000000..f64ecb98d--- /dev/null+++ b/apps/web/src/components/project/gitea-repository-browser-modal.tsx@@ -0,0 +1,169 @@+import { useQuery } from "@tanstack/react-query";+import { ExternalLink, GitBranch, Lock, Search } from "lucide-react";+import React from "react";+import { useTranslation } from "react-i18next";+import { Badge } from "@/components/ui/badge";+import { Button } from "@/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";+import { Input } from "@/components/ui/input";+import listGiteaRepositories, {+ type ListGiteaRepositoriesResponse,+} from "@/fetchers/gitea-integration/list-gitea-repositories";+import { cn } from "@/lib/cn";++type GiteaRepositoryBrowserModalProps = {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ onSelectRepository: (repository: { owner: string; name: string }) => void;+ selectedRepository?: string;+ baseUrl: string;+ accessToken: string;+};++export function GiteaRepositoryBrowserModal({+ open,+ onOpenChange,+ onSelectRepository,+ selectedRepository,+ baseUrl,+ accessToken,+}: GiteaRepositoryBrowserModalProps) {+ const { t } = useTranslation();+ const [searchTerm, setSearchTerm] = React.useState("");++ const canFetch =+ open && baseUrl.trim().length > 0 && accessToken.trim().length > 0;++ const { data, isLoading, error, refetch } = useQuery({+ queryKey: ["gitea-repositories", baseUrl, accessToken],+ queryFn: () => listGiteaRepositories({ baseUrl, accessToken }),+ enabled: canFetch,+ });++ const filteredRepositories = React.useMemo(() => {+ if (!data?.repositories) return [];++ if (!searchTerm) return data.repositories;++ const search = searchTerm.toLowerCase();+ return data.repositories.filter((repo) =>+ repo.full_name.toLowerCase().includes(search),+ );+ }, [data?.repositories, searchTerm]);++ const handleSelectRepository = (+ repository: ListGiteaRepositoriesResponse["repositories"][number],+ ) => {+ onSelectRepository({+ owner: repository.owner.login,+ name: repository.name,+ });+ onOpenChange(false);+ };++ const resetAndCloseModal = (next: boolean) => {+ if (!next) {+ setSearchTerm("");+ }+ onOpenChange(next);+ };++ return (+ <Dialog open={open} onOpenChange={resetAndCloseModal}>+ <DialogContent className="!max-w-2xl max-h-[85vh] p-0 gap-0 flex flex-col">+ <DialogHeader className="px-6 pt-6 pb-4">+ <DialogTitle className="flex items-center gap-2">+ <GitBranch className="size-5" />+ {t("settings:giteaIntegration.browseModalTitle")}+ </DialogTitle>+ <DialogDescription>+ {t("settings:giteaIntegration.browseModalHint")}+ </DialogDescription>+ </DialogHeader>++ <div className="px-6 pb-4">+ <div className="relative">+ <Search className="absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" />+ <Input+ className="pl-9"+ placeholder={t("settings:giteaIntegration.searchRepos")}+ value={searchTerm}+ onChange={(e) => setSearchTerm(e.target.value)}+ />+ </div>+ </div>++ <div className="flex-1 overflow-y-auto border-t border-border px-6 py-2">+ {!canFetch && (+ <p className="text-sm text-muted-foreground py-8 text-center">+ {t("settings:giteaIntegration.browseNeedsCredentials")}+ </p>+ )}+ {canFetch && isLoading && (+ <p className="text-sm text-muted-foreground py-8 text-center">+ {t("settings:giteaIntegration.loadingRepos")}+ </p>+ )}+ {canFetch && error && (+ <div className="py-6 text-center space-y-2">+ <p className="text-sm text-destructive">+ {error instanceof Error ? error.message : "Error"}+ </p>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => refetch()}+ >+ {t("settings:giteaIntegration.retry")}+ </Button>+ </div>+ )}+ {canFetch && data && (+ <ul className="space-y-1">+ {filteredRepositories.map((repo) => (+ <li key={repo.id}>+ <button+ type="button"+ onClick={() => handleSelectRepository(repo)}+ className={cn(+ "w-full flex items-center justify-between gap-3 rounded-md px-3 py-2 text-left text-sm hover:bg-muted/80 transition-colors",+ selectedRepository === repo.full_name && "bg-muted",+ )}+ >+ <span className="font-medium truncate">+ {repo.full_name}+ </span>+ <div className="flex items-center gap-2 shrink-0">+ {repo.private ? (+ <Lock className="size-3.5 text-muted-foreground" />+ ) : null}+ <Badge variant="secondary" className="text-xs">+ {repo.owner.login}+ </Badge>+ <a+ href={repo.html_url}+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary"+ onClick={(e) => e.stopPropagation()}+ >+ <ExternalLink className="size-3.5" />+ </a>+ </div>+ </button>+ </li>+ ))}+ </ul>+ )}+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/apps/web/src/components/project/workflow-editor.tsx b/apps/web/src/components/project/workflow-editor.tsxindex 07e61e536..002bddc83 100644--- a/apps/web/src/components/project/workflow-editor.tsx+++ b/apps/web/src/components/project/workflow-editor.tsx@@ -30,28 +30,6 @@ export default function WorkflowEditor({ projectId }: WorkflowEditorProps) {useGetWorkflowRules(projectId);const { mutateAsync: upsertRule } = useUpsertWorkflowRule();- const handleChange = async (eventType: string, columnId: string | null) => {- if (!columnId) return;-- try {- await upsertRule({- projectId,- data: {- integrationType: "github",- eventType,- columnId,- },- });- toast.success(t("settings:workflowEditor.toastUpdated"));- } catch (error) {- toast.error(- error instanceof Error- ? error.message- : t("settings:workflowEditor.toastError"),- );- }- };-if (columnsLoading || rulesLoading) {return (<div className="text-sm text-muted-foreground">@@ -68,28 +46,32 @@ export default function WorkflowEditor({ projectId }: WorkflowEditorProps) {);}- const githubRules = rules?.filter((r) => r.integrationType === "github");-- return (+ const renderRuleSection = (+ integrationType: "github" | "gitea",+ headingKey: "githubHeading" | "giteaHeading",+ hintKey: "githubHint" | "giteaHint",+ ) => (<div className="space-y-4"><div className="space-y-1"><h3 className="text-sm font-medium">- {t("settings:workflowEditor.githubHeading")}+ {t(`settings:workflowEditor.${headingKey}`)}</h3><p className="text-xs text-muted-foreground">- {t("settings:workflowEditor.githubHint")}+ {t(`settings:workflowEditor.${hintKey}`)}</p></div><div className="space-y-2">{GITHUB_EVENT_TYPES.map((eventType) => {- const currentRule = githubRules?.find(- (r) => r.eventType === eventType,+ const currentRule = rules?.find(+ (r) =>+ r.integrationType === integrationType &&+ r.eventType === eventType,);return (<div- key={eventType}+ key={`${integrationType}-${eventType}`}className="flex items-center justify-between gap-4 p-3 border border-border rounded-md bg-sidebar"><span className="text-sm">@@ -97,7 +79,26 @@ export default function WorkflowEditor({ projectId }: WorkflowEditorProps) {</span><Selectvalue={currentRule?.columnId ?? ""}- onValueChange={(value) => handleChange(eventType, value)}+ onValueChange={async (value) => {+ if (!value) return;+ try {+ await upsertRule({+ projectId,+ data: {+ integrationType,+ eventType,+ columnId: value,+ },+ });+ toast.success(t("settings:workflowEditor.toastUpdated"));+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : t("settings:workflowEditor.toastError"),+ );+ }+ }}><SelectTrigger className="w-48 h-8 text-sm"><SelectValue@@ -124,4 +125,11 @@ export default function WorkflowEditor({ projectId }: WorkflowEditorProps) {</div></div>);++ return (+ <div className="space-y-10">+ {renderRuleSection("github", "githubHeading", "githubHint")}+ {renderRuleSection("gitea", "giteaHeading", "giteaHint")}+ </div>+ );}diff --git a/apps/web/src/components/task/task-properties-sidebar.tsx b/apps/web/src/components/task/task-properties-sidebar.tsxindex 3a06dfa03..ef1c90d7b 100644--- a/apps/web/src/components/task/task-properties-sidebar.tsx+++ b/apps/web/src/components/task/task-properties-sidebar.tsx@@ -19,6 +19,7 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import labelColors from "@/constants/label-colors";+import useGetGiteaIntegration from "@/hooks/queries/gitea-integration/use-get-gitea-integration";import useGetGithubIntegration from "@/hooks/queries/github-integration/use-get-github-integration";import useGetLabelsByTask from "@/hooks/queries/label/use-get-labels-by-task";import useGetProject from "@/hooks/queries/project/use-get-project";@@ -80,10 +81,14 @@ export default function TaskPropertiesSidebar({const { data: workspaceUsers } = useGetActiveWorkspaceUsers(workspaceId);const { data: taskLabels = [] } = useGetLabelsByTask(taskId ?? "");const { data: githubIntegration } = useGetGithubIntegration(projectId);+ const { data: giteaIntegration } = useGetGiteaIntegration(projectId);const projectSlug = project?.slug;const taskNumber = task?.number;- const branchPattern = githubIntegration?.branchPattern || "{slug}-{number}";+ const branchPattern =+ githubIntegration?.branchPattern ||+ giteaIntegration?.branchPattern ||+ "{slug}-{number}";const assignee = workspaceUsers?.members?.find((member) => member.userId === task?.userId,diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/projects/$projectId/integrations.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/projects/$projectId/integrations.tsxindex 71758d49c..d5109ee06 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/projects/$projectId/integrations.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/projects/$projectId/integrations.tsx@@ -1,6 +1,7 @@import { createFileRoute } from "@tanstack/react-router";import {ChevronDown,+ FolderGit,Github,MessageCircle,Radio,@@ -11,6 +12,7 @@ import { useTranslation } from "react-i18next";import PageTitle from "@/components/page-title";import { DiscordIntegrationSettings } from "@/components/project/discord-integration-settings";import { GenericWebhookIntegrationSettings } from "@/components/project/generic-webhook-integration-settings";+import { GiteaIntegrationSettings } from "@/components/project/gitea-integration-settings";import { GitHubIntegrationSettings } from "@/components/project/github-integration-settings";import { SlackIntegrationSettings } from "@/components/project/slack-integration-settings";import {@@ -52,6 +54,14 @@ function RouteComponent() {<GitHubIntegrationSettings projectId={projectId} /></IntegrationSection>+ <IntegrationSection+ icon={<FolderGit className="size-4" />}+ subtitle={t("settings:projectIntegrations.giteaSectionSubtitle")}+ title={t("settings:projectIntegrations.giteaSectionTitle")}+ >+ <GiteaIntegrationSettings projectId={projectId} />+ </IntegrationSection>+<IntegrationSectionicon={<MessageCircle className="size-4" />}subtitle={t("settings:projectIntegrations.discordSectionSubtitle")}