refac
This commit is contained in:
1 parent
bd406851ea
commit
a3908f1281
3 files changed
+80
-44
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
import { onMount, getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
|
|
||||||
import { WEBUI_NAME, config, settings } from '$lib/stores';
|
import { WEBUI_NAME, config, settings } from '$lib/stores';
|
||||||
|
|
||||||
@@ -16,7 +16,15 @@
|
|||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
|
|
||||||
let changelog = null;
|
type ChangelogEntry = {
|
||||||
|
raw?: string;
|
||||||
|
};
|
||||||
|
type ChangelogVersion = {
|
||||||
|
date: string;
|
||||||
|
[section: string]: string | ChangelogEntry[];
|
||||||
|
};
|
||||||
|
|
||||||
|
let changelog: Record<string, ChangelogVersion> | null = null;
|
||||||
let error = false;
|
let error = false;
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
@@ -41,19 +49,37 @@
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatDate = (date) => {
|
const formatDate = (date: string) => {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const [year, month, day] = date.split('-');
|
const [year, month, day] = date.split('-');
|
||||||
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
const months = [
|
||||||
|
'Jan',
|
||||||
|
'Feb',
|
||||||
|
'Mar',
|
||||||
|
'Apr',
|
||||||
|
'May',
|
||||||
|
'Jun',
|
||||||
|
'Jul',
|
||||||
|
'Aug',
|
||||||
|
'Sep',
|
||||||
|
'Oct',
|
||||||
|
'Nov',
|
||||||
|
'Dec'
|
||||||
|
];
|
||||||
const monthIndex = Number(month) - 1;
|
const monthIndex = Number(month) - 1;
|
||||||
|
|
||||||
return year && monthIndex >= 0 && monthIndex < months.length && day
|
return year && monthIndex >= 0 && monthIndex < months.length && day
|
||||||
? `${months[monthIndex]} ${Number(day)}, ${year}`
|
? `${months[monthIndex]} ${Number(day)}, ${year}`
|
||||||
: date;
|
: date;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSectionEntries = (version: string, section: string) => {
|
||||||
|
const entries = changelog?.[version]?.[section];
|
||||||
|
return Array.isArray(entries) ? entries : [];
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
@@ -62,15 +88,18 @@
|
|||||||
className="bg-white dark:bg-gray-900 rounded-3xl overflow-hidden"
|
className="bg-white dark:bg-gray-900 rounded-3xl overflow-hidden"
|
||||||
containerClassName="p-3"
|
containerClassName="p-3"
|
||||||
>
|
>
|
||||||
<div class="flex max-h-[78vh] flex-col">
|
<div class="flex max-h-[58vh] flex-col">
|
||||||
<div class="flex shrink-0 items-start justify-between gap-4 px-4 pb-3 pt-4 dark:text-white text-black">
|
<div
|
||||||
|
class="flex shrink-0 items-start justify-between gap-4 px-4 pb-2.5 pt-3.5 dark:text-white text-black"
|
||||||
|
>
|
||||||
<div class="min-w-0">
|
<div class="min-w-0">
|
||||||
<h2 class="m-0 truncate text-base font-medium">
|
<h2 class="m-0 truncate text-base font-normal">
|
||||||
{$i18n.t("What's New in")} {$WEBUI_NAME}
|
{$i18n.t("What's New in")}
|
||||||
|
{$WEBUI_NAME}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="mt-1 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400">
|
<div class="mt-1 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400">
|
||||||
<span>{$i18n.t('Release Notes')}</span>
|
<span>{$i18n.t('Release Notes')}</span>
|
||||||
<span class="h-1 w-1 rounded-full bg-gray-300 dark:bg-gray-700" />
|
<span class="h-1 w-1 rounded-full bg-gray-300 dark:bg-gray-700"></span>
|
||||||
<span>v{WEBUI_VERSION}</span>
|
<span>v{WEBUI_VERSION}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -84,22 +113,24 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="min-h-0 flex-1 overflow-y-auto px-4 py-3 text-gray-700 scrollbar-hidden dark:text-gray-100">
|
<div
|
||||||
|
class="min-h-0 flex-1 overflow-y-auto px-4 py-2 text-gray-700 scrollbar-hidden dark:text-gray-100"
|
||||||
|
>
|
||||||
{#if changelog}
|
{#if changelog}
|
||||||
<div class="space-y-6">
|
<div class="space-y-4">
|
||||||
{#each Object.keys(changelog) as version}
|
{#each Object.keys(changelog) as version}
|
||||||
<section class="pr-1">
|
<section class="pr-1">
|
||||||
<div class="mb-3">
|
<div class="mb-2">
|
||||||
<h3 class="m-0 text-sm font-semibold text-gray-950 dark:text-white">v{version}</h3>
|
<h3 class="m-0 text-sm font-normal text-gray-950 dark:text-white">v{version}</h3>
|
||||||
<div class="mt-0.5 text-[0.6875rem] text-gray-400 dark:text-gray-500">
|
<div class="mt-0.5 text-[0.6875rem] text-gray-400 dark:text-gray-500">
|
||||||
{formatDate(changelog[version].date)}
|
{formatDate(changelog[version].date)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
|
{#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
|
||||||
<div class="mb-4 w-full">
|
<div class="mb-3 w-full">
|
||||||
<div
|
<div
|
||||||
class="mb-2 text-[0.6875rem] font-semibold uppercase tracking-wide {section ===
|
class="mb-2 text-[0.6875rem] font-normal uppercase tracking-wide {section ===
|
||||||
'added'
|
'added'
|
||||||
? 'text-blue-600 dark:text-blue-300'
|
? 'text-blue-600 dark:text-blue-300'
|
||||||
: section === 'fixed'
|
: section === 'fixed'
|
||||||
@@ -114,14 +145,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2 text-[0.8125rem] leading-relaxed">
|
<div class="space-y-2 text-[0.8125rem] leading-relaxed">
|
||||||
{#each changelog[version][section] as entry}
|
{#each getSectionEntries(version, section) as entry}
|
||||||
<div class="flex gap-2.5">
|
<div class="flex gap-2.5">
|
||||||
<span
|
<span
|
||||||
class="mt-[0.6em] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-gray-700"
|
class="mt-[0.6em] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-gray-700"
|
||||||
/>
|
></span>
|
||||||
<div
|
<div
|
||||||
class="min-w-0 markdown-prose-sm !max-w-none !text-[0.8125rem] text-gray-600 dark:text-gray-300 [&_*]:!my-0"
|
class="min-w-0 markdown-prose-sm !max-w-none !text-[0.8125rem] text-gray-600 dark:text-gray-300 [&_*]:!my-0 [&_b]:!font-normal [&_strong]:!font-normal"
|
||||||
>
|
>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html DOMPurify.sanitize(entry?.raw)}
|
{@html DOMPurify.sanitize(entry?.raw)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,24 +174,26 @@
|
|||||||
error = false;
|
error = false;
|
||||||
init();
|
init();
|
||||||
}}
|
}}
|
||||||
class="text-sm font-medium text-gray-700 transition hover:text-black dark:text-gray-300 dark:hover:text-white"
|
class="text-sm font-normal text-gray-700 transition hover:text-black dark:text-gray-300 dark:hover:text-white"
|
||||||
>
|
>
|
||||||
{$i18n.t('Retry')}
|
{$i18n.t('Retry')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex items-center justify-center py-16 text-sm text-gray-400 dark:text-gray-500">
|
<div
|
||||||
|
class="flex items-center justify-center py-16 text-sm text-gray-400 dark:text-gray-500"
|
||||||
|
>
|
||||||
{$i18n.t('Loading release notes...')}
|
{$i18n.t('Loading release notes...')}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex shrink-0 justify-end px-4 pb-4 pt-2 text-sm">
|
<div class="flex shrink-0 justify-end px-4 pb-3.5 pt-1.5 text-sm">
|
||||||
<button
|
<button
|
||||||
on:click={closeModal}
|
on:click={closeModal}
|
||||||
class="font-medium text-gray-600 transition hover:text-gray-950 dark:text-gray-400 dark:hover:text-white"
|
class="font-normal text-gray-600 transition hover:text-gray-950 dark:text-gray-400 dark:hover:text-white"
|
||||||
>
|
>
|
||||||
<span class="relative">{$i18n.t('Done')}</span>
|
<span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -217,11 +217,7 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Modal
|
<Modal bind:show={showCreateModal} size="md">
|
||||||
bind:show={showCreateModal}
|
|
||||||
size="full"
|
|
||||||
className="!w-[calc(100vw-2rem)] sm:!w-[calc(100vw-3rem)] lg:!w-[calc(100vw-4rem)] !max-w-[80rem] h-[min(54rem,calc(100dvh-4rem))] max-h-[calc(100dvh-4rem)] flex flex-col bg-white dark:bg-gray-900 rounded-4xl"
|
|
||||||
>
|
|
||||||
<CreateKnowledgeBase
|
<CreateKnowledgeBase
|
||||||
modal={true}
|
modal={true}
|
||||||
onBack={() => {
|
onBack={() => {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-full max-h-full {modal ? 'h-full flex flex-col' : ''}">
|
<div class="w-full max-h-full">
|
||||||
{#if modal}
|
{#if modal}
|
||||||
<div class="flex justify-between items-center dark:text-gray-100 px-5 pt-4 pb-2">
|
<div class="flex justify-between items-center dark:text-gray-100 px-5 pt-4 pb-2">
|
||||||
<h3 class="text-base font-normal">{$i18n.t('Create a knowledge base')}</h3>
|
<h3 class="text-base font-normal">{$i18n.t('Create a knowledge base')}</h3>
|
||||||
@@ -92,25 +92,29 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form
|
<form
|
||||||
class="flex flex-col {modal ? 'px-5 pb-3 flex-1 min-h-0' : 'max-w-lg mx-auto mt-10 mb-10'}"
|
class="flex flex-col {modal ? 'px-5 pb-3' : 'max-w-lg mx-auto mt-10 mb-10'}"
|
||||||
on:submit|preventDefault={() => {
|
on:submit|preventDefault={() => {
|
||||||
submitHandler();
|
submitHandler();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="w-full flex flex-col {modal ? 'flex-1 min-h-0' : 'justify-center'}">
|
<div class="w-full flex flex-col {modal ? '' : 'justify-center'}">
|
||||||
{#if !modal}
|
{#if !modal}
|
||||||
<div class=" text-2xl font-normal mb-2.5">
|
<div class=" text-2xl font-normal mb-2.5">
|
||||||
{$i18n.t('Create a knowledge base')}
|
{$i18n.t('Create a knowledge base')}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="w-full flex flex-col gap-2.5 {modal ? 'flex-1 min-h-0' : ''}">
|
<div class="w-full flex flex-col gap-2.5">
|
||||||
<div class="w-full shrink-0">
|
<div class="w-full">
|
||||||
<div class=" text-sm mb-2">{$i18n.t('What are you working on?')}</div>
|
<div class="{modal ? 'text-xs text-gray-500' : 'text-sm'} mb-2">
|
||||||
|
{$i18n.t('What are you working on?')}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="w-full mt-1">
|
<div class="w-full mt-1">
|
||||||
<input
|
<input
|
||||||
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
class={modal
|
||||||
|
? 'w-full text-sm bg-transparent outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700'
|
||||||
|
: 'w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden'}
|
||||||
type="text"
|
type="text"
|
||||||
bind:value={name}
|
bind:value={name}
|
||||||
placeholder={$i18n.t('Name your knowledge base')}
|
placeholder={$i18n.t('Name your knowledge base')}
|
||||||
@@ -119,15 +123,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class={modal ? 'flex-1 min-h-0 flex flex-col' : ''}>
|
<div>
|
||||||
<div class="text-sm mb-2">{$i18n.t('What are you trying to achieve?')}</div>
|
<div class="{modal ? 'text-xs text-gray-500' : 'text-sm'} mb-2">
|
||||||
|
{$i18n.t('What are you trying to achieve?')}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="w-full mt-1 {modal ? 'flex-1 min-h-0 flex' : ''}">
|
<div class="w-full mt-1">
|
||||||
<textarea
|
<textarea
|
||||||
class="w-full {modal
|
class={modal
|
||||||
? 'flex-1 min-h-0'
|
? 'w-full resize-none text-sm bg-transparent outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700'
|
||||||
: ''} resize-none rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
: 'w-full resize-none rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden'}
|
||||||
rows="4"
|
rows={modal ? 6 : 4}
|
||||||
bind:value={description}
|
bind:value={description}
|
||||||
placeholder={$i18n.t('Describe your knowledge base and objectives')}
|
placeholder={$i18n.t('Describe your knowledge base and objectives')}
|
||||||
required
|
required
|
||||||
@@ -137,7 +143,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-2 shrink-0">
|
<div class="mt-2">
|
||||||
<AccessControl
|
<AccessControl
|
||||||
bind:accessGrants
|
bind:accessGrants
|
||||||
accessRoles={['read', 'write']}
|
accessRoles={['read', 'write']}
|
||||||
@@ -148,7 +154,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end {modal ? 'pt-3 gap-2 shrink-0' : 'mt-2'}">
|
<div class="flex justify-end {modal ? 'pt-3 gap-2' : 'mt-2'}">
|
||||||
{#if modal}
|
{#if modal}
|
||||||
<button
|
<button
|
||||||
class="px-3 py-1 text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-200 transition"
|
class="px-3 py-1 text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-200 transition"
|
||||||
|
|||||||
Reference in new issue
Block a user