mirror of
https://github.com/open-webui/open-webui
synced 2025-04-29 10:42:55 +00:00
refac: banners
This commit is contained in:
parent
c5636ff68c
commit
30d02c638c
@ -1957,61 +1957,13 @@
|
|||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
{history}
|
||||||
title={$chatTitle}
|
title={$chatTitle}
|
||||||
bind:selectedModels
|
bind:selectedModels
|
||||||
shareEnabled={!!history.currentId}
|
shareEnabled={!!history.currentId}
|
||||||
{initNewChat}
|
{initNewChat}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if !history.currentId && !$chatId && selectedModels.length <= 1 && ($banners.length > 0 || ($config?.license_metadata?.type ?? null) === 'trial' || (($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats))}
|
|
||||||
<div class="absolute top-12 left-0 right-0 w-full z-30">
|
|
||||||
<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))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="flex flex-col flex-auto z-10 w-full @container">
|
<div class="flex flex-col flex-auto z-10 w-full @container">
|
||||||
{#if $settings?.landingPageMode === 'chat' || createMessagesList(history, history.currentId).length > 0}
|
{#if $settings?.landingPageMode === 'chat' || createMessagesList(history, history.currentId).length > 0}
|
||||||
<div
|
<div
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
WEBUI_NAME,
|
WEBUI_NAME,
|
||||||
|
banners,
|
||||||
chatId,
|
chatId,
|
||||||
|
config,
|
||||||
mobile,
|
mobile,
|
||||||
settings,
|
settings,
|
||||||
showArchivedChats,
|
showArchivedChats,
|
||||||
@ -26,6 +28,7 @@
|
|||||||
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
||||||
|
|
||||||
import PencilSquare from '../icons/PencilSquare.svelte';
|
import PencilSquare from '../icons/PencilSquare.svelte';
|
||||||
|
import Banner from '../common/Banner.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -34,6 +37,7 @@
|
|||||||
export let shareEnabled: boolean = false;
|
export let shareEnabled: boolean = false;
|
||||||
|
|
||||||
export let chat;
|
export let chat;
|
||||||
|
export let history;
|
||||||
export let selectedModels;
|
export let selectedModels;
|
||||||
export let showModelSelector = true;
|
export let showModelSelector = true;
|
||||||
|
|
||||||
@ -43,7 +47,8 @@
|
|||||||
|
|
||||||
<ShareChatModal bind:show={showShareChatModal} chatId={$chatId} />
|
<ShareChatModal bind:show={showShareChatModal} chatId={$chatId} />
|
||||||
|
|
||||||
<nav class="sticky top-0 z-30 w-full px-1.5 py-1.5 -mb-8 flex items-center drag-region">
|
<nav class="sticky top-0 z-30 w-full py-1.5 -mb-8 flex flex-col items-center drag-region">
|
||||||
|
<div class="flex items-center w-full px-1.5">
|
||||||
<div
|
<div
|
||||||
class=" bg-linear-to-b via-50% from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 dark:to-transparent pointer-events-none absolute inset-0 -bottom-7 z-[-1]"
|
class=" bg-linear-to-b via-50% from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 dark:to-transparent pointer-events-none absolute inset-0 -bottom-7 z-[-1]"
|
||||||
></div>
|
></div>
|
||||||
@ -175,4 +180,54 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#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))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
|
Loading…
Reference in New Issue
Block a user