hide extensions/custom categories when no custom nodes

This commit is contained in:
pythongosssss
2026-03-12 13:51:35 -07:00
parent 0772f2a7fe
commit 12fd0981a8
5 changed files with 38 additions and 10 deletions

View File

@@ -79,11 +79,16 @@ describe('NodeSearchCategorySidebar', () => {
expect(wrapper.text()).toContain('Favorites')
})
it('should show Custom source category', async () => {
const wrapper = await createWrapper()
it('should show Custom source category when custom nodes exist', async () => {
const wrapper = await createWrapper({ hasCustomNodes: true })
expect(wrapper.text()).toContain('Custom')
})
it('should not show Custom source category when no custom nodes exist', async () => {
const wrapper = await createWrapper()
expect(wrapper.text()).not.toContain('Custom')
})
it('should mark the selected preset category as selected', async () => {
const wrapper = await createWrapper({
selectedCategory: DEFAULT_CATEGORY

View File

@@ -97,6 +97,7 @@ const {
hideChevrons = false,
hidePresets = false,
hasEssentialNodes = false,
hasCustomNodes = false,
nodeDefs,
rootLabel,
rootKey
@@ -104,6 +105,7 @@ const {
hideChevrons?: boolean
hidePresets?: boolean
hasEssentialNodes?: boolean
hasCustomNodes?: boolean
nodeDefs?: ComfyNodeDefImpl[]
rootLabel?: string
rootKey?: string
@@ -134,7 +136,9 @@ const sourceCategories = computed(() => {
if (hasEssentialNodes) {
categories.push({ id: 'essentials', label: t('g.essentials') })
}
categories.push({ id: 'custom', label: t('g.custom') })
if (hasCustomNodes) {
categories.push({ id: 'custom', label: t('g.custom') })
}
return categories
})

View File

@@ -23,6 +23,7 @@
:has-essential-nodes="nodeAvailability.essential"
:has-blueprint-nodes="nodeAvailability.blueprint"
:has-partner-nodes="nodeAvailability.partner"
:has-custom-nodes="nodeAvailability.custom"
@toggle-filter="onToggleFilter"
@clear-filter-group="onClearFilterGroup"
@focus-search="nextTick(() => searchInputRef?.focus())"
@@ -39,6 +40,7 @@
:hide-chevrons="!anyTreeCategoryHasChildren"
:hide-presets="rootFilter !== null"
:has-essential-nodes="nodeAvailability.essential"
:has-custom-nodes="nodeAvailability.custom"
:node-defs="rootFilteredNodeDefs"
:root-label="rootFilterLabel"
:root-key="rootFilter ?? undefined"
@@ -140,15 +142,17 @@ const nodeAvailability = computed(() => {
let essential = false
let blueprint = false
let partner = false
let custom = false
for (const n of nodeDefStore.visibleNodeDefs) {
if (!essential && flags.nodeLibraryEssentialsEnabled && isEssentialNode(n))
essential = true
if (!blueprint && n.category.startsWith(BLUEPRINT_CATEGORY))
blueprint = true
if (!partner && n.api_node) partner = true
if (essential && blueprint && partner) break
if (!custom && isCustomNode(n)) custom = true
if (essential && blueprint && partner && custom) break
}
return { essential, blueprint, partner }
return { essential, blueprint, partner, custom }
})
const dialogRef = ref<HTMLElement>()

View File

@@ -52,7 +52,7 @@ describe(NodeSearchFilterBar, () => {
}
it('should render Extensions button and Input/Output popover triggers', async () => {
const wrapper = await createWrapper()
const wrapper = await createWrapper({ hasCustomNodes: true })
const buttons = wrapper.findAll('button')
const texts = buttons.map((b) => b.text())
@@ -73,9 +73,17 @@ describe(NodeSearchFilterBar, () => {
expect(texts).toContain('Essentials')
})
it('should emit selectCategory when category button is clicked', async () => {
it('should not render Extensions button when no custom nodes exist', async () => {
const wrapper = await createWrapper()
const buttons = wrapper.findAll('button')
const texts = buttons.map((b) => b.text())
expect(texts).not.toContain('Extensions')
})
it('should emit selectCategory when category button is clicked', async () => {
const wrapper = await createWrapper({ hasCustomNodes: true })
const extensionsBtn = wrapper
.findAll('button')
.find((b) => b.text() === 'Extensions')!
@@ -85,7 +93,10 @@ describe(NodeSearchFilterBar, () => {
})
it('should apply active styling when activeCategory matches', async () => {
const wrapper = await createWrapper({ activeCategory: 'custom' })
const wrapper = await createWrapper({
activeCategory: 'custom',
hasCustomNodes: true
})
const extensionsBtn = wrapper
.findAll('button')

View File

@@ -66,13 +66,15 @@ const {
activeCategory = null,
hasEssentialNodes = false,
hasBlueprintNodes = false,
hasPartnerNodes = false
hasPartnerNodes = false,
hasCustomNodes = false
} = defineProps<{
filters?: FuseFilterWithValue<ComfyNodeDefImpl, string>[]
activeCategory?: string | null
hasEssentialNodes?: boolean
hasBlueprintNodes?: boolean
hasPartnerNodes?: boolean
hasCustomNodes?: boolean
}>()
const emit = defineEmits<{
@@ -98,7 +100,9 @@ const categoryButtons = computed(() => {
if (hasEssentialNodes) {
buttons.push({ id: 'essentials', label: t('g.essentials') })
}
buttons.push({ id: 'custom', label: t('g.extensions') })
if (hasCustomNodes) {
buttons.push({ id: 'custom', label: t('g.extensions') })
}
return buttons
})