mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: channel delete
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
bind:show={showEditChannelModal}
|
||||
{channel}
|
||||
edit={true}
|
||||
{onUpdate}
|
||||
onSubmit={async ({ name, access_control }) => {
|
||||
const res = await updateChannelById(localStorage.token, channel.id, {
|
||||
name,
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { getContext, createEventDispatcher, onMount } from 'svelte';
|
||||
import { createNewChannel } from '$lib/apis/channels';
|
||||
import { createNewChannel, deleteChannelById } from '$lib/apis/channels';
|
||||
|
||||
import Modal from '$lib/components/common/Modal.svelte';
|
||||
import AccessControl from '$lib/components/workspace/common/AccessControl.svelte';
|
||||
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let show = false;
|
||||
export let onSubmit: Function = () => {};
|
||||
export let onUpdate: Function = () => {};
|
||||
|
||||
export let channel = null;
|
||||
export let edit = false;
|
||||
@@ -47,6 +50,20 @@
|
||||
|
||||
const deleteHandler = async () => {
|
||||
showDeleteConfirmDialog = false;
|
||||
|
||||
const res = await deleteChannelById(localStorage.token, channel.id).catch((error) => {
|
||||
toast.error(error.message);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
toast.success('Channel deleted successfully');
|
||||
onUpdate();
|
||||
|
||||
if ($page.url.pathname === `/channels/${channel.id}`) {
|
||||
goto('/');
|
||||
}
|
||||
}
|
||||
|
||||
show = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user