Skip to content

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

Python

gate fetch latest docs (#2185)

Edwin Jose2ecf20f281cf
diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsx
index cb1a949d7..a11408682 100644
--- a/frontend/app/knowledge/page.tsx
+++ b/frontend/app/knowledge/page.tsx
@@ -34,6 +34,7 @@ import { KnowledgeActionsDropdown } from "@/components/knowledge-actions-dropdow
import { KnowledgeBatchActionsBar } from "@/components/knowledge-batch-actions-bar";
import { KnowledgeSearchBar } from "@/components/knowledge-search-bar";
import { KnowledgeSearchInput } from "@/components/knowledge-search-input";
+import { RequirePermission } from "@/components/require-permission";
import { StatusBadge } from "@/components/ui/status-badge";
import {
Tooltip,
@@ -958,36 +959,39 @@ function SearchPage() {
</>
)}
</Button>
- <Button
- type="button"
- variant="outline"
- className="rounded-lg flex-shrink-0"
- disabled={refreshOpenragDocsMutation.isPending}
- onClick={async () => {
- trackButton({
- CTA: "Fetch Latest Docs",
- elementId: "fetch-latest-docs-button",
- namespace: "knowledge",
- });
- 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>
+ <RequirePermission perm="config:write">
+ <Button
+ type="button"
+ variant="outline"
+ className="rounded-lg flex-shrink-0"
+ disabled={refreshOpenragDocsMutation.isPending}
+ onClick={async () => {
+ trackButton({
+ CTA: "Fetch Latest Docs",
+ elementId: "fetch-latest-docs-button",
+ namespace: "knowledge",
+ });
+ 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>
+ </RequirePermission>
{selectedRows.length > 0 && (
<Button
type="button"
diff --git a/frontend/components/knowledge-search-bar.tsx b/frontend/components/knowledge-search-bar.tsx
index 484682403..dd3c68095 100644
--- a/frontend/components/knowledge-search-bar.tsx
+++ b/frontend/components/knowledge-search-bar.tsx
@@ -7,6 +7,7 @@ import {
useSyncAllConnectors,
useSyncAllConnectorsPreview,
} from "@/app/api/mutations/useSyncConnector";
+import { RequirePermission } from "@/components/require-permission";
import { Button } from "@/components/ui/button";
import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context";
import { cn } from "@/lib/utils";
@@ -166,29 +167,31 @@ export const KnowledgeSearchBar = () => {
>
<RefreshCw className="h-4 w-4 m-4 text-[var(--icon-primary)]" />
</Button>
- <Button
- type="button"
- variant="ghost"
- disabled={refreshOpenragDocsMutation.isPending}
- className="h-auto flex-shrink-0 rounded-none px-3 text-sm hover:bg-accent hover:text-foreground"
- 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>
+ <RequirePermission perm="config:write">
+ <Button
+ type="button"
+ variant="ghost"
+ disabled={refreshOpenragDocsMutation.isPending}
+ className="h-auto flex-shrink-0 rounded-none px-3 text-sm hover:bg-accent hover:text-foreground"
+ 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>
+ </RequirePermission>
<div className="ml-auto">
<KnowledgeDropdown />
</div>