From 2b0d9c26eb137e49905150ce3fff921bd3e4915f Mon Sep 17 00:00:00 2001 From: Silentoplayz <50341825+Silentoplayz@users.noreply.github.com> Date: Thu, 3 Apr 2025 22:20:40 -0400 Subject: [PATCH 1/3] fix: don't show export button if nothing to export --- src/lib/components/admin/Evaluations/Feedbacks.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/components/admin/Evaluations/Feedbacks.svelte b/src/lib/components/admin/Evaluations/Feedbacks.svelte index 026755b8a..fa3707117 100644 --- a/src/lib/components/admin/Evaluations/Feedbacks.svelte +++ b/src/lib/components/admin/Evaluations/Feedbacks.svelte @@ -92,6 +92,11 @@ }; const exportHandler = async () => { + if (feedbacks.length === 0) { + toast.info($i18n.t('No feedback available to export.')); + return; + } + const _feedbacks = await exportAllFeedbacks(localStorage.token).catch((err) => { toast.error(err); return null; @@ -115,7 +120,7 @@ {feedbacks.length} -
+ {#if feedbacks.length > 0}
-
+ {/if}
Date: Fri, 4 Apr 2025 02:38:03 +0000 Subject: [PATCH 2/3] Update Feedbacks.svelte fix --- src/lib/components/admin/Evaluations/Feedbacks.svelte | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib/components/admin/Evaluations/Feedbacks.svelte b/src/lib/components/admin/Evaluations/Feedbacks.svelte index fa3707117..3733576d0 100644 --- a/src/lib/components/admin/Evaluations/Feedbacks.svelte +++ b/src/lib/components/admin/Evaluations/Feedbacks.svelte @@ -92,10 +92,6 @@ }; const exportHandler = async () => { - if (feedbacks.length === 0) { - toast.info($i18n.t('No feedback available to export.')); - return; - } const _feedbacks = await exportAllFeedbacks(localStorage.token).catch((err) => { toast.error(err); From 41b9ff9e00deba85917770d3bb78f6f4f2a9a4f9 Mon Sep 17 00:00:00 2001 From: Silentoplayz <50341825+Silentoplayz@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:33:30 -0400 Subject: [PATCH 3/3] fix: funcs, models, prompts, & tools conditional export button --- src/lib/components/admin/Functions.svelte | 64 ++++++++++--------- src/lib/components/workspace/Models.svelte | 51 +++++++-------- src/lib/components/workspace/Prompts.svelte | 55 ++++++++-------- src/lib/components/workspace/Tools.svelte | 70 ++++++++++----------- 4 files changed, 122 insertions(+), 118 deletions(-) diff --git a/src/lib/components/admin/Functions.svelte b/src/lib/components/admin/Functions.svelte index f5868d09c..87f4958d4 100644 --- a/src/lib/components/admin/Functions.svelte +++ b/src/lib/components/admin/Functions.svelte @@ -430,39 +430,41 @@
- + if (_functions) { + let blob = new Blob([JSON.stringify(_functions)], { + type: 'application/json' + }); + saveAs(blob, `functions-export-${Date.now()}.json`); + } + }} + > +
{$i18n.t('Export Functions')}
+ +
+ + + +
+ + {/if} diff --git a/src/lib/components/workspace/Models.svelte b/src/lib/components/workspace/Models.svelte index 3c509a0bc..c9137fb85 100644 --- a/src/lib/components/workspace/Models.svelte +++ b/src/lib/components/workspace/Models.svelte @@ -93,13 +93,10 @@ const tab = await window.open(`${url}/models/create`, '_blank'); - // Define the event handler function const messageHandler = (event) => { if (event.origin !== url) return; if (event.data === 'loaded') { tab.postMessage(JSON.stringify(model), '*'); - - // Remove the event listener after handling the message window.removeEventListener('message', messageHandler); } }; @@ -477,29 +474,33 @@ - +
+ + + +
+ + {/if} {/if} diff --git a/src/lib/components/workspace/Prompts.svelte b/src/lib/components/workspace/Prompts.svelte index 98401f3f9..0c16b49a2 100644 --- a/src/lib/components/workspace/Prompts.svelte +++ b/src/lib/components/workspace/Prompts.svelte @@ -285,33 +285,36 @@ - +
+ + + +
+ + {/if} {/if} diff --git a/src/lib/components/workspace/Tools.svelte b/src/lib/components/workspace/Tools.svelte index c42ebb485..593797822 100644 --- a/src/lib/components/workspace/Tools.svelte +++ b/src/lib/components/workspace/Tools.svelte @@ -71,13 +71,10 @@ const tab = await window.open(`${url}/tools/create`, '_blank'); - // Define the event handler function const messageHandler = (event) => { if (event.origin !== url) return; if (event.data === 'loaded') { tab.postMessage(JSON.stringify(item), '*'); - - // Remove the event listener after handling the message window.removeEventListener('message', messageHandler); } }; @@ -124,8 +121,7 @@ if (res) { toast.success($i18n.t('Tool deleted successfully')); - - init(); + await init(); } }; @@ -398,39 +394,41 @@ - + if (_tools) { + let blob = new Blob([JSON.stringify(_tools)], { + type: 'application/json' + }); + saveAs(blob, `tools-export-${Date.now()}.json`); + } + }} + > +
{$i18n.t('Export Tools')}
+ +
+ + + +
+ + {/if} {/if}