import React from "react"; import { useTranslation } from "react-i18next"; import { I18nKey } from "#/i18n/declaration"; import { cn } from "#/utils/utils"; import { CirclePlusCheckToggle } from "#/components/shared/buttons/circle-plus-check-toggle"; import { BrandButton } from "#/components/features/settings/brand-button"; import { extensionModuleCardInteractiveClassName, extensionModuleCardPillClassName, extensionModuleCardSurfaceClassName, } from "#/utils/extension-module-card-classes"; import type { PluginViewModel } from "./build-plugins-view-model"; interface PluginCardProps { plugin: PluginViewModel; /** A mutation targeting this plugin is in flight. */ isBusy?: boolean; /** Management actions are unavailable (e.g. non-local backend). */ isDisabled?: boolean; onOpen: () => void; onInstall: () => void; onToggle: (enabled: boolean) => void; } export function PluginCard({ plugin, isBusy = false, isDisabled = false, onOpen, onInstall, onToggle, }: PluginCardProps) { const { t } = useTranslation("openhands"); const handleKeyDown = (event: React.KeyboardEvent) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); onOpen(); } }; const handleInstall = (event?: React.MouseEvent) => { event?.stopPropagation(); onInstall(); }; return (

{plugin.name}

{plugin.source ? (

{plugin.source}

) : null}
{plugin.installed ? ( ) : plugin.isLocal ? ( {t(I18nKey.SETTINGS$PLUGINS_FILTER_LOCAL)} ) : ( {t( isBusy ? I18nKey.SETTINGS$PLUGINS_INSTALLING : I18nKey.SETTINGS$PLUGINS_INSTALL, )} )}
{plugin.description ? (

{plugin.description}

) : null} {(plugin.installed || plugin.isLocal) && plugin.version ? ( {t(I18nKey.SETTINGS$SKILLS_VERSION, { version: plugin.version })} ) : null}
); }