Line data Source code
1 16 : <template>
2 68 : <div class="flex min-h-0 flex-1 flex-col">
3 : <ComfyHubCreateProfileForm
4 : v-if="currentStep === 'profileCreation'"
5 : data-testid="publish-gate-flow"
6 : :on-profile-created="() => onGateComplete()"
7 : :on-close="onGateClose"
8 : :show-close-button="false"
9 : />
10 : <div v-else class="flex min-h-0 flex-1 flex-col">
11 : <div class="flex min-h-0 flex-1 flex-col overflow-y-auto">
12 : <ComfyHubDescribeStep
13 : v-if="currentStep === 'describe'"
14 : :name="formData.name"
15 : :description="formData.description"
16 : :tags="formData.tags"
17 : @update:name="onUpdateFormData({ name: $event })"
18 : @update:description="onUpdateFormData({ description: $event })"
19 : @update:tags="onUpdateFormData({ tags: $event })"
20 : />
21 : <div
22 : v-else-if="currentStep === 'examples'"
23 : class="flex min-h-0 flex-1 flex-col gap-6 px-6 py-4"
24 : >
25 : <ComfyHubThumbnailStep
26 : :thumbnail-type="formData.thumbnailType"
27 : :thumbnail-file="formData.thumbnailFile"
28 : :thumbnail-url="formData.thumbnailUrl"
29 : :existing-thumbnail-type="formData.existingThumbnailType"
30 : :comparison-before-file="formData.comparisonBeforeFile"
31 : :comparison-after-file="formData.comparisonAfterFile"
32 : :comparison-after-url="formData.comparisonAfterUrl"
33 : @update:thumbnail-type="onUpdateFormData({ thumbnailType: $event })"
34 : @update:thumbnail-file="onUpdateFormData({ thumbnailFile: $event })"
35 : @update:thumbnail-url="onUpdateFormData({ thumbnailUrl: $event })"
36 : @update:comparison-before-file="
37 : onUpdateFormData({ comparisonBeforeFile: $event })
38 : "
39 : @update:comparison-after-file="
40 : onUpdateFormData({ comparisonAfterFile: $event })
41 : "
42 : @update:comparison-after-url="
43 : onUpdateFormData({ comparisonAfterUrl: $event })
44 : "
45 : />
46 : <ComfyHubExamplesStep
47 : :example-images="formData.exampleImages"
48 : @update:example-images="onUpdateFormData({ exampleImages: $event })"
49 : />
50 : </div>
51 : <div
52 : v-else-if="currentStep === 'finish' && isProfileLoading"
53 : class="flex min-h-0 flex-1 flex-col gap-4 px-6 py-4"
54 : >
55 : <Skeleton class="h-4 w-1/4" />
56 : <Skeleton class="h-20 w-full rounded-2xl" />
57 : </div>
58 : <ComfyHubFinishStep
59 : v-else-if="currentStep === 'finish' && hasProfile && profile"
60 : v-model:ready="finishStepReady"
61 : v-model:acknowledged="assetsAcknowledged"
62 : :profile
63 : />
64 : <ComfyHubProfilePromptPanel
65 : v-else-if="currentStep === 'finish'"
66 : @request-profile="onRequireProfile"
67 : />
68 : </div>
69 : <ComfyHubPublishFooter
70 : :is-first-step
71 : :is-last-step
72 : :is-publish-disabled
73 : :is-publishing="isPublishInFlight"
74 : :is-update
75 : @back="onGoBack"
76 : @next="onGoNext"
77 : @publish="handlePublish"
78 : />
79 : </div>
80 : </div>
81 : </template>
82 :
83 : <script setup lang="ts">
84 : import { computed, ref } from 'vue'
85 :
86 : import { useErrorHandling } from '@/composables/useErrorHandling'
87 : import { useFeatureFlags } from '@/composables/useFeatureFlags'
88 : import { useComfyHubProfileGate } from '@/platform/workflow/sharing/composables/useComfyHubProfileGate'
89 : import ComfyHubCreateProfileForm from '@/platform/workflow/sharing/components/profile/ComfyHubCreateProfileForm.vue'
90 : import type { ComfyHubPublishStep } from '@/platform/workflow/sharing/composables/useComfyHubPublishWizard'
91 : import type { ComfyHubPublishFormData } from '@/platform/workflow/sharing/types/comfyHubTypes'
92 : import Skeleton from '@comfyorg/design-system/skeleton/Skeleton'
93 : import ComfyHubDescribeStep from './ComfyHubDescribeStep.vue'
94 : import ComfyHubExamplesStep from './ComfyHubExamplesStep.vue'
95 : import ComfyHubFinishStep from './ComfyHubFinishStep.vue'
96 : import ComfyHubProfilePromptPanel from './ComfyHubProfilePromptPanel.vue'
97 : import ComfyHubThumbnailStep from './ComfyHubThumbnailStep.vue'
98 : import ComfyHubPublishFooter from './ComfyHubPublishFooter.vue'
99 :
100 : const {
101 : currentStep,
102 : formData,
103 : isFirstStep,
104 : isLastStep,
105 : isPublishing = false,
106 : isUpdate = false,
107 : onGoNext,
108 : onGoBack,
109 : onUpdateFormData,
110 : onPublish,
111 : onRequireProfile,
112 : onGateComplete = () => {},
113 : onGateClose = () => {}
114 : } = defineProps<{
115 : currentStep: ComfyHubPublishStep
116 : formData: ComfyHubPublishFormData
117 : isFirstStep: boolean
118 : isLastStep: boolean
119 : isPublishing?: boolean
120 : isUpdate?: boolean
121 : onGoNext: () => void
122 : onGoBack: () => void
123 : onUpdateFormData: (patch: Partial<ComfyHubPublishFormData>) => void
124 : onPublish: () => Promise<void>
125 : onRequireProfile: () => void
126 : onGateComplete?: () => void
127 : onGateClose?: () => void
128 : }>()
129 :
130 30 : const { toastErrorHandler } = useErrorHandling()
131 30 : const { flags } = useFeatureFlags()
132 30 : const { checkProfile, hasProfile, isFetchingProfile, profile } =
133 : useComfyHubProfileGate()
134 30 : const isProfileLoading = computed(
135 : () => hasProfile.value === null || isFetchingProfile.value
136 : )
137 30 : const finishStepReady = ref(false)
138 30 : const assetsAcknowledged = ref(false)
139 30 : const isResolvingPublishAccess = ref(false)
140 30 : const isPublishInFlight = computed(
141 : () => isPublishing || isResolvingPublishAccess.value
142 : )
143 30 : const isFinishStepVisible = computed(
144 : () =>
145 : currentStep === 'finish' &&
146 : hasProfile.value === true &&
147 : profile.value !== null
148 : )
149 30 : const isPublishDisabled = computed(
150 : () =>
151 : isPublishInFlight.value ||
152 : (flags.comfyHubProfileGateEnabled && hasProfile.value !== true) ||
153 : (isFinishStepVisible.value && !finishStepReady.value)
154 : )
155 :
156 3 : async function handlePublish() {
157 3 : if (isResolvingPublishAccess.value || isPublishing) {
158 0 : return
159 : }
160 :
161 3 : isResolvingPublishAccess.value = true
162 3 : try {
163 3 : if (!flags.comfyHubProfileGateEnabled) {
164 3 : await onPublish()
165 3 : return
166 : }
167 :
168 0 : let profileExists: boolean
169 0 : try {
170 0 : profileExists = await checkProfile()
171 : } catch (error) {
172 0 : toastErrorHandler(error)
173 0 : return
174 : }
175 :
176 0 : if (profileExists) {
177 0 : await onPublish()
178 0 : return
179 : }
180 :
181 0 : onRequireProfile()
182 : } catch (error) {
183 0 : toastErrorHandler(error)
184 : } finally {
185 3 : isResolvingPublishAccess.value = false
186 : }
187 : }
188 : </script>
|