11<template >
22 <div
3+ ref =" menuButtonRef"
34 v-tooltip =" {
45 value: t('sideToolbar.labels.menu'),
56 showDelay: 300,
2930 >
3031 <template #item =" { item , props } " >
3132 <a
33+ v-if =" item.key !== 'nodes-2.0-toggle'"
3234 class =" p-menubar-item-link px-4 py-2"
3335 v-bind =" props.action"
3436 :href =" item.url"
6567 </span >
6668 <i v-if =" item.items" class =" pi pi-angle-right ml-auto" />
6769 </a >
70+ <div
71+ v-else
72+ class =" flex items-center justify-between px-4 py-2"
73+ @click.stop =" handleNodes2ToggleClick"
74+ >
75+ <span class =" p-menubar-item-label text-nowrap" >{{ item.label }}</span >
76+ <ToggleSwitch
77+ v-model =" nodes2Enabled"
78+ class =" ml-4"
79+ :aria-label =" item.label"
80+ :pt =" {
81+ root: {
82+ style: {
83+ width: '38px',
84+ height: '20px'
85+ }
86+ },
87+ handle: {
88+ style: {
89+ width: '16px',
90+ height: '16px'
91+ }
92+ }
93+ }"
94+ @click.stop
95+ @update:model-value =" onNodes2ToggleChange"
96+ />
97+ </div >
6898 </template >
6999 </TieredMenu >
70100</template >
73103import type { MenuItem } from ' primevue/menuitem'
74104import TieredMenu from ' primevue/tieredmenu'
75105import type { TieredMenuMethods , TieredMenuState } from ' primevue/tieredmenu'
76- import { computed , nextTick , ref } from ' vue'
106+ import ToggleSwitch from ' primevue/toggleswitch'
107+ import { computed , nextTick , onMounted , ref } from ' vue'
77108import { useI18n } from ' vue-i18n'
78109
79110import SettingDialogHeader from ' @/components/dialog/header/SettingDialogHeader.vue'
80111import ComfyLogo from ' @/components/icons/ComfyLogo.vue'
112+ import { useComfyMenu } from ' @/composables/useComfyMenu'
81113import { useWorkflowTemplateSelectorDialog } from ' @/composables/useWorkflowTemplateSelectorDialog'
82114import SettingDialogContent from ' @/platform/settings/components/SettingDialogContent.vue'
115+ import { useSettingStore } from ' @/platform/settings/settingStore'
83116import { useTelemetry } from ' @/platform/telemetry'
84117import { useColorPaletteService } from ' @/services/colorPaletteService'
85118import { useCommandStore } from ' @/stores/commandStore'
@@ -98,10 +131,20 @@ const colorPaletteStore = useColorPaletteStore()
98131const colorPaletteService = useColorPaletteService ()
99132const dialogStore = useDialogStore ()
100133const managerState = useManagerState ()
134+ const settingStore = useSettingStore ()
135+ const { registerMenuButton } = useComfyMenu ()
101136
102137const menuRef = ref <
103138 ({ dirty: boolean } & TieredMenuMethods & TieredMenuState ) | null
104139> (null )
140+ const menuButtonRef = ref <HTMLElement | null >(null )
141+
142+ const nodes2Enabled = computed ({
143+ get : () => settingStore .get (' Comfy.VueNodes.Enabled' ) ?? false ,
144+ set : async (value : boolean ) => {
145+ await settingStore .set (' Comfy.VueNodes.Enabled' , value )
146+ }
147+ })
105148
106149const telemetry = useTelemetry ()
107150
@@ -112,6 +155,10 @@ function onLogoMenuClick(event: MouseEvent) {
112155 menuRef .value ?.toggle (event )
113156}
114157
158+ onMounted (() => {
159+ registerMenuButton (menuButtonRef .value )
160+ })
161+
115162const translateMenuItem = (item : MenuItem ): MenuItem => {
116163 const label = typeof item .label === ' function' ? item .label () : item .label
117164 const translatedLabel = label
@@ -164,6 +211,10 @@ const extraMenuItems = computed(() => [
164211 label: t (' menu.theme' ),
165212 items: themeMenuItems .value
166213 },
214+ {
215+ key: ' nodes-2.0-toggle' ,
216+ label: ' Nodes 2.0'
217+ },
167218 { separator: true },
168219 {
169220 key: ' browse-templates' ,
@@ -281,6 +332,17 @@ const hasActiveStateSiblings = (item: MenuItem): boolean => {
281332 menuItemStore .menuItemHasActiveStateChildren [item .parentPath ])
282333 )
283334}
335+
336+ const handleNodes2ToggleClick = () => {
337+ return false
338+ }
339+
340+ const onNodes2ToggleChange = async (value : boolean ) => {
341+ await settingStore .set (' Comfy.VueNodes.Enabled' , value )
342+ telemetry ?.trackUiButtonClicked ({
343+ button_id: ` menu_nodes_2.0_toggle_${value ? ' enabled' : ' disabled' } `
344+ })
345+ }
284346 </script >
285347
286348<style scoped>
0 commit comments