mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
Migrate node library sidebar to use unique name instead of display name (#702)
* Migrate node library sidebar to use unique name instead of display name * Break word
This commit is contained in:
@@ -61,7 +61,7 @@ test.describe('Menu', () => {
|
|||||||
|
|
||||||
test.describe('Node library sidebar', () => {
|
test.describe('Node library sidebar', () => {
|
||||||
test.beforeEach(async ({ comfyPage }) => {
|
test.beforeEach(async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [])
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {})
|
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {})
|
||||||
// Open the sidebar
|
// Open the sidebar
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
@@ -96,17 +96,14 @@ test.describe('Menu', () => {
|
|||||||
await tab.getFolder('sampling').click()
|
await tab.getFolder('sampling').click()
|
||||||
|
|
||||||
// Bookmark the node
|
// Bookmark the node
|
||||||
await tab
|
await tab.getNode('KSamplerAdvanced').locator('.bookmark-button').click()
|
||||||
.getNode('KSampler (Advanced)')
|
|
||||||
.locator('.bookmark-button')
|
|
||||||
.click()
|
|
||||||
|
|
||||||
// Verify the bookmark is added to the bookmarks tab
|
// Verify the bookmark is added to the bookmarks tab
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['KSampler (Advanced)']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['KSamplerAdvanced'])
|
||||||
// Verify the bookmark node with the same name is added to the tree.
|
// Verify the bookmark node with the same name is added to the tree.
|
||||||
expect(await tab.getNode('KSampler (Advanced)').count()).toBe(2)
|
expect(await tab.getNode('KSamplerAdvanced').count()).toBe(2)
|
||||||
|
|
||||||
// Hover on the bookmark node to display the preview
|
// Hover on the bookmark node to display the preview
|
||||||
await comfyPage.page.hover('.node-lib-bookmark-tree-explorer .tree-leaf')
|
await comfyPage.page.hover('.node-lib-bookmark-tree-explorer .tree-leaf')
|
||||||
@@ -116,7 +113,7 @@ test.describe('Menu', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Ignores unrecognized node', async ({ comfyPage }) => {
|
test('Ignores unrecognized node', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo'])
|
||||||
|
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
expect(await tab.getFolder('sampling').count()).toBe(1)
|
expect(await tab.getFolder('sampling').count()).toBe(1)
|
||||||
@@ -124,7 +121,7 @@ test.describe('Menu', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Displays empty bookmarks folder', async ({ comfyPage }) => {
|
test('Displays empty bookmarks folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
expect(await tab.getFolder('foo').count()).toBe(1)
|
expect(await tab.getFolder('foo').count()).toBe(1)
|
||||||
})
|
})
|
||||||
@@ -134,13 +131,13 @@ test.describe('Menu', () => {
|
|||||||
await tab.newFolderButton.click()
|
await tab.newFolderButton.click()
|
||||||
await comfyPage.page.keyboard.press('Enter')
|
await comfyPage.page.keyboard.press('Enter')
|
||||||
expect(await tab.getFolder('New Folder').count()).toBe(1)
|
expect(await tab.getFolder('New Folder').count()).toBe(1)
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['New Folder/']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['New Folder/'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can add nested bookmark folder', async ({ comfyPage }) => {
|
test('Can add nested bookmark folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
|
|
||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
@@ -149,25 +146,25 @@ test.describe('Menu', () => {
|
|||||||
await comfyPage.page.keyboard.press('Enter')
|
await comfyPage.page.keyboard.press('Enter')
|
||||||
|
|
||||||
expect(await tab.getFolder('bar').count()).toBe(1)
|
expect(await tab.getFolder('bar').count()).toBe(1)
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['foo/', 'foo/bar/']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['foo/', 'foo/bar/'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can delete bookmark folder', async ({ comfyPage }) => {
|
test('Can delete bookmark folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
|
|
||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
await comfyPage.page.getByLabel('Delete').click()
|
await comfyPage.page.getByLabel('Delete').click()
|
||||||
|
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
[]
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can rename bookmark folder', async ({ comfyPage }) => {
|
test('Can rename bookmark folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
|
|
||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
@@ -175,24 +172,24 @@ test.describe('Menu', () => {
|
|||||||
await comfyPage.page.keyboard.insertText('bar')
|
await comfyPage.page.keyboard.insertText('bar')
|
||||||
await comfyPage.page.keyboard.press('Enter')
|
await comfyPage.page.keyboard.press('Enter')
|
||||||
|
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['bar/']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['bar/'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can add bookmark by dragging node to bookmark folder', async ({
|
test('Can add bookmark by dragging node to bookmark folder', async ({
|
||||||
comfyPage
|
comfyPage
|
||||||
}) => {
|
}) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab.getFolder('sampling').click()
|
await tab.getFolder('sampling').click()
|
||||||
await comfyPage.page.dragAndDrop(
|
await comfyPage.page.dragAndDrop(
|
||||||
tab.nodeSelector('KSampler (Advanced)'),
|
tab.nodeSelector('KSamplerAdvanced'),
|
||||||
tab.folderSelector('foo')
|
tab.folderSelector('foo')
|
||||||
)
|
)
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['foo/', 'foo/KSampler (Advanced)']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['foo/', 'foo/KSamplerAdvanced'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can add bookmark by clicking bookmark button', async ({
|
test('Can add bookmark by clicking bookmark button', async ({
|
||||||
@@ -200,48 +197,42 @@ test.describe('Menu', () => {
|
|||||||
}) => {
|
}) => {
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab.getFolder('sampling').click()
|
await tab.getFolder('sampling').click()
|
||||||
await tab
|
await tab.getNode('KSamplerAdvanced').locator('.bookmark-button').click()
|
||||||
.getNode('KSampler (Advanced)')
|
expect(
|
||||||
.locator('.bookmark-button')
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
.click()
|
).toEqual(['KSamplerAdvanced'])
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
|
||||||
['KSampler (Advanced)']
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can unbookmark node (Top level bookmark)', async ({ comfyPage }) => {
|
test('Can unbookmark node (Top level bookmark)', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [
|
||||||
'KSampler (Advanced)'
|
'KSamplerAdvanced'
|
||||||
])
|
])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab
|
await tab.getNode('KSamplerAdvanced').locator('.bookmark-button').click()
|
||||||
.getNode('KSampler (Advanced)')
|
expect(
|
||||||
.locator('.bookmark-button')
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
.click()
|
).toEqual([])
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can unbookmark node (Library node bookmark)', async ({
|
test('Can unbookmark node (Library node bookmark)', async ({
|
||||||
comfyPage
|
comfyPage
|
||||||
}) => {
|
}) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [
|
||||||
'KSampler (Advanced)'
|
'KSamplerAdvanced'
|
||||||
])
|
])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab.getFolder('sampling').click()
|
await tab.getFolder('sampling').click()
|
||||||
await comfyPage.page
|
await comfyPage.page
|
||||||
.locator(tab.nodeSelector('KSampler (Advanced)'))
|
.locator(tab.nodeSelector('KSamplerAdvanced'))
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.locator('.bookmark-button')
|
.locator('.bookmark-button')
|
||||||
.click()
|
.click()
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
[]
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual([])
|
||||||
})
|
})
|
||||||
test('Can customize icon', async ({ comfyPage }) => {
|
test('Can customize icon', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
await comfyPage.page.getByLabel('Customize').click()
|
await comfyPage.page.getByLabel('Customize').click()
|
||||||
@@ -264,7 +255,7 @@ test.describe('Menu', () => {
|
|||||||
})
|
})
|
||||||
// If color is left as default, it should not be saved
|
// If color is left as default, it should not be saved
|
||||||
test('Can customize icon (default field)', async ({ comfyPage }) => {
|
test('Can customize icon (default field)', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
const tab = comfyPage.menu.nodeLibraryTab
|
const tab = comfyPage.menu.nodeLibraryTab
|
||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
await comfyPage.page.getByLabel('Customize').click()
|
await comfyPage.page.getByLabel('Customize').click()
|
||||||
@@ -282,7 +273,7 @@ test.describe('Menu', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
test('Can rename customized bookmark folder', async ({ comfyPage }) => {
|
test('Can rename customized bookmark folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {
|
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {
|
||||||
'foo/': {
|
'foo/': {
|
||||||
icon: 'pi-folder',
|
icon: 'pi-folder',
|
||||||
@@ -295,9 +286,9 @@ test.describe('Menu', () => {
|
|||||||
await comfyPage.page.keyboard.insertText('bar')
|
await comfyPage.page.keyboard.insertText('bar')
|
||||||
await comfyPage.page.keyboard.press('Enter')
|
await comfyPage.page.keyboard.press('Enter')
|
||||||
await comfyPage.nextFrame()
|
await comfyPage.nextFrame()
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
['bar/']
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual(['bar/'])
|
||||||
expect(
|
expect(
|
||||||
await comfyPage.getSetting('Comfy.NodeLibrary.BookmarksCustomization')
|
await comfyPage.getSetting('Comfy.NodeLibrary.BookmarksCustomization')
|
||||||
).toEqual({
|
).toEqual({
|
||||||
@@ -309,7 +300,7 @@ test.describe('Menu', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Can delete customized bookmark folder', async ({ comfyPage }) => {
|
test('Can delete customized bookmark folder', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', ['foo/'])
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', ['foo/'])
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {
|
await comfyPage.setSetting('Comfy.NodeLibrary.BookmarksCustomization', {
|
||||||
'foo/': {
|
'foo/': {
|
||||||
icon: 'pi-folder',
|
icon: 'pi-folder',
|
||||||
@@ -320,18 +311,18 @@ test.describe('Menu', () => {
|
|||||||
await tab.getFolder('foo').click({ button: 'right' })
|
await tab.getFolder('foo').click({ button: 'right' })
|
||||||
await comfyPage.page.getByLabel('Delete').click()
|
await comfyPage.page.getByLabel('Delete').click()
|
||||||
await comfyPage.nextFrame()
|
await comfyPage.nextFrame()
|
||||||
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
expect(
|
||||||
[]
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
)
|
).toEqual([])
|
||||||
expect(
|
expect(
|
||||||
await comfyPage.getSetting('Comfy.NodeLibrary.BookmarksCustomization')
|
await comfyPage.getSetting('Comfy.NodeLibrary.BookmarksCustomization')
|
||||||
).toEqual({})
|
).toEqual({})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Can filter nodes in both trees', async ({ comfyPage }) => {
|
test('Can filter nodes in both trees', async ({ comfyPage }) => {
|
||||||
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [
|
||||||
'foo/',
|
'foo/',
|
||||||
'foo/KSampler (Advanced)',
|
'foo/KSamplerAdvanced',
|
||||||
'KSampler'
|
'KSampler'
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -339,7 +330,23 @@ test.describe('Menu', () => {
|
|||||||
await tab.nodeLibrarySearchBoxInput.fill('KSampler')
|
await tab.nodeLibrarySearchBoxInput.fill('KSampler')
|
||||||
// Node search box is debounced and may take some time to update.
|
// Node search box is debounced and may take some time to update.
|
||||||
await comfyPage.page.waitForTimeout(1000)
|
await comfyPage.page.waitForTimeout(1000)
|
||||||
expect(await tab.getNode('KSampler (Advanced)').count()).toBe(2)
|
expect(await tab.getNode('KSamplerAdvanced').count()).toBe(2)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Can migrate legacy bookmarks', async ({ comfyPage }) => {
|
||||||
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks', [
|
||||||
|
'foo/',
|
||||||
|
'foo/KSampler (Advanced)'
|
||||||
|
])
|
||||||
|
await comfyPage.setSetting('Comfy.NodeLibrary.Bookmarks.V2', [])
|
||||||
|
await comfyPage.page.reload()
|
||||||
|
await comfyPage.setup()
|
||||||
|
expect(await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks')).toEqual(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
await comfyPage.getSetting('Comfy.NodeLibrary.Bookmarks.V2')
|
||||||
|
).toEqual(['foo/', 'foo/KSamplerAdvanced'])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -141,4 +141,7 @@ onUnmounted(() => {
|
|||||||
.leaf-label {
|
.leaf-label {
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
}
|
}
|
||||||
|
:deep(.editable-text span) {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
ContextMenu
|
ContextMenu
|
||||||
} from '@comfyorg/litegraph'
|
} from '@comfyorg/litegraph'
|
||||||
import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
|
import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
|
||||||
|
import { useNodeBookmarkStore } from '@/stores/nodeBookmarkStore'
|
||||||
|
|
||||||
const emit = defineEmits(['ready'])
|
const emit = defineEmits(['ready'])
|
||||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||||
@@ -145,6 +146,9 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Migrate legacy bookmarks
|
||||||
|
useNodeBookmarkStore().migrateLegacyBookmarks()
|
||||||
emit('ready')
|
emit('ready')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import {
|
|||||||
ComfyNodeDefImpl,
|
ComfyNodeDefImpl,
|
||||||
useNodeDefStore
|
useNodeDefStore
|
||||||
} from '@/stores/nodeDefStore'
|
} from '@/stores/nodeDefStore'
|
||||||
import { computed, nextTick, ref, Ref } from 'vue'
|
import { computed, nextTick, onMounted, ref, Ref } from 'vue'
|
||||||
import type { TreeNode } from 'primevue/treenode'
|
import type { TreeNode } from 'primevue/treenode'
|
||||||
import Popover from 'primevue/popover'
|
import Popover from 'primevue/popover'
|
||||||
import Divider from 'primevue/divider'
|
import Divider from 'primevue/divider'
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ const bookmarkedRoot = computed<TreeNode>(() => {
|
|||||||
const filterTree = (node: TreeNode): TreeNode | null => {
|
const filterTree = (node: TreeNode): TreeNode | null => {
|
||||||
if (node.leaf) {
|
if (node.leaf) {
|
||||||
// Check if the node's display_name is in the filteredNodeDefs list
|
// Check if the node's display_name is in the filteredNodeDefs list
|
||||||
return props.filteredNodeDefs.some(
|
return props.filteredNodeDefs.some((def) => def.name === node.data.name)
|
||||||
(def) => def.display_name === node.data.display_name
|
|
||||||
)
|
|
||||||
? node
|
? node
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
@@ -145,8 +143,7 @@ const renderedBookmarkedRoot = computed<TreeExplorerNode<ComfyNodeDefImpl>>(
|
|||||||
nodeBookmarkStore.toggleBookmark(nodeDefToAdd)
|
nodeBookmarkStore.toggleBookmark(nodeDefToAdd)
|
||||||
}
|
}
|
||||||
const folderNodeDef = node.data as ComfyNodeDefImpl
|
const folderNodeDef = node.data as ComfyNodeDefImpl
|
||||||
const nodePath =
|
const nodePath = folderNodeDef.category + '/' + nodeDefToAdd.name
|
||||||
folderNodeDef.category + '/' + nodeDefToAdd.display_name
|
|
||||||
nodeBookmarkStore.addBookmark(nodePath)
|
nodeBookmarkStore.addBookmark(nodePath)
|
||||||
},
|
},
|
||||||
...(node.leaf
|
...(node.leaf
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineProps, ref, watch, onMounted, onUnmounted } from 'vue'
|
import { ref, watch, onMounted, onUnmounted } from 'vue'
|
||||||
import Galleria from 'primevue/galleria'
|
import Galleria from 'primevue/galleria'
|
||||||
import { ResultItemImpl } from '@/stores/queueStore'
|
import { ResultItemImpl } from '@/stores/queueStore'
|
||||||
import ComfyImage from '@/components/common/ComfyImage.vue'
|
import ComfyImage from '@/components/common/ComfyImage.vue'
|
||||||
|
|||||||
@@ -8,12 +8,33 @@ import type { TreeNode } from 'primevue/treenode'
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import type { BookmarkCustomization } from '@/types/apiTypes'
|
import type { BookmarkCustomization } from '@/types/apiTypes'
|
||||||
|
|
||||||
|
export const BOOKMARK_SETTING_ID = 'Comfy.NodeLibrary.Bookmarks.V2'
|
||||||
|
|
||||||
export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
const nodeDefStore = useNodeDefStore()
|
const nodeDefStore = useNodeDefStore()
|
||||||
|
|
||||||
|
const migrateLegacyBookmarks = () => {
|
||||||
|
settingStore
|
||||||
|
.get('Comfy.NodeLibrary.Bookmarks')
|
||||||
|
.forEach((bookmark: string) => {
|
||||||
|
// If the bookmark is a folder, add it as a bookmark
|
||||||
|
if (bookmark.endsWith('/')) {
|
||||||
|
addBookmark(bookmark)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const category = bookmark.split('/').slice(0, -1).join('/')
|
||||||
|
const displayName = bookmark.split('/').pop()
|
||||||
|
const nodeDef = nodeDefStore.nodeDefsByDisplayName[displayName]
|
||||||
|
|
||||||
|
if (!nodeDef) return
|
||||||
|
addBookmark(`${category}/${nodeDef.name}`)
|
||||||
|
})
|
||||||
|
settingStore.set('Comfy.NodeLibrary.Bookmarks', [])
|
||||||
|
}
|
||||||
|
|
||||||
const bookmarks = computed<string[]>(() =>
|
const bookmarks = computed<string[]>(() =>
|
||||||
settingStore.get('Comfy.NodeLibrary.Bookmarks')
|
settingStore.get(BOOKMARK_SETTING_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
const bookmarksSet = computed<Set<string>>(() => new Set(bookmarks.value))
|
const bookmarksSet = computed<Set<string>>(() => new Set(bookmarks.value))
|
||||||
@@ -25,8 +46,7 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
// For a node in custom bookmark folders, check if its nodePath is in bookmarksSet
|
// For a node in custom bookmark folders, check if its nodePath is in bookmarksSet
|
||||||
// For a node in the nodeDefStore, check if its name is bookmarked at top level
|
// For a node in the nodeDefStore, check if its name is bookmarked at top level
|
||||||
const isBookmarked = (node: ComfyNodeDefImpl) =>
|
const isBookmarked = (node: ComfyNodeDefImpl) =>
|
||||||
bookmarksSet.value.has(node.nodePath) ||
|
bookmarksSet.value.has(node.nodePath) || bookmarksSet.value.has(node.name)
|
||||||
bookmarksSet.value.has(node.display_name)
|
|
||||||
|
|
||||||
const toggleBookmark = (node: ComfyNodeDefImpl) => {
|
const toggleBookmark = (node: ComfyNodeDefImpl) => {
|
||||||
if (isBookmarked(node)) {
|
if (isBookmarked(node)) {
|
||||||
@@ -34,9 +54,9 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
// Delete the bookmark at the top level if it exists
|
// Delete the bookmark at the top level if it exists
|
||||||
// This is used for clicking the bookmark button in the node library, i.e.
|
// This is used for clicking the bookmark button in the node library, i.e.
|
||||||
// the node is inside original/standard node library tree node
|
// the node is inside original/standard node library tree node
|
||||||
deleteBookmark(node.display_name)
|
deleteBookmark(node.name)
|
||||||
} else {
|
} else {
|
||||||
addBookmark(node.display_name)
|
addBookmark(node.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,9 +66,9 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
if (bookmark.endsWith('/')) return createDummyFolderNodeDef(bookmark)
|
if (bookmark.endsWith('/')) return createDummyFolderNodeDef(bookmark)
|
||||||
|
|
||||||
const parts = bookmark.split('/')
|
const parts = bookmark.split('/')
|
||||||
const displayName = parts.pop()
|
const name = parts.pop()
|
||||||
const category = parts.join('/')
|
const category = parts.join('/')
|
||||||
const srcNodeDef = nodeDefStore.nodeDefsByDisplayName[displayName]
|
const srcNodeDef = nodeDefStore.nodeDefsByName[name]
|
||||||
if (!srcNodeDef) {
|
if (!srcNodeDef) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -61,15 +81,12 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addBookmark = (nodePath: string) => {
|
const addBookmark = (nodePath: string) => {
|
||||||
settingStore.set('Comfy.NodeLibrary.Bookmarks', [
|
settingStore.set(BOOKMARK_SETTING_ID, [...bookmarks.value, nodePath])
|
||||||
...bookmarks.value,
|
|
||||||
nodePath
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteBookmark = (nodePath: string) => {
|
const deleteBookmark = (nodePath: string) => {
|
||||||
settingStore.set(
|
settingStore.set(
|
||||||
'Comfy.NodeLibrary.Bookmarks',
|
BOOKMARK_SETTING_ID,
|
||||||
bookmarks.value.filter((b: string) => b !== nodePath)
|
bookmarks.value.filter((b: string) => b !== nodePath)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -107,7 +124,7 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
settingStore.set(
|
settingStore.set(
|
||||||
'Comfy.NodeLibrary.Bookmarks',
|
BOOKMARK_SETTING_ID,
|
||||||
bookmarks.value.map((b: string) =>
|
bookmarks.value.map((b: string) =>
|
||||||
b.startsWith(folderNode.nodePath)
|
b.startsWith(folderNode.nodePath)
|
||||||
? b.replace(folderNode.nodePath, newNodePath)
|
? b.replace(folderNode.nodePath, newNodePath)
|
||||||
@@ -122,7 +139,7 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
throw new Error('Cannot delete non-folder node')
|
throw new Error('Cannot delete non-folder node')
|
||||||
}
|
}
|
||||||
settingStore.set(
|
settingStore.set(
|
||||||
'Comfy.NodeLibrary.Bookmarks',
|
BOOKMARK_SETTING_ID,
|
||||||
bookmarks.value.filter(
|
bookmarks.value.filter(
|
||||||
(b: string) =>
|
(b: string) =>
|
||||||
b !== folderNode.nodePath && !b.startsWith(folderNode.nodePath)
|
b !== folderNode.nodePath && !b.startsWith(folderNode.nodePath)
|
||||||
@@ -201,6 +218,8 @@ export const useNodeBookmarkStore = defineStore('nodeBookmark', () => {
|
|||||||
deleteBookmarkCustomization,
|
deleteBookmarkCustomization,
|
||||||
renameBookmarkCustomization,
|
renameBookmarkCustomization,
|
||||||
defaultBookmarkIcon,
|
defaultBookmarkIcon,
|
||||||
defaultBookmarkColor
|
defaultBookmarkColor,
|
||||||
|
|
||||||
|
migrateLegacyBookmarks
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export class ComfyNodeDefImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get nodePath(): string {
|
get nodePath(): string {
|
||||||
return (this.category ? this.category + '/' : '') + this.display_name
|
return (this.category ? this.category + '/' : '') + this.name
|
||||||
}
|
}
|
||||||
|
|
||||||
get isDummyFolder(): boolean {
|
get isDummyFolder(): boolean {
|
||||||
|
|||||||
@@ -208,7 +208,14 @@ export const useSettingStore = defineStore('setting', {
|
|||||||
// Bookmarks are in format of category/display_name. e.g. "conditioning/CLIPTextEncode"
|
// Bookmarks are in format of category/display_name. e.g. "conditioning/CLIPTextEncode"
|
||||||
app.ui.settings.addSetting({
|
app.ui.settings.addSetting({
|
||||||
id: 'Comfy.NodeLibrary.Bookmarks',
|
id: 'Comfy.NodeLibrary.Bookmarks',
|
||||||
name: 'Node library bookmarks',
|
name: 'Node library bookmarks with display name (deprecated)',
|
||||||
|
type: 'hidden',
|
||||||
|
defaultValue: []
|
||||||
|
})
|
||||||
|
|
||||||
|
app.ui.settings.addSetting({
|
||||||
|
id: 'Comfy.NodeLibrary.Bookmarks.V2',
|
||||||
|
name: 'Node library bookmarks v2 with unique name',
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
defaultValue: []
|
defaultValue: []
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -439,6 +439,7 @@ const zSettings = z.record(z.any()).and(
|
|||||||
'Comfy.InvertMenuScrolling': z.boolean(),
|
'Comfy.InvertMenuScrolling': z.boolean(),
|
||||||
'Comfy.Logging.Enabled': z.boolean(),
|
'Comfy.Logging.Enabled': z.boolean(),
|
||||||
'Comfy.NodeLibrary.Bookmarks': z.array(z.string()),
|
'Comfy.NodeLibrary.Bookmarks': z.array(z.string()),
|
||||||
|
'Comfy.NodeLibrary.Bookmarks.V2': z.array(z.string()),
|
||||||
'Comfy.NodeLibrary.BookmarksCustomization': z.record(
|
'Comfy.NodeLibrary.BookmarksCustomization': z.record(
|
||||||
z.string(),
|
z.string(),
|
||||||
zBookmarkCustomization
|
zBookmarkCustomization
|
||||||
|
|||||||
Reference in New Issue
Block a user