feat: Add custom step continuation flow with save/use/branch options
Custom steps during tree navigation now support a complete workflow: - PostStepActionModal: Save for Later / Use Now / Both options - ContinuationModal: Pick descendant nodes or build custom branch - ForkTreeModal: Save modified tree as personal copy at completion - Custom steps are recorded in decisions array for export - Fix popular-tags API endpoint URL mismatch - Add aria-labels for accessibility on select/button elements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { stepsApi } from '@/api'
|
||||
import { StepForm } from './StepForm'
|
||||
import { StepLibraryBrowser } from './StepLibraryBrowser'
|
||||
import type { Step, StepCreate } from '@/types/step'
|
||||
@@ -25,7 +24,7 @@ export interface CustomStepDraft {
|
||||
interface CustomStepModalProps {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
onInsertStep: (step: Step | CustomStepDraft) => void
|
||||
onInsertStep: (step: Step | CustomStepDraft, isFromLibrary: boolean) => void
|
||||
}
|
||||
|
||||
type Tab = 'create' | 'browse'
|
||||
@@ -37,26 +36,22 @@ export function CustomStepModal({ isOpen, onClose, onInsertStep }: CustomStepMod
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
const handleFormSubmit = async (data: StepCreate, saveToLibrary: boolean) => {
|
||||
const handleFormSubmit = async (data: StepCreate, _saveToLibrary: boolean) => {
|
||||
// Note: saveToLibrary preference is no longer used here - the PostStepActionModal
|
||||
// handles the decision of whether to save to library, use now, or both
|
||||
setIsSubmitting(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
if (saveToLibrary) {
|
||||
// Save to library first, then return the saved step
|
||||
const savedStep = await stepsApi.create(data)
|
||||
onInsertStep(savedStep)
|
||||
} else {
|
||||
// Return as draft (not saved to library)
|
||||
const draft: CustomStepDraft = {
|
||||
title: data.title,
|
||||
step_type: data.step_type,
|
||||
content: data.content,
|
||||
category_id: data.category_id,
|
||||
tags: data.tags
|
||||
}
|
||||
onInsertStep(draft)
|
||||
// Always create a draft - saving to library is handled by PostStepActionModal
|
||||
const draft: CustomStepDraft = {
|
||||
title: data.title,
|
||||
step_type: data.step_type,
|
||||
content: data.content,
|
||||
category_id: data.category_id,
|
||||
tags: data.tags
|
||||
}
|
||||
onInsertStep(draft, false) // false = not from library (user typed it)
|
||||
} catch (err) {
|
||||
console.error('Failed to create step:', err)
|
||||
setError('Failed to create step. Please try again.')
|
||||
@@ -65,7 +60,7 @@ export function CustomStepModal({ isOpen, onClose, onInsertStep }: CustomStepMod
|
||||
}
|
||||
|
||||
const handleBrowserInsert = (step: Step) => {
|
||||
onInsertStep(step)
|
||||
onInsertStep(step, true) // true = from library (already saved)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user