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