-
Notifications
You must be signed in to change notification settings - Fork 390
subscription page #6064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
subscription page #6064
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6f2c404
subscription page
jtydhr88 776c36f
[automated] Apply ESLint and Prettier fixes
actions-user bc32b82
bug fix
jtydhr88 88edbb5
test fix
jtydhr88 ae0980c
code improve
jtydhr88 03869d7
ui improve
jtydhr88 62439c5
[automated] Apply ESLint and Prettier fixes
actions-user c629798
code improve
jtydhr88 6f9aef0
code improve
jtydhr88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
christian-byrne marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <template> | ||
| <component | ||
| :is="currentButton" | ||
| :key="isActiveSubscription ? 'queue' : 'subscribe'" | ||
| /> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
|
|
||
| import ComfyQueueButton from '@/components/actionbar/ComfyRunButton/ComfyQueueButton.vue' | ||
| import SubscribeToRunButton from '@/platform/cloud/subscription/components/SubscribeToRun.vue' | ||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
|
|
||
| const { isActiveSubscription } = useSubscription() | ||
|
|
||
| const currentButton = computed(() => | ||
| isActiveSubscription.value ? ComfyQueueButton : SubscribeToRunButton | ||
| ) | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineAsyncComponent } from 'vue' | ||
|
|
||
| import { isCloud } from '@/platform/distribution/types' | ||
|
|
||
| export default isCloud | ||
| ? defineAsyncComponent(() => import('./CloudRunButtonWrapper.vue')) | ||
| : defineAsyncComponent(() => import('./ComfyQueueButton.vue')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,39 @@ | ||
| <template> | ||
| <div class="flex items-center gap-2 bg-comfy-menu-secondary px-3"> | ||
| <div | ||
| class="flex items-center gap-2 bg-comfy-menu-secondary" | ||
| :class="[{ 'flex-row-reverse': reverseOrder }, noPadding ? '' : 'px-3']" | ||
| > | ||
| <div | ||
| v-if="badge.label" | ||
| class="rounded-full bg-white px-1.5 py-0.5 text-xxxs font-semibold text-black" | ||
| :class="labelClass" | ||
| > | ||
| {{ badge.label }} | ||
| </div> | ||
| <div class="font-inter text-sm font-extrabold text-slate-100"> | ||
| <div | ||
| class="font-inter text-sm font-extrabold text-slate-100" | ||
| :class="textClass" | ||
| > | ||
| {{ badge.text }} | ||
| </div> | ||
| </div> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import type { TopbarBadge } from '@/types/comfy' | ||
|
|
||
| defineProps<{ | ||
| badge: TopbarBadge | ||
| }>() | ||
| withDefaults( | ||
| defineProps<{ | ||
| badge: TopbarBadge | ||
| reverseOrder?: boolean | ||
| noPadding?: boolean | ||
| labelClass?: string | ||
| textClass?: string | ||
| }>(), | ||
| { | ||
| reverseOrder: false, | ||
| noPadding: false, | ||
| labelClass: '', | ||
| textClass: '' | ||
| } | ||
| ) | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const MONTHLY_SUBSCRIPTION_PRICE = 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { watch } from 'vue' | ||
|
|
||
| import { useCurrentUser } from '@/composables/auth/useCurrentUser' | ||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
| import { useExtensionService } from '@/services/extensionService' | ||
|
|
||
| useExtensionService().registerExtension({ | ||
| name: 'Comfy.CloudSubscription', | ||
|
|
||
| setup: async () => { | ||
| const { isLoggedIn } = useCurrentUser() | ||
| const { requireActiveSubscription } = useSubscription() | ||
|
|
||
| const checkSubscriptionStatus = () => { | ||
| if (!isLoggedIn.value) return | ||
|
|
||
| void requireActiveSubscription() | ||
| } | ||
|
|
||
| watch(() => isLoggedIn.value, checkSubscriptionStatus, { | ||
| immediate: true | ||
| }) | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,5 @@ import './widgetInputs' | |
|
|
||
| if (isCloud) { | ||
| import('./cloudBadge') | ||
| import('./cloudSubscription') | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/platform/cloud/subscription/components/SubscribeButton.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <template> | ||
| <Button | ||
| :label="label || $t('subscription.required.subscribe')" | ||
| :size="size" | ||
| :class="buttonClass" | ||
| :loading="isLoading" | ||
| :disabled="isPolling" | ||
| severity="primary" | ||
| @click="handleSubscribe" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
| import { onBeforeUnmount, ref } from 'vue' | ||
|
|
||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
|
|
||
| withDefaults( | ||
| defineProps<{ | ||
| label?: string | ||
| size?: 'small' | 'large' | ||
| buttonClass?: string | ||
| }>(), | ||
| { | ||
| size: 'large', | ||
| buttonClass: 'w-full font-bold' | ||
| } | ||
| ) | ||
|
|
||
| const emit = defineEmits<{ | ||
| subscribed: [] | ||
| }>() | ||
|
|
||
| const { subscribe, isActiveSubscription, fetchStatus } = useSubscription() | ||
|
|
||
| const isLoading = ref(false) | ||
| const isPolling = ref(false) | ||
| let pollInterval: number | null = null | ||
|
|
||
| const POLL_INTERVAL_MS = 3000 // Poll every 3 seconds | ||
| const MAX_POLL_DURATION_MS = 5 * 60 * 1000 // Stop polling after 5 minutes | ||
|
|
||
| const startPollingSubscriptionStatus = () => { | ||
| isPolling.value = true | ||
| isLoading.value = true | ||
|
|
||
| const startTime = Date.now() | ||
|
|
||
| const poll = async () => { | ||
| try { | ||
| if (Date.now() - startTime > MAX_POLL_DURATION_MS) { | ||
| stopPolling() | ||
| return | ||
| } | ||
|
|
||
| await fetchStatus() | ||
|
|
||
| if (isActiveSubscription.value) { | ||
| stopPolling() | ||
| emit('subscribed') | ||
| } | ||
| } catch (error) { | ||
| console.error( | ||
| '[SubscribeButton] Error polling subscription status:', | ||
| error | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| void poll() | ||
| pollInterval = window.setInterval(poll, POLL_INTERVAL_MS) | ||
| } | ||
|
|
||
| const stopPolling = () => { | ||
| if (pollInterval) { | ||
| clearInterval(pollInterval) | ||
| pollInterval = null | ||
| } | ||
| isPolling.value = false | ||
| isLoading.value = false | ||
| } | ||
|
|
||
| const handleSubscribe = async () => { | ||
| isLoading.value = true | ||
| try { | ||
| await subscribe() | ||
|
|
||
| startPollingSubscriptionStatus() | ||
| } catch (error) { | ||
| console.error('[SubscribeButton] Error initiating subscription:', error) | ||
| isLoading.value = false | ||
| } | ||
| } | ||
|
|
||
| onBeforeUnmount(() => { | ||
| stopPolling() | ||
| }) | ||
| </script> |
23 changes: 23 additions & 0 deletions
23
src/platform/cloud/subscription/components/SubscribeToRun.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <template> | ||
| <Button | ||
| v-tooltip.bottom="{ | ||
| value: $t('subscription.subscribeToRun'), | ||
| showDelay: 600 | ||
| }" | ||
| class="subscribe-to-run-button" | ||
| :label="$t('subscription.subscribeToRun')" | ||
| icon="pi pi-lock" | ||
| severity="primary" | ||
| size="small" | ||
| data-testid="subscribe-to-run-button" | ||
| @click="showSubscriptionDialog" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
|
|
||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
|
|
||
| const { showSubscriptionDialog } = useSubscription() | ||
| </script> |
35 changes: 35 additions & 0 deletions
35
src/platform/cloud/subscription/components/SubscriptionBenefits.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <template> | ||
| <div class="flex flex-col gap-3"> | ||
| <div class="flex items-start gap-2"> | ||
| <i class="pi pi-check mt-1 text-sm" /> | ||
| <span class="text-sm"> | ||
| {{ $t('subscription.benefits.benefit1') }} | ||
| </span> | ||
| </div> | ||
|
|
||
| <div class="flex items-start gap-2"> | ||
| <i class="pi pi-check mt-1 text-sm" /> | ||
| <span class="text-sm"> | ||
| {{ $t('subscription.benefits.benefit2') }} | ||
| </span> | ||
| </div> | ||
|
|
||
| <Button | ||
| :label="$t('subscription.viewMoreDetails')" | ||
| text | ||
| icon="pi pi-external-link" | ||
| icon-pos="left" | ||
| size="small" | ||
| class="self-start !p-0 text-sm hover:!bg-transparent [&]:!text-[inherit]" | ||
| @click="handleViewMoreDetails" | ||
| /> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
|
|
||
| const handleViewMoreDetails = () => { | ||
| window.open('https://www.comfy.org/cloud', '_blank') | ||
| } | ||
| </script> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christian-byrne do we want assets here or should this just get uploaded to GCS and we serve up a publicly signed link?