MCPcopy Index your code
hub / github.com/pythongosssss/ComfyUI-Custom-Scripts / getMenuOptions

Method getMenuOptions

web/js/workflows.js:90–120  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

88 }
89
90 getMenuOptions(callback) {
91 const menu = [];
92 const directories = new Map();
93 for (const workflow of this.workflows || []) {
94 const path = workflow.split("/");
95 let parent = menu;
96 let currentPath = "";
97 for (let i = 0; i < path.length - 1; i++) {
98 currentPath += "/" + path[i];
99 let newParent = directories.get(currentPath);
100 if (!newParent) {
101 newParent = {
102 title: path[i],
103 has_submenu: true,
104 submenu: {
105 options: [],
106 },
107 };
108 parent.push(newParent);
109 newParent = newParent.submenu.options;
110 directories.set(currentPath, newParent);
111 }
112 parent = newParent;
113 }
114 parent.push({
115 title: path[path.length - 1],
116 callback: () => callback(workflow),
117 });
118 }
119 return menu;
120 }
121
122 constructor() {
123 function addWorkflowMenu(type, getOptions) {

Callers 2

constructorMethod · 0.95
beforeRegisterNodeDefFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected