mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-12 22:23:01 +02:00
@ -1,21 +1,21 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
|
|
||||||
import { PopupSpec } from "@/components/admin/connectors/Popup";
|
import { PopupSpec } from "@/components/admin/connectors/Popup";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { NEXT_PUBLIC_WEB_DOMAIN } from "@/lib/constants";
|
|
||||||
import { ClipboardIcon } from "@/components/icons/icons";
|
import { ClipboardIcon } from "@/components/icons/icons";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { ThreeDotsLoader } from "@/components/Loading";
|
import { ThreeDotsLoader } from "@/components/Loading";
|
||||||
|
import { SettingsContext } from "@/components/settings/SettingsProvider";
|
||||||
|
|
||||||
export function AnonymousUserPath({
|
export function AnonymousUserPath({
|
||||||
setPopup,
|
setPopup,
|
||||||
}: {
|
}: {
|
||||||
setPopup: (popup: PopupSpec) => void;
|
setPopup: (popup: PopupSpec) => void;
|
||||||
}) {
|
}) {
|
||||||
const fetcher = (url: string) => fetch(url).then((res) => res.json());
|
const settings = useContext(SettingsContext);
|
||||||
const [customPath, setCustomPath] = useState<string | null>(null);
|
const [customPath, setCustomPath] = useState<string | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -116,7 +116,7 @@ export function AnonymousUserPath({
|
|||||||
<div className="flex flex-col gap-2 justify-center items-start">
|
<div className="flex flex-col gap-2 justify-center items-start">
|
||||||
<div className="w-full flex-grow flex items-center rounded-md shadow-sm">
|
<div className="w-full flex-grow flex items-center rounded-md shadow-sm">
|
||||||
<span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-gray-500 sm:text-sm h-10">
|
<span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-gray-500 sm:text-sm h-10">
|
||||||
{NEXT_PUBLIC_WEB_DOMAIN}/anonymous/
|
{settings?.webDomain}/anonymous/
|
||||||
</span>
|
</span>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
@ -141,7 +141,7 @@ export function AnonymousUserPath({
|
|||||||
className="h-10 px-4"
|
className="h-10 px-4"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
`${NEXT_PUBLIC_WEB_DOMAIN}/anonymous/${anonymousUserPath}`
|
`${settings?.webDomain}/anonymous/${anonymousUserPath}`
|
||||||
);
|
);
|
||||||
setPopup({
|
setPopup({
|
||||||
message: "Invite link copied!",
|
message: "Invite link copied!",
|
||||||
|
@ -62,4 +62,5 @@ export interface CombinedSettings {
|
|||||||
customAnalyticsScript: string | null;
|
customAnalyticsScript: string | null;
|
||||||
isMobile?: boolean;
|
isMobile?: boolean;
|
||||||
webVersion: string | null;
|
webVersion: string | null;
|
||||||
|
webDomain: string | null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useState, useEffect, useRef } from "react";
|
import React, { useState, useEffect, useRef, useContext } from "react";
|
||||||
import { useUser } from "@/components/user/UserProvider";
|
import { useUser } from "@/components/user/UserProvider";
|
||||||
import { usePopup } from "@/components/admin/connectors/Popup";
|
import { usePopup } from "@/components/admin/connectors/Popup";
|
||||||
import {
|
import {
|
||||||
@ -31,11 +31,12 @@ import { useNRFPreferences } from "@/components/context/NRFPreferencesContext";
|
|||||||
import { SettingsPanel } from "../../components/nrf/SettingsPanel";
|
import { SettingsPanel } from "../../components/nrf/SettingsPanel";
|
||||||
import { ShortcutsDisplay } from "../../components/nrf/ShortcutsDisplay";
|
import { ShortcutsDisplay } from "../../components/nrf/ShortcutsDisplay";
|
||||||
import LoginPage from "../../auth/login/LoginPage";
|
import LoginPage from "../../auth/login/LoginPage";
|
||||||
import { AuthType, NEXT_PUBLIC_WEB_DOMAIN } from "@/lib/constants";
|
import { AuthType } from "@/lib/constants";
|
||||||
import { sendSetDefaultNewTabMessage } from "@/lib/extension/utils";
|
import { sendSetDefaultNewTabMessage } from "@/lib/extension/utils";
|
||||||
import { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
|
import { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
|
||||||
import { CHROME_MESSAGE } from "@/lib/extension/constants";
|
import { CHROME_MESSAGE } from "@/lib/extension/constants";
|
||||||
import { ApiKeyModal } from "@/components/llm/ApiKeyModal";
|
import { ApiKeyModal } from "@/components/llm/ApiKeyModal";
|
||||||
|
import { SettingsContext } from "@/components/settings/SettingsProvider";
|
||||||
|
|
||||||
export default function NRFPage({
|
export default function NRFPage({
|
||||||
requestCookies,
|
requestCookies,
|
||||||
@ -56,6 +57,7 @@ export default function NRFPage({
|
|||||||
const { isNight } = useNightTime();
|
const { isNight } = useNightTime();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { ccPairs, documentSets, tags, llmProviders } = useChatContext();
|
const { ccPairs, documentSets, tags, llmProviders } = useChatContext();
|
||||||
|
const settings = useContext(SettingsContext);
|
||||||
|
|
||||||
const { popup, setPopup } = usePopup();
|
const { popup, setPopup } = usePopup();
|
||||||
|
|
||||||
@ -196,7 +198,7 @@ export default function NRFPage({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newHref =
|
const newHref =
|
||||||
`${NEXT_PUBLIC_WEB_DOMAIN}/chat?send-on-load=true&user-prompt=` +
|
`${settings?.webDomain}/chat?send-on-load=true&user-prompt=` +
|
||||||
encodeURIComponent(userMessage) +
|
encodeURIComponent(userMessage) +
|
||||||
filterString;
|
filterString;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
} from "@/app/admin/settings/interfaces";
|
} from "@/app/admin/settings/interfaces";
|
||||||
import {
|
import {
|
||||||
CUSTOM_ANALYTICS_ENABLED,
|
CUSTOM_ANALYTICS_ENABLED,
|
||||||
|
HOST_URL,
|
||||||
SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED,
|
SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED,
|
||||||
} from "@/lib/constants";
|
} from "@/lib/constants";
|
||||||
import { fetchSS } from "@/lib/utilsSS";
|
import { fetchSS } from "@/lib/utilsSS";
|
||||||
@ -99,6 +100,7 @@ export async function fetchSettingsSS(): Promise<CombinedSettings | null> {
|
|||||||
enterpriseSettings,
|
enterpriseSettings,
|
||||||
customAnalyticsScript,
|
customAnalyticsScript,
|
||||||
webVersion,
|
webVersion,
|
||||||
|
webDomain: HOST_URL,
|
||||||
};
|
};
|
||||||
|
|
||||||
return combinedSettings;
|
return combinedSettings;
|
||||||
|
@ -175,7 +175,14 @@ export async function fetchChatData(searchParams: {
|
|||||||
);
|
);
|
||||||
const sidebarToggled = requestCookies.get(SIDEBAR_TOGGLED_COOKIE_NAME);
|
const sidebarToggled = requestCookies.get(SIDEBAR_TOGGLED_COOKIE_NAME);
|
||||||
|
|
||||||
const toggleSidebar = sidebarToggled
|
// IF user is an anoymous user, we don't want to show the sidebar (they have no access to chat history)
|
||||||
|
const toggleSidebar =
|
||||||
|
!user?.is_anonymous_user &&
|
||||||
|
(sidebarToggled
|
||||||
|
? sidebarToggled.value.toLocaleLowerCase() == "true" || false
|
||||||
|
: NEXT_PUBLIC_DEFAULT_SIDEBAR_OPEN);
|
||||||
|
|
||||||
|
sidebarToggled
|
||||||
? sidebarToggled.value.toLocaleLowerCase() == "true" || false
|
? sidebarToggled.value.toLocaleLowerCase() == "true" || false
|
||||||
: NEXT_PUBLIC_DEFAULT_SIDEBAR_OPEN;
|
: NEXT_PUBLIC_DEFAULT_SIDEBAR_OPEN;
|
||||||
|
|
||||||
|
@ -89,6 +89,3 @@ export const NEXT_PUBLIC_DELETE_ALL_CHATS_ENABLED =
|
|||||||
|
|
||||||
export const NEXT_PUBLIC_ENABLE_CHROME_EXTENSION =
|
export const NEXT_PUBLIC_ENABLE_CHROME_EXTENSION =
|
||||||
process.env.NEXT_PUBLIC_ENABLE_CHROME_EXTENSION?.toLowerCase() === "true";
|
process.env.NEXT_PUBLIC_ENABLE_CHROME_EXTENSION?.toLowerCase() === "true";
|
||||||
|
|
||||||
export const NEXT_PUBLIC_WEB_DOMAIN =
|
|
||||||
process.env.NEXT_PUBLIC_WEB_DOMAIN || "http://127.0.0.1:3000";
|
|
||||||
|
@ -112,6 +112,7 @@ export const getAuthUrlSS = async (
|
|||||||
nextUrl: string | null
|
nextUrl: string | null
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
// Returns the auth url for the given auth type
|
// Returns the auth url for the given auth type
|
||||||
|
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case "disabled":
|
case "disabled":
|
||||||
return "";
|
return "";
|
||||||
|
Reference in New Issue
Block a user