refactor: simplify PackInstallButton isInstalling state management

- Remove isInstalling prop from PackInstallButton component
- Use internal computed property with comfyManagerStore.isPackInstalling()
- Remove redundant isInstalling computations from parent components
- Fix test mocks for useConflictDetection and es-toolkit/compat
- Clean up unused imports and inject dependencies

This centralizes the installation state management in the store,
reducing code duplication and complexity across components.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jin Yi
2025-08-27 23:00:42 +09:00
parent a5153cd4b9
commit 267e07e26d
8 changed files with 23 additions and 51 deletions

View File

@@ -47,7 +47,6 @@ type NodePack = components['schemas']['Node']
const {
nodePacks,
isLoading = false,
isInstalling = false,
label = 'Install',
size = 'sm',
hasConflict,
@@ -55,7 +54,6 @@ const {
} = defineProps<{
nodePacks: NodePack[]
isLoading?: boolean
isInstalling?: boolean
label?: string
size?: ButtonSize
hasConflict?: boolean
@@ -65,6 +63,12 @@ const {
const managerStore = useComfyManagerStore()
const { showNodeConflictDialog } = useDialogService()
// Check if any of the packs are currently being installed
const isInstalling = computed(() => {
if (!nodePacks?.length) return false
return nodePacks.some((pack) => managerStore.isPackInstalling(pack.id))
})
const createPayload = (installItem: NodePack) => {
if (!installItem.id) {
throw new Error('Node ID is required for installation')
@@ -107,14 +111,12 @@ const installAllPacks = async () => {
buttonText: t('manager.conflicts.installAnyway'),
onButtonClick: async () => {
// Proceed with installation
// isInstalling.value = true
await performInstallation(nodePacks)
}
})
return
}
// No conflicts or conflicts acknowledged - proceed with installation
// isInstalling.value = true
await performInstallation(nodePacks)
}
@@ -124,7 +126,7 @@ const performInstallation = async (packs: NodePack[]) => {
}
const computedLabel = computed(() =>
isInstalling
isInstalling.value
? t('g.installing')
: label ??
(nodePacks.length > 1 ? t('manager.installSelected') : t('g.install'))