From 12357149147aff4d5f48585310ffab4534fcea6a Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Sun, 26 May 2024 17:10:25 +0100 Subject: [PATCH] feat: add ENABLE_COMMUNITY_SHARING --- backend/apps/webui/main.py | 2 ++ backend/config.py | 6 +++++ backend/main.py | 1 + src/lib/components/chat/ShareChatModal.svelte | 24 ++++++++++--------- src/lib/stores/index.ts | 11 +++++---- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/backend/apps/webui/main.py b/backend/apps/webui/main.py index d736cef9a..e5ef35058 100644 --- a/backend/apps/webui/main.py +++ b/backend/apps/webui/main.py @@ -24,6 +24,7 @@ from config import ( WEBUI_AUTH_TRUSTED_EMAIL_HEADER, JWT_EXPIRES_IN, AppConfig, + ENABLE_COMMUNITY_SHARING, ) app = FastAPI() @@ -41,6 +42,7 @@ app.state.config.DEFAULT_USER_ROLE = DEFAULT_USER_ROLE app.state.config.USER_PERMISSIONS = USER_PERMISSIONS app.state.config.WEBHOOK_URL = WEBHOOK_URL +app.state.config.ENABLE_COMMUNITY_SHARING = ENABLE_COMMUNITY_SHARING app.state.MODELS = {} app.state.AUTH_TRUSTED_EMAIL_HEADER = WEBUI_AUTH_TRUSTED_EMAIL_HEADER diff --git a/backend/config.py b/backend/config.py index daa89de57..83eb1b37a 100644 --- a/backend/config.py +++ b/backend/config.py @@ -566,6 +566,12 @@ WEBHOOK_URL = PersistentConfig( ENABLE_ADMIN_EXPORT = os.environ.get("ENABLE_ADMIN_EXPORT", "True").lower() == "true" +ENABLE_COMMUNITY_SHARING = PersistentConfig( + "ENABLE_COMMUNITY_SHARING", + "ui.enable_community_sharing", + os.environ.get("ENABLE_COMMUNITY_SHARING", "True").lower() == "true", +) + #################################### # WEBUI_SECRET_KEY #################################### diff --git a/backend/main.py b/backend/main.py index ab43da853..7a5bd8126 100644 --- a/backend/main.py +++ b/backend/main.py @@ -365,6 +365,7 @@ async def get_app_config(): "auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER), "enable_image_generation": images_app.state.config.ENABLED, "enable_admin_export": ENABLE_ADMIN_EXPORT, + "enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING, }, } diff --git a/src/lib/components/chat/ShareChatModal.svelte b/src/lib/components/chat/ShareChatModal.svelte index 2c0042fb5..0a1d02058 100644 --- a/src/lib/components/chat/ShareChatModal.svelte +++ b/src/lib/components/chat/ShareChatModal.svelte @@ -1,6 +1,6 @@