Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/app/settings/_components/s3-settings-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export default function S3SettingsDialog({
toast.success("Amazon S3 configured", {
description:
selectedBuckets.length > 0
? `Will ingest from: ${selectedBuckets.join(", ")}`
: "Will auto-discover and ingest all accessible buckets.",
? `Filtered to: ${selectedBuckets.join(", ")}`
: "All accessible buckets are included.",
icon: <AwsLogo className="w-4 h-4" />,
});

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/settings/_components/s3-settings-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ export function S3SettingsForm({
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label className="text-sm font-medium">
Select Buckets to Ingest
Restrict to Specific Buckets
<span className="ml-1 text-muted-foreground font-normal">
(leave all unchecked to ingest everything)
(leave all unchecked to include all)
</span>
</Label>
{buckets.length > 1 && (
Expand Down
7 changes: 7 additions & 0 deletions frontend/components/connectors/aws-s3/bucket-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import type { useSyncConnector } from "@/app/api/mutations/useSyncConnector";
import { useS3BucketStatusQuery } from "@/app/api/queries/useS3BucketStatusQuery";
import { useS3DefaultsQuery } from "@/app/api/queries/useS3DefaultsQuery";
import { SharedBucketView } from "../shared-bucket-view";

export interface S3BucketViewProps {
Expand All @@ -25,6 +26,7 @@ export function S3BucketView({
error: bucketsError,
refetch,
} = useS3BucketStatusQuery(connector.connectionId, { enabled: true });
const { data: defaults } = useS3DefaultsQuery({ enabled: true });
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return (
<SharedBucketView
connector={connector}
Expand All @@ -37,6 +39,11 @@ export function S3BucketView({
addTask={addTask}
onBack={onBack}
onDone={onDone}
initialSelectedBuckets={
defaults?.connection_id === connector.connectionId
? defaults?.bucket_names
: undefined
}
/>
);
}
23 changes: 22 additions & 1 deletion frontend/components/connectors/shared-bucket-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useQueryClient } from "@tanstack/react-query";
import { ArrowLeft, FileSearch, FolderOpen, RefreshCw } from "lucide-react";
import { useState } from "react";
import { useEffect, useRef, useState } from "react";
import { toast } from "sonner";
import type { useSyncConnector } from "@/app/api/mutations/useSyncConnector";
import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery";
Expand All @@ -28,6 +28,7 @@ export interface SharedBucketViewProps {
) => void;
onBack: () => void;
onDone: () => void;
initialSelectedBuckets?: string[];
}

export function SharedBucketView({
Expand All @@ -41,6 +42,7 @@ export function SharedBucketView({
addTask,
onBack,
onDone,
initialSelectedBuckets,
}: SharedBucketViewProps) {
const queryClient = useQueryClient();
const { isAuthenticated, isNoAuthMode } = useAuth();
Expand All @@ -53,12 +55,31 @@ export function SharedBucketView({
const [selectedBuckets, setSelectedBuckets] = useState<Set<string>>(
new Set(),
);
const hasAppliedInitial = useRef(false);
const [ingestSettings, setIngestSettings] = useSessionIngestSettings();
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
const [browseDialogBucket, setBrowseDialogBucket] = useState<string | null>(
null,
);

useEffect(() => {
if (
!hasAppliedInitial.current &&
buckets?.length &&
initialSelectedBuckets?.length
) {
hasAppliedInitial.current = true;
if (selectedBuckets.size === 0) {
const valid = initialSelectedBuckets.filter((name) =>
buckets.some((b) => b.name === name),
);
if (valid.length) {
setSelectedBuckets(new Set(valid));
}
}
}
}, [buckets, initialSelectedBuckets]); // eslint-disable-line react-hooks/exhaustive-deps

const invalidate = () => {
queryClient.invalidateQueries({ queryKey: invalidateQueryKey });
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { useSyncConnector } from "@/app/api/mutations/useSyncConnector";
import { SharedBucketView } from "@/components/connectors/shared-bucket-view";
import { useIBMCOSBucketStatusQuery } from "../useIBMCOSBucketStatusQuery";
import { useIBMCOSDefaultsQuery } from "../useIBMCOSDefaultsQuery";

export interface IBMCOSBucketViewProps {
connector: any;
Expand All @@ -25,6 +26,7 @@ export function IBMCOSBucketView({
error: bucketsError,
refetch,
} = useIBMCOSBucketStatusQuery(connector.connectionId, { enabled: true });
const { data: defaults } = useIBMCOSDefaultsQuery({ enabled: true });
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return (
<SharedBucketView
connector={connector}
Expand All @@ -37,6 +39,11 @@ export function IBMCOSBucketView({
addTask={addTask}
onBack={onBack}
onDone={onDone}
initialSelectedBuckets={
defaults?.connection_id === connector.connectionId
? defaults?.bucket_names
: undefined
}
/>
);
}
4 changes: 2 additions & 2 deletions frontend/enhancements/connectors/ibm-cos/settings-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default function IBMCOSSettingsDialog({
toast.success("IBM Cloud Object Storage configured", {
description:
selectedBuckets.length > 0
? `Will ingest from: ${selectedBuckets.join(", ")}`
: "Will auto-discover and ingest all accessible buckets.",
? `Filtered to: ${selectedBuckets.join(", ")}`
: "All accessible buckets are included.",
icon: <IBMCOSIcon className="w-4 h-4" />,
});

Expand Down
4 changes: 2 additions & 2 deletions frontend/enhancements/connectors/ibm-cos/settings-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ export function IBMCOSSettingsForm({
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label className="text-sm font-medium">
Select Buckets to Ingest
Restrict to Specific Buckets
<span className="ml-1 text-muted-foreground font-normal">
(leave all unchecked to ingest everything)
(leave all unchecked to include all)
</span>
</Label>
{buckets.length > 1 && (
Expand Down
Loading