mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-09 03:18:18 +00:00
refac
This commit is contained in:
parent
461cc7aff9
commit
8145774e32
4 changed files with 32 additions and 16 deletions
|
|
@ -349,6 +349,18 @@ async def update_folder_name_by_id(
|
|||
)
|
||||
|
||||
if folder:
|
||||
if (
|
||||
user.role != 'admin'
|
||||
and user.id != folder.user_id
|
||||
and form_data.data
|
||||
and 'share_mode' in form_data.data
|
||||
and form_data.data['share_mode'] != (folder.data or {}).get('share_mode')
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
if form_data.name is not None:
|
||||
# Check if folder with same name exists
|
||||
existing_folder = await Folders.get_folder_by_parent_id_and_user_id_and_name(
|
||||
|
|
@ -532,13 +544,12 @@ async def update_folder_access_by_id(
|
|||
detail=ERROR_MESSAGES.NOT_FOUND,
|
||||
)
|
||||
|
||||
# Only owner, admin, or write-granted user can update access
|
||||
# Editing folder contents does not grant permission to manage sharing.
|
||||
if user.role != 'admin' and user.id != folder.user_id:
|
||||
if not await _has_folder_access(user.id, folder, 'write', db):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
form_data.access_grants = await filter_allowed_access_grants(
|
||||
await Config.get('user.permissions'),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
import { selectedFolder } from '$lib/stores';
|
||||
import { selectedFolder, user } from '$lib/stores';
|
||||
|
||||
import {
|
||||
deleteFolderById,
|
||||
|
|
@ -247,6 +247,7 @@
|
|||
{#if !readOnly}
|
||||
<div class="flex items-center translate-x-2.5">
|
||||
<FolderMenu
|
||||
canShare={$user?.role === 'admin' || folder.user_id === $user?.id}
|
||||
align="end"
|
||||
onEdit={() => {
|
||||
showFolderModal = true;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
export let onEdit = () => {};
|
||||
export let onExport = () => {};
|
||||
export let onShare = () => {};
|
||||
export let canShare = false;
|
||||
export let onDelete = () => {};
|
||||
export let onCreateSubFolder = () => {};
|
||||
export let onMarkAllRead = () => {};
|
||||
|
|
@ -92,15 +93,17 @@
|
|||
<div class="flex items-center">{$i18n.t('Export')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] select-none cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-900"
|
||||
on:click={() => {
|
||||
onShare();
|
||||
}}
|
||||
>
|
||||
<ShareIcon className="size-3.5" />
|
||||
<div class="flex items-center">{$i18n.t('Share')}</div>
|
||||
</button>
|
||||
{#if canShare}
|
||||
<button
|
||||
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] select-none cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-900"
|
||||
on:click={() => {
|
||||
onShare();
|
||||
}}
|
||||
>
|
||||
<ShareIcon className="size-3.5" />
|
||||
<div class="flex items-center">{$i18n.t('Share')}</div>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<hr class="border-gray-50/30 dark:border-gray-800/30 mx-1 my-0.5" />
|
||||
|
||||
|
|
|
|||
|
|
@ -861,6 +861,7 @@
|
|||
class="absolute z-10 right-2 hover-reveal self-center flex items-center dark:text-gray-300"
|
||||
>
|
||||
<FolderMenu
|
||||
canShare={$user?.role === 'admin' || !folders[folderId]?.shared}
|
||||
onEdit={() => {
|
||||
showFolderModal = true;
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue