refac: Improve banner handling and command visibility in chat UI
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
export let history;
|
||||
export let selectedModels;
|
||||
export let showModelSelector = true;
|
||||
export let showBanners = true;
|
||||
|
||||
let closedBannerIds = [];
|
||||
|
||||
let showShareChatModal = false;
|
||||
let showDownloadChatModal = false;
|
||||
@@ -199,52 +202,60 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !history.currentId && !$chatId && ($banners.length > 0 || ($config?.license_metadata?.type ?? null) === 'trial' || (($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats))}
|
||||
<div class=" w-full z-30 mt-5">
|
||||
<div class=" flex flex-col gap-1 w-full">
|
||||
{#if ($config?.license_metadata?.type ?? null) === 'trial'}
|
||||
<Banner
|
||||
banner={{
|
||||
type: 'info',
|
||||
title: 'Trial License',
|
||||
content: $i18n.t(
|
||||
'You are currently using a trial license. Please contact support to upgrade your license.'
|
||||
)
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if ($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats}
|
||||
<Banner
|
||||
banner={{
|
||||
type: 'error',
|
||||
title: 'License Error',
|
||||
content: $i18n.t(
|
||||
'Exceeded the number of seats in your license. Please contact support to increase the number of seats.'
|
||||
)
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#each $banners.filter( (b) => (b.dismissible ? !JSON.parse(localStorage.getItem('dismissedBannerIds') ?? '[]').includes(b.id) : true) ) as banner}
|
||||
<Banner
|
||||
{banner}
|
||||
on:dismiss={(e) => {
|
||||
const bannerId = e.detail;
|
||||
|
||||
localStorage.setItem(
|
||||
'dismissedBannerIds',
|
||||
JSON.stringify(
|
||||
[
|
||||
bannerId,
|
||||
...JSON.parse(localStorage.getItem('dismissedBannerIds') ?? '[]')
|
||||
].filter((id) => $banners.find((b) => b.id === id))
|
||||
<div class="absolute top-[100%] left-0 right-0 h-fit">
|
||||
{#if !history.currentId && !$chatId && ($banners.length > 0 || ($config?.license_metadata?.type ?? null) === 'trial' || (($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats))}
|
||||
<div class=" w-full z-30 mt-5">
|
||||
<div class=" flex flex-col gap-1 w-full">
|
||||
{#if ($config?.license_metadata?.type ?? null) === 'trial'}
|
||||
<Banner
|
||||
banner={{
|
||||
type: 'info',
|
||||
title: 'Trial License',
|
||||
content: $i18n.t(
|
||||
'You are currently using a trial license. Please contact support to upgrade your license.'
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if ($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats}
|
||||
<Banner
|
||||
banner={{
|
||||
type: 'error',
|
||||
title: 'License Error',
|
||||
content: $i18n.t(
|
||||
'Exceeded the number of seats in your license. Please contact support to increase the number of seats.'
|
||||
)
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showBanners}
|
||||
{#each $banners.filter((b) => ![...JSON.parse(localStorage.getItem('dismissedBannerIds') ?? '[]'), ...closedBannerIds].includes(b.id)) as banner}
|
||||
<Banner
|
||||
{banner}
|
||||
on:dismiss={(e) => {
|
||||
const bannerId = e.detail;
|
||||
|
||||
if (banner.dismissible) {
|
||||
localStorage.setItem(
|
||||
'dismissedBannerIds',
|
||||
JSON.stringify(
|
||||
[
|
||||
bannerId,
|
||||
...JSON.parse(localStorage.getItem('dismissedBannerIds') ?? '[]')
|
||||
].filter((id) => $banners.find((b) => b.id === id))
|
||||
)
|
||||
);
|
||||
} else {
|
||||
closedBannerIds = [...closedBannerIds, bannerId];
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user