mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-02-17 07:45:47 +00:00
Compare commits
2 Commits
tracking_t
...
additional
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c33f33f6e | ||
|
|
a8f87588ff |
@@ -36,6 +36,9 @@ from onyx.utils.logger import setup_logger
|
||||
logger = setup_logger()
|
||||
router = APIRouter(prefix="/auth/saml")
|
||||
|
||||
# Define non-authenticated user roles that should be re-created during SAML login
|
||||
NON_AUTHENTICATED_ROLES = {UserRole.SLACK_USER, UserRole.EXT_PERM_USER}
|
||||
|
||||
|
||||
async def upsert_saml_user(email: str) -> User:
|
||||
logger.debug(f"Attempting to upsert SAML user with email: {email}")
|
||||
@@ -51,7 +54,7 @@ async def upsert_saml_user(email: str) -> User:
|
||||
try:
|
||||
user = await user_manager.get_by_email(email)
|
||||
# If user has a non-authenticated role, treat as non-existent
|
||||
if not user.role.is_web_login():
|
||||
if user.role in NON_AUTHENTICATED_ROLES:
|
||||
raise exceptions.UserNotExists()
|
||||
return user
|
||||
except exceptions.UserNotExists:
|
||||
|
||||
@@ -23,7 +23,6 @@ from onyx.utils.url import add_url_params
|
||||
from onyx.utils.variable_functionality import fetch_versioned_implementation
|
||||
from shared_configs.configs import MULTI_TENANT
|
||||
|
||||
|
||||
HTML_EMAIL_TEMPLATE = """\
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
@@ -886,8 +886,11 @@ def monitor_ccpair_permissions_taskset(
|
||||
record_type=RecordType.PERMISSION_SYNC_PROGRESS,
|
||||
data={
|
||||
"cc_pair_id": cc_pair_id,
|
||||
"total_docs_synced": initial if initial is not None else 0,
|
||||
"remaining_docs_to_sync": remaining,
|
||||
"id": payload.id if payload else None,
|
||||
"total_docs": initial if initial is not None else 0,
|
||||
"remaining_docs": remaining,
|
||||
"synced_docs": (initial - remaining) if initial is not None else 0,
|
||||
"is_complete": remaining == 0,
|
||||
},
|
||||
tenant_id=tenant_id,
|
||||
)
|
||||
@@ -903,13 +906,6 @@ def monitor_ccpair_permissions_taskset(
|
||||
f"num_synced={initial}"
|
||||
)
|
||||
|
||||
# Add telemetry for permission syncing complete
|
||||
optional_telemetry(
|
||||
record_type=RecordType.PERMISSION_SYNC_COMPLETE,
|
||||
data={"cc_pair_id": cc_pair_id},
|
||||
tenant_id=tenant_id,
|
||||
)
|
||||
|
||||
update_sync_record_status(
|
||||
db_session=db_session,
|
||||
entity_id=cc_pair_id,
|
||||
|
||||
@@ -56,6 +56,7 @@ from onyx.indexing.indexing_pipeline import build_indexing_pipeline
|
||||
from onyx.natural_language_processing.search_nlp_models import (
|
||||
InformationContentClassificationModel,
|
||||
)
|
||||
from onyx.redis.redis_connector import RedisConnector
|
||||
from onyx.utils.logger import setup_logger
|
||||
from onyx.utils.logger import TaskAttemptSingleton
|
||||
from onyx.utils.telemetry import create_milestone_and_report
|
||||
@@ -577,8 +578,11 @@ def _run_indexing(
|
||||
data={
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"cc_pair_id": ctx.cc_pair_id,
|
||||
"current_docs_indexed": document_count,
|
||||
"current_chunks_indexed": chunk_count,
|
||||
"connector_id": ctx.connector_id,
|
||||
"credential_id": ctx.credential_id,
|
||||
"total_docs_indexed": document_count,
|
||||
"total_chunks": chunk_count,
|
||||
"batch_num": batch_num,
|
||||
"source": ctx.source.value,
|
||||
},
|
||||
tenant_id=tenant_id,
|
||||
@@ -599,15 +603,26 @@ def _run_indexing(
|
||||
checkpoint=checkpoint,
|
||||
)
|
||||
|
||||
# Add telemetry for completed indexing
|
||||
redis_connector = RedisConnector(tenant_id, ctx.cc_pair_id)
|
||||
redis_connector_index = redis_connector.new_index(
|
||||
index_attempt_start.search_settings_id
|
||||
)
|
||||
final_progress = redis_connector_index.get_progress() or 0
|
||||
|
||||
optional_telemetry(
|
||||
record_type=RecordType.INDEXING_COMPLETE,
|
||||
data={
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"cc_pair_id": ctx.cc_pair_id,
|
||||
"connector_id": ctx.connector_id,
|
||||
"credential_id": ctx.credential_id,
|
||||
"total_docs_indexed": document_count,
|
||||
"total_chunks": chunk_count,
|
||||
"batch_count": batch_num,
|
||||
"time_elapsed_seconds": time.monotonic() - start_time,
|
||||
"source": ctx.source.value,
|
||||
"redis_progress": final_progress,
|
||||
},
|
||||
tenant_id=tenant_id,
|
||||
)
|
||||
|
||||
@@ -217,6 +217,7 @@ def mark_attempt_in_progress(
|
||||
"index_attempt_id": index_attempt.id,
|
||||
"status": IndexingStatus.IN_PROGRESS.value,
|
||||
"cc_pair_id": index_attempt.connector_credential_pair_id,
|
||||
"search_settings_id": index_attempt.search_settings_id,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
@@ -245,6 +246,9 @@ def mark_attempt_succeeded(
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"status": IndexingStatus.SUCCESS.value,
|
||||
"cc_pair_id": attempt.connector_credential_pair_id,
|
||||
"search_settings_id": attempt.search_settings_id,
|
||||
"total_docs_indexed": attempt.total_docs_indexed,
|
||||
"new_docs_indexed": attempt.new_docs_indexed,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
@@ -273,6 +277,9 @@ def mark_attempt_partially_succeeded(
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"status": IndexingStatus.COMPLETED_WITH_ERRORS.value,
|
||||
"cc_pair_id": attempt.connector_credential_pair_id,
|
||||
"search_settings_id": attempt.search_settings_id,
|
||||
"total_docs_indexed": attempt.total_docs_indexed,
|
||||
"new_docs_indexed": attempt.new_docs_indexed,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
@@ -305,6 +312,10 @@ def mark_attempt_canceled(
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"status": IndexingStatus.CANCELED.value,
|
||||
"cc_pair_id": attempt.connector_credential_pair_id,
|
||||
"search_settings_id": attempt.search_settings_id,
|
||||
"reason": reason,
|
||||
"total_docs_indexed": attempt.total_docs_indexed,
|
||||
"new_docs_indexed": attempt.new_docs_indexed,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
@@ -339,6 +350,10 @@ def mark_attempt_failed(
|
||||
"index_attempt_id": index_attempt_id,
|
||||
"status": IndexingStatus.FAILED.value,
|
||||
"cc_pair_id": attempt.connector_credential_pair_id,
|
||||
"search_settings_id": attempt.search_settings_id,
|
||||
"reason": failure_reason,
|
||||
"total_docs_indexed": attempt.total_docs_indexed,
|
||||
"new_docs_indexed": attempt.new_docs_indexed,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
|
||||
@@ -39,7 +39,6 @@ class RecordType(str, Enum):
|
||||
INDEXING_PROGRESS = "indexing_progress"
|
||||
INDEXING_COMPLETE = "indexing_complete"
|
||||
PERMISSION_SYNC_PROGRESS = "permission_sync_progress"
|
||||
PERMISSION_SYNC_COMPLETE = "permission_sync_complete"
|
||||
INDEX_ATTEMPT_STATUS = "index_attempt_status"
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ ENV NEXT_PUBLIC_DISABLE_STREAMING=${NEXT_PUBLIC_DISABLE_STREAMING}
|
||||
ARG NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA
|
||||
ENV NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA=${NEXT_PUBLIC_NEW_CHAT_DIRECTS_TO_SAME_PERSONA}
|
||||
|
||||
# allow user to specify custom feedback options
|
||||
ARG NEXT_PUBLIC_POSITIVE_PREDEFINED_FEEDBACK_OPTIONS
|
||||
ENV NEXT_PUBLIC_POSITIVE_PREDEFINED_FEEDBACK_OPTIONS=${NEXT_PUBLIC_POSITIVE_PREDEFINED_FEEDBACK_OPTIONS}
|
||||
|
||||
|
||||
12200
web/package-lock.json
generated
12200
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -93,12 +93,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chromatic-com/playwright": "^0.10.2",
|
||||
"@playwright/test": "^1.39.0",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"@types/chrome": "^0.0.287",
|
||||
"@types/jest": "^29.5.14",
|
||||
"chromatic": "^11.25.2",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint": "^8.48.0",
|
||||
"eslint-config-next": "^14.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "2.8.8",
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function PostHogPageView(): null {
|
||||
// Track pageviews
|
||||
if (pathname) {
|
||||
let url = window.origin + pathname;
|
||||
if (searchParams?.toString()) {
|
||||
if (searchParams.toString()) {
|
||||
url = url + `?${searchParams.toString()}`;
|
||||
}
|
||||
posthog.capture("$pageview", {
|
||||
|
||||
@@ -149,7 +149,7 @@ export function AssistantEditor({
|
||||
const { refreshAssistants, isImageGenerationAvailable } = useAssistants();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const isAdminPage = searchParams?.get("admin") === "true";
|
||||
const isAdminPage = searchParams.get("admin") === "true";
|
||||
|
||||
const { popup, setPopup } = usePopup();
|
||||
const { labels, refreshLabels, createLabel, updateLabel, deleteLabel } =
|
||||
@@ -469,14 +469,8 @@ export function AssistantEditor({
|
||||
description: Yup.string().required(
|
||||
"Must provide a description for the Assistant"
|
||||
),
|
||||
system_prompt: Yup.string().max(
|
||||
8000,
|
||||
"Instructions must be less than 8000 characters"
|
||||
),
|
||||
task_prompt: Yup.string().max(
|
||||
8000,
|
||||
"Reminders must be less than 8000 characters"
|
||||
),
|
||||
system_prompt: Yup.string(),
|
||||
task_prompt: Yup.string(),
|
||||
is_public: Yup.boolean().required(),
|
||||
document_set_ids: Yup.array().of(Yup.number()),
|
||||
num_chunks: Yup.number().nullable(),
|
||||
|
||||
@@ -26,8 +26,8 @@ export default function OAuthCallbackPage() {
|
||||
);
|
||||
|
||||
// Extract query parameters
|
||||
const code = searchParams?.get("code");
|
||||
const state = searchParams?.get("state");
|
||||
const code = searchParams.get("code");
|
||||
const state = searchParams.get("state");
|
||||
|
||||
const pathname = usePathname();
|
||||
const connector = pathname?.split("/")[3];
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { AdminPageTitle } from "@/components/admin/Title";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Title from "@/components/ui/title";
|
||||
import { KeyIcon } from "@/components/icons/icons";
|
||||
import { getSourceMetadata, isValidSource } from "@/lib/sources";
|
||||
import { ConfluenceAccessibleResource, ValidSources } from "@/lib/types";
|
||||
@@ -73,7 +74,7 @@ export default function OAuthFinalizePage() {
|
||||
>([]);
|
||||
|
||||
// Extract query parameters
|
||||
const credentialParam = searchParams?.get("credential");
|
||||
const credentialParam = searchParams.get("credential");
|
||||
const credential = credentialParam ? parseInt(credentialParam, 10) : NaN;
|
||||
const pathname = usePathname();
|
||||
const connector = pathname?.split("/")[3];
|
||||
@@ -84,7 +85,7 @@ export default function OAuthFinalizePage() {
|
||||
// connector (url segment)= "google-drive"
|
||||
// sourceType (for looking up metadata) = "google_drive"
|
||||
|
||||
if (isNaN(credential) || !connector) {
|
||||
if (isNaN(credential)) {
|
||||
setStatusMessage("Improperly formed OAuth finalization request.");
|
||||
setStatusDetails("Invalid or missing credential id.");
|
||||
setIsError(true);
|
||||
|
||||
@@ -23,8 +23,8 @@ const ResetPasswordPage: React.FC = () => {
|
||||
const { popup, setPopup } = usePopup();
|
||||
const [isWorking, setIsWorking] = useState(false);
|
||||
const searchParams = useSearchParams();
|
||||
const token = searchParams?.get("token");
|
||||
const tenantId = searchParams?.get(TENANT_ID_COOKIE_NAME);
|
||||
const token = searchParams.get("token");
|
||||
const tenantId = searchParams.get(TENANT_ID_COOKIE_NAME);
|
||||
// Keep search param same name as cookie for simplicity
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -15,9 +15,9 @@ export function Verify({ user }: { user: User | null }) {
|
||||
const [error, setError] = useState("");
|
||||
|
||||
const verify = useCallback(async () => {
|
||||
const token = searchParams?.get("token");
|
||||
const token = searchParams.get("token");
|
||||
const firstUser =
|
||||
searchParams?.get("first_user") && NEXT_PUBLIC_CLOUD_ENABLED;
|
||||
searchParams.get("first_user") && NEXT_PUBLIC_CLOUD_ENABLED;
|
||||
if (!token) {
|
||||
setError(
|
||||
"Missing verification token. Try requesting a new verification email."
|
||||
|
||||
@@ -196,9 +196,7 @@ export function ChatPage({
|
||||
setCurrentMessageFiles,
|
||||
} = useDocumentsContext();
|
||||
|
||||
const defaultAssistantIdRaw = searchParams?.get(
|
||||
SEARCH_PARAM_NAMES.PERSONA_ID
|
||||
);
|
||||
const defaultAssistantIdRaw = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
||||
const defaultAssistantId = defaultAssistantIdRaw
|
||||
? parseInt(defaultAssistantIdRaw)
|
||||
: undefined;
|
||||
@@ -254,8 +252,8 @@ export function ChatPage({
|
||||
);
|
||||
|
||||
const { user, isAdmin } = useUser();
|
||||
const slackChatId = searchParams?.get("slackChatId");
|
||||
const existingChatIdRaw = searchParams?.get("chatId");
|
||||
const slackChatId = searchParams.get("slackChatId");
|
||||
const existingChatIdRaw = searchParams.get("chatId");
|
||||
|
||||
const [showHistorySidebar, setShowHistorySidebar] = useState(false);
|
||||
|
||||
@@ -277,7 +275,7 @@ export function ChatPage({
|
||||
|
||||
const processSearchParamsAndSubmitMessage = (searchParamsString: string) => {
|
||||
const newSearchParams = new URLSearchParams(searchParamsString);
|
||||
const message = newSearchParams?.get("user-prompt");
|
||||
const message = newSearchParams.get("user-prompt");
|
||||
|
||||
filterManager.buildFiltersFromQueryString(
|
||||
newSearchParams.toString(),
|
||||
@@ -286,7 +284,7 @@ export function ChatPage({
|
||||
tags
|
||||
);
|
||||
|
||||
const fileDescriptorString = newSearchParams?.get(SEARCH_PARAM_NAMES.FILES);
|
||||
const fileDescriptorString = newSearchParams.get(SEARCH_PARAM_NAMES.FILES);
|
||||
const overrideFileDescriptors: FileDescriptor[] = fileDescriptorString
|
||||
? JSON.parse(decodeURIComponent(fileDescriptorString))
|
||||
: [];
|
||||
@@ -326,7 +324,7 @@ export function ChatPage({
|
||||
: undefined
|
||||
);
|
||||
// Gather default temperature settings
|
||||
const search_param_temperature = searchParams?.get(
|
||||
const search_param_temperature = searchParams.get(
|
||||
SEARCH_PARAM_NAMES.TEMPERATURE
|
||||
);
|
||||
|
||||
@@ -553,7 +551,7 @@ export function ChatPage({
|
||||
if (
|
||||
newMessageHistory.length === 1 &&
|
||||
!submitOnLoadPerformed.current &&
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.SEEDED) === "true"
|
||||
searchParams.get(SEARCH_PARAM_NAMES.SEEDED) === "true"
|
||||
) {
|
||||
submitOnLoadPerformed.current = true;
|
||||
const seededMessage = newMessageHistory[0].message;
|
||||
@@ -574,11 +572,11 @@ export function ChatPage({
|
||||
|
||||
initialSessionFetch();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [existingChatSessionId, searchParams?.get(SEARCH_PARAM_NAMES.PERSONA_ID)]);
|
||||
}, [existingChatSessionId, searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID)]);
|
||||
|
||||
useEffect(() => {
|
||||
const userFolderId = searchParams?.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID);
|
||||
const allMyDocuments = searchParams?.get(
|
||||
const userFolderId = searchParams.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID);
|
||||
const allMyDocuments = searchParams.get(
|
||||
SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS
|
||||
);
|
||||
|
||||
@@ -601,14 +599,14 @@ export function ChatPage({
|
||||
}
|
||||
}, [
|
||||
userFolders,
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID),
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS),
|
||||
searchParams.get(SEARCH_PARAM_NAMES.USER_FOLDER_ID),
|
||||
searchParams.get(SEARCH_PARAM_NAMES.ALL_MY_DOCUMENTS),
|
||||
addSelectedFolder,
|
||||
clearSelectedItems,
|
||||
]);
|
||||
|
||||
const [message, setMessage] = useState(
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.USER_PROMPT) || ""
|
||||
searchParams.get(SEARCH_PARAM_NAMES.USER_PROMPT) || ""
|
||||
);
|
||||
|
||||
const [completeMessageDetail, setCompleteMessageDetail] = useState<
|
||||
@@ -1050,7 +1048,7 @@ export function ChatPage({
|
||||
|
||||
// Equivalent to `loadNewPageLogic`
|
||||
useEffect(() => {
|
||||
if (searchParams?.get(SEARCH_PARAM_NAMES.SEND_ON_LOAD)) {
|
||||
if (searchParams.get(SEARCH_PARAM_NAMES.SEND_ON_LOAD)) {
|
||||
processSearchParamsAndSubmitMessage(searchParams.toString());
|
||||
}
|
||||
}, [searchParams, router]);
|
||||
@@ -1233,7 +1231,7 @@ export function ChatPage({
|
||||
const isNewSession = chatSessionIdRef.current === null;
|
||||
|
||||
const searchParamBasedChatSessionName =
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.TITLE) || null;
|
||||
searchParams.get(SEARCH_PARAM_NAMES.TITLE) || null;
|
||||
|
||||
if (isNewSession) {
|
||||
currChatSessionId = await createChatSession(
|
||||
@@ -1411,11 +1409,11 @@ export function ChatPage({
|
||||
modelVersion:
|
||||
modelOverride?.modelName ||
|
||||
llmManager.currentLlm.modelName ||
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.MODEL_VERSION) ||
|
||||
searchParams.get(SEARCH_PARAM_NAMES.MODEL_VERSION) ||
|
||||
undefined,
|
||||
temperature: llmManager.temperature || undefined,
|
||||
systemPromptOverride:
|
||||
searchParams?.get(SEARCH_PARAM_NAMES.SYSTEM_PROMPT) || undefined,
|
||||
searchParams.get(SEARCH_PARAM_NAMES.SYSTEM_PROMPT) || undefined,
|
||||
useExistingUserMessage: isSeededChat,
|
||||
useLanggraph:
|
||||
settings?.settings.pro_search_enabled &&
|
||||
|
||||
@@ -668,7 +668,7 @@ const PARAMS_TO_SKIP = [
|
||||
];
|
||||
|
||||
export function buildChatUrl(
|
||||
existingSearchParams: ReadonlyURLSearchParams | null,
|
||||
existingSearchParams: ReadonlyURLSearchParams,
|
||||
chatSessionId: string | null,
|
||||
personaId: number | null,
|
||||
search?: boolean
|
||||
@@ -685,7 +685,7 @@ export function buildChatUrl(
|
||||
finalSearchParams.push(`${SEARCH_PARAM_NAMES.PERSONA_ID}=${personaId}`);
|
||||
}
|
||||
|
||||
existingSearchParams?.forEach((value, key) => {
|
||||
existingSearchParams.forEach((value, key) => {
|
||||
if (!PARAMS_TO_SKIP.includes(key)) {
|
||||
finalSearchParams.push(`${key}=${value}`);
|
||||
}
|
||||
@@ -719,7 +719,7 @@ export async function uploadFilesForChat(
|
||||
return [responseJson.files as FileDescriptor[], null];
|
||||
}
|
||||
|
||||
export function useScrollonStream({
|
||||
export async function useScrollonStream({
|
||||
chatState,
|
||||
scrollableDivRef,
|
||||
scrollDist,
|
||||
@@ -817,5 +817,5 @@ export function useScrollonStream({
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [chatState, distance, scrollDist, scrollableDivRef, enableAutoScroll]);
|
||||
}, [chatState, distance, scrollDist, scrollableDivRef]);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ export const SEARCH_PARAM_NAMES = {
|
||||
SEND_ON_LOAD: "send-on-load",
|
||||
};
|
||||
|
||||
export function shouldSubmitOnLoad(
|
||||
searchParams: ReadonlyURLSearchParams | null
|
||||
) {
|
||||
const rawSubmitOnLoad = searchParams?.get(SEARCH_PARAM_NAMES.SUBMIT_ON_LOAD);
|
||||
export function shouldSubmitOnLoad(searchParams: ReadonlyURLSearchParams) {
|
||||
const rawSubmitOnLoad = searchParams.get(SEARCH_PARAM_NAMES.SUBMIT_ON_LOAD);
|
||||
if (rawSubmitOnLoad === "true" || rawSubmitOnLoad === "1") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export function UserDropdown({
|
||||
|
||||
// Construct the current URL
|
||||
const currentUrl = `${pathname}${
|
||||
searchParams?.toString() ? `?${searchParams.toString()}` : ""
|
||||
searchParams.toString() ? `?${searchParams.toString()}` : ""
|
||||
}`;
|
||||
|
||||
// Encode the current URL to use as a redirect parameter
|
||||
|
||||
@@ -59,8 +59,8 @@ export function ClientLayout({
|
||||
const { llmProviders } = useChatContext();
|
||||
const { popup, setPopup } = usePopup();
|
||||
if (
|
||||
(pathname && pathname.startsWith("/admin/connectors")) ||
|
||||
(pathname && pathname.startsWith("/admin/embeddings"))
|
||||
pathname.startsWith("/admin/connectors") ||
|
||||
pathname.startsWith("/admin/embeddings")
|
||||
) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export const ChatProvider: React.FC<{
|
||||
const { sessions } = await response.json();
|
||||
setChatSessions(sessions);
|
||||
|
||||
const currentSessionId = searchParams?.get("chatId");
|
||||
const currentSessionId = searchParams.get("chatId");
|
||||
if (
|
||||
currentSessionId &&
|
||||
!sessions.some(
|
||||
|
||||
@@ -34,7 +34,7 @@ export const EmbeddingFormProvider: React.FC<{
|
||||
const pathname = usePathname();
|
||||
|
||||
// Initialize formStep based on the URL parameter
|
||||
const initialStep = parseInt(searchParams?.get("step") || "0", 10);
|
||||
const initialStep = parseInt(searchParams.get("step") || "0", 10);
|
||||
const [formStep, setFormStep] = useState(initialStep);
|
||||
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
||||
|
||||
@@ -56,10 +56,8 @@ export const EmbeddingFormProvider: React.FC<{
|
||||
|
||||
useEffect(() => {
|
||||
// Update URL when formStep changes
|
||||
const updatedSearchParams = new URLSearchParams(
|
||||
searchParams?.toString() || ""
|
||||
);
|
||||
const existingStep = updatedSearchParams?.get("step");
|
||||
const updatedSearchParams = new URLSearchParams(searchParams.toString());
|
||||
const existingStep = updatedSearchParams.get("step");
|
||||
updatedSearchParams.set("step", formStep.toString());
|
||||
const newUrl = `${pathname}?${updatedSearchParams.toString()}`;
|
||||
|
||||
@@ -72,7 +70,7 @@ export const EmbeddingFormProvider: React.FC<{
|
||||
|
||||
// Update formStep when URL changes
|
||||
useEffect(() => {
|
||||
const stepFromUrl = parseInt(searchParams?.get("step") || "0", 10);
|
||||
const stepFromUrl = parseInt(searchParams.get("step") || "0", 10);
|
||||
if (stepFromUrl !== formStep) {
|
||||
setFormStep(stepFromUrl);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export const FormProvider: React.FC<{
|
||||
const pathname = usePathname();
|
||||
|
||||
// Initialize formStep based on the URL parameter
|
||||
const initialStep = parseInt(searchParams?.get("step") || "0", 10);
|
||||
const initialStep = parseInt(searchParams.get("step") || "0", 10);
|
||||
const [formStep, setFormStep] = useState(initialStep);
|
||||
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
||||
|
||||
@@ -56,10 +56,8 @@ export const FormProvider: React.FC<{
|
||||
|
||||
useEffect(() => {
|
||||
// Update URL when formStep changes
|
||||
const updatedSearchParams = new URLSearchParams(
|
||||
searchParams?.toString() || ""
|
||||
);
|
||||
const existingStep = updatedSearchParams?.get("step");
|
||||
const updatedSearchParams = new URLSearchParams(searchParams.toString());
|
||||
const existingStep = updatedSearchParams.get("step");
|
||||
updatedSearchParams.set("step", formStep.toString());
|
||||
const newUrl = `${pathname}?${updatedSearchParams.toString()}`;
|
||||
|
||||
@@ -71,7 +69,7 @@ export const FormProvider: React.FC<{
|
||||
}, [formStep, router, pathname, searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
const stepFromUrl = parseInt(searchParams?.get("step") || "0", 10);
|
||||
const stepFromUrl = parseInt(searchParams.get("step") || "0", 10);
|
||||
if (stepFromUrl !== formStep) {
|
||||
setFormStep(stepFromUrl);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export const HealthCheckBanner = () => {
|
||||
useEffect(() => {
|
||||
if (userError && userError.status === 403) {
|
||||
logout().then(() => {
|
||||
if (!pathname?.includes("/auth")) {
|
||||
if (!pathname.includes("/auth")) {
|
||||
setShowLoggedOutModal(true);
|
||||
}
|
||||
});
|
||||
@@ -61,7 +61,7 @@ export const HealthCheckBanner = () => {
|
||||
expirationTimeoutRef.current = setTimeout(() => {
|
||||
setExpired(true);
|
||||
|
||||
if (!pathname?.includes("/auth")) {
|
||||
if (!pathname.includes("/auth")) {
|
||||
setShowLoggedOutModal(true);
|
||||
}
|
||||
}, timeUntilExpire);
|
||||
@@ -205,7 +205,7 @@ export const HealthCheckBanner = () => {
|
||||
}
|
||||
|
||||
if (error instanceof RedirectError || expired) {
|
||||
if (!pathname?.includes("/auth")) {
|
||||
if (!pathname.includes("/auth")) {
|
||||
setShowLoggedOutModal(true);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -19,12 +19,12 @@ function setWelcomeFlowComplete() {
|
||||
Cookies.set(COMPLETED_WELCOME_FLOW_COOKIE, "true", { expires: 365 });
|
||||
}
|
||||
|
||||
export function CompletedWelcomeFlowDummyComponent() {
|
||||
export function _CompletedWelcomeFlowDummyComponent() {
|
||||
setWelcomeFlowComplete();
|
||||
return null;
|
||||
}
|
||||
|
||||
export function WelcomeModal({ user }: { user: User | null }) {
|
||||
export function _WelcomeModal({ user }: { user: User | null }) {
|
||||
const router = useRouter();
|
||||
|
||||
const [providerOptions, setProviderOptions] = useState<
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
CompletedWelcomeFlowDummyComponent,
|
||||
WelcomeModal as WelcomeModalComponent,
|
||||
_CompletedWelcomeFlowDummyComponent,
|
||||
_WelcomeModal,
|
||||
} from "./WelcomeModal";
|
||||
import { COMPLETED_WELCOME_FLOW_COOKIE } from "./constants";
|
||||
import { User } from "@/lib/types";
|
||||
@@ -24,8 +24,8 @@ export function WelcomeModal({
|
||||
}) {
|
||||
const hasCompletedWelcomeFlow = hasCompletedWelcomeFlowSS(requestCookies);
|
||||
if (hasCompletedWelcomeFlow) {
|
||||
return <CompletedWelcomeFlowDummyComponent />;
|
||||
return <_CompletedWelcomeFlowDummyComponent />;
|
||||
}
|
||||
|
||||
return <WelcomeModalComponent user={user} />;
|
||||
return <_WelcomeModal user={user} />;
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ export function NewTeamModal() {
|
||||
const { setPopup } = usePopup();
|
||||
|
||||
useEffect(() => {
|
||||
const hasNewTeamParam = searchParams?.has("new_team");
|
||||
const hasNewTeamParam = searchParams.has("new_team");
|
||||
if (hasNewTeamParam) {
|
||||
setShowNewTeamModal(true);
|
||||
fetchTenantInfo();
|
||||
|
||||
// Remove the new_team parameter from the URL without page reload
|
||||
const newParams = new URLSearchParams(searchParams?.toString() || "");
|
||||
const newParams = new URLSearchParams(searchParams.toString());
|
||||
newParams.delete("new_team");
|
||||
const newUrl =
|
||||
window.location.pathname +
|
||||
|
||||
@@ -16,7 +16,7 @@ export const usePopupFromQuery = (messages: PopupMessages) => {
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
|
||||
// Get the value for search param with key "message"
|
||||
const messageValue = searchParams?.get("message");
|
||||
const messageValue = searchParams.get("message");
|
||||
|
||||
// Check if any key from messages object is present in search params
|
||||
if (messageValue && messageValue in messages) {
|
||||
|
||||
@@ -148,7 +148,7 @@ function usePaginatedFetch<T extends PaginatedType>({
|
||||
// Updates the URL with the current page number
|
||||
const updatePageUrl = useCallback(
|
||||
(page: number) => {
|
||||
if (currentPath && searchParams) {
|
||||
if (currentPath) {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
params.set("page", page.toString());
|
||||
router.replace(`${currentPath}?${params.toString()}`, {
|
||||
|
||||
Reference in New Issue
Block a user