import React from "react"; import { useTranslation } from "react-i18next"; import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop"; import { ModalCloseButton } from "#/components/shared/modals/modal-close-button"; import { BrandButton } from "#/components/features/settings/brand-button"; import { SettingsInput } from "#/components/features/settings/settings-input"; import { useInstallPlugin } from "#/hooks/mutation/use-install-plugin"; import { I18nKey } from "#/i18n/declaration"; import { cn } from "#/utils/utils"; import { modalTitleLgClassName } from "#/utils/modal-classes"; interface AddPluginModalProps { onClose: () => void; onInstalled?: () => void; } export function AddPluginModal({ onClose, onInstalled }: AddPluginModalProps) { const { t } = useTranslation("openhands"); const installPlugin = useInstallPlugin(); const [source, setSource] = React.useState(""); const [ref, setRef] = React.useState(""); const [repoPath, setRepoPath] = React.useState(""); const trimmedSource = source.trim(); const canSubmit = trimmedSource.length > 0 && !installPlugin.isPending; const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); if (!canSubmit) return; installPlugin.mutate( { source: trimmedSource, ref: ref.trim() || null, repo_path: repoPath.trim() || null, }, { onSuccess: () => { onInstalled?.(); onClose(); }, }, ); }; return (

{t(I18nKey.SETTINGS$PLUGINS_ADD_MODAL_TITLE)}

{t(I18nKey.SETTINGS$PLUGINS_ADD_MODAL_INTRO)}

); }