add workspace setting

This commit is contained in:
pablonyx 2025-04-02 16:32:07 -07:00
parent b9465f5bc4
commit bf4e7ae6b1
4 changed files with 18 additions and 0 deletions

View File

@ -48,6 +48,7 @@ class Settings(BaseModel):
application_status: ApplicationStatus = ApplicationStatus.ACTIVE
anonymous_user_enabled: bool | None = None
pro_search_enabled: bool | None = None
search_page_disabled: bool | None = None
temperature_override_enabled: bool | None = False
auto_scroll: bool | None = False

View File

@ -260,6 +260,14 @@ export function SettingsForm() {
}
/>
<Checkbox
label="Disable Search Page"
sublabel="If set, users will not be able to access the search page."
checked={settings.search_page_disabled ?? false}
onChange={(e) =>
handleToggleSettingsField("search_page_disabled", e.target.checked)
}
/>
{NEXT_PUBLIC_CLOUD_ENABLED && settings.anonymous_user_enabled && (
<AnonymousUserPath setPopup={setPopup} />
)}

View File

@ -11,6 +11,7 @@ export enum QueryHistoryType {
}
export interface Settings {
search_page_disabled: boolean;
anonymous_user_enabled: boolean;
anonymous_user_path?: string;
maximum_chat_retention_days?: number | null;

View File

@ -3,6 +3,9 @@ import { useChatContext } from "@/components/context/ChatContext";
import FunctionalWrapper from "../../components/chat/FunctionalWrapper";
import SearchPage from "./SearchPage";
import { redirect } from "next/navigation";
import { useContext } from "react";
import { SettingsContext } from "@/components/settings/SettingsProvider";
export default function WrappedSearch({
defaultSidebarOff,
@ -11,6 +14,11 @@ export default function WrappedSearch({
// we don't want to show the sidebar by default when the user opens the side panel
defaultSidebarOff?: boolean;
}) {
const combinedSettings = useContext(SettingsContext);
const isSearchPageDisabled = combinedSettings?.settings.search_page_disabled;
if (isSearchPageDisabled) {
redirect("/chat");
}
return (
<FunctionalWrapper
content={(sidebarVisible, toggle) => (