Merge pull request #12426 from silentoplayz/fix-feedback

fix: Conditionally hide export buttons
This commit is contained in:
Timothy Jaeryang Baek 2025-04-05 01:30:51 -07:00 committed by GitHub
commit a2f2203325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 125 additions and 120 deletions

View File

@ -92,6 +92,7 @@
}; };
const exportHandler = async () => { const exportHandler = async () => {
const _feedbacks = await exportAllFeedbacks(localStorage.token).catch((err) => { const _feedbacks = await exportAllFeedbacks(localStorage.token).catch((err) => {
toast.error(err); toast.error(err);
return null; return null;
@ -115,7 +116,7 @@
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{feedbacks.length}</span> <span class="text-lg font-medium text-gray-500 dark:text-gray-300">{feedbacks.length}</span>
</div> </div>
<div> {#if feedbacks.length > 0}
<div> <div>
<Tooltip content={$i18n.t('Export')}> <Tooltip content={$i18n.t('Export')}>
<button <button
@ -128,7 +129,7 @@
</button> </button>
</Tooltip> </Tooltip>
</div> </div>
</div> {/if}
</div> </div>
<div <div

View File

@ -430,39 +430,41 @@
</div> </div>
</button> </button>
<button {#if $functions.length}
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition" <button
on:click={async () => { class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
const _functions = await exportFunctions(localStorage.token).catch((error) => { on:click={async () => {
toast.error(`${error}`); const _functions = await exportFunctions(localStorage.token).catch((error) => {
return null; toast.error(`${error}`);
}); return null;
if (_functions) {
let blob = new Blob([JSON.stringify(_functions)], {
type: 'application/json'
}); });
saveAs(blob, `functions-export-${Date.now()}.json`);
}
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Functions')}</div>
<div class=" self-center"> if (_functions) {
<svg let blob = new Blob([JSON.stringify(_functions)], {
xmlns="http://www.w3.org/2000/svg" type: 'application/json'
viewBox="0 0 16 16" });
fill="currentColor" saveAs(blob, `functions-export-${Date.now()}.json`);
class="w-4 h-4" }
> }}
<path >
fill-rule="evenodd" <div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Functions')}</div>
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd" <div class=" self-center">
/> <svg
</svg> xmlns="http://www.w3.org/2000/svg"
</div> viewBox="0 0 16 16"
</button> fill="currentColor"
class="w-4 h-4"
>
<path
fill-rule="evenodd"
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd"
/>
</svg>
</div>
</button>
{/if}
</div> </div>
</div> </div>

View File

@ -93,13 +93,10 @@
const tab = await window.open(`${url}/models/create`, '_blank'); const tab = await window.open(`${url}/models/create`, '_blank');
// Define the event handler function
const messageHandler = (event) => { const messageHandler = (event) => {
if (event.origin !== url) return; if (event.origin !== url) return;
if (event.data === 'loaded') { if (event.data === 'loaded') {
tab.postMessage(JSON.stringify(model), '*'); tab.postMessage(JSON.stringify(model), '*');
// Remove the event listener after handling the message
window.removeEventListener('message', messageHandler); window.removeEventListener('message', messageHandler);
} }
}; };
@ -477,29 +474,33 @@
</div> </div>
</button> </button>
<button {#if models.length}
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition" <button
on:click={async () => { class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
downloadModels(models); on:click={async () => {
}} downloadModels(models);
> }}
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Models')}</div> >
<div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Export Models')}
</div>
<div class=" self-center"> <div class=" self-center">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
fill="currentColor" fill="currentColor"
class="w-3.5 h-3.5" class="w-3.5 h-3.5"
> >
<path <path
fill-rule="evenodd" fill-rule="evenodd"
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z" d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd" clip-rule="evenodd"
/> />
</svg> </svg>
</div> </div>
</button> </button>
{/if}
</div> </div>
</div> </div>
{/if} {/if}

View File

@ -285,33 +285,36 @@
</div> </div>
</button> </button>
<button {#if prompts.length}
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition" <button
on:click={async () => { class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
// promptsImportInputElement.click(); on:click={async () => {
let blob = new Blob([JSON.stringify(prompts)], { let blob = new Blob([JSON.stringify(prompts)], {
type: 'application/json' type: 'application/json'
}); });
saveAs(blob, `prompts-export-${Date.now()}.json`); saveAs(blob, `prompts-export-${Date.now()}.json`);
}} }}
> >
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Prompts')}</div> <div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Export Prompts')}
</div>
<div class=" self-center"> <div class=" self-center">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
fill="currentColor" fill="currentColor"
class="w-4 h-4" class="w-4 h-4"
> >
<path <path
fill-rule="evenodd" fill-rule="evenodd"
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z" d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd" clip-rule="evenodd"
/> />
</svg> </svg>
</div> </div>
</button> </button>
{/if}
</div> </div>
</div> </div>
{/if} {/if}

View File

@ -71,13 +71,10 @@
const tab = await window.open(`${url}/tools/create`, '_blank'); const tab = await window.open(`${url}/tools/create`, '_blank');
// Define the event handler function
const messageHandler = (event) => { const messageHandler = (event) => {
if (event.origin !== url) return; if (event.origin !== url) return;
if (event.data === 'loaded') { if (event.data === 'loaded') {
tab.postMessage(JSON.stringify(item), '*'); tab.postMessage(JSON.stringify(item), '*');
// Remove the event listener after handling the message
window.removeEventListener('message', messageHandler); window.removeEventListener('message', messageHandler);
} }
}; };
@ -124,8 +121,7 @@
if (res) { if (res) {
toast.success($i18n.t('Tool deleted successfully')); toast.success($i18n.t('Tool deleted successfully'));
await init();
init();
} }
}; };
@ -398,39 +394,41 @@
</div> </div>
</button> </button>
<button {#if tools.length}
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition" <button
on:click={async () => { class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
const _tools = await exportTools(localStorage.token).catch((error) => { on:click={async () => {
toast.error(`${error}`); const _tools = await exportTools(localStorage.token).catch((error) => {
return null; toast.error(`${error}`);
}); return null;
if (_tools) {
let blob = new Blob([JSON.stringify(_tools)], {
type: 'application/json'
}); });
saveAs(blob, `tools-export-${Date.now()}.json`);
}
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
<div class=" self-center"> if (_tools) {
<svg let blob = new Blob([JSON.stringify(_tools)], {
xmlns="http://www.w3.org/2000/svg" type: 'application/json'
viewBox="0 0 16 16" });
fill="currentColor" saveAs(blob, `tools-export-${Date.now()}.json`);
class="w-4 h-4" }
> }}
<path >
fill-rule="evenodd" <div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd" <div class=" self-center">
/> <svg
</svg> xmlns="http://www.w3.org/2000/svg"
</div> viewBox="0 0 16 16"
</button> fill="currentColor"
class="w-4 h-4"
>
<path
fill-rule="evenodd"
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
clip-rule="evenodd"
/>
</svg>
</div>
</button>
{/if}
</div> </div>
</div> </div>
{/if} {/if}