Skip to content

Commit 217db17

Browse files
committed
fix: Subgraph edit toggle logic
1 parent 0f3e4ed commit 217db17

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/components/rightSidePanel/RightSidePanel.vue

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SubgraphNode } from '@/lib/litegraph/src/litegraph'
1010
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
1111
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
1212
import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore'
13+
import type { RightSidePanelTab } from '@/stores/workspace/rightSidePanelStore'
1314
import { isLGraphNode } from '@/utils/litegraphUtil'
1415
import { cn } from '@/utils/tailwindUtil'
1516
@@ -54,8 +55,13 @@ function closePanel() {
5455
rightSidePanelStore.closePanel()
5556
}
5657
57-
const tabs = computed<{ label: () => string; value: string }[]>(() => {
58-
const list = [
58+
type RightSidePanelTabList = Array<{
59+
label: () => string
60+
value: RightSidePanelTab
61+
}>
62+
63+
const tabs = computed<RightSidePanelTabList>(() => {
64+
const list: RightSidePanelTabList = [
5965
{
6066
label: () => t('rightSidePanel.parameters'),
6167
value: 'parameters'
@@ -108,7 +114,11 @@ watchEffect(() => {
108114
: 'bg-secondary-background'
109115
)
110116
"
111-
@click="isEditingSubgraph = !isEditingSubgraph"
117+
@click="
118+
rightSidePanelStore.openPanel(
119+
isEditingSubgraph ? 'parameters' : 'subgraph'
120+
)
121+
"
112122
>
113123
<i class="icon-[lucide--settings-2]" />
114124
</IconButton>
@@ -124,11 +134,15 @@ watchEffect(() => {
124134
</IconButton>
125135
</div>
126136
</div>
127-
<nav
128-
v-if="hasSelection && !(isSubgraphNode && isEditingSubgraph)"
129-
class="px-4 pb-2 pt-1"
130-
>
131-
<TabList v-model="activeTab">
137+
<nav v-if="hasSelection" class="px-4 pb-2 pt-1">
138+
<TabList
139+
v-model="activeTab"
140+
@update:model-value="
141+
(newTab) => {
142+
rightSidePanelStore.openPanel(newTab as RightSidePanelTab)
143+
}
144+
"
145+
>
132146
<Tab
133147
v-for="tab in tabs"
134148
:key="tab.value"

src/stores/workspace/rightSidePanelStore.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
import { defineStore } from 'pinia'
2-
import { ref } from 'vue'
2+
import { computed, ref } from 'vue'
33

4-
type RightSidePanelTab = 'parameters' | 'settings' | 'info' | 'subgraph'
4+
export type RightSidePanelTab = 'parameters' | 'settings' | 'info' | 'subgraph'
55

66
/**
77
* Store for managing the right side panel state.
88
* This panel displays properties and settings for selected nodes.
99
*/
1010
export const useRightSidePanelStore = defineStore('rightSidePanel', () => {
11-
// Panel visibility state
1211
const isOpen = ref(false)
13-
const isEditingSubgraph = ref(false)
14-
15-
// Active tab in the node properties panel
1612
const activeTab = ref<RightSidePanelTab>('parameters')
13+
const isEditingSubgraph = computed(() => activeTab.value === 'subgraph')
1714

18-
// Actions
1915
function openPanel(tab?: RightSidePanelTab) {
2016
isOpen.value = true
21-
if (tab === 'subgraph') {
22-
activeTab.value = 'parameters'
23-
isEditingSubgraph.value = true
24-
} else if (tab) {
17+
if (tab) {
2518
activeTab.value = tab
26-
isEditingSubgraph.value = false
2719
}
2820
}
2921

3022
function closePanel() {
3123
isOpen.value = false
32-
isEditingSubgraph.value = false
3324
}
3425

3526
function togglePanel() {

0 commit comments

Comments
 (0)