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

View File

@ -430,6 +430,7 @@
</div>
</button>
{#if $functions.length}
<button
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"
on:click={async () => {
@ -463,6 +464,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>

View File

@ -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,13 +474,16 @@
</div>
</button>
{#if models.length}
<button
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"
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">
<svg
@ -500,6 +500,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}

View File

@ -285,17 +285,19 @@
</div>
</button>
{#if prompts.length}
<button
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"
on:click={async () => {
// promptsImportInputElement.click();
let blob = new Blob([JSON.stringify(prompts)], {
type: 'application/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">
<svg
@ -312,6 +314,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}

View File

@ -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,6 +394,7 @@
</div>
</button>
{#if tools.length}
<button
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"
on:click={async () => {
@ -431,6 +428,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}