Compare commits
2 commits
main
...
fix/remove
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b7ca71f2c | ||
|
|
f25fd49686 |
2 changed files with 334 additions and 342 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { AlertCircle, ArrowLeft } from "lucide-react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { Button } from "@/components/ui/button";
|
import { useEffect, useState } from "react";
|
||||||
import { ArrowLeft, AlertCircle } from "lucide-react";
|
import { type CloudFile, UnifiedCloudPicker } from "@/components/cloud-picker";
|
||||||
import { UnifiedCloudPicker, CloudFile } from "@/components/cloud-picker";
|
|
||||||
import type { IngestSettings } from "@/components/cloud-picker/types";
|
import type { IngestSettings } from "@/components/cloud-picker/types";
|
||||||
import { useTask } from "@/contexts/task-context";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Toast } from "@/components/ui/toast";
|
import { Toast } from "@/components/ui/toast";
|
||||||
|
import { useTask } from "@/contexts/task-context";
|
||||||
|
|
||||||
// CloudFile interface is now imported from the unified cloud picker
|
// CloudFile interface is now imported from the unified cloud picker
|
||||||
|
|
||||||
|
|
@ -36,9 +36,8 @@ export default function UploadProviderPage() {
|
||||||
const [selectedFiles, setSelectedFiles] = useState<CloudFile[]>([]);
|
const [selectedFiles, setSelectedFiles] = useState<CloudFile[]>([]);
|
||||||
const [isIngesting, setIsIngesting] = useState<boolean>(false);
|
const [isIngesting, setIsIngesting] = useState<boolean>(false);
|
||||||
const [currentSyncTaskId, setCurrentSyncTaskId] = useState<string | null>(
|
const [currentSyncTaskId, setCurrentSyncTaskId] = useState<string | null>(
|
||||||
null
|
null,
|
||||||
);
|
);
|
||||||
const [showSuccessToast, setShowSuccessToast] = useState(false);
|
|
||||||
const [ingestSettings, setIngestSettings] = useState<IngestSettings>({
|
const [ingestSettings, setIngestSettings] = useState<IngestSettings>({
|
||||||
chunkSize: 1000,
|
chunkSize: 1000,
|
||||||
chunkOverlap: 200,
|
chunkOverlap: 200,
|
||||||
|
|
@ -64,14 +63,14 @@ export default function UploadProviderPage() {
|
||||||
|
|
||||||
if (!providerInfo || !providerInfo.available) {
|
if (!providerInfo || !providerInfo.available) {
|
||||||
setError(
|
setError(
|
||||||
`Cloud provider "${provider}" is not available or configured.`
|
`Cloud provider "${provider}" is not available or configured.`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check connector status
|
// Check connector status
|
||||||
const statusResponse = await fetch(
|
const statusResponse = await fetch(
|
||||||
`/api/connectors/${provider}/status`
|
`/api/connectors/${provider}/status`,
|
||||||
);
|
);
|
||||||
if (!statusResponse.ok) {
|
if (!statusResponse.ok) {
|
||||||
throw new Error(`Failed to check ${provider} status`);
|
throw new Error(`Failed to check ${provider} status`);
|
||||||
|
|
@ -81,18 +80,18 @@ export default function UploadProviderPage() {
|
||||||
const connections = statusData.connections || [];
|
const connections = statusData.connections || [];
|
||||||
const activeConnection = connections.find(
|
const activeConnection = connections.find(
|
||||||
(conn: { is_active: boolean; connection_id: string }) =>
|
(conn: { is_active: boolean; connection_id: string }) =>
|
||||||
conn.is_active
|
conn.is_active,
|
||||||
);
|
);
|
||||||
const isConnected = activeConnection !== undefined;
|
const isConnected = activeConnection !== undefined;
|
||||||
|
|
||||||
let hasAccessToken = false;
|
let hasAccessToken = false;
|
||||||
let accessTokenError: string | undefined = undefined;
|
let accessTokenError: string | undefined;
|
||||||
|
|
||||||
// Try to get access token for connected connectors
|
// Try to get access token for connected connectors
|
||||||
if (isConnected && activeConnection) {
|
if (isConnected && activeConnection) {
|
||||||
try {
|
try {
|
||||||
const tokenResponse = await fetch(
|
const tokenResponse = await fetch(
|
||||||
`/api/connectors/${provider}/token?connection_id=${activeConnection.connection_id}`
|
`/api/connectors/${provider}/token?connection_id=${activeConnection.connection_id}`,
|
||||||
);
|
);
|
||||||
if (tokenResponse.ok) {
|
if (tokenResponse.ok) {
|
||||||
const tokenData = await tokenResponse.json();
|
const tokenData = await tokenResponse.json();
|
||||||
|
|
@ -127,7 +126,7 @@ export default function UploadProviderPage() {
|
||||||
setError(
|
setError(
|
||||||
error instanceof Error
|
error instanceof Error
|
||||||
? error.message
|
? error.message
|
||||||
: "Failed to load connector information"
|
: "Failed to load connector information",
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
@ -143,12 +142,13 @@ export default function UploadProviderPage() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentSyncTaskId) return;
|
if (!currentSyncTaskId) return;
|
||||||
|
|
||||||
const currentTask = tasks.find(task => task.task_id === currentSyncTaskId);
|
const currentTask = tasks.find(
|
||||||
|
(task) => task.task_id === currentSyncTaskId,
|
||||||
|
);
|
||||||
|
|
||||||
if (currentTask && currentTask.status === "completed") {
|
if (currentTask && currentTask.status === "completed") {
|
||||||
// Task completed successfully, show toast and redirect
|
// Task completed successfully, show toast and redirect
|
||||||
setIsIngesting(false);
|
setIsIngesting(false);
|
||||||
setShowSuccessToast(true);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push("/knowledge");
|
router.push("/knowledge");
|
||||||
}, 2000); // 2 second delay to let user see toast
|
}, 2000); // 2 second delay to let user see toast
|
||||||
|
|
@ -178,7 +178,7 @@ export default function UploadProviderPage() {
|
||||||
settings?: IngestSettings;
|
settings?: IngestSettings;
|
||||||
} = {
|
} = {
|
||||||
connection_id: connector.connectionId,
|
connection_id: connector.connectionId,
|
||||||
selected_files: selectedFiles.map(file => file.id),
|
selected_files: selectedFiles.map((file) => file.id),
|
||||||
settings: ingestSettings,
|
settings: ingestSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -373,14 +373,6 @@ export default function UploadProviderPage() {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Success toast notification */}
|
|
||||||
<Toast
|
|
||||||
message="Ingested successfully!."
|
|
||||||
show={showSuccessToast}
|
|
||||||
onHide={() => setShowSuccessToast(false)}
|
|
||||||
duration={20000}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
||||||
newTask.status === "completed"
|
newTask.status === "completed"
|
||||||
) {
|
) {
|
||||||
// Task just completed - show success toast
|
// Task just completed - show success toast
|
||||||
toast.success("Task completed successfully!", {
|
toast.success("Task completed successfully", {
|
||||||
description: `Task ${newTask.task_id} has finished processing.`,
|
description: `Task ${newTask.task_id} has finished processing.`,
|
||||||
action: {
|
action: {
|
||||||
label: "View",
|
label: "View",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue