|
|
@@ -4,6 +4,7 @@ import { workflowsApi, nodesApi, Workflow } from '../api/workflows'
|
|
|
import { usersApi, projectsApi } from '../api/users'
|
|
|
import { workflowGroupsApi, WorkflowGroup } from '../api/workflowGroups'
|
|
|
import { Plus, Play, Pause, Trash2, MoreVertical, AlertTriangle, X, FolderPlus, FolderInput, Clock, User, Zap, Copy, FolderKanban} from 'lucide-react'
|
|
|
+import { useProjectStore } from '../stores/projectStore'
|
|
|
import { useState, useMemo} from 'react'
|
|
|
import { formatDistanceToNow, format } from 'date-fns'
|
|
|
import { GroupBreadcrumb } from '../components/GroupBreadcrumb'
|
|
|
@@ -96,17 +97,19 @@ export default function WorkflowsPage() {
|
|
|
})
|
|
|
const currentPath = pathData || []
|
|
|
|
|
|
+ const projectId = useProjectStore((s) => s.projectId)
|
|
|
+
|
|
|
// Fetch groups in current location
|
|
|
const { data: groupsData, isLoading: isLoadingGroups } = useQuery({
|
|
|
- queryKey: ['workflow-groups', currentGroupId || 'root'],
|
|
|
- queryFn: () => workflowGroupsApi.list(currentGroupId || 'root'),
|
|
|
+ queryKey: ['workflow-groups', currentGroupId || 'root', projectId],
|
|
|
+ queryFn: () => workflowGroupsApi.list(currentGroupId || 'root', projectId || undefined),
|
|
|
})
|
|
|
const groups: WorkflowGroup[] = groupsData?.groups || []
|
|
|
|
|
|
// Fetch workflows in current location
|
|
|
const { data: workflowsData, isLoading: isLoadingWorkflows } = useQuery({
|
|
|
- queryKey: ['workflows', currentGroupId || ''],
|
|
|
- queryFn: () => workflowsApi.list(1, 100, currentGroupId || ''),
|
|
|
+ queryKey: ['workflows', currentGroupId || '', projectId],
|
|
|
+ queryFn: () => workflowsApi.list(1, 100, currentGroupId || '', projectId || undefined),
|
|
|
})
|
|
|
const workflows: Workflow[] = workflowsData?.workflows || []
|
|
|
|
|
|
@@ -259,7 +262,6 @@ export default function WorkflowsPage() {
|
|
|
queryKey: ['projects'],
|
|
|
queryFn: () => projectsApi.list(),
|
|
|
})
|
|
|
- const [projectFilter, setProjectFilter] = useState<string>('all')
|
|
|
const [workflowToMoveProject, setWorkflowToMoveProject] = useState<Workflow | null>(null)
|
|
|
|
|
|
const moveToProjectMutation = useMutation({
|
|
|
@@ -273,9 +275,9 @@ export default function WorkflowsPage() {
|
|
|
})
|
|
|
|
|
|
const visibleWorkflows = useMemo(() => {
|
|
|
- if (projectFilter === 'all') return workflows
|
|
|
- return workflows.filter((w: any) => w.projectId === projectFilter)
|
|
|
- }, [workflows, projectFilter])
|
|
|
+ // The server has already narrowed these to the selected project.
|
|
|
+ return workflows
|
|
|
+ }, [workflows])
|
|
|
|
|
|
// Get current group name for title
|
|
|
const currentGroup = currentPath.length > 0 ? currentPath[currentPath.length - 1] : null
|
|
|
@@ -292,19 +294,6 @@ export default function WorkflowsPage() {
|
|
|
<div className="flex items-center justify-between mb-6">
|
|
|
<h1 className="text-2xl font-bold text-gray-900 dark:text-gray-100">{pageTitle}</h1>
|
|
|
<div className="flex items-center gap-2">
|
|
|
- {projects.length > 1 && (
|
|
|
- <select
|
|
|
- value={projectFilter}
|
|
|
- onChange={(e) => setProjectFilter(e.target.value)}
|
|
|
- className="px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-700 text-gray-700 dark:text-gray-300"
|
|
|
- title="Show one project's workflows"
|
|
|
- >
|
|
|
- <option value="all">All projects</option>
|
|
|
- {projects.map((p) => (
|
|
|
- <option key={p._id} value={p._id}>{p.name}</option>
|
|
|
- ))}
|
|
|
- </select>
|
|
|
- )}
|
|
|
<button
|
|
|
onClick={() => setShowNewGroupModal(true)}
|
|
|
className="flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-slate-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-700"
|