Quellcode durchsuchen

feat custom text and title

DrMelone vor 4 Monaten
Ursprung
Commit
143cb4cc34

+ 12 - 0
backend/open_webui/config.py

@@ -989,6 +989,18 @@ DEFAULT_USER_ROLE = PersistentConfig(
     os.getenv("DEFAULT_USER_ROLE", "pending"),
 )
 
+ACCOUNT_PENDING_TITLE = PersistentConfig(
+    "ACCOUNT_PENDING_TITLE",
+    "ui.account_pending_title",
+    os.environ.get("ACCOUNT_PENDING_TITLE", "")
+)
+
+ACCOUNT_PENDING_TEXT = PersistentConfig(
+    "ACCOUNT_PENDING_TEXT",
+    "ui.account_pending_text",
+    os.environ.get("ACCOUNT_PENDING_TEXT", "")
+)
+
 USER_PERMISSIONS_WORKSPACE_MODELS_ACCESS = (
     os.environ.get("USER_PERMISSIONS_WORKSPACE_MODELS_ACCESS", "False").lower()
     == "true"

+ 9 - 0
backend/open_webui/routers/auths.py

@@ -696,6 +696,8 @@ async def get_admin_config(request: Request, user=Depends(get_admin_user)):
         "ENABLE_CHANNELS": request.app.state.config.ENABLE_CHANNELS,
         "ENABLE_NOTES": request.app.state.config.ENABLE_NOTES,
         "ENABLE_USER_WEBHOOKS": request.app.state.config.ENABLE_USER_WEBHOOKS,
+        "ACCOUNT_PENDING_TEXT": request.app.state.config.ACCOUNT_PENDING_TEXT,
+        "ACCOUNT_PENDING_TITLE": request.app.state.config.ACCOUNT_PENDING_TITLE,
     }
 
 
@@ -713,6 +715,8 @@ class AdminConfig(BaseModel):
     ENABLE_CHANNELS: bool
     ENABLE_NOTES: bool
     ENABLE_USER_WEBHOOKS: bool
+    ACCOUNT_PENDING_TEXT: Optional[str] = None
+    ACCOUNT_PENDING_TITLE: Optional[str] = None
 
 
 @router.post("/admin/config")
@@ -750,6 +754,9 @@ async def update_admin_config(
 
     request.app.state.config.ENABLE_USER_WEBHOOKS = form_data.ENABLE_USER_WEBHOOKS
 
+    request.app.state.config.ACCOUNT_PENDING_TEXT = form_data.ACCOUNT_PENDING_TEXT
+    request.app.state.config.ACCOUNT_PENDING_TITLE = form_data.ACCOUNT_PENDING_TITLE
+
     return {
         "SHOW_ADMIN_DETAILS": request.app.state.config.SHOW_ADMIN_DETAILS,
         "WEBUI_URL": request.app.state.config.WEBUI_URL,
@@ -764,6 +771,8 @@ async def update_admin_config(
         "ENABLE_CHANNELS": request.app.state.config.ENABLE_CHANNELS,
         "ENABLE_NOTES": request.app.state.config.ENABLE_NOTES,
         "ENABLE_USER_WEBHOOKS": request.app.state.config.ENABLE_USER_WEBHOOKS,
+        "ACCOUNT_PENDING_TEXT": request.app.state.config.ACCOUNT_PENDING_TEXT,
+        "ACCOUNT_PENDING_TITLE": request.app.state.config.ACCOUNT_PENDING_TITLE,
     }
 
 

+ 26 - 0
src/lib/components/admin/Settings/General.svelte

@@ -305,6 +305,32 @@
 						<Switch bind:state={adminConfig.SHOW_ADMIN_DETAILS} />
 					</div>
 
+					<div class="mb-3.5">
+						<div class=" self-center text-xs font-medium mb-1">{$i18n.t('Custom Account Pending Title')}</div>
+						<textarea
+							class="w-full mt-1 rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
+							rows="2"
+							placeholder={$i18n.t('Enter custom title. Supports line breaks. Leave empty for default.')}
+							bind:value={adminConfig.ACCOUNT_PENDING_TITLE}
+						></textarea>
+						<div class="mt-1 text-xs text-gray-400 dark:text-gray-500">
+							{$i18n.t('This title displays on the account pending screen. If empty, the default title is shown.')}
+						</div>
+					</div>
+
+					<div class="mb-3.5">
+						<div class=" self-center text-xs font-medium mb-1">{$i18n.t('Custom Account Pending Text')}</div>
+						<textarea
+							class="w-full mt-1 rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
+							rows="3"
+							placeholder={$i18n.t('Enter custom text. Leave empty for default.')}
+							bind:value={adminConfig.ACCOUNT_PENDING_TEXT}
+						></textarea>
+						<div class="mt-1 text-xs text-gray-400 dark:text-gray-500">
+							{$i18n.t('This text displays on the account pending screen. If empty, the default message is shown.')}
+						</div>
+					</div>
+
 					<div class="mb-2.5 flex w-full justify-between pr-2">
 						<div class=" self-center text-xs font-medium">{$i18n.t('Enable API Key')}</div>
 

+ 15 - 8
src/lib/components/layout/Overlay/AccountPending.svelte

@@ -1,6 +1,7 @@
 <script lang="ts">
 	import { getAdminDetails } from '$lib/apis/auths';
 	import { onMount, tick, getContext } from 'svelte';
+	import { config } from '$lib/stores';
 
 	const i18n = getContext('i18n');
 
@@ -20,16 +21,22 @@
 	>
 		<div class="m-auto pb-10 flex flex-col justify-center">
 			<div class="max-w-md">
-				<div class="text-center dark:text-white text-2xl font-medium z-50">
-					{$i18n.t('Account Activation Pending')}<br />
-					{$i18n.t('Contact Admin for WebUI Access')}
+				<div class="text-center dark:text-white text-2xl font-medium z-50" style="white-space: pre-wrap;">
+					{#if $config?.ui?.account_pending_title && $config?.ui?.account_pending_title.trim() !== ""}
+						{$config.ui.account_pending_title}
+					{:else}
+						{$i18n.t('Account Activation Pending')}{#if !$config?.ui?.account_pending_title || $config?.ui?.account_pending_title.trim() === ""}<br />{/if}{$i18n.t('Contact Admin for WebUI Access')}
+					{/if}
 				</div>
 
-				<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full">
-					{$i18n.t('Your account status is currently pending activation.')}<br />
-					{$i18n.t(
-						'To access the WebUI, please reach out to the administrator. Admins can manage user statuses from the Admin Panel.'
-					)}
+				<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full" style="white-space: pre-wrap;">
+					{#if $config?.ui?.account_pending_text && $config?.ui?.account_pending_text.trim() !== ""}
+						{$config.ui.account_pending_text}
+					{:else}
+						{$i18n.t('Your account status is currently pending activation.')}{'\n'}{$i18n.t(
+							'To access the WebUI, please reach out to the administrator. Admins can manage user statuses from the Admin Panel.'
+						)}
+					{/if}
 				</div>
 
 				{#if adminDetails}