fix: importing tools or functions says it succeeded when every item failed (#35267)

Re-importing an export whose IDs already exist showed an "already registered" error for each item and then a green "imported successfully" toast. The success toast now only shows when at least one tool or function was actually imported. A partial import still shows it, next to the errors for the items that failed.

Fixes #35266
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 22:52:41 +04:00
1 parent b6175ef1a7
commit 75ca922153
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -771,6 +771,7 @@
const _functions = JSON.parse(event.target.result);
console.log(_functions);
let imported = false;
for (let func of _functions) {
if ('function' in func) {
// Required for Community JSON import
@@ -781,9 +782,10 @@
toast.error(`${error}`);
return null;
});
if (res) imported = true;
}
toast.success($i18n.t('Functions imported successfully'));
if (imported) toast.success($i18n.t('Functions imported successfully'));
functions = await getFunctionList(localStorage.token);
_functions.set(await getFunctions(localStorage.token));
models.set(await getModels(localStorage.token, false, true));
+3 -1
View File
@@ -777,14 +777,16 @@
const _tools = JSON.parse(event.target.result);
console.log(_tools);
let imported = false;
for (const tool of _tools) {
const res = await createNewTool(localStorage.token, tool).catch((error) => {
toast.error(`${error}`);
return null;
});
if (res) imported = true;
}
toast.success($i18n.t('Tool imported successfully'));
if (imported) toast.success($i18n.t('Tool imported successfully'));
await init();
importFiles = null;
toolsImportInputElement.value = '';