-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract action code for easier updates
- Loading branch information
1 parent
3713551
commit 608cba0
Showing
2 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
ui/admin/app/components/tools/toolGrid/ToolCardActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { EllipsisVerticalIcon } from "lucide-react"; | ||
import { toast } from "sonner"; | ||
|
||
import { ToolReference } from "~/lib/model/toolReferences"; | ||
import { ToolReferenceService } from "~/lib/service/api/toolreferenceService"; | ||
|
||
import { LoadingSpinner } from "~/components/ui/LoadingSpinner"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "~/components/ui/dropdown-menu"; | ||
import { useAsync } from "~/hooks/useAsync"; | ||
import { usePollSingleTool } from "~/hooks/usePollSingleTool"; | ||
|
||
export function ToolCardActions({ tool }: { tool: ToolReference }) { | ||
const { startPolling, isPolling } = usePollSingleTool(tool.id); | ||
|
||
const forceRefresh = useAsync( | ||
ToolReferenceService.forceRefreshToolReference, | ||
{ | ||
onSuccess: () => { | ||
toast.success("Tool reference force refreshed"); | ||
startPolling(); | ||
}, | ||
} | ||
); | ||
|
||
return ( | ||
<div className="flex items-center gap-2"> | ||
{(forceRefresh.isLoading || isPolling) && <LoadingSpinner />} | ||
|
||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" size="icon" className="m-0"> | ||
<EllipsisVerticalIcon /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
|
||
<DropdownMenuContent side="top" align="start"> | ||
<DropdownMenuItem onClick={() => forceRefresh.execute(tool.id)}> | ||
Refresh Tool | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</div> | ||
); | ||
} |