Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

conditional rendering

Mrunal Salunke8dd9c558b721
diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsx
index 5bb7f1564..76e7a4b54 100644
--- a/frontend/app/knowledge/page.tsx
+++ b/frontend/app/knowledge/page.tsx
@@ -605,56 +605,14 @@ function SearchPage() {
{/* Search Input Area */}
<div className="flex items-center gap-3 mb-6">
<div className="flex-1 flex items-center gap-3">
- <KnowledgeSearchBar />
- {/* <KnowledgeSearchInput />
- {isCloudBrand && (
- <Button
- type="button"
- variant="outline"
- className="flex-shrink-0"
- disabled={syncAllConnectorsMutation.isPending}
- onClick={async () => {
- try {
- toast.info("Syncing all cloud connectors...");
- const result =
- await syncAllConnectorsMutation.mutateAsync();
- if (result.status === "no_files") {
- toast.info(
- result.message ||
- "No cloud files to sync. Add files from cloud connectors first.",
- );
- } else if (
- result.synced_connectors &&
- result.synced_connectors.length > 0
- ) {
- toast.success(
- `Sync started for ${result.synced_connectors.join(", ")}. Check task notifications for progress.`,
- );
- } else if (result.errors && result.errors.length > 0) {
- toast.error("Some connectors failed to sync");
- }
- } catch (error) {
- toast.error(
- error instanceof Error
- ? error.message
- : "Failed to sync connectors",
- );
- }
- }}
- >
- {syncAllConnectorsMutation.isPending ? (
- <>
- <RefreshCw className="h-4 w-4 mr-2 animate-spin" />
- Syncing...
- </>
- ) : (
- <>
- <RefreshCw className="h-4 w-4" />
- </>
- )}
- </Button>
+ {isCloudBrand ? (
+ <KnowledgeSearchBar />
+ ) : (
+ <>
+ <KnowledgeSearchInput />
+ <KnowledgeDropdown />
+ </>
)}
- <KnowledgeDropdown /> */}
</div>
{selectedRows.length > 0 && (
@@ -667,81 +625,78 @@ function SearchPage() {
Delete
</Button>
)}
- {!isCloudBrand && (
- <Button
- type="button"
- variant="outline"
- className="rounded-lg flex-shrink-0"
- disabled={syncAllConnectorsMutation.isPending}
- onClick={async () => {
- try {
- toast.info("Syncing all cloud connectors...");
- const result = await syncAllConnectorsMutation.mutateAsync();
- if (result.status === "no_files") {
- toast.info(
- result.message ||
- "No cloud files to sync. Add files from cloud connectors first.",
- );
- } else if (
- result.synced_connectors &&
- result.synced_connectors.length > 0
- ) {
- toast.success(
- `Sync started for ${result.synced_connectors.join(", ")}. Check task notifications for progress.`,
- );
- } else if (result.errors && result.errors.length > 0) {
- toast.error("Some connectors failed to sync");
- }
- } catch (error) {
- toast.error(
- error instanceof Error
- ? error.message
- : "Failed to sync connectors",
- );
- }
- }}
- >
- {syncAllConnectorsMutation.isPending ? (
- <>
- <RefreshCw className="h-4 w-4 mr-2 animate-spin" />
- Syncing...
- </>
- ) : (
- <>
- <RefreshCw className="h-4 w-4 mr-2" />
- Sync
- </>
- )}
- </Button>
- )}
- {!isCloudBrand && (
- <Button
- type="button"
- variant="outline"
- className="rounded-lg flex-shrink-0"
- disabled={refreshOpenragDocsMutation.isPending}
- onClick={async () => {
- try {
- toast.info("Refreshing OpenRAG docs...");
- const result = await refreshOpenragDocsMutation.mutateAsync();
- toast.success(result.message);
- } catch (error) {
- toast.error(
- error instanceof Error
- ? error.message
- : "Failed to refresh OpenRAG docs",
+ <Button
+ type="button"
+ variant="outline"
+ className="rounded-lg flex-shrink-0"
+ disabled={syncAllConnectorsMutation.isPending}
+ onClick={async () => {
+ try {
+ toast.info("Syncing all cloud connectors...");
+ const result = await syncAllConnectorsMutation.mutateAsync();
+ if (result.status === "no_files") {
+ toast.info(
+ result.message ||
+ "No cloud files to sync. Add files from cloud connectors first.",
);
+ } else if (
+ result.synced_connectors &&
+ result.synced_connectors.length > 0
+ ) {
+ toast.success(
+ `Sync started for ${result.synced_connectors.join(", ")}. Check task notifications for progress.`,
+ );
+ } else if (result.errors && result.errors.length > 0) {
+ toast.error("Some connectors failed to sync");
}
- }}
- >
- {refreshOpenragDocsMutation.isPending ? (
- <>Refreshing docs...</>
- ) : (
- <>Fetch latest docs</>
- )}
- </Button>
- )}
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to sync connectors",
+ );
+ }
+ }}
+ >
+ {syncAllConnectorsMutation.isPending ? (
+ <>
+ <RefreshCw className="h-4 w-4 mr-2 animate-spin" />
+ Syncing...
+ </>
+ ) : (
+ <>
+ <RefreshCw className="h-4 w-4 mr-2" />
+ Sync
+ </>
+ )}
+ </Button>
+
+ <Button
+ type="button"
+ variant="outline"
+ className="rounded-lg flex-shrink-0"
+ disabled={refreshOpenragDocsMutation.isPending}
+ onClick={async () => {
+ try {
+ toast.info("Refreshing OpenRAG docs...");
+ const result = await refreshOpenragDocsMutation.mutateAsync();
+ toast.success(result.message);
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to refresh OpenRAG docs",
+ );
+ }
+ }}
+ >
+ {refreshOpenragDocsMutation.isPending ? (
+ <>Refreshing docs...</>
+ ) : (
+ <>Fetch latest docs</>
+ )}
+ </Button>
</div>
<AgGridReact
className="w-full overflow-auto"