mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
feat: add granular import/export permissions for workspace items (#19242)
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / merge-slim-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / merge-slim-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
* feat: add granular import/export permissions for workspace items (#55) Co-authored-by: Claude <noreply@anthropic.com> * Fix permissions toggles not saving in EditGroupModal (#58) Co-authored-by: Claude <noreply@anthropic.com> * Fix permissions toggles not saving in EditGroupModal (#59) Co-authored-by: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
0ed174f6a1
commit
b4bc71d1bd
13 changed files with 242 additions and 95 deletions
|
|
@ -1231,6 +1231,30 @@ USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS = (
|
||||||
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS", "False").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS", "False").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_MODELS_IMPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_MODELS_IMPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_MODELS_EXPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_MODELS_EXPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_PROMPTS_IMPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_PROMPTS_IMPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_PROMPTS_EXPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_PROMPTS_EXPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_TOOLS_IMPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_IMPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_WORKSPACE_TOOLS_EXPORT = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_EXPORT", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING = (
|
USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING = (
|
||||||
os.environ.get(
|
os.environ.get(
|
||||||
"USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING", "False"
|
"USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING", "False"
|
||||||
|
|
@ -1374,6 +1398,12 @@ DEFAULT_USER_PERMISSIONS = {
|
||||||
"knowledge": USER_PERMISSIONS_WORKSPACE_KNOWLEDGE_ACCESS,
|
"knowledge": USER_PERMISSIONS_WORKSPACE_KNOWLEDGE_ACCESS,
|
||||||
"prompts": USER_PERMISSIONS_WORKSPACE_PROMPTS_ACCESS,
|
"prompts": USER_PERMISSIONS_WORKSPACE_PROMPTS_ACCESS,
|
||||||
"tools": USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS,
|
"tools": USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS,
|
||||||
|
"models_import": USER_PERMISSIONS_WORKSPACE_MODELS_IMPORT,
|
||||||
|
"models_export": USER_PERMISSIONS_WORKSPACE_MODELS_EXPORT,
|
||||||
|
"prompts_import": USER_PERMISSIONS_WORKSPACE_PROMPTS_IMPORT,
|
||||||
|
"prompts_export": USER_PERMISSIONS_WORKSPACE_PROMPTS_EXPORT,
|
||||||
|
"tools_import": USER_PERMISSIONS_WORKSPACE_TOOLS_IMPORT,
|
||||||
|
"tools_export": USER_PERMISSIONS_WORKSPACE_TOOLS_EXPORT,
|
||||||
},
|
},
|
||||||
"sharing": {
|
"sharing": {
|
||||||
"public_models": USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING,
|
"public_models": USER_PERMISSIONS_WORKSPACE_MODELS_ALLOW_PUBLIC_SHARING,
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,19 @@ async def create_new_model(
|
||||||
|
|
||||||
|
|
||||||
@router.get("/export", response_model=list[ModelModel])
|
@router.get("/export", response_model=list[ModelModel])
|
||||||
async def export_models(user=Depends(get_admin_user)):
|
async def export_models(request: Request, user=Depends(get_verified_user)):
|
||||||
return Models.get_models()
|
if user.role != "admin" and not has_permission(
|
||||||
|
user.id, "workspace.models_export", request.app.state.config.USER_PERMISSIONS
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail=ERROR_MESSAGES.UNAUTHORIZED,
|
||||||
|
)
|
||||||
|
|
||||||
|
if user.role == "admin" and BYPASS_ADMIN_ACCESS_CONTROL:
|
||||||
|
return Models.get_models()
|
||||||
|
else:
|
||||||
|
return Models.get_models_by_user_id(user.id)
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
|
@ -128,8 +139,17 @@ class ModelsImportForm(BaseModel):
|
||||||
|
|
||||||
@router.post("/import", response_model=bool)
|
@router.post("/import", response_model=bool)
|
||||||
async def import_models(
|
async def import_models(
|
||||||
user: str = Depends(get_admin_user), form_data: ModelsImportForm = (...)
|
request: Request,
|
||||||
|
user=Depends(get_verified_user),
|
||||||
|
form_data: ModelsImportForm = (...),
|
||||||
):
|
):
|
||||||
|
if user.role != "admin" and not has_permission(
|
||||||
|
user.id, "workspace.models_import", request.app.state.config.USER_PERMISSIONS
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail=ERROR_MESSAGES.UNAUTHORIZED,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
data = form_data.models
|
data = form_data.models
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,13 @@ async def get_prompt_list(user=Depends(get_verified_user)):
|
||||||
async def create_new_prompt(
|
async def create_new_prompt(
|
||||||
request: Request, form_data: PromptForm, user=Depends(get_verified_user)
|
request: Request, form_data: PromptForm, user=Depends(get_verified_user)
|
||||||
):
|
):
|
||||||
if user.role != "admin" and not has_permission(
|
if user.role != "admin" and not (
|
||||||
user.id, "workspace.prompts", request.app.state.config.USER_PERMISSIONS
|
has_permission(
|
||||||
|
user.id, "workspace.prompts", request.app.state.config.USER_PERMISSIONS
|
||||||
|
)
|
||||||
|
or has_permission(
|
||||||
|
user.id, "workspace.prompts_import", request.app.state.config.USER_PERMISSIONS
|
||||||
|
)
|
||||||
):
|
):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
|
|
||||||
|
|
@ -247,9 +247,19 @@ async def load_tool_from_url(
|
||||||
|
|
||||||
|
|
||||||
@router.get("/export", response_model=list[ToolModel])
|
@router.get("/export", response_model=list[ToolModel])
|
||||||
async def export_tools(user=Depends(get_admin_user)):
|
async def export_tools(request: Request, user=Depends(get_verified_user)):
|
||||||
tools = Tools.get_tools()
|
if user.role != "admin" and not has_permission(
|
||||||
return tools
|
user.id, "workspace.tools_export", request.app.state.config.USER_PERMISSIONS
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail=ERROR_MESSAGES.UNAUTHORIZED,
|
||||||
|
)
|
||||||
|
|
||||||
|
if user.role == "admin" and BYPASS_ADMIN_ACCESS_CONTROL:
|
||||||
|
return Tools.get_tools()
|
||||||
|
else:
|
||||||
|
return Tools.get_tools_by_user_id(user.id, "read")
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
|
@ -263,8 +273,13 @@ async def create_new_tools(
|
||||||
form_data: ToolForm,
|
form_data: ToolForm,
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
):
|
):
|
||||||
if user.role != "admin" and not has_permission(
|
if user.role != "admin" and not (
|
||||||
user.id, "workspace.tools", request.app.state.config.USER_PERMISSIONS
|
has_permission(
|
||||||
|
user.id, "workspace.tools", request.app.state.config.USER_PERMISSIONS
|
||||||
|
)
|
||||||
|
or has_permission(
|
||||||
|
user.id, "workspace.tools_import", request.app.state.config.USER_PERMISSIONS
|
||||||
|
)
|
||||||
):
|
):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,12 @@ class WorkspacePermissions(BaseModel):
|
||||||
knowledge: bool = False
|
knowledge: bool = False
|
||||||
prompts: bool = False
|
prompts: bool = False
|
||||||
tools: bool = False
|
tools: bool = False
|
||||||
|
models_import: bool = False
|
||||||
|
models_export: bool = False
|
||||||
|
prompts_import: bool = False
|
||||||
|
prompts_export: bool = False
|
||||||
|
tools_import: bool = False
|
||||||
|
tools_export: bool = False
|
||||||
|
|
||||||
|
|
||||||
class SharingPermissions(BaseModel):
|
class SharingPermissions(BaseModel):
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,20 @@
|
||||||
models: false,
|
models: false,
|
||||||
knowledge: false,
|
knowledge: false,
|
||||||
prompts: false,
|
prompts: false,
|
||||||
tools: false
|
tools: false,
|
||||||
|
models_import: false,
|
||||||
|
models_export: false,
|
||||||
|
prompts_import: false,
|
||||||
|
prompts_export: false,
|
||||||
|
tools_import: false,
|
||||||
|
tools_export: false
|
||||||
},
|
},
|
||||||
sharing: {
|
sharing: {
|
||||||
public_models: false,
|
public_models: false,
|
||||||
public_knowledge: false,
|
public_knowledge: false,
|
||||||
public_prompts: false,
|
public_prompts: false,
|
||||||
public_tools: false
|
public_tools: false,
|
||||||
|
public_notes: false
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
controls: true,
|
controls: true,
|
||||||
|
|
@ -72,7 +79,8 @@
|
||||||
direct_tool_servers: false,
|
direct_tool_servers: false,
|
||||||
web_search: true,
|
web_search: true,
|
||||||
image_generation: true,
|
image_generation: true,
|
||||||
code_interpreter: true
|
code_interpreter: true,
|
||||||
|
notes: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export let userIds = [];
|
export let userIds = [];
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,13 @@
|
||||||
models: false,
|
models: false,
|
||||||
knowledge: false,
|
knowledge: false,
|
||||||
prompts: false,
|
prompts: false,
|
||||||
tools: false
|
tools: false,
|
||||||
|
models_import: false,
|
||||||
|
models_export: false,
|
||||||
|
prompts_import: false,
|
||||||
|
prompts_export: false,
|
||||||
|
tools_import: false,
|
||||||
|
tools_export: false
|
||||||
},
|
},
|
||||||
sharing: {
|
sharing: {
|
||||||
public_models: false,
|
public_models: false,
|
||||||
|
|
@ -97,6 +103,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if permissions.workspace.models}
|
||||||
|
<div class="ml-4 flex flex-col gap-1 mt-1">
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Import Models')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.models_import} />
|
||||||
|
</div>
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Export Models')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.models_export} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
|
|
@ -129,6 +152,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if permissions.workspace.prompts}
|
||||||
|
<div class="ml-4 flex flex-col gap-1 mt-1">
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Import Prompts')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.prompts_import} />
|
||||||
|
</div>
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Export Prompts')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.prompts_export} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
|
|
@ -151,6 +191,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if permissions.workspace.tools}
|
||||||
|
<div class="ml-4 flex flex-col gap-1 mt-1">
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Import Tools')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.tools_import} />
|
||||||
|
</div>
|
||||||
|
<div class="flex w-full justify-between my-1">
|
||||||
|
<div class="self-center text-xs">
|
||||||
|
{$i18n.t('Export Tools')}
|
||||||
|
</div>
|
||||||
|
<Switch bind:state={permissions.workspace.tools_export} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex w-full justify-end gap-1.5">
|
<div class="flex w-full justify-end gap-1.5">
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.models_import}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
@ -319,19 +319,19 @@
|
||||||
{$i18n.t('Import')}
|
{$i18n.t('Import')}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if models.length}
|
{#if models.length && ($user?.role === 'admin' || $user?.permissions?.workspace?.models_export)}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
downloadModels(models);
|
downloadModels(models);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class=" self-center font-medium line-clamp-1">
|
<div class=" self-center font-medium line-clamp-1">
|
||||||
{$i18n.t('Export')}
|
{$i18n.t('Export')}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
<a
|
<a
|
||||||
class=" px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
class=" px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
import Download from '$lib/components/icons/Download.svelte';
|
import Download from '$lib/components/icons/Download.svelte';
|
||||||
import ArrowUpCircle from '$lib/components/icons/ArrowUpCircle.svelte';
|
import ArrowUpCircle from '$lib/components/icons/ArrowUpCircle.svelte';
|
||||||
|
|
||||||
import { config } from '$lib/stores';
|
import { config, user as currentUser } from '$lib/stores';
|
||||||
import Link from '$lib/components/icons/Link.svelte';
|
import Link from '$lib/components/icons/Link.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
@ -148,16 +148,18 @@
|
||||||
<div class="flex items-center">{$i18n.t('Copy Link')}</div>
|
<div class="flex items-center">{$i18n.t('Copy Link')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
|
||||||
<DropdownMenu.Item
|
{#if $currentUser?.role === 'admin' || $currentUser?.permissions?.workspace?.models_export}
|
||||||
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
<DropdownMenu.Item
|
||||||
on:click={() => {
|
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
||||||
exportHandler();
|
on:click={() => {
|
||||||
}}
|
exportHandler();
|
||||||
>
|
}}
|
||||||
<Download />
|
>
|
||||||
|
<Download />
|
||||||
|
|
||||||
<div class="flex items-center">{$i18n.t('Export')}</div>
|
<div class="flex items-center">{$i18n.t('Export')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $config?.features.enable_community_sharing}
|
{#if $config?.features.enable_community_sharing}
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex w-full justify-end gap-1.5">
|
<div class="flex w-full justify-end gap-1.5">
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_import}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
@ -236,22 +236,22 @@
|
||||||
{$i18n.t('Import')}
|
{$i18n.t('Import')}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if prompts.length}
|
{#if prompts.length && ($user?.role === 'admin' || $user?.permissions?.workspace?.prompts_export)}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
let blob = new Blob([JSON.stringify(prompts)], {
|
let blob = new Blob([JSON.stringify(prompts)], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
});
|
});
|
||||||
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class=" self-center font-medium line-clamp-1">
|
<div class=" self-center font-medium line-clamp-1">
|
||||||
{$i18n.t('Export')}
|
{$i18n.t('Export')}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
<a
|
<a
|
||||||
class=" px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
class=" px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import { DropdownMenu } from 'bits-ui';
|
import { DropdownMenu } from 'bits-ui';
|
||||||
import { flyAndScale } from '$lib/utils/transitions';
|
import { flyAndScale } from '$lib/utils/transitions';
|
||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { config } from '$lib/stores';
|
import { config, user } from '$lib/stores';
|
||||||
|
|
||||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||||
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
|
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
|
||||||
|
|
@ -68,16 +68,18 @@
|
||||||
<div class="flex items-center">{$i18n.t('Clone')}</div>
|
<div class="flex items-center">{$i18n.t('Clone')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
|
||||||
<DropdownMenu.Item
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_export}
|
||||||
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
<DropdownMenu.Item
|
||||||
on:click={() => {
|
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
||||||
exportHandler();
|
on:click={() => {
|
||||||
}}
|
exportHandler();
|
||||||
>
|
}}
|
||||||
<Download />
|
>
|
||||||
|
<Download />
|
||||||
|
|
||||||
<div class="flex items-center">{$i18n.t('Export')}</div>
|
<div class="flex items-center">{$i18n.t('Export')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<hr class="border-gray-50 dark:border-gray-850 my-1" />
|
<hr class="border-gray-50 dark:border-gray-850 my-1" />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex w-full justify-end gap-1.5">
|
<div class="flex w-full justify-end gap-1.5">
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.tools_import}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
@ -243,29 +243,29 @@
|
||||||
{$i18n.t('Import')}
|
{$i18n.t('Import')}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if tools.length}
|
{#if tools.length && ($user?.role === 'admin' || $user?.permissions?.workspace?.tools_export)}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
const _tools = await exportTools(localStorage.token).catch((error) => {
|
const _tools = await exportTools(localStorage.token).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
return null;
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (_tools) {
|
||||||
|
let blob = new Blob([JSON.stringify(_tools)], {
|
||||||
|
type: 'application/json'
|
||||||
});
|
});
|
||||||
|
saveAs(blob, `tools-export-${Date.now()}.json`);
|
||||||
if (_tools) {
|
}
|
||||||
let blob = new Blob([JSON.stringify(_tools)], {
|
}}
|
||||||
type: 'application/json'
|
>
|
||||||
});
|
<div class=" self-center font-medium line-clamp-1">
|
||||||
saveAs(blob, `tools-export-${Date.now()}.json`);
|
{$i18n.t('Export')}
|
||||||
}
|
</div>
|
||||||
}}
|
</button>
|
||||||
>
|
|
||||||
<div class=" self-center font-medium line-clamp-1">
|
|
||||||
{$i18n.t('Export')}
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
|
import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
|
||||||
import DocumentDuplicate from '$lib/components/icons/DocumentDuplicate.svelte';
|
import DocumentDuplicate from '$lib/components/icons/DocumentDuplicate.svelte';
|
||||||
import Download from '$lib/components/icons/Download.svelte';
|
import Download from '$lib/components/icons/Download.svelte';
|
||||||
import { config } from '$lib/stores';
|
import { config, user } from '$lib/stores';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
|
@ -93,16 +93,18 @@
|
||||||
<div class="flex items-center">{$i18n.t('Clone')}</div>
|
<div class="flex items-center">{$i18n.t('Clone')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
|
||||||
<DropdownMenu.Item
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.tools_export}
|
||||||
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
<DropdownMenu.Item
|
||||||
on:click={() => {
|
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
||||||
exportHandler();
|
on:click={() => {
|
||||||
}}
|
exportHandler();
|
||||||
>
|
}}
|
||||||
<Download />
|
>
|
||||||
|
<Download />
|
||||||
|
|
||||||
<div class="flex items-center">{$i18n.t('Export')}</div>
|
<div class="flex items-center">{$i18n.t('Export')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<hr class="border-gray-50 dark:border-gray-850 my-1" />
|
<hr class="border-gray-50 dark:border-gray-850 my-1" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue