[Manager] Use inject for installing button state (#3143)

This commit is contained in:
Christian Byrne
2025-03-19 07:33:47 -07:00
committed by GitHub
parent c5af11d1ea
commit ff59245a7f
2 changed files with 18 additions and 6 deletions

View File

@@ -6,12 +6,12 @@
'w-full': fullWidth,
'w-min-content': !fullWidth
}"
:disabled="isExecuted"
:disabled="isInstalling"
v-bind="$attrs"
@click="onClick"
>
<span class="py-2.5 px-3">
<template v-if="isExecuted">
<template v-if="isInstalling">
{{ loadingMessage ?? $t('g.loading') }}
</template>
<template v-else>
@@ -23,7 +23,9 @@
<script setup lang="ts">
import Button from 'primevue/button'
import { ref } from 'vue'
import { inject, ref } from 'vue'
import { IsInstallingKey } from '@/types/comfyManagerTypes'
const {
label,
@@ -43,10 +45,10 @@ defineOptions({
inheritAttrs: false
})
const isExecuted = ref(false)
const isInstalling = inject(IsInstallingKey, ref(false))
const onClick = (): void => {
isExecuted.value = true
isInstalling.value = true
emit('action')
}
</script>

View File

@@ -44,7 +44,8 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { whenever } from '@vueuse/core'
import { computed, provide, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import PackStatusMessage from '@/components/dialog/content/manager/PackStatusMessage.vue'
@@ -54,6 +55,7 @@ import InfoPanelHeader from '@/components/dialog/content/manager/infoPanel/InfoP
import InfoTabs from '@/components/dialog/content/manager/infoPanel/InfoTabs.vue'
import MetadataRow from '@/components/dialog/content/manager/infoPanel/MetadataRow.vue'
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
import { IsInstallingKey } from '@/types/comfyManagerTypes'
import { components } from '@/types/comfyRegistryTypes'
interface InfoItem {
@@ -66,6 +68,14 @@ const { nodePack } = defineProps<{
nodePack: components['schemas']['Node']
}>()
const managerStore = useComfyManagerStore()
const isInstalled = computed(() => managerStore.isPackInstalled(nodePack.id))
const isInstalling = ref(false)
provide(IsInstallingKey, isInstalling)
whenever(isInstalled, () => {
isInstalling.value = false
})
const { isPackInstalled } = useComfyManagerStore()
const { t, d, n } = useI18n()