repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { Button } from "@/components/ui/button"; |
| #2 | import { Pencil, Archive, Trash, Pause, Play, ChevronDown } from "lucide-react"; |
| #3 | import { useUI } from "@/hooks/useUI"; |
| #4 | import { useMemoriesApi } from "@/hooks/useMemoriesApi"; |
| #5 | import { |
| #6 | DropdownMenu, |
| #7 | DropdownMenuContent, |
| #8 | DropdownMenuItem, |
| #9 | DropdownMenuTrigger, |
| #10 | DropdownMenuLabel, |
| #11 | DropdownMenuSeparator, |
| #12 | } from "@/components/ui/dropdown-menu"; |
| #13 | |
| #14 | interface MemoryActionsProps { |
| #15 | memoryId: string; |
| #16 | memoryContent: string; |
| #17 | memoryState: string; |
| #18 | } |
| #19 | |
| #20 | export function MemoryActions({ |
| #21 | memoryId, |
| #22 | memoryContent, |
| #23 | memoryState, |
| #24 | }: MemoryActionsProps) { |
| #25 | const { handleOpenUpdateMemoryDialog } = useUI(); |
| #26 | const { updateMemoryState, isLoading } = useMemoriesApi(); |
| #27 | |
| #28 | const handleEdit = () => { |
| #29 | handleOpenUpdateMemoryDialog(memoryId, memoryContent); |
| #30 | }; |
| #31 | |
| #32 | const handleStateChange = (newState: string) => { |
| #33 | updateMemoryState([memoryId], newState); |
| #34 | }; |
| #35 | |
| #36 | const getStateLabel = () => { |
| #37 | switch (memoryState) { |
| #38 | case "archived": |
| #39 | return "Archived"; |
| #40 | case "paused": |
| #41 | return "Paused"; |
| #42 | default: |
| #43 | return "Active"; |
| #44 | } |
| #45 | }; |
| #46 | |
| #47 | const getStateIcon = () => { |
| #48 | switch (memoryState) { |
| #49 | case "archived": |
| #50 | return <Archive className="h-3 w-3 mr-2" />; |
| #51 | case "paused": |
| #52 | return <Pause className="h-3 w-3 mr-2" />; |
| #53 | default: |
| #54 | return <Play className="h-3 w-3 mr-2" />; |
| #55 | } |
| #56 | }; |
| #57 | |
| #58 | return ( |
| #59 | <div className="flex gap-2"> |
| #60 | <DropdownMenu> |
| #61 | <DropdownMenuTrigger asChild> |
| #62 | <Button |
| #63 | disabled={isLoading} |
| #64 | variant="outline" |
| #65 | size="sm" |
| #66 | className="shadow-md bg-zinc-900 border border-zinc-700/50 hover:bg-zinc-950 text-zinc-400" |
| #67 | > |
| #68 | <span className="font-semibold">{getStateLabel()}</span> |
| #69 | <ChevronDown className="h-3 w-3 mt-1 -ml-1" /> |
| #70 | </Button> |
| #71 | </DropdownMenuTrigger> |
| #72 | <DropdownMenuContent className="w-40 bg-zinc-900 border-zinc-800 text-zinc-100"> |
| #73 | <DropdownMenuLabel>Change State</DropdownMenuLabel> |
| #74 | <DropdownMenuSeparator className="bg-zinc-800" /> |
| #75 | <DropdownMenuItem |
| #76 | onClick={() => handleStateChange("active")} |
| #77 | className="cursor-pointer flex items-center" |
| #78 | disabled={memoryState === "active"} |
| #79 | > |
| #80 | <Play className="h-3 w-3 mr-2" /> |
| #81 | <span className="font-semibold">Active</span> |
| #82 | </DropdownMenuItem> |
| #83 | <DropdownMenuItem |
| #84 | onClick={() => handleStateChange("paused")} |
| #85 | className="cursor-pointer flex items-center" |
| #86 | disabled={memoryState === "paused"} |
| #87 | > |
| #88 | <Pause className="h-3 w-3 mr-2" /> |
| #89 | <span className="font-semibold">Pause</span> |
| #90 | </DropdownMenuItem> |
| #91 | <DropdownMenuItem |
| #92 | onClick={() => handleStateChange("archived")} |
| #93 | className="cursor-pointer flex items-center" |
| #94 | disabled={memoryState === "archived"} |
| #95 | > |
| #96 | <Archive className="h-3 w-3 mr-2" /> |
| #97 | <span className="font-semibold">Archive</span> |
| #98 | </DropdownMenuItem> |
| #99 | </DropdownMenuContent> |
| #100 | </DropdownMenu> |
| #101 | |
| #102 | <Button |
| #103 | disabled={isLoading} |
| #104 | variant="outline" |
| #105 | size="sm" |
| #106 | onClick={handleEdit} |
| #107 | className="shadow-md bg-zinc-900 border border-zinc-700/50 hover:bg-zinc-950 text-zinc-400" |
| #108 | > |
| #109 | <Pencil className="h-3 w-3 -mr-1" /> |
| #110 | <span className="font-semibold">Edit</span> |
| #111 | </Button> |
| #112 | </div> |
| #113 | ); |
| #114 | } |
| #115 |