open-webui/src/lib/components/ChangelogModal.svelte

118 lines
3.5 KiB
Svelte
Raw Normal View History

2024-02-23 08:30:26 +00:00
<script lang="ts">
2025-09-10 10:50:10 +00:00
import DOMPurify from 'dompurify';
import { onMount, getContext } from 'svelte';
2024-02-23 08:30:26 +00:00
import { Confetti } from 'svelte-confetti';
2024-02-23 08:47:54 +00:00
2024-10-23 07:38:59 +00:00
import { WEBUI_NAME, config, settings } from '$lib/stores';
2024-02-23 08:47:54 +00:00
2024-02-24 01:12:19 +00:00
import { WEBUI_VERSION } from '$lib/constants';
2024-02-23 08:30:26 +00:00
import { getChangelog } from '$lib/apis';
2024-02-23 08:47:54 +00:00
import Modal from './common/Modal.svelte';
2024-10-23 07:38:59 +00:00
import { updateUserSettings } from '$lib/apis/users';
2025-06-25 22:44:45 +00:00
import XMark from '$lib/components/icons/XMark.svelte';
2024-02-23 08:47:54 +00:00
const i18n = getContext('i18n');
2024-02-23 08:30:26 +00:00
export let show = false;
let changelog = null;
const init = async () => {
changelog = await getChangelog();
};
2025-09-18 22:50:39 +00:00
$: if (show) {
init();
}
2024-02-23 08:30:26 +00:00
</script>
2025-09-10 10:50:10 +00:00
<Modal bind:show size="xl">
2025-09-20 05:56:25 +00:00
<div class="px-6 pt-5 dark:text-white text-black">
2024-02-23 08:30:26 +00:00
<div class="flex justify-between items-start">
2025-09-20 05:56:25 +00:00
<div class="text-xl font-medium">
{$i18n.t("What's New in")}
2024-03-04 08:53:56 +00:00
{$WEBUI_NAME}
2024-02-23 09:18:30 +00:00
<Confetti x={[-1, -0.25]} y={[0, 0.5]} />
2024-02-23 08:30:26 +00:00
</div>
<button
class="self-center"
on:click={() => {
2024-04-16 21:01:12 +00:00
localStorage.version = $config.version;
2024-02-23 08:30:26 +00:00
show = false;
}}
2025-06-25 22:44:45 +00:00
aria-label={$i18n.t('Close')}
2024-02-23 08:30:26 +00:00
>
2025-06-27 11:44:26 +00:00
<XMark className={'size-5'}>
2025-06-27 11:30:00 +00:00
<p class="sr-only">{$i18n.t('Close')}</p>
</XMark>
2024-02-23 08:30:26 +00:00
</button>
</div>
2024-02-23 09:18:30 +00:00
<div class="flex items-center mt-1">
<div class="text-sm dark:text-gray-200">{$i18n.t('Release Notes')}</div>
2025-09-20 05:56:25 +00:00
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50/50 dark:bg-gray-850/50" />
2024-02-23 08:30:26 +00:00
<div class="text-sm dark:text-gray-200">
2024-02-24 01:12:19 +00:00
v{WEBUI_VERSION}
2024-02-23 08:30:26 +00:00
</div>
</div>
2024-02-23 09:18:30 +00:00
</div>
2024-05-02 09:47:16 +00:00
<div class=" w-full p-4 px-5 text-gray-700 dark:text-gray-100">
2025-09-20 05:56:25 +00:00
<div class=" overflow-y-scroll max-h-[30rem] scrollbar-hidden">
2024-02-23 09:18:30 +00:00
<div class="mb-3">
2024-02-23 08:30:26 +00:00
{#if changelog}
{#each Object.keys(changelog) as version}
2024-02-23 09:31:28 +00:00
<div class=" mb-3 pr-2">
2024-07-08 20:35:25 +00:00
<div class="font-semibold text-xl mb-1 dark:text-white">
2024-02-23 09:31:28 +00:00
v{version} - {changelog[version].date}
</div>
2024-02-23 08:30:26 +00:00
2025-09-20 05:56:25 +00:00
<hr class="border-gray-50/50 dark:border-gray-850/50 my-2" />
2024-02-23 09:18:30 +00:00
2024-02-23 09:31:28 +00:00
{#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
2025-09-10 10:50:10 +00:00
<div class="w-full">
2024-02-23 09:31:28 +00:00
<div
2024-07-08 20:35:25 +00:00
class="font-semibold uppercase text-xs {section === 'added'
2025-09-20 05:56:25 +00:00
? 'bg-blue-500/20 text-blue-700 dark:text-blue-200'
2024-02-23 09:31:28 +00:00
: section === 'fixed'
2025-09-20 05:56:25 +00:00
? 'bg-green-500/20 text-green-700 dark:text-green-200'
2024-08-13 10:12:35 +00:00
: section === 'changed'
2025-09-20 05:56:25 +00:00
? 'bg-yellow-500/20 text-yellow-700 dark:text-yellow-200'
2024-08-13 10:12:35 +00:00
: section === 'removed'
2025-09-20 05:56:25 +00:00
? 'bg-red-500/20 text-red-700 dark:text-red-200'
: ''} w-fit rounded-xl px-2 my-2.5"
2024-02-23 09:31:28 +00:00
>
{section}
</div>
2024-02-23 08:30:26 +00:00
2025-09-10 10:50:10 +00:00
<div class="my-2.5 px-1.5 markdown-prose-sm !list-none !w-full !max-w-none">
{#each changelog[version][section] as entry}
<div class="my-2">
{@html DOMPurify.sanitize(entry?.raw)}
2024-02-23 08:30:26 +00:00
</div>
2024-02-23 09:31:28 +00:00
{/each}
</div>
2024-02-23 08:30:26 +00:00
</div>
2024-02-23 09:31:28 +00:00
{/each}
</div>
2024-02-23 08:30:26 +00:00
{/each}
{/if}
</div>
</div>
<div class="flex justify-end pt-3 text-sm font-medium">
<button
2024-10-23 07:38:59 +00:00
on:click={async () => {
2024-02-23 08:47:54 +00:00
localStorage.version = $config.version;
2024-10-23 07:38:59 +00:00
await settings.set({ ...$settings, ...{ version: $config.version } });
await updateUserSettings(localStorage.token, { ui: $settings });
2024-02-23 08:30:26 +00:00
show = false;
}}
2024-11-19 22:18:32 +00:00
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
2024-02-23 08:30:26 +00:00
>
<span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
2024-02-23 08:30:26 +00:00
</button>
</div>
</div>
</Modal>