mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Merge pull request #9 from chriswritescode-dev/fix-settings-menu
Add shadcn checkbox and improve UI interactions
This commit is contained in:
5 files changed
+130
-50
No files matched your search
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^5.2.2",
|
||||
"@monaco-editor/react": "^4.7.0",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
|
||||
@@ -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";
|
||||
@@ -45,37 +46,35 @@ export function RepoCard({
|
||||
: "border-border hover:border-border hover:shadow-blue-900/20"
|
||||
}`}
|
||||
>
|
||||
<div className="p-4 sm:p-6">
|
||||
<div className="p-2 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);
|
||||
}}
|
||||
{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();
|
||||
if (onSelect) {
|
||||
onSelect(repo.id, !isSelected);
|
||||
}
|
||||
}}
|
||||
className="w-5 h-5 rounded border-gray-600 accent-blue-500 cursor-pointer"
|
||||
/>
|
||||
)}
|
||||
<h3
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (isReady) {
|
||||
navigate(`/repos/${repo.id}`);
|
||||
}
|
||||
}}
|
||||
className={`font-semibold text-lg text-foreground truncate group-hover:text-blue-400 transition-colors ${
|
||||
isReady ? "cursor-pointer" : "cursor-not-allowed opacity-60"
|
||||
}`}
|
||||
>
|
||||
{repoName}
|
||||
</h3>
|
||||
className={`font-semibold text-lg text-foreground truncate group-hover:text-blue-400 transition-colors ${
|
||||
onSelect ? "cursor-pointer" : "cursor-not-allowed opacity-60"
|
||||
}`}
|
||||
>
|
||||
{repoName}
|
||||
</h3>
|
||||
{repo.isWorktree && (
|
||||
<Badge
|
||||
className="text-xs px-2.5 py-0.5 bg-purple-600/20 text-purple-400 border-purple-600/40"
|
||||
@@ -106,8 +105,8 @@ export function RepoCard({
|
||||
<span>Cloning repository...</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -119,20 +118,21 @@ export function RepoCard({
|
||||
<ExternalLink className="w-4 h-4 mr-2" />
|
||||
Open
|
||||
</Button>
|
||||
{repo.repoUrl && (
|
||||
|
||||
|
||||
<Button
|
||||
size="sm"
|
||||
|
||||
variant="outline"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setAddBranchOpen(true);
|
||||
}}
|
||||
disabled={!isReady}
|
||||
disabled={!isReady || !repo.repoUrl}
|
||||
className="h-10 sm:h-9 w-10 p-0"
|
||||
>
|
||||
<GitBranch className="w-4 h-4" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -149,8 +149,7 @@ export function RepoCard({
|
||||
) : (
|
||||
<Trash2 className="w-4 h-4" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</Button> </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 }
|
||||
Generated
+30
@@ -61,6 +61,9 @@ importers:
|
||||
'@monaco-editor/react':
|
||||
specifier: ^4.7.0
|
||||
version: 4.7.0(monaco-editor@0.55.1)(react-dom@19.2.0)(react@19.2.0)
|
||||
'@radix-ui/react-checkbox':
|
||||
specifier: ^1.3.3
|
||||
version: 1.3.3(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0)
|
||||
'@radix-ui/react-dialog':
|
||||
specifier: ^1.1.15
|
||||
version: 1.1.15(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0)
|
||||
@@ -821,6 +824,33 @@ packages:
|
||||
react-dom: 19.2.0(react@19.2.0)
|
||||
dev: false
|
||||
|
||||
/@radix-ui/react-checkbox@1.3.3(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0):
|
||||
resolution: {integrity: sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==}
|
||||
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
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.7)(react@19.2.0)
|
||||
'@radix-ui/react-context': 1.1.2(@types/react@19.2.7)(react@19.2.0)
|
||||
'@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0)
|
||||
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0)
|
||||
'@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.2.7)(react@19.2.0)
|
||||
'@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.7)(react@19.2.0)
|
||||
'@radix-ui/react-use-size': 1.1.1(@types/react@19.2.7)(react@19.2.0)
|
||||
'@types/react': 19.2.7
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.7)
|
||||
react: 19.2.0
|
||||
react-dom: 19.2.0(react@19.2.0)
|
||||
dev: false
|
||||
|
||||
/@radix-ui/react-collection@1.1.7(@types/react-dom@19.2.3)(@types/react@19.2.7)(react-dom@19.2.0)(react@19.2.0):
|
||||
resolution: {integrity: sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw==}
|
||||
peerDependencies:
|
||||
|
||||
Reference in new issue
Block a user