Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
2a10438b
Commit
2a10438b
authored
Apr 20, 2024
by
Timothy J. Baek
Browse files
feat: share from chat menu
parent
7eb14437
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
10 deletions
+45
-10
src/lib/components/chat/ShareChatModal.svelte
src/lib/components/chat/ShareChatModal.svelte
+9
-7
src/lib/components/common/Modal.svelte
src/lib/components/common/Modal.svelte
+1
-1
src/lib/components/icons/Share.svelte
src/lib/components/icons/Share.svelte
+11
-0
src/lib/components/layout/Navbar.svelte
src/lib/components/layout/Navbar.svelte
+1
-1
src/lib/components/layout/Sidebar.svelte
src/lib/components/layout/Sidebar.svelte
+10
-0
src/lib/components/layout/Sidebar/ChatMenu.svelte
src/lib/components/layout/Sidebar/ChatMenu.svelte
+13
-1
No files found.
src/lib/components/chat/ShareChatModal.svelte
View file @
2a10438b
...
@@ -3,12 +3,14 @@
...
@@ -3,12 +3,14 @@
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { deleteSharedChatById, getChatById, shareChatById } from '$lib/apis/chats';
import { deleteSharedChatById, getChatById, shareChatById } from '$lib/apis/chats';
import {
chatId,
modelfiles } from '$lib/stores';
import { modelfiles } from '$lib/stores';
import { copyToClipboard } from '$lib/utils';
import { copyToClipboard } from '$lib/utils';
import Modal from '../common/Modal.svelte';
import Modal from '../common/Modal.svelte';
import Link from '../icons/Link.svelte';
import Link from '../icons/Link.svelte';
export let chatId;
let chat = null;
let chat = null;
let shareUrl = null;
let shareUrl = null;
const i18n = getContext('i18n');
const i18n = getContext('i18n');
...
@@ -16,10 +18,10 @@
...
@@ -16,10 +18,10 @@
const shareLocalChat = async () => {
const shareLocalChat = async () => {
const _chat = chat;
const _chat = chat;
const sharedChat = await shareChatById(localStorage.token,
$
chatId);
const sharedChat = await shareChatById(localStorage.token, chatId);
shareUrl = `${window.location.origin}/s/${sharedChat.id}`;
shareUrl = `${window.location.origin}/s/${sharedChat.id}`;
console.log(shareUrl);
console.log(shareUrl);
chat = await getChatById(localStorage.token,
$
chatId);
chat = await getChatById(localStorage.token, chatId);
return shareUrl;
return shareUrl;
};
};
...
@@ -57,8 +59,8 @@
...
@@ -57,8 +59,8 @@
$: if (show) {
$: if (show) {
(async () => {
(async () => {
if (
$
chatId) {
if (chatId) {
chat = await getChatById(localStorage.token,
$
chatId);
chat = await getChatById(localStorage.token, chatId);
} else {
} else {
chat = null;
chat = null;
console.log(chat);
console.log(chat);
...
@@ -102,10 +104,10 @@
...
@@ -102,10 +104,10 @@
<button
<button
class="underline"
class="underline"
on:click={async () => {
on:click={async () => {
const res = await deleteSharedChatById(localStorage.token,
$
chatId);
const res = await deleteSharedChatById(localStorage.token, chatId);
if (res) {
if (res) {
chat = await getChatById(localStorage.token,
$
chatId);
chat = await getChatById(localStorage.token, chatId);
}
}
}}>delete this link</button
}}>delete this link</button
> and create a new shared link.
> and create a new shared link.
...
...
src/lib/components/common/Modal.svelte
View file @
2a10438b
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
<div
bind:this={modalElement}
bind:this={modalElement}
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-
50
overflow-hidden overscroll-contain"
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-
[9999]
overflow-hidden overscroll-contain"
in:fade={{ duration: 10 }}
in:fade={{ duration: 10 }}
on:click={() => {
on:click={() => {
show = false;
show = false;
...
...
src/lib/components/icons/Share.svelte
0 → 100644
View file @
2a10438b
<script lang="ts">
export let className = 'w-4 h-4';
</script>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class={className}>
<path
fill-rule="evenodd"
d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"
clip-rule="evenodd"
/>
</svg>
src/lib/components/layout/Navbar.svelte
View file @
2a10438b
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
let showDownloadChatModal = false;
let showDownloadChatModal = false;
</script>
</script>
<ShareChatModal bind:show={showShareChatModal} />
<ShareChatModal bind:show={showShareChatModal}
chatId={$chatId}
/>
<nav id="nav" class=" sticky py-2.5 top-0 flex flex-row justify-center z-30">
<nav id="nav" class=" sticky py-2.5 top-0 flex flex-row justify-center z-30">
<div
<div
class=" flex {$settings?.fullScreenMode ?? null ? 'max-w-full' : 'max-w-3xl'}
class=" flex {$settings?.fullScreenMode ?? null ? 'max-w-full' : 'max-w-3xl'}
...
...
src/lib/components/layout/Sidebar.svelte
View file @
2a10438b
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
import { WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_BASE_URL } from '$lib/constants';
import Tooltip from '../common/Tooltip.svelte';
import Tooltip from '../common/Tooltip.svelte';
import ChatMenu from './Sidebar/ChatMenu.svelte';
import ChatMenu from './Sidebar/ChatMenu.svelte';
import ShareChatModal from '../chat/ShareChatModal.svelte';
let show = false;
let show = false;
let navElement;
let navElement;
...
@@ -31,12 +32,15 @@
...
@@ -31,12 +32,15 @@
let title: string = 'UI';
let title: string = 'UI';
let search = '';
let search = '';
let shareChatId = null;
let selectedChatId = null;
let selectedChatId = null;
let chatDeleteId = null;
let chatDeleteId = null;
let chatTitleEditId = null;
let chatTitleEditId = null;
let chatTitle = '';
let chatTitle = '';
let showShareChatModal = false;
let showDropdown = false;
let showDropdown = false;
let isEditing = false;
let isEditing = false;
...
@@ -136,6 +140,8 @@
...
@@ -136,6 +140,8 @@
};
};
</script>
</script>
<ShareChatModal bind:show={showShareChatModal} chatId={shareChatId} />
<div
<div
bind:this={navElement}
bind:this={navElement}
class="h-screen max-h-[100dvh] min-h-screen {show
class="h-screen max-h-[100dvh] min-h-screen {show
...
@@ -547,6 +553,10 @@
...
@@ -547,6 +553,10 @@
<div class="flex self-center space-x-1.5 z-10">
<div class="flex self-center space-x-1.5 z-10">
<ChatMenu
<ChatMenu
chatId={chat.id}
chatId={chat.id}
shareHandler={() => {
shareChatId = selectedChatId;
showShareChatModal = true;
}}
renameHandler={() => {
renameHandler={() => {
chatTitle = chat.title;
chatTitle = chat.title;
chatTitleEditId = chat.id;
chatTitleEditId = chat.id;
...
...
src/lib/components/layout/Sidebar/ChatMenu.svelte
View file @
2a10438b
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
import Pencil from '$lib/components/icons/Pencil.svelte';
import Pencil from '$lib/components/icons/Pencil.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tags from '$lib/components/chat/Tags.svelte';
import Tags from '$lib/components/chat/Tags.svelte';
import Share from '$lib/components/icons/Share.svelte';
export let shareHandler: Function;
export let renameHandler: Function;
export let renameHandler: Function;
export let deleteHandler: Function;
export let deleteHandler: Function;
export let onClose: Function;
export let onClose: Function;
...
@@ -31,12 +33,22 @@
...
@@ -31,12 +33,22 @@
<div slot="content">
<div slot="content">
<DropdownMenu.Content
<DropdownMenu.Content
class="w-full max-w-[1
5
0px] rounded-lg px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-900 dark:text-white shadow"
class="w-full max-w-[1
8
0px] rounded-lg px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-900 dark:text-white shadow"
sideOffset={-2}
sideOffset={-2}
side="bottom"
side="bottom"
align="start"
align="start"
transition={flyAndScale}
transition={flyAndScale}
>
>
<DropdownMenu.Item
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
on:click={() => {
shareHandler();
}}
>
<Share />
<div class="flex items-center">Share</div>
</DropdownMenu.Item>
<DropdownMenu.Item
<DropdownMenu.Item
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
on:click={() => {
on:click={() => {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment