mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
fix: add plurilization to node pack count in custom node manager dialog (#8191)
This commit is contained in:
@@ -158,6 +158,7 @@
|
|||||||
"choose_file_to_upload": "choose file to upload",
|
"choose_file_to_upload": "choose file to upload",
|
||||||
"capture": "capture",
|
"capture": "capture",
|
||||||
"nodes": "Nodes",
|
"nodes": "Nodes",
|
||||||
|
"nodesCount": "{count} nodes | {count} node | {count} nodes",
|
||||||
"community": "Community",
|
"community": "Community",
|
||||||
"all": "All",
|
"all": "All",
|
||||||
"versionMismatchWarning": "Version Compatibility Warning",
|
"versionMismatchWarning": "Version Compatibility Warning",
|
||||||
|
|||||||
@@ -10,15 +10,22 @@ import type {
|
|||||||
RegistryPack
|
RegistryPack
|
||||||
} from '@/workbench/extensions/manager/types/comfyManagerTypes'
|
} from '@/workbench/extensions/manager/types/comfyManagerTypes'
|
||||||
|
|
||||||
|
const translateMock = vi.hoisted(() =>
|
||||||
|
vi.fn((key: string, choice?: number) =>
|
||||||
|
typeof choice === 'number' ? `${key}-${choice}` : key
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const dateMock = vi.hoisted(() => vi.fn(() => '2024. 1. 1.'))
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
vi.mock('vue-i18n', () => ({
|
vi.mock('vue-i18n', () => ({
|
||||||
useI18n: vi.fn(() => ({
|
useI18n: vi.fn(() => ({
|
||||||
d: vi.fn(() => '2024. 1. 1.'),
|
d: dateMock,
|
||||||
t: vi.fn((key: string) => key)
|
t: translateMock
|
||||||
})),
|
})),
|
||||||
createI18n: vi.fn(() => ({
|
createI18n: vi.fn(() => ({
|
||||||
global: {
|
global: {
|
||||||
t: vi.fn((key: string) => key),
|
t: translateMock,
|
||||||
te: vi.fn(() => true)
|
te: vi.fn(() => true)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -187,6 +194,18 @@ describe('PackCard', () => {
|
|||||||
// Should still render without errors
|
// Should still render without errors
|
||||||
expect(wrapper.exists()).toBe(true)
|
expect(wrapper.exists()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should use localized singular/plural nodes label', () => {
|
||||||
|
const packWithNodes = {
|
||||||
|
...mockNodePack,
|
||||||
|
comfy_nodes: ['node-a']
|
||||||
|
} as MergedNodePack
|
||||||
|
|
||||||
|
const wrapper = createWrapper({ nodePack: packWithNodes })
|
||||||
|
|
||||||
|
expect(wrapper.text()).toContain('g.nodesCount-1')
|
||||||
|
expect(translateMock).toHaveBeenCalledWith('g.nodesCount', 1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('component structure', () => {
|
describe('component structure', () => {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="flex flex-col gap-y-2">
|
<div class="flex flex-col gap-y-2">
|
||||||
<div class="flex flex-1 items-center gap-2">
|
<div class="flex flex-1 items-center gap-2">
|
||||||
<div v-if="nodesCount" class="p-2 pl-0 text-xs">
|
<div v-if="nodesLabel" class="p-2 pl-0 text-xs">
|
||||||
{{ nodesCount }} {{ $t('g.nodes') }}
|
{{ nodesLabel }}
|
||||||
</div>
|
</div>
|
||||||
<PackVersionBadge
|
<PackVersionBadge
|
||||||
:node-pack="nodePack"
|
:node-pack="nodePack"
|
||||||
@@ -94,7 +94,7 @@ const { nodePack, isSelected = false } = defineProps<{
|
|||||||
isSelected?: boolean
|
isSelected?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { d } = useI18n()
|
const { d, t } = useI18n()
|
||||||
|
|
||||||
const colorPaletteStore = useColorPaletteStore()
|
const colorPaletteStore = useColorPaletteStore()
|
||||||
const isLightTheme = computed(
|
const isLightTheme = computed(
|
||||||
@@ -115,6 +115,9 @@ const isDisabled = computed(
|
|||||||
const nodesCount = computed(() =>
|
const nodesCount = computed(() =>
|
||||||
isMergedNodePack(nodePack) ? nodePack.comfy_nodes?.length : undefined
|
isMergedNodePack(nodePack) ? nodePack.comfy_nodes?.length : undefined
|
||||||
)
|
)
|
||||||
|
const nodesLabel = computed(() =>
|
||||||
|
nodesCount.value ? t('g.nodesCount', nodesCount.value) : ''
|
||||||
|
)
|
||||||
const publisherName = computed(() => {
|
const publisherName = computed(() => {
|
||||||
if (!nodePack) return null
|
if (!nodePack) return null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user