OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
fix: added visual loading spinner and success/error toast when restoring default langflow flows (#1931)
Zephyrus893f66eaceea
diff --git a/frontend/app/settings/_components/agent-settings-section.tsx b/frontend/app/settings/_components/agent-settings-section.tsxindex 4397fba0b..a28f7d4f8 100644--- a/frontend/app/settings/_components/agent-settings-section.tsx+++ b/frontend/app/settings/_components/agent-settings-section.tsx@@ -44,6 +44,7 @@ export function AgentSettingsSection() {const pathname = usePathname();const focusLlmModel = searchParams.get("focusLlmModel") === "true";+ const [isRestoringFlow, setIsRestoringFlow] = useState<boolean>(false);const [openLlmSelector, setOpenLlmSelector] = useState(false);const [systemPrompt, setSystemPrompt] = useState<string>("");@@ -231,24 +232,38 @@ export function AgentSettingsSection() {};const handleRestoreRetrievalFlow = (closeDialog: () => void) => {+ setIsRestoringFlow(true);+trackButton({CTA: "Restore Flow - Agent",elementId: "restore-agent-flow-button",namespace: "settings",});+fetch("/api/reset-flow/retrieval", { method: "POST" })- .then((res) => {- if (res.ok) return res.json();- throw new Error(`HTTP ${res.status}: ${res.statusText}`);- })+ .then((res) =>+ res.text().then((text) => {+ const body = text ? JSON.parse(text) : {};+ if (!res.ok) {+ throw new Error(+ body.error ?? `HTTP ${res.status}: ${res.statusText}`,+ );+ }+ }),+ ).then(() => {setSystemPrompt(DEFAULT_AGENT_SETTINGS.system_prompt);+ toast.success("Default agent flow settings restored successfully");closeDialog();}).catch((err) => {console.error("Error restoring retrieval flow:", err);+ toast.error(+ err.message || "Failed to restore default agent flow settings",+ );closeDialog();- });+ })+ .finally(() => setIsRestoringFlow(false));};return (@@ -276,6 +291,7 @@ export function AgentSettingsSection() {confirmText="Restore"variant="destructive"onConfirm={handleRestoreRetrievalFlow}+ isLoading={isRestoringFlow}/><ConfirmationDialogtrigger={diff --git a/frontend/app/settings/_components/ingest-settings-section.tsx b/frontend/app/settings/_components/ingest-settings-section.tsxindex 04e977b7f..2a896be32 100644--- a/frontend/app/settings/_components/ingest-settings-section.tsx+++ b/frontend/app/settings/_components/ingest-settings-section.tsx@@ -38,6 +38,8 @@ export function IngestSettingsSection() {const isCloudBrand = useIsCloudBrand();const { isAuthenticated, isNoAuthMode, isIbmAuthMode, runMode } = useAuth();+ const [isRestoringFlow, setIsRestoringFlow] = useState<boolean>(false);+const [chunkSize, setChunkSize] = useState<number>(1024);const [chunkOverlap, setChunkOverlap] = useState<number>(50);const [chunkValidationError, setChunkValidationError] = useState<@@ -286,16 +288,24 @@ export function IngestSettingsSection() {};const handleRestoreIngestFlow = (closeDialog: () => void) => {+ setIsRestoringFlow(true);+trackButton({CTA: "Restore Flow - Ingest",elementId: "restore-ingest-flow-button",namespace: "settings",});fetch("/api/reset-flow/ingest", { method: "POST" })- .then((res) => {- if (res.ok) return res.json();- throw new Error(`HTTP ${res.status}: ${res.statusText}`);- })+ .then((res) =>+ res.text().then((text) => {+ const body = text ? JSON.parse(text) : {};+ if (!res.ok) {+ throw new Error(+ body.error ?? `HTTP ${res.status}: ${res.statusText}`,+ );+ }+ }),+ ).then(() => {setChunkSize(DEFAULT_KNOWLEDGE_SETTINGS.chunk_size);setChunkOverlap(DEFAULT_KNOWLEDGE_SETTINGS.chunk_overlap);@@ -304,12 +314,17 @@ export function IngestSettingsSection() {setPictureDescriptions(DEFAULT_KNOWLEDGE_SETTINGS.picture_descriptions);setDisableIngestWithLangflow(false);setChunkValidationError(null);+ toast.success("Default ingest flow settings restored successfully");closeDialog();}).catch((err) => {console.error("Error restoring ingest flow:", err);+ toast.error(+ err.message || "Failed to restore default ingest flow settings",+ );closeDialog();- });+ })+ .finally(() => setIsRestoringFlow(false));};return (@@ -337,6 +352,7 @@ export function IngestSettingsSection() {confirmText="Restore"variant="destructive"onConfirm={handleRestoreIngestFlow}+ isLoading={isRestoringFlow}/><ConfirmationDialogtrigger={diff --git a/frontend/components/confirmation-dialog.tsx b/frontend/components/confirmation-dialog.tsxindex 1eb9f569f..5d4f92e2e 100644--- a/frontend/components/confirmation-dialog.tsx+++ b/frontend/components/confirmation-dialog.tsx@@ -1,5 +1,6 @@"use client";+import { Loader2 } from "lucide-react";import { ReactNode, useState } from "react";import { Button } from "@/components/ui/button";import {@@ -22,6 +23,7 @@ interface ConfirmationDialogProps {onCancel?: () => void;variant?: "default" | "destructive" | "warning";confirmIcon?: ReactNode | null;+ isLoading?: boolean;}export function ConfirmationDialog({@@ -34,6 +36,7 @@ export function ConfirmationDialog({onCancel,variant = "default",confirmIcon = null,+ isLoading = false,}: ConfirmationDialogProps) {const [open, setOpen] = useState(false);@@ -61,7 +64,13 @@ export function ConfirmationDialog({<Button variant="ghost" onClick={handleCancel} size="sm">{cancelText}</Button>- <Button variant={variant} onClick={handleConfirm} size="sm">+ <Button+ variant={variant}+ onClick={handleConfirm}+ size="sm"+ disabled={isLoading}+ >+ {isLoading && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}{confirmText}{confirmIcon}</Button>