From b3cff9512e7dc56b468d69c6c59f6b4c76e5deb5 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:11:32 +0800 Subject: [PATCH] update --- .../src/components/LayoutRenderer.vue | 76 ++++++++++++------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/packages/frontend/src/components/LayoutRenderer.vue b/packages/frontend/src/components/LayoutRenderer.vue index af9403f..f2d8f17 100644 --- a/packages/frontend/src/components/LayoutRenderer.vue +++ b/packages/frontend/src/components/LayoutRenderer.vue @@ -230,8 +230,52 @@ const componentProps = computed(() => { } }); -// --- REMOVED sidebarComponentProps computed property --- -// Props for sidebar components will be determined directly in the template +// --- New computed property for sidebar component props and events --- +const sidebarProps = computed(() => (paneName: PaneName | null) => { + if (!paneName) return {}; + + const baseProps = { class: 'sidebar-pane-content' }; // Base props for all sidebar components + + switch (paneName) { + case 'editor': + return { + ...baseProps, + tabs: editorTabsFromStore.value, // Access .value for refs from storeToRefs + activeTabId: activeEditorTabIdFromStore.value, // Access .value + sessionId: props.activeSessionId, + // Event forwarding + onCloseTab: (tabId: string) => emit('closeEditorTab', tabId), + onActivateTab: (tabId: string) => emit('activateEditorTab', tabId), + 'onUpdate:content': (payload: { tabId: string; content: string }) => emit('updateEditorContent', payload), + onRequestSave: (tabId: string) => emit('saveEditorTab', tabId), + }; + case 'connections': + return { + ...baseProps, + // Event forwarding + onConnectRequest: (id: number) => { + console.log(`[LayoutRenderer Sidebar] Forwarding 'connect-request' for ID: ${id}`); + emit('connect-request', id); + }, + onOpenNewSession: (id: number) => { + console.log(`[LayoutRenderer Sidebar] Forwarding 'open-new-session' for ID: ${id}`); + emit('open-new-session', id); + }, + onRequestEditConnection: (conn: any) => { + console.log(`[LayoutRenderer Sidebar] Forwarding 'request-edit-connection'`); + emit('request-edit-connection', conn); + }, + // We might not need 'request-add-connection' from the sidebar context + // onRequestAddConnection: () => emit('request-add-connection') + }; + // Add cases for other components if they need specific props or event forwarding in the sidebar + // case 'fileManager': return { ...baseProps, ... }; + // case 'commandHistory': return { ...baseProps, onExecuteCommand: (cmd: string) => emit('sendCommand', cmd) }; + // case 'quickCommands': return { ...baseProps, onExecuteCommand: (cmd: string) => emit('sendCommand', cmd) }; + default: + return baseProps; // Return only base props for other components + } +}); // --- Methods --- @@ -476,18 +520,8 @@ const getIconClasses = (paneName: PaneName): string[] => { v-if="currentLeftSidebarComponent" :is="currentLeftSidebarComponent" :key="`left-panel-${activeLeftSidebarPane}`" - class="sidebar-pane-content" - v-bind="activeLeftSidebarPane === 'editor' ? { - tabs: editorTabsFromStore, - activeTabId: activeEditorTabIdFromStore, - sessionId: activeSessionId, // Pass session ID if needed by editor in sidebar - onCloseTab: (tabId: string) => emit('closeEditorTab', tabId), - onActivateTab: (tabId: string) => emit('activateEditorTab', tabId), - 'onUpdate:content': (payload: { tabId: string; content: string }) => emit('updateEditorContent', payload), - onRequestSave: (tabId: string) => emit('saveEditorTab', tabId) - } : {}" - /> - + v-bind="sidebarProps(activeLeftSidebarPane)" + /> @@ -497,18 +531,8 @@ const getIconClasses = (paneName: PaneName): string[] => { v-if="currentRightSidebarComponent" :is="currentRightSidebarComponent" :key="`right-panel-${activeRightSidebarPane}`" - class="sidebar-pane-content" - v-bind="activeRightSidebarPane === 'editor' ? { - tabs: editorTabsFromStore, - activeTabId: activeEditorTabIdFromStore, - sessionId: activeSessionId, // Pass session ID if needed by editor in sidebar - onCloseTab: (tabId: string) => emit('closeEditorTab', tabId), - onActivateTab: (tabId: string) => emit('activateEditorTab', tabId), - 'onUpdate:content': (payload: { tabId: string; content: string }) => emit('updateEditorContent', payload), - onRequestSave: (tabId: string) => emit('saveEditorTab', tabId) - } : {}" - /> - + v-bind="sidebarProps(activeRightSidebarPane)" + />