refac: move ui flags into feature flags

This commit is contained in:
Jun Siang Cheah 2024-05-26 17:05:26 +01:00
parent 7b81271b9e
commit 6c5f5fe368
5 changed files with 25 additions and 19 deletions

View File

@ -356,14 +356,16 @@ async def get_app_config():
"status": True,
"name": WEBUI_NAME,
"version": VERSION,
"auth": WEBUI_AUTH,
"auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER),
"enable_signup": webui_app.state.config.ENABLE_SIGNUP,
"enable_image_generation": images_app.state.config.ENABLED,
"enable_admin_export": ENABLE_ADMIN_EXPORT,
"default_locale": default_locale,
"default_models": webui_app.state.config.DEFAULT_MODELS,
"default_prompt_suggestions": webui_app.state.config.DEFAULT_PROMPT_SUGGESTIONS,
"feature_flags": {
"auth": WEBUI_AUTH,
"enable_signup": webui_app.state.config.ENABLE_SIGNUP,
"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,
},
}

View File

@ -34,7 +34,7 @@
<div>
<div class=" mb-2 text-sm font-medium">{$i18n.t('Database')}</div>
{#if $config?.enable_admin_export ?? true}
{#if $config?.feature_flags.enable_admin_export ?? true}
<div class=" flex w-full justify-between">
<!-- <div class=" self-center text-xs font-medium">{$i18n.t('Allow Chat Deletion')}</div> -->

View File

@ -693,7 +693,7 @@
</button>
</Tooltip>
{#if $config.enable_image_generation && !readOnly}
{#if $config?.feature_flags.enable_image_generation && !readOnly}
<Tooltip content="Generate Image" placement="bottom">
<button
class="{isLastMessage

View File

@ -126,15 +126,19 @@ type Prompt = {
};
type Config = {
status?: boolean;
name?: string;
version?: string;
default_locale?: string;
images?: boolean;
default_models?: string[];
default_prompt_suggestions?: PromptSuggestion[];
auth_trusted_header?: boolean;
model_config?: GlobalModelConfig;
status: boolean;
name: string;
version: string;
default_locale: string;
default_models: string[];
default_prompt_suggestions: PromptSuggestion[];
feature_flags: {
auth?: boolean;
enable_signup?: boolean;
auth_trusted_header?: boolean;
enable_image_generation?: boolean;
enable_admin_export?: boolean;
};
};
type PromptSuggestion = {

View File

@ -60,7 +60,7 @@
await goto('/');
}
loaded = true;
if (($config?.auth_trusted_header ?? false) || $config?.auth === false) {
if (($config?.feature_flags.auth_trusted_header ?? false) || $config?.feature_flags.auth === false) {
await signInHandler();
}
});
@ -102,7 +102,7 @@
</div> -->
<div class="w-full sm:max-w-md px-10 min-h-screen flex flex-col text-center">
{#if ($config?.auth_trusted_header ?? false) || $config?.auth === false}
{#if ($config?.feature_flags.auth_trusted_header ?? false) || $config?.feature_flags.auth === false}
<div class=" my-auto pb-10 w-full">
<div
class="flex items-center justify-center gap-3 text-xl sm:text-2xl text-center font-bold dark:text-gray-200"
@ -194,7 +194,7 @@
{mode === 'signin' ? $i18n.t('Sign in') : $i18n.t('Create Account')}
</button>
{#if $config.enable_signup}
{#if $config?.feature_flags.enable_signup}
<div class=" mt-4 text-sm text-center">
{mode === 'signin'
? $i18n.t("Don't have an account?")