mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Add shadcn checkbox component and update repo/session cards
This commit is contained in:
1 parent
f49c23eea7
commit
977507fa82
5 files changed
+119
-36
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Loader2, Trash2, GitBranch, ExternalLink } from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useState } from "react";
|
||||
@@ -48,21 +49,19 @@ export function RepoCard({
|
||||
<div className="p-4 sm:p-6">
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
{onSelect && (
|
||||
<input
|
||||
type="checkbox"
|
||||
id="select-repo"
|
||||
checked={isSelected}
|
||||
onChange={(e) => {
|
||||
e.stopPropagation();
|
||||
onSelect(repo.id, e.target.checked);
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
className="w-5 h-5 rounded border-gray-600 accent-blue-500 cursor-pointer"
|
||||
/>
|
||||
)}
|
||||
{onSelect && (
|
||||
<Checkbox
|
||||
id="select-repo"
|
||||
checked={isSelected}
|
||||
onCheckedChange={(checked) => {
|
||||
onSelect(repo.id, checked === true);
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
className="w-5 h-5"
|
||||
/>
|
||||
)}
|
||||
<h3
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -106,19 +105,22 @@ export function RepoCard({
|
||||
<span>Cloning repository...</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
<div className="flex justify-between">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(`/repos/${repo.id}`);
|
||||
}}
|
||||
disabled={!isReady}
|
||||
className="cursor-pointer flex-1 h-10 sm:h-9 px-3"
|
||||
className="cursor-pointer w-[150px] h-10 sm:h-9 px-3"
|
||||
>
|
||||
<ExternalLink className="w-4 h-4 mr-2" />
|
||||
Open
|
||||
</Button>
|
||||
|
||||
<div className="flex gap-2">
|
||||
|
||||
{repo.repoUrl && (
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -149,7 +151,7 @@ export function RepoCard({
|
||||
) : (
|
||||
<Trash2 className="w-4 h-4" />
|
||||
)}
|
||||
</Button>
|
||||
</Button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,10 @@ import { useSessions, useDeleteSession } from "@/hooks/useOpenCode";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { DeleteSessionDialog } from "./DeleteSessionDialog";
|
||||
import { Trash2, GitBranch, Clock, Search } from "lucide-react";
|
||||
import { Trash2, GitBranch, Clock, Search, MoreHorizontal } from "lucide-react";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
|
||||
interface SessionListProps {
|
||||
@@ -126,7 +128,7 @@ export const SessionList = ({
|
||||
<Button
|
||||
onClick={toggleSelectAll}
|
||||
variant={selectedSessions.size > 0 ? "default" : "outline"}
|
||||
className="whitespace-nowrap"
|
||||
className="whitespace-nowrap hidden md:flex"
|
||||
>
|
||||
{filteredSessions.every((session) =>
|
||||
selectedSessions.has(session.id),
|
||||
@@ -144,15 +146,37 @@ export const SessionList = ({
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
Delete ({selectedSessions.size})
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleBulkDelete}
|
||||
variant="destructive"
|
||||
disabled={selectedSessions.size === 0}
|
||||
size="icon"
|
||||
className="md:hidden"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="md:hidden"
|
||||
disabled={filteredSessions.length === 0}
|
||||
>
|
||||
<MoreHorizontal className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{filteredSessions.length > 0 && (
|
||||
<DropdownMenuItem onClick={toggleSelectAll}>
|
||||
{filteredSessions.every((session) =>
|
||||
selectedSessions.has(session.id),
|
||||
)
|
||||
? "Deselect All"
|
||||
: "Select All"}
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={handleBulkDelete}
|
||||
disabled={selectedSessions.size === 0}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
Delete ({selectedSessions.size})
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -177,17 +201,15 @@ export const SessionList = ({
|
||||
>
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<div className="flex items-start gap-2 flex-1 min-w-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
<Checkbox
|
||||
checked={selectedSessions.has(session.id)}
|
||||
onChange={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleSessionSelection(session.id, e.target.checked);
|
||||
onCheckedChange={(checked) => {
|
||||
toggleSessionSelection(session.id, checked === true);
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
className="w-5 h-5 rounded border-gray-600 accent-blue-500 cursor-pointer flex-shrink-0 mt-0.5"
|
||||
className="w-5 h-5 flex-shrink-0 mt-0.5"
|
||||
/>
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="text-sm font-medium text-white truncate">
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as React from "react"
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||
import { Check } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator
|
||||
className={cn("flex items-center justify-center text-current")}
|
||||
>
|
||||
<Check className="h-4 w-4" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
))
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
||||
|
||||
export { Checkbox }
|
||||
Reference in new issue
Block a user