mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 17:52:16 +00:00
Remove refresh button when all nodes are selected (#3690)
This commit is contained in:
@@ -99,18 +99,6 @@ test.describe('Selection Toolbox', () => {
|
|||||||
).not.toBeVisible()
|
).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('displays refresh button in toolbox when all nodes are selected', async ({
|
|
||||||
comfyPage
|
|
||||||
}) => {
|
|
||||||
// Select all nodes
|
|
||||||
await comfyPage.page.focus('canvas')
|
|
||||||
await comfyPage.page.keyboard.press('Control+A')
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
comfyPage.page.locator('.selection-toolbox .pi-refresh')
|
|
||||||
).toBeVisible()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('displays bypass button in toolbox when nodes are selected', async ({
|
test('displays bypass button in toolbox when nodes are selected', async ({
|
||||||
comfyPage
|
comfyPage
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import type { LGraphNode } from '@comfyorg/litegraph'
|
import type { IWidget, LGraphNode } from '@comfyorg/litegraph'
|
||||||
import type { IWidget } from '@comfyorg/litegraph'
|
|
||||||
import { computed, ref, watchEffect } from 'vue'
|
import { computed, ref, watchEffect } from 'vue'
|
||||||
|
|
||||||
import { useCommandStore } from '@/stores/commandStore'
|
|
||||||
import { useCanvasStore } from '@/stores/graphStore'
|
import { useCanvasStore } from '@/stores/graphStore'
|
||||||
import { isLGraphNode } from '@/utils/litegraphUtil'
|
import { isLGraphNode } from '@/utils/litegraphUtil'
|
||||||
|
|
||||||
@@ -20,14 +18,10 @@ const isRefreshableWidget = (widget: IWidget): widget is RefreshableWidget =>
|
|||||||
*/
|
*/
|
||||||
export const useRefreshableSelection = () => {
|
export const useRefreshableSelection = () => {
|
||||||
const graphStore = useCanvasStore()
|
const graphStore = useCanvasStore()
|
||||||
const commandStore = useCommandStore()
|
|
||||||
const selectedNodes = ref<LGraphNode[]>([])
|
const selectedNodes = ref<LGraphNode[]>([])
|
||||||
const isAllNodesSelected = ref(false)
|
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
selectedNodes.value = graphStore.selectedItems.filter(isLGraphNode)
|
selectedNodes.value = graphStore.selectedItems.filter(isLGraphNode)
|
||||||
isAllNodesSelected.value =
|
|
||||||
graphStore.canvas?.graph?.nodes?.every((node) => !!node.selected) ?? false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const refreshableWidgets = computed(() =>
|
const refreshableWidgets = computed(() =>
|
||||||
@@ -36,18 +30,12 @@ export const useRefreshableSelection = () => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const isRefreshable = computed(
|
const isRefreshable = computed(() => refreshableWidgets.value.length > 0)
|
||||||
() => refreshableWidgets.value.length > 0 || isAllNodesSelected.value
|
|
||||||
)
|
|
||||||
|
|
||||||
async function refreshSelected() {
|
async function refreshSelected() {
|
||||||
if (!isRefreshable.value) return
|
if (!isRefreshable.value) return
|
||||||
|
|
||||||
if (isAllNodesSelected.value) {
|
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
|
||||||
await commandStore.execute('Comfy.RefreshNodeDefinitions')
|
|
||||||
} else {
|
|
||||||
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user