Click "Workflow Gallery" shows the options

Also Fixed the "Close" menu behavior: it should close the menu popover instead of the entire Manager dialog
This commit is contained in:
johnqiao 2023-12-27 11:54:46 -07:00
parent fed1acfba4
commit a05393fb75

View File

@ -113,7 +113,7 @@ let share_option = 'all';
// copied style from https://github.com/pythongosssss/ComfyUI-Custom-Scripts // copied style from https://github.com/pythongosssss/ComfyUI-Custom-Scripts
const style = ` const style = `
#comfyworkflows-button { #workflowgallery-button {
width: 310px; width: 310px;
height: 27px; height: 27px;
padding: 0px !important; padding: 0px !important;
@ -237,7 +237,7 @@ const style = `
.pysssss-workflow-popup-2 ~ .litecontextmenu { .pysssss-workflow-popup-2 ~ .litecontextmenu {
transform: scale(1.3); transform: scale(1.3);
} }
#comfyworkflows-button-menu { #workflowgallery-button-menu {
z-index: 10000000000 !important; z-index: 10000000000 !important;
} }
#cm-manual-button-menu { #cm-manual-button-menu {
@ -831,7 +831,7 @@ class ManagerMenuDialog extends ComfyDialog {
{ {
title: "Close", title: "Close",
callback: () => { callback: () => {
this.close(); LiteGraph.closeAllContextMenus();
}, },
} }
], ],
@ -849,66 +849,14 @@ class ManagerMenuDialog extends ComfyDialog {
]), ]),
$el("button", { $el("button", {
id: 'comfyworkflows-button', id: 'workflowgallery-button',
type: "button", type: "button",
textContent: "Workflow Gallery", textContent: "Workflow Gallery",
onclick: () => { window.open("https://comfyworkflows.com/", "comfyui-workflow-gallery"); } onclick: this.handleWorkflowGalleryButtonClick,
}, [ }, [
$el("div.pysssss-workflow-arrow-2", { $el("div.pysssss-workflow-arrow-2", {
id: `comfyworkflows-button-arrow`, id: `comfyworkflows-button-arrow`,
onclick: (e) => { onclick: this.handleWorkflowGalleryButtonClick
e.preventDefault();
e.stopPropagation();
LiteGraph.closeAllContextMenus();
const menu = new LiteGraph.ContextMenu(
[
{
title: "Share your art",
callback: () => {
if (share_option === 'openart') {
showOpenArtShareDialog();
return;
} else if (share_option === 'matrix' || share_option === 'comfyworkflows') {
showShareDialog(share_option);
return;
}
if(!ShareDialogChooser.instance) {
ShareDialogChooser.instance = new ShareDialogChooser();
}
ShareDialogChooser.instance.show();
},
},
{
title: "Open 'openart.ai'",
callback: () => {
window.open("https://openart.ai/workflows/dev", "comfyui-workflow-gallery");
},
},
{
title: "Open 'comfyworkflows.com'",
callback: () => {
window.open("https://comfyworkflows.com/", "comfyui-workflow-gallery");
},
},
{
title: "Close",
callback: () => {
this.close();
},
}
],
{
event: e,
scale: 1.3,
},
window
);
// set the id so that we can override the context menu's z-index to be above the comfyui manager menu
menu.root.id = "comfyworkflows-button-menu";
menu.root.classList.add("pysssss-workflow-popup-2");
},
}) })
]), ]),
@ -963,6 +911,59 @@ class ManagerMenuDialog extends ComfyDialog {
show() { show() {
this.element.style.display = "block"; this.element.style.display = "block";
} }
handleWorkflowGalleryButtonClick(e) {
e.preventDefault();
e.stopPropagation();
LiteGraph.closeAllContextMenus();
const menu = new LiteGraph.ContextMenu(
[
{
title: "Share your art",
callback: () => {
if (share_option === 'openart') {
showOpenArtShareDialog();
return;
} else if (share_option === 'matrix' || share_option === 'comfyworkflows') {
showShareDialog(share_option);
return;
}
if (!ShareDialogChooser.instance) {
ShareDialogChooser.instance = new ShareDialogChooser();
}
ShareDialogChooser.instance.show();
},
},
{
title: "Open 'openart.ai'",
callback: () => {
window.open("https://openart.ai/workflows/dev", "comfyui-workflow-gallery");
},
},
{
title: "Open 'comfyworkflows.com'",
callback: () => {
window.open("https://comfyworkflows.com/", "comfyui-workflow-gallery");
},
},
{
title: "Close",
callback: () => {
LiteGraph.closeAllContextMenus();
},
}
],
{
event: e,
scale: 1.3,
},
window
);
// set the id so that we can override the context menu's z-index to be above the comfyui manager menu
menu.root.id = "workflowgallery-button-menu";
menu.root.classList.add("pysssss-workflow-popup-2");
}
} }