From 13cbf86309bc5687a73049928d065695955cff69 Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Tue, 17 Jun 2025 12:42:32 +0530 Subject: [PATCH] Updated Layout --- src/components/config/GitHubConfigForm.tsx | 105 ++++++------ src/components/config/GiteaConfigForm.tsx | 52 +----- .../config/OrganizationStrategy.tsx | 154 ++++++++++++------ src/lib/gitea.ts | 2 +- 4 files changed, 168 insertions(+), 145 deletions(-) diff --git a/src/components/config/GitHubConfigForm.tsx b/src/components/config/GitHubConfigForm.tsx index f1704bf..6d13a20 100644 --- a/src/components/config/GitHubConfigForm.tsx +++ b/src/components/config/GitHubConfigForm.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card, @@ -10,14 +10,16 @@ import { import { githubApi } from "@/lib/api"; import type { GitHubConfig, MirrorOptions, AdvancedOptions } from "@/types/config"; import { Input } from "../ui/input"; -import { Checkbox } from "../ui/checkbox"; import { toast } from "sonner"; -import { AlertTriangle } from "lucide-react"; +import { AlertTriangle, Info } from "lucide-react"; import { Alert, AlertDescription } from "../ui/alert"; -import { Info } from "lucide-react"; -import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; import { GitHubMirrorSettings } from "./GitHubMirrorSettings"; import { Separator } from "../ui/separator"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; interface GitHubConfigFormProps { config: GitHubConfig; @@ -123,12 +125,52 @@ export function GitHubConfigForm({
- +
+ + + + + + +
+

GitHub Token Requirements

+
+

+ You need to create a Classic GitHub PAT Token with the following scopes: +

+
    +
  • repo
  • +
  • admin:org
  • +
+

+ The organization access is required for mirroring organization repositories. +

+

+ Generate tokens at{" "} + + github.com/settings/tokens + +

+
+
+
+
+

Required for private repositories, organizations, and starred @@ -163,45 +205,8 @@ export function GitHubConfigForm({ if (onAdvancedOptionsAutoSave) onAdvancedOptionsAutoSave(newOptions); }} /> - + - - - - -

Note:
-
- You need to create a{" "} - Classic GitHub PAT Token{" "} - with following scopes: -
- -
- The organization access is required for mirroring organization - repositories. -
-
- You can generate tokens at{" "} - - github.com/settings/tokens - - . -
- - - ); } diff --git a/src/components/config/GiteaConfigForm.tsx b/src/components/config/GiteaConfigForm.tsx index 0b79324..ef353b0 100644 --- a/src/components/config/GiteaConfigForm.tsx +++ b/src/components/config/GiteaConfigForm.tsx @@ -210,12 +210,13 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g

- + { const newConfig = { ...config, organization: org }; @@ -227,54 +228,15 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g setConfig(newConfig); if (onAutoSave) onAutoSave(newConfig); }} + onVisibilityChange={(visibility) => { + const newConfig = { ...config, visibility }; + setConfig(newConfig); + if (onAutoSave) onAutoSave(newConfig); + }} githubUsername={githubUsername} giteaUsername={config.username} /> - - - -
- - -

- Visibility for newly created organizations -

-
- - - {/* Footer content can be added here if needed */} - ); } diff --git a/src/components/config/OrganizationStrategy.tsx b/src/components/config/OrganizationStrategy.tsx index e78d538..3ffab31 100644 --- a/src/components/config/OrganizationStrategy.tsx +++ b/src/components/config/OrganizationStrategy.tsx @@ -4,7 +4,8 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Badge } from "@/components/ui/badge"; -import { Info, GitBranch, FolderTree, Package, Star, Building2, User, ChevronDown, ChevronUp } from "lucide-react"; +import { Info, GitBranch, FolderTree, Package, Star, Building2, User, ChevronDown, ChevronUp, Globe, Lock, Shield } from "lucide-react"; +import { Separator } from "@/components/ui/separator"; import { Tooltip, TooltipContent, @@ -22,6 +23,7 @@ import { CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; +import type { GiteaOrgVisibility } from "@/types/config"; export type MirrorStrategy = "preserve" | "single-org" | "flat-user"; @@ -29,9 +31,11 @@ interface OrganizationStrategyProps { strategy: MirrorStrategy; destinationOrg?: string; starredReposOrg?: string; + visibility: GiteaOrgVisibility; onStrategyChange: (strategy: MirrorStrategy) => void; onDestinationOrgChange: (org: string) => void; onStarredReposOrgChange: (org: string) => void; + onVisibilityChange: (visibility: GiteaOrgVisibility) => void; githubUsername?: string; giteaUsername?: string; } @@ -223,7 +227,7 @@ const StrategyVisualizer: React.FC<{ ); return ( -
+
@@ -256,17 +260,24 @@ export const OrganizationStrategy: React.FC = ({ strategy, destinationOrg, starredReposOrg, + visibility, onStrategyChange, onDestinationOrgChange, onStarredReposOrgChange, + onVisibilityChange, githubUsername, giteaUsername, }) => { + const visibilityOptions = [ + { value: "public" as GiteaOrgVisibility, label: "Public", icon: Globe, description: "Visible to everyone" }, + { value: "private" as GiteaOrgVisibility, label: "Private", icon: Lock, description: "Visible to members only" }, + { value: "limited" as GiteaOrgVisibility, label: "Limited", icon: Shield, description: "Visible to logged-in users" }, + ]; return ( -
+
-

Organization Strategy

+

Organization Strategy

Choose how your repositories will be organized in Gitea

@@ -354,67 +365,112 @@ export const OrganizationStrategy: React.FC = ({
- {strategy === "single-org" && ( -
- -
-
- - onDestinationOrgChange(e.target.value)} - placeholder="github-mirrors" - className="mt-1.5" - /> -
-
-
-
- )} + - -
-
-