From e1e3009a30f9808ce06582d81a60e391f5ca09ec Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 16 Sep 2025 10:54:13 -0500 Subject: [PATCH] refac: granular onedrive integration types --- backend/open_webui/config.py | 7 +++ backend/open_webui/main.py | 8 +++ .../chat/MessageInput/InputMenu.svelte | 52 ++++++++++++------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 207d4405ee..ca090efa22 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -730,6 +730,7 @@ def load_oauth_providers(): } if FEISHU_CLIENT_ID.value and FEISHU_CLIENT_SECRET.value: + def feishu_oauth_register(client: OAuth): client.register( name="feishu", @@ -2167,6 +2168,12 @@ ENABLE_ONEDRIVE_INTEGRATION = PersistentConfig( "onedrive.enable", os.getenv("ENABLE_ONEDRIVE_INTEGRATION", "False").lower() == "true", ) +ENABLE_ONEDRIVE_PERSONAL = ( + os.environ.get("ENABLE_ONEDRIVE_PERSONAL", "True").lower() == "true" +) +ENABLE_ONEDRIVE_BUSINESS = ( + os.environ.get("ENABLE_ONEDRIVE_BUSINESS", "True").lower() == "true" +) ONEDRIVE_CLIENT_ID = PersistentConfig( "ONEDRIVE_CLIENT_ID", diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 6b536c78bc..2d328cfc31 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1730,6 +1730,14 @@ async def get_app_config(request: Request): "enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS, "enable_google_drive_integration": app.state.config.ENABLE_GOOGLE_DRIVE_INTEGRATION, "enable_onedrive_integration": app.state.config.ENABLE_ONEDRIVE_INTEGRATION, + **( + { + "enable_onedrive_personal": app.state.config.ENABLE_ONEDRIVE_PERSONAL, + "enable_onedrive_business": app.state.config.ENABLE_ONEDRIVE_BUSINESS, + } + if app.state.config.ENABLE_ONEDRIVE_INTEGRATION + else {} + ), } if user is not None else {} diff --git a/src/lib/components/chat/MessageInput/InputMenu.svelte b/src/lib/components/chat/MessageInput/InputMenu.svelte index 73dc069f91..ec7ddf29ae 100644 --- a/src/lib/components/chat/MessageInput/InputMenu.svelte +++ b/src/lib/components/chat/MessageInput/InputMenu.svelte @@ -298,7 +298,7 @@ {/if} - {#if $config?.features?.enable_onedrive_integration} + {#if $config?.features?.enable_onedrive_integration && ($config?.features?.enable_onedrive_personal || $config?.features?.enable_onedrive_business)} - { - uploadOneDriveHandler('personal'); - }} - > -
{$i18n.t('Microsoft OneDrive (personal)')}
-
- { - uploadOneDriveHandler('organizations'); - }} - > -
-
{$i18n.t('Microsoft OneDrive (work/school)')}
-
{$i18n.t('Includes SharePoint')}
-
-
+ {#if $config?.features?.enable_onedrive_personal} + { + uploadOneDriveHandler('personal'); + }} + > +
+
{$i18n.t('Microsoft OneDrive (personal)')}
+
+ {$i18n.t('Includes OneDrive Consumer')} +
+
+
+ {/if} + + {#if $config?.features?.enable_onedrive_business} + { + uploadOneDriveHandler('organizations'); + }} + > +
+
+ {$i18n.t('Microsoft OneDrive (work/school)')} +
+
{$i18n.t('Includes SharePoint')}
+
+
+ {/if}
{/if}