- feat(mcp): unify notifications via onNotify in form and wizard

- refactor(mcp): remove HTML5 required to avoid native popups

- refactor(ui): propagate onNotify from App → McpPanel → McpFormModal → McpWizardModal

- feat(settings): use onNotify for export and file-selection feedback

- fix(ui): notify link-open failures via onNotify; remove unused appType prop from ProviderList

- chore: format codebase and ensure typecheck passes
This commit is contained in:
Jason
2025-10-10 20:52:16 +08:00
parent bfdf7d4ad5
commit e88562be98
10 changed files with 99 additions and 22 deletions

View File

@@ -8,6 +8,11 @@ interface McpWizardModalProps {
isOpen: boolean;
onClose: () => void;
onApply: (json: string) => void;
onNotify?: (
message: string,
type: "success" | "error",
duration?: number,
) => void;
}
/**
@@ -66,6 +71,7 @@ const McpWizardModal: React.FC<McpWizardModalProps> = ({
isOpen,
onClose,
onApply,
onNotify,
}) => {
const { t } = useTranslation();
const [wizardType, setWizardType] = useState<"stdio" | "http">("stdio");
@@ -124,11 +130,11 @@ const McpWizardModal: React.FC<McpWizardModalProps> = ({
const handleApply = () => {
if (wizardType === "stdio" && !wizardCommand.trim()) {
alert(t("mcp.error.commandRequired"));
onNotify?.(t("mcp.error.commandRequired"), "error", 3000);
return;
}
if (wizardType === "http" && !wizardUrl.trim()) {
alert(t("mcp.wizard.urlRequired"));
onNotify?.(t("mcp.wizard.urlRequired"), "error", 3000);
return;
}
@@ -256,7 +262,6 @@ const McpWizardModal: React.FC<McpWizardModalProps> = ({
onChange={(e) => setWizardCommand(e.target.value)}
onKeyDown={handleKeyDown}
placeholder={t("mcp.wizard.commandPlaceholder")}
required
className="w-full rounded-lg border border-gray-200 px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-emerald-500/20 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100"
/>
</div>
@@ -321,7 +326,6 @@ const McpWizardModal: React.FC<McpWizardModalProps> = ({
onChange={(e) => setWizardUrl(e.target.value)}
onKeyDown={handleKeyDown}
placeholder={t("mcp.wizard.urlPlaceholder")}
required
className="w-full rounded-lg border border-gray-200 px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-emerald-500/20 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100"
/>
</div>