Line data Source code
1 : import type { MaybeRefOrGetter } from 'vue'
2 : import { computed, toValue } from 'vue'
3 :
4 : import { useMissingNodesErrorStore } from '@/platform/workflowErrors/nodeReplacement/missingNodesErrorStore'
5 : import { useDeploymentSwitcherOffered } from '@/platform/workspace/composables/useDeploymentSwitcherOffered'
6 : import { nodesNeedingDeployment } from '@/platform/workspace/missingForDeployment'
7 : import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore'
8 :
9 : /**
10 : * Whether the open workflow needs a deployment: it lacks nodes with no
11 : * replacement, on a page booted on Comfy Cloud that was served the listing.
12 : */
13 0 : export function useWorkflowNeedsDeployment() {
14 0 : const pickStore = useDeploymentPickStore()
15 0 : const missingNodesErrorStore = useMissingNodesErrorStore()
16 0 : const switcherOffered = useDeploymentSwitcherOffered()
17 0 : return computed(
18 : () =>
19 : switcherOffered.value &&
20 : pickStore.isVisible &&
21 : pickStore.bootDeployment === null &&
22 : nodesNeedingDeployment(
23 : missingNodesErrorStore.missingNodesError?.nodeTypes ?? []
24 : ).length > 0
25 : )
26 : }
27 :
28 : /**
29 : * Whether Comfy Cloud offers a custom deployment for the open workflow's
30 : * missing nodes, given whether Cloud and each deployment were found lacking.
31 : */
32 0 : export function useCustomDeploymentOffered(
33 : noneRunIt: MaybeRefOrGetter<boolean>
34 : ) {
35 0 : const pickStore = useDeploymentPickStore()
36 0 : const needsDeployment = useWorkflowNeedsDeployment()
37 :
38 0 : return computed(
39 : () =>
40 : needsDeployment.value &&
41 : (pickStore.deployments.length === 0 || toValue(noneRunIt))
42 : )
43 : }
|