Line data Source code
1 1 : <template>
2 : <DefineDocsLink>
3 : <Button
4 : variant="link"
5 : size="link"
6 : class="w-fit"
7 : as="a"
8 : :href="docsUrl"
9 : target="_blank"
10 : rel="noopener noreferrer"
11 : >
12 : {{ $t('deployToComfyApi.readDocs') }}
13 : <i aria-hidden="true" class="icon-[lucide--square-arrow-out-up-right]" />
14 : </Button>
15 : </DefineDocsLink>
16 :
17 : <div class="@container w-[min(640px,calc(100vw-2rem))]">
18 : <div
19 : data-testid="deploy-to-comfy-api-card"
20 : class="relative max-h-[85dvh] overflow-y-auto rounded-2xl border bg-background shadow-2xl"
21 : >
22 : <Button
23 : variant="muted-textonly"
24 : size="icon"
25 : :aria-label="$t('g.close')"
26 : class="absolute top-3 right-3 z-20"
27 : @click="emit('dismiss')"
28 : >
29 : <i class="icon-[lucide--x]" />
30 : </Button>
31 :
32 : <div class="p-2">
33 : <Video
34 : :sources="videoSources"
35 : :poster-src="posterSrc"
36 : autoplay
37 : muted
38 : loop
39 : plays-inline
40 : :playback-labels="{ play: $t('g.play'), pause: $t('g.pause') }"
41 : data-testid="deploy-to-comfy-api-video"
42 : class="aspect-video w-full rounded-lg object-cover"
43 : >
44 : <template #fallback>
45 : <div
46 : data-testid="deploy-to-comfy-api-video-placeholder"
47 : class="grid aspect-video w-full place-items-center rounded-lg bg-secondary"
48 : >
49 : <span
50 : class="grid size-16 place-items-center rounded-full border border-foreground/30 bg-foreground/10"
51 : aria-hidden="true"
52 : >
53 : <i class="icon-[lucide--play] size-6" />
54 : </span>
55 : </div>
56 : </template>
57 : </Video>
58 : </div>
59 :
60 : <section class="flex flex-col gap-9 p-6 @xl:gap-6 @xl:p-9">
61 : <div class="flex flex-col gap-4">
62 : <DialogTitle class="my-0 text-xl @xl:text-2xl">
63 : {{ $t('deployToComfyApi.title') }}
64 : </DialogTitle>
65 : <p class="my-0 text-sm/5 text-muted-foreground">
66 : {{ $t('deployToComfyApi.body') }}
67 : </p>
68 : <p
69 : class="my-0 text-sm/5 text-muted-foreground"
70 : data-testid="deploy-to-comfy-api-summary"
71 : >
72 : {{ summary }}
73 : </p>
74 : <ReuseDocsLink class="@xl:hidden" />
75 : </div>
76 :
77 : <footer
78 : class="flex flex-col-reverse gap-2.5 @xl:flex-row @xl:items-center @xl:justify-end"
79 : >
80 : <ReuseDocsLink class="hidden @xl:mr-auto @xl:inline-flex" />
81 : <Button
82 : variant="secondary"
83 : size="lg"
84 : class="w-full @xl:w-auto"
85 : data-testid="deploy-to-comfy-api-agent"
86 : :loading="isCopying"
87 : @click="copyWith(copyBrief)"
88 : >
89 : <template v-if="copied">
90 : <i class="icon-[lucide--check]" aria-hidden="true" />
91 : {{ $t('deployToComfyApi.copied') }}
92 : </template>
93 : <template v-else>
94 : <i class="icon-[lucide--copy]" aria-hidden="true" />
95 : {{ $t('deployToComfyApi.deployWithAgent') }}
96 : </template>
97 : </Button>
98 : <DeployInstallationButton
99 : v-if="deploysInstallation"
100 : @opened="emit('done')"
101 : />
102 : <Button
103 : v-else
104 : variant="inverted"
105 : size="lg"
106 : class="w-full @xl:w-auto"
107 : as="a"
108 : :href="platformUrl"
109 : target="_blank"
110 : rel="noopener noreferrer"
111 : data-testid="deploy-to-comfy-api-platform"
112 : @click="emit('done')"
113 : >
114 : {{ $t('deployToComfyApi.deployOnPlatform') }}
115 : </Button>
116 : </footer>
117 : </section>
118 : </div>
119 : </div>
120 : </template>
121 :
122 : <script setup lang="ts">
123 : import { createReusableTemplate } from '@vueuse/core'
124 : import { computed } from 'vue'
125 : import { useI18n } from 'vue-i18n'
126 : import type { ComponentProps } from 'vue-component-type-helpers'
127 :
128 : import Video from '@comfyorg/design-system/media/Video'
129 : import Button from '@comfyorg/design-system/button/Button'
130 : import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle'
131 : import { useExternalLink } from '@/composables/useExternalLink'
132 : import { getComfyPlatformBaseUrl } from '@/config/comfyApi'
133 : import DeployInstallationButton from '@/platform/workflow/deploy/components/DeployInstallationButton.vue'
134 : import { useAgentHandoff } from '@/platform/workflow/deploy/composables/useAgentHandoff'
135 : import { useBriefCopy } from '@/platform/workspace/composables/useBriefCopy'
136 :
137 : const {
138 : videoSources = [],
139 : posterSrc = '',
140 : deploysInstallation = false
141 : } = defineProps<{
142 : videoSources?: ComponentProps<typeof Video>['sources']
143 : posterSrc?: string
144 : deploysInstallation?: boolean
145 : }>()
146 :
147 1 : const emit = defineEmits<{
148 : done: []
149 : dismiss: []
150 : }>()
151 :
152 : defineOptions({ inheritAttrs: false })
153 :
154 1 : const { t } = useI18n()
155 1 : const { buildDocsUrl } = useExternalLink()
156 1 : const { captureInputs, copyBrief } = useAgentHandoff()
157 1 : const [DefineDocsLink, ReuseDocsLink] = createReusableTemplate()
158 1 : const { isCopying, copied, copyWith } = useBriefCopy()
159 :
160 1 : const docsUrl = buildDocsUrl('/development/overview', { includeLocale: true })
161 1 : const inputs = captureInputs()
162 1 : const platformUrl = getComfyPlatformBaseUrl()
163 :
164 1 : const summary = computed(() =>
165 : [
166 : t('deployToComfyApi.summaryPacks', inputs.nodePacks.length),
167 : t('deployToComfyApi.summaryModels', inputs.models.length),
168 : t('deployToComfyApi.summaryClasses', inputs.nodeClasses.length)
169 : ].join(' ยท ')
170 : )
171 : </script>
|