From 16c0132b027b7c6ab293485cdbd89f7a46ee52b7 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Fri, 13 Mar 2026 12:38:05 -0400 Subject: [PATCH] feat: rewrite ScriptLibraryPage with Browse/Configure pane modes - Add paneMode state ('browse' | 'configure') local to page - Move ScriptFilterBar inside left pane column (hidden in configure mode) - inputValue owned at page level to survive mode transitions - Left pane: ScriptFilterBar + ScriptTemplateList in browse; ScriptConfigurePane in configure - Right pane: ScriptPreview only (read-only); empty state when no template selected - canGenerate derived from usePermissions().isEngineer (matching ScriptGeneratorPanel pattern) Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/ScriptLibraryPage.tsx | 64 +++++++++++++++++++----- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/ScriptLibraryPage.tsx b/frontend/src/pages/ScriptLibraryPage.tsx index e51445ba..48f6cc42 100644 --- a/frontend/src/pages/ScriptLibraryPage.tsx +++ b/frontend/src/pages/ScriptLibraryPage.tsx @@ -1,19 +1,28 @@ import { useState, useEffect } from 'react' +import { Terminal } from 'lucide-react' import { useScriptGeneratorStore } from '@/store/scriptGeneratorStore' +import { usePermissions } from '@/hooks/usePermissions' import { ScriptFilterBar } from '@/components/scripts/ScriptFilterBar' import { ScriptTemplateList } from '@/components/scripts/ScriptTemplateList' -import { ScriptGeneratorPanel } from '@/components/scripts/ScriptGeneratorPanel' +import { ScriptConfigurePane } from '@/components/scripts/ScriptConfigurePane' +import { ScriptPreview } from '@/components/scripts/ScriptPreview' export default function ScriptLibraryPage() { - // inputValue is owned here so ScriptFilterBar and ScriptTemplateList - // can coordinate clear-search without direct coupling. + const [paneMode, setPaneMode] = useState<'browse' | 'configure'>('browse') + // inputValue owned here so it survives Configure ↔ Browse transitions const [inputValue, setInputValue] = useState('') + const loadCategories = useScriptGeneratorStore(s => s.loadCategories) const loadTemplates = useScriptGeneratorStore(s => s.loadTemplates) const setSearch = useScriptGeneratorStore(s => s.setSearch) + const selectTemplate = useScriptGeneratorStore(s => s.selectTemplate) + const clearOutput = useScriptGeneratorStore(s => s.clearOutput) + const selectedTemplate = useScriptGeneratorStore(s => s.selectedTemplate) + + const { isEngineer } = usePermissions() + const canGenerate = isEngineer useEffect(() => { - // loadCategories must complete before loadTemplates can resolve slugs loadCategories().then(() => loadTemplates()) }, [loadCategories, loadTemplates]) @@ -22,6 +31,16 @@ export default function ScriptLibraryPage() { setSearch('') } + const onConfigure = (id: string) => { + selectTemplate(id) + setPaneMode('configure') + } + + const onBack = () => { + clearOutput() + setPaneMode('browse') + } + return (
{/* Page header */} @@ -32,18 +51,37 @@ export default function ScriptLibraryPage() {

- {/* Filter bar */} - - {/* Two-column layout */}
- {/* Template list — scrollable */} -
- -
+ {/* Left pane — Browse or Configure mode */} + {paneMode === 'browse' ? ( +
+
+ +
+
+ +
+
+ ) : ( + + )} - {/* Generator panel */} - + {/* Right pane — read-only ScriptPreview */} + {selectedTemplate === null ? ( +
+ +

Select a template to get started

+
+ ) : ( +
+ +
+ )}
)