feat: open ForkModal on fork action in TreeLibraryPage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { foldersApi } from '@/api/folders'
|
|||||||
import { sessionsApi } from '@/api/sessions'
|
import { sessionsApi } from '@/api/sessions'
|
||||||
import type { TreeListItem, CategoryListItem, FolderListItem, Session } from '@/types'
|
import type { TreeListItem, CategoryListItem, FolderListItem, Session } from '@/types'
|
||||||
import { FolderEditModal } from '@/components/library/FolderEditModal'
|
import { FolderEditModal } from '@/components/library/FolderEditModal'
|
||||||
|
import { ForkModal } from '@/components/library/ForkModal'
|
||||||
import { ConfirmDialog } from '@/components/common/ConfirmDialog'
|
import { ConfirmDialog } from '@/components/common/ConfirmDialog'
|
||||||
import { TreeGridView } from '@/components/library/TreeGridView'
|
import { TreeGridView } from '@/components/library/TreeGridView'
|
||||||
import { TreeListView } from '@/components/library/TreeListView'
|
import { TreeListView } from '@/components/library/TreeListView'
|
||||||
@@ -72,8 +73,8 @@ export function TreeLibraryPage() {
|
|||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
||||||
const [isDeleting, setIsDeleting] = useState(false)
|
const [isDeleting, setIsDeleting] = useState(false)
|
||||||
|
|
||||||
// Fork state
|
// Fork modal state
|
||||||
const [isForkingTree, setIsForkingTree] = useState(false)
|
const [forkTarget, setForkTarget] = useState<TreeListItem | null>(null)
|
||||||
|
|
||||||
// AI builder state
|
// AI builder state
|
||||||
const [showAIBuilder, setShowAIBuilder] = useState(false)
|
const [showAIBuilder, setShowAIBuilder] = useState(false)
|
||||||
@@ -244,19 +245,9 @@ export function TreeLibraryPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleForkTree = async (treeId: string) => {
|
const handleForkTree = (treeId: string) => {
|
||||||
if (isForkingTree) return
|
const tree = trees.find((t) => t.id === treeId)
|
||||||
setIsForkingTree(true)
|
if (tree) setForkTarget(tree)
|
||||||
try {
|
|
||||||
await treesApi.fork(treeId)
|
|
||||||
toast.success('Flow forked successfully')
|
|
||||||
navigate('/my-trees')
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to fork flow:', err)
|
|
||||||
toast.error('Failed to fork flow')
|
|
||||||
} finally {
|
|
||||||
setIsForkingTree(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasActiveFilters =
|
const hasActiveFilters =
|
||||||
@@ -572,6 +563,14 @@ export function TreeLibraryPage() {
|
|||||||
onClose={() => setShowAIBuilder(false)}
|
onClose={() => setShowAIBuilder(false)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{forkTarget && (
|
||||||
|
<ForkModal
|
||||||
|
treeId={forkTarget.id}
|
||||||
|
treeName={forkTarget.name}
|
||||||
|
onClose={() => setForkTarget(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user