feat: add ViewToggle component, uncomment in both pages
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
50
frontend/src/components/assistant/ViewToggle.tsx
Normal file
50
frontend/src/components/assistant/ViewToggle.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useFeatureFlag } from '@/hooks/useFeatureFlag'
|
||||
|
||||
interface ViewToggleProps {
|
||||
currentView: 'flowpilot' | 'cockpit'
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
export function ViewToggle({ currentView, sessionId }: ViewToggleProps) {
|
||||
const navigate = useNavigate()
|
||||
const hasCockpit = useFeatureFlag('flowpilot_cockpit')
|
||||
|
||||
if (!hasCockpit) return null
|
||||
|
||||
const handleSwitch = (view: 'flowpilot' | 'cockpit') => {
|
||||
if (view === currentView) return
|
||||
const path = view === 'cockpit'
|
||||
? `/cockpit/${sessionId}`
|
||||
: `/assistant/${sessionId}`
|
||||
navigate(path)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center rounded-lg border border-border bg-card p-0.5 text-xs">
|
||||
<button
|
||||
onClick={() => handleSwitch('flowpilot')}
|
||||
className={cn(
|
||||
'rounded-md px-2.5 py-1 font-medium transition-colors',
|
||||
currentView === 'flowpilot'
|
||||
? 'bg-elevated text-foreground'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
)}
|
||||
>
|
||||
FlowPilot
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleSwitch('cockpit')}
|
||||
className={cn(
|
||||
'rounded-md px-2.5 py-1 font-medium transition-colors',
|
||||
currentView === 'cockpit'
|
||||
? 'bg-elevated text-foreground'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
)}
|
||||
>
|
||||
Cockpit
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user