This commit is contained in:
Timothy Jaeryang Baek 2025-05-14 21:39:17 +04:00
parent 29ae231ee0
commit 74ccec2812
6 changed files with 64 additions and 45 deletions

View File

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

View File

@ -292,8 +292,8 @@ from open_webui.config import (
ENABLE_EVALUATION_ARENA_MODELS,
USER_PERMISSIONS,
DEFAULT_USER_ROLE,
ACCOUNT_PENDING_TEXT,
ACCOUNT_PENDING_TITLE,
PENDING_USER_OVERLAY_CONTENT,
PENDING_USER_OVERLAY_TITLE,
DEFAULT_PROMPT_SUGGESTIONS,
DEFAULT_MODELS,
DEFAULT_ARENA_MODEL,
@ -575,8 +575,8 @@ app.state.config.ADMIN_EMAIL = ADMIN_EMAIL
app.state.config.DEFAULT_MODELS = DEFAULT_MODELS
app.state.config.DEFAULT_PROMPT_SUGGESTIONS = DEFAULT_PROMPT_SUGGESTIONS
app.state.config.DEFAULT_USER_ROLE = DEFAULT_USER_ROLE
app.state.config.ACCOUNT_PENDING_TEXT = ACCOUNT_PENDING_TEXT
app.state.config.ACCOUNT_PENDING_TITLE = ACCOUNT_PENDING_TITLE
app.state.config.PENDING_USER_OVERLAY_CONTENT = PENDING_USER_OVERLAY_CONTENT
app.state.config.PENDING_USER_OVERLAY_TITLE = PENDING_USER_OVERLAY_TITLE
app.state.config.USER_PERMISSIONS = USER_PERMISSIONS
app.state.config.WEBHOOK_URL = WEBHOOK_URL
@ -1402,8 +1402,8 @@ async def get_app_config(request: Request):
"sharepoint_tenant_id": ONEDRIVE_SHAREPOINT_TENANT_ID.value,
},
"ui": {
"account_pending_title": app.state.config.ACCOUNT_PENDING_TITLE,
"account_pending_text": app.state.config.ACCOUNT_PENDING_TEXT,
"pending_user_overlay_title": app.state.config.PENDING_USER_OVERLAY_TITLE,
"pending_user_overlay_content": app.state.config.PENDING_USER_OVERLAY_CONTENT,
},
"license_metadata": app.state.LICENSE_METADATA,
**(

View File

@ -696,8 +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,
"PENDING_USER_OVERLAY_TITLE": request.app.state.config.PENDING_USER_OVERLAY_TITLE,
"PENDING_USER_OVERLAY_CONTENT": request.app.state.config.PENDING_USER_OVERLAY_CONTENT,
}
@ -715,8 +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
PENDING_USER_OVERLAY_TITLE: Optional[str] = None
PENDING_USER_OVERLAY_CONTENT: Optional[str] = None
@router.post("/admin/config")
@ -754,8 +754,12 @@ 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
request.app.state.config.PENDING_USER_OVERLAY_TITLETLE = (
form_data.PENDING_USER_OVERLAY_TITLE
)
request.app.state.config.PENDING_USER_OVERLAY_CONTENT = (
form_data.PENDING_USER_OVERLAY_CONTENT
)
return {
"SHOW_ADMIN_DETAILS": request.app.state.config.SHOW_ADMIN_DETAILS,
@ -771,8 +775,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,
"PENDING_USER_OVERLAY_TITLE": request.app.state.config.PENDING_USER_OVERLAY_TITLE,
"PENDING_USER_OVERLAY_CONTENT": request.app.state.config.PENDING_USER_OVERLAY_CONTENT,
}

View File

@ -18,6 +18,7 @@
import { compareVersion } from '$lib/utils';
import { onMount, getContext } from 'svelte';
import { toast } from 'svelte-sonner';
import Textarea from '$lib/components/common/Textarea.svelte';
const i18n = getContext('i18n');
@ -306,23 +307,28 @@
</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 a custom title to be displayed on the account pending screen. Leave empty for default.')}
bind:value={adminConfig.ACCOUNT_PENDING_TITLE}
></textarea>
<div class=" self-center text-xs font-medium mb-1">
{$i18n.t('Pending User Overlay Title')}
</div>
<Textarea
rows={2}
placeholder={$i18n.t(
'Enter a title for the pending user info overlay. Leave empty for default.'
)}
bind:value={adminConfig.PENDING_USER_OVERLAY_TITLE}
/>
</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 a custom text to be displayed on the account pending screen. Leave empty for default.')}
bind:value={adminConfig.ACCOUNT_PENDING_TEXT}
></textarea>
<div class=" self-center text-xs font-medium mb-1">
{$i18n.t('Pending User Overlay Content')}
</div>
<Textarea
placeholder={$i18n.t(
'Enter content for the pending user info overlay. Leave empty for default.'
)}
bind:value={adminConfig.PENDING_USER_OVERLAY_CONTENT}
/>
</div>
<div class="mb-2.5 flex w-full justify-between pr-2">

View File

@ -21,17 +21,23 @@
>
<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" style="white-space: pre-wrap;">
{#if $config?.ui?.account_pending_title && $config?.ui?.account_pending_title.trim() !== ""}
{$config.ui.account_pending_title}
<div
class="text-center dark:text-white text-2xl font-medium z-50"
style="white-space: pre-wrap;"
>
{#if $config?.ui?.pending_user_overlay_title && $config?.ui?.pending_user_overlay_title.trim() !== ''}
{$config.ui.pending_user_overlay_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')}
{$i18n.t('Account Activation Pending')}<br />{$i18n.t('Contact Admin for WebUI Access')}
{/if}
</div>
<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}
<div
class=" mt-4 text-center text-sm dark:text-gray-200 w-full"
style="white-space: pre-wrap;"
>
{#if $config?.ui?.pending_user_overlay_content && $config?.ui?.pending_user_overlay_content.trim() !== ''}
{$config.ui.pending_user_overlay_content}
{: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.'

View File

@ -220,8 +220,10 @@ type Config = {
[key: string]: string;
};
};
account_pending_title?: string;
account_pending_text?: string;
ui?: {
pending_user_overlay_title?: string;
pending_user_overlay_description?: string;
};
};
type PromptSuggestion = {