From 42314ab0e3ea3340698f7265f8c024a63361462f Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Sun, 15 Jun 2025 13:08:39 +0530 Subject: [PATCH] feat: add collapsible component and integrate it into OrganizationStrategy for improved UI --- bun.lock | 3 + package.json | 1 + .../config/OrganizationStrategy.tsx | 63 +++++++++++++------ src/components/ui/collapsible.tsx | 31 +++++++++ 4 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 src/components/ui/collapsible.tsx diff --git a/bun.lock b/bun.lock index 918b5c3..d3ab0dd 100644 --- a/bun.lock +++ b/bun.lock @@ -10,6 +10,7 @@ "@octokit/rest": "^21.1.1", "@radix-ui/react-avatar": "^1.1.9", "@radix-ui/react-checkbox": "^1.3.1", + "@radix-ui/react-collapsible": "^1.1.11", "@radix-ui/react-dialog": "^1.1.13", "@radix-ui/react-dropdown-menu": "^2.1.14", "@radix-ui/react-label": "^2.1.6", @@ -282,6 +283,8 @@ "@radix-ui/react-checkbox": ["@radix-ui/react-checkbox@1.3.2", "", { "dependencies": { "@radix-ui/primitive": "1.1.2", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-presence": "1.1.4", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-controllable-state": "1.2.2", "@radix-ui/react-use-previous": "1.1.1", "@radix-ui/react-use-size": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-yd+dI56KZqawxKZrJ31eENUwqc1QSqg4OZ15rybGjF2ZNwMO+wCyHzAVLRp9qoYJf7kYy0YpZ2b0JCzJ42HZpA=="], + "@radix-ui/react-collapsible": ["@radix-ui/react-collapsible@1.1.11", "", { "dependencies": { "@radix-ui/primitive": "1.1.2", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-id": "1.1.1", "@radix-ui/react-presence": "1.1.4", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-controllable-state": "1.2.2", "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-2qrRsVGSCYasSz1RFOorXwl0H7g7J1frQtgpQgYrt+MOidtPAINHn9CPovQXb83r8ahapdx3Tu0fa/pdFFSdPg=="], + "@radix-ui/react-collection": ["@radix-ui/react-collection@1.1.7", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw=="], "@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="], diff --git a/package.json b/package.json index 7e41176..cc4ce54 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@octokit/rest": "^21.1.1", "@radix-ui/react-avatar": "^1.1.9", "@radix-ui/react-checkbox": "^1.3.1", + "@radix-ui/react-collapsible": "^1.1.11", "@radix-ui/react-dialog": "^1.1.13", "@radix-ui/react-dropdown-menu": "^2.1.14", "@radix-ui/react-label": "^2.1.6", diff --git a/src/components/config/OrganizationStrategy.tsx b/src/components/config/OrganizationStrategy.tsx index 41d6360..fe219bb 100644 --- a/src/components/config/OrganizationStrategy.tsx +++ b/src/components/config/OrganizationStrategy.tsx @@ -1,10 +1,10 @@ -import React from "react"; +import React, { useState } from "react"; import { Card } from "@/components/ui/card"; 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 } from "lucide-react"; +import { Info, GitBranch, FolderTree, Package, Star, Building2, User, ChevronDown, ChevronUp } from "lucide-react"; import { Tooltip, TooltipContent, @@ -12,6 +12,11 @@ import { TooltipTrigger, } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@/components/ui/collapsible"; export type MirrorStrategy = "preserve" | "single-org" | "flat-user"; @@ -74,7 +79,12 @@ const StrategyVisualizer: React.FC<{ starredReposOrg?: string; githubUsername?: string; giteaUsername?: string; -}> = ({ strategy, destinationOrg, starredReposOrg, githubUsername = "you", giteaUsername = "you" }) => { +}> = ({ strategy, destinationOrg, starredReposOrg, githubUsername, giteaUsername }) => { + const [isOpen, setIsOpen] = useState(false); + const displayGithubUsername = githubUsername || ""; + const displayGiteaUsername = giteaUsername || ""; + const isGithubPlaceholder = !githubUsername; + const isGiteaPlaceholder = !giteaUsername; const renderPreserveStructure = () => (
@@ -82,7 +92,7 @@ const StrategyVisualizer: React.FC<{
- {githubUsername}/my-repo + {displayGithubUsername}/my-repo
@@ -104,7 +114,7 @@ const StrategyVisualizer: React.FC<{
- {giteaUsername}/my-repo + {displayGiteaUsername}/my-repo
@@ -126,7 +136,7 @@ const StrategyVisualizer: React.FC<{
- {githubUsername}/my-repo + {displayGithubUsername}/my-repo
@@ -170,7 +180,7 @@ const StrategyVisualizer: React.FC<{
- {githubUsername}/my-repo + {displayGithubUsername}/my-repo
@@ -192,11 +202,11 @@ const StrategyVisualizer: React.FC<{
- {giteaUsername}/my-repo + {displayGiteaUsername}/my-repo
- {giteaUsername}/team-repo + {displayGiteaUsername}/team-repo
@@ -209,17 +219,30 @@ const StrategyVisualizer: React.FC<{ return (
- -
-

- - Repository Mapping Preview -

-
- {strategy === "preserve" && renderPreserveStructure()} - {strategy === "single-org" && renderSingleOrg()} - {strategy === "flat-user" && renderFlatUser()} -
+ + + +
+

+ + + Repository Mapping Preview + + {isOpen ? ( + + ) : ( + + )} +

+
+
+ + {strategy === "preserve" && renderPreserveStructure()} + {strategy === "single-org" && renderSingleOrg()} + {strategy === "flat-user" && renderFlatUser()} + +
+
); }; diff --git a/src/components/ui/collapsible.tsx b/src/components/ui/collapsible.tsx new file mode 100644 index 0000000..77f86be --- /dev/null +++ b/src/components/ui/collapsible.tsx @@ -0,0 +1,31 @@ +import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" + +function Collapsible({ + ...props +}: React.ComponentProps) { + return +} + +function CollapsibleTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function CollapsibleContent({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Collapsible, CollapsibleTrigger, CollapsibleContent }