Line data Source code
1 : <template>
2 : <div
3 0 : v-if="first && !deploymentDialogAppeared"
4 : class="flex w-full items-center gap-2 pr-8"
5 : data-testid="error-overlay-deployment-offer"
6 : >
7 : <span class="size-4 shrink-0" aria-hidden="true" />
8 : <span class="min-w-0 flex-1 truncate text-sm text-foreground">
9 : {{ t('errorOverlay.runsOn', { deployment: first.label }) }}
10 : </span>
11 : <Button
12 : v-if="moreCount > 0"
13 : variant="muted-textonly"
14 : size="unset"
15 : class="min-h-8 shrink-0 rounded-lg px-2 py-2 text-xs font-normal"
16 : @click="openSwitcher()"
17 : >
18 : {{ t('errorOverlay.moreDeployments', { count: moreCount }) }}
19 : </Button>
20 : <Button
21 : variant="secondary"
22 : size="unset"
23 : class="min-h-8 shrink-0 rounded-lg px-3 py-2 text-xs font-normal"
24 : :disabled="isSwitching"
25 : @click="choose(first.deploymentId)"
26 : >
27 : {{ t('errorOverlay.switchDeployment') }}
28 : </Button>
29 : </div>
30 : <div
31 : v-else-if="customDeploymentOffered && !deploymentDialogAppeared"
32 : class="flex w-full items-center gap-2 pr-8"
33 : data-testid="error-overlay-custom-deployment-offer"
34 : >
35 : <span class="size-4 shrink-0" aria-hidden="true" />
36 : <span class="min-w-0 flex-1 truncate text-sm text-foreground">
37 : {{ t('errorOverlay.runOnCustomDeployment') }}
38 : </span>
39 : <Button
40 : variant="secondary"
41 : size="unset"
42 : class="min-h-8 shrink-0 rounded-lg px-3 py-2 text-xs font-normal"
43 : @click="openWorkflowNeedsDeploymentDialog()"
44 : >
45 : {{ t('errorOverlay.setUpCustomDeployment') }}
46 : </Button>
47 : </div>
48 : </template>
49 :
50 : <script setup lang="ts">
51 : import { whenever } from '@vueuse/core'
52 : import { computed, ref } from 'vue'
53 : import { useI18n } from 'vue-i18n'
54 :
55 : import Button from '@comfyorg/design-system/button/Button'
56 : import { useCustomDeploymentOffered } from '@/platform/workspace/composables/useCustomDeploymentOffered'
57 : import { useMissingNodeDeploymentOffer } from '@/platform/workspace/composables/useMissingNodeDeploymentOffer'
58 : import {
59 : isWorkflowNeedsDeploymentDialogOpen,
60 : openWorkflowNeedsDeploymentDialog
61 : } from '@/platform/workspace/openCustomDeploymentDialog'
62 :
63 0 : const { t } = useI18n()
64 0 : const { offer, choose, isSwitching, openSwitcher } =
65 : useMissingNodeDeploymentOffer()
66 0 : const customDeploymentOffered = useCustomDeploymentOffered(
67 : () => offer.value?.kind === 'none'
68 : )
69 0 : const deploymentDialogAppeared = ref(false)
70 0 : whenever(
71 : isWorkflowNeedsDeploymentDialogOpen,
72 : () => {
73 0 : deploymentDialogAppeared.value = true
74 : },
75 : { immediate: true }
76 : )
77 :
78 0 : const choices = computed(() =>
79 : offer.value?.kind === 'choices' ? offer.value.choices : []
80 : )
81 0 : const first = computed(() => choices.value[0])
82 0 : const moreCount = computed(() => choices.value.length - 1)
83 : </script>
|