Skip to content
Merged
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
356 changes: 356 additions & 0 deletions JIRA_ATLASSIAN_REVIEW.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import dynamic from 'next/dynamic'

const View = dynamic(() => import('@ui/CsvTransfomer'), { ssr: false })

interface Props {
cronEnabled: boolean
}

const CsvTransformerClient = ({ cronEnabled }: Props) => {
return <View cronEnabled={cronEnabled} />
const CsvTransformerClient = () => {
return <View />
}

export default CsvTransformerClient
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import React from 'react'
import CsvTransformerClient from './CsvTransformerClient'

const Page = () => {
const cronEnabled = process.env.ENABLE_CSV_RUN_CRON === 'true'

return (
<>
<CsvTransformerClient cronEnabled={cronEnabled} />
<CsvTransformerClient />
</>
)
}
Expand Down
66 changes: 57 additions & 9 deletions packages-answers/ui/src/CsvTransfomer/CsvTransformer.Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import { Container, Box, Stack, Tabs, Tab, Typography, Alert, AlertTitle } from
import ProcessCsv from './ProcessCsv'
import ProcessingHistory from './ProcessingHistory'

interface CsvTransformerProps {
cronEnabled?: boolean
}
type WorkerBannerState = 'loading' | 'enabled' | 'disabled' | 'error'

function TabPanel(props: any) {
const { children, currentValue, value, ...other } = props
Expand All @@ -38,9 +36,10 @@ function TabPanel(props: any) {
)
}

const CsvTransformer = ({ cronEnabled = false }: CsvTransformerProps) => {
const CsvTransformer = () => {
const { user, isLoading } = useUser()
const [chatflows, setChatflows] = useState([])
const [workerBanner, setWorkerBanner] = useState<WorkerBannerState>('loading')
const searchParams = useSearchParams()
const router = useRouter()
const tab = searchParams.get('tab') ?? 'process'
Expand All @@ -65,6 +64,41 @@ const CsvTransformer = ({ cronEnabled = false }: CsvTransformerProps) => {
fetchChatflows()
}, [fetchChatflows])

useEffect(() => {
if (isLoading) return
if (!user) {
setWorkerBanner('error')
return
}
let cancelled = false
const loadWorkerStatus = async () => {
const baseURL = sessionStorage.getItem('baseURL') || ''
const token = sessionStorage.getItem('access_token')
if (!baseURL || !token) {
if (!cancelled) setWorkerBanner('error')
return
}
try {
const response = await fetch(`${baseURL}/api/v1/csv-parser/worker-status`, {
headers: {
'x-request-from': 'aai',
Authorization: `Bearer ${token}`
}
})
if (!response.ok) throw new Error('worker-status failed')
const data = (await response.json()) as { workerEnabled?: boolean }
if (cancelled) return
setWorkerBanner(data.workerEnabled ? 'enabled' : 'disabled')
} catch {
if (!cancelled) setWorkerBanner('error')
}
}
loadWorkerStatus()
return () => {
cancelled = true
}
}, [isLoading, user])

// Auto-refresh when user returns from marketplace (only if no CSV chatflows currently)
useEffect(() => {
const handleVisibilityChange = () => {
Expand Down Expand Up @@ -100,16 +134,30 @@ const CsvTransformer = ({ cronEnabled = false }: CsvTransformerProps) => {
<Typography variant='h2' component='h1'>
AI CSV Transformer
</Typography>
{cronEnabled ? (
{workerBanner === 'loading' && (
<Alert severity='info' variant='outlined'>
<AlertTitle>Checking worker status</AlertTitle>
Loading background CSV processing status from the API server…
</Alert>
)}
{workerBanner === 'enabled' && (
<Alert severity='success' variant='outlined'>
<AlertTitle>Background processing is enabled</AlertTitle>
Submitted CSVs will be picked up by the cron worker on this environment.
Submitted CSVs will be picked up by the cron worker on the Flowise/API server (status from API).
</Alert>
) : (
)}
{workerBanner === 'disabled' && (
<Alert severity='warning' variant='outlined'>
<AlertTitle>Background processing is disabled</AlertTitle>
CSV runs can be created but they will not be processed until <code>ENABLE_CSV_RUN_CRON=true</code> is set on the
server (then the worker is restarted).
CSV runs can be created but will not be processed until <code>ENABLE_CSV_RUN_CRON=true</code> is set on the
Flowise/API server and that process is restarted.
</Alert>
)}
{workerBanner === 'error' && (
<Alert severity='warning' variant='outlined'>
<AlertTitle>Could not load worker status</AlertTitle>
The UI could not read CSV worker status from the API (session, network, or server error). Background processing may
still be enabled on the server.
</Alert>
)}
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
Expand Down
Loading
Loading