Repository navigation
FE-1251 feat: add flagged payment recovery UI #14701
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b40bf9a
feat: add flagged payment recovery UI
dante01yoon 6f57279
fix: handle payment portal failures
dante01yoon 0dd0fc4
fix: prevent duplicate payment portal requests
dante01yoon 9bfe750
fix: ignore stale payment portal completion
dante01yoon 9a8fe5a
fix: refresh billing after portal return
dante01yoon 4b71f02
fix: align payment recovery styling and copy
dante01yoon 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
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
108 changes: 101 additions & 7 deletions
108
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 |
|---|---|---|
| @@ -1,19 +1,113 @@ | ||
| <template> | ||
| <component | ||
| :is="currentButton" | ||
| :key="canRunWorkflows ? 'queue' : 'subscribe'" | ||
| <ComfyQueueButton | ||
| v-if="canRunWorkflows || paymentRecoveryLock" | ||
| :payment-recovery-lock="paymentRecoveryLock" | ||
| @payment-recovery-click="showPaymentRecoveryDialog" | ||
| /> | ||
| <SubscribeToRunButton v-else /> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { useEventListener } from '@vueuse/core' | ||
| import { computed, onUnmounted, ref } from 'vue' | ||
|
|
||
| import ComfyQueueButton from '@/components/actionbar/ComfyRunButton/ComfyQueueButton.vue' | ||
| import { useBillingContext } from '@/composables/billing/useBillingContext' | ||
| import { useErrorHandling } from '@/composables/useErrorHandling' | ||
| import { useFeatureFlags } from '@/composables/useFeatureFlags' | ||
| import SubscribeToRunButton from '@/platform/cloud/subscription/components/SubscribeToRun.vue' | ||
| import SubscriptionPausedDialog from '@/platform/workspace/components/SubscriptionPausedDialog.vue' | ||
| import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI' | ||
| import { useDialogService } from '@/services/dialogService' | ||
| import { useDialogStore } from '@/stores/dialogStore' | ||
|
|
||
| const { canRunWorkflows } = useBillingContext() | ||
| const DIALOG_KEY = 'subscription-paused' | ||
| const { | ||
| canRunWorkflows, | ||
| billingStatus, | ||
| manageSubscription, | ||
| fetchStatus, | ||
| fetchBalance | ||
| } = useBillingContext() | ||
| const { flags } = useFeatureFlags() | ||
| const { permissions } = useWorkspaceUI() | ||
| const dialogService = useDialogService() | ||
| const dialogStore = useDialogStore() | ||
| const { toastErrorHandler } = useErrorHandling() | ||
| const isUpdatingPayment = ref(false) | ||
| let paymentPortalRequest: Promise<void> | null = null | ||
| let isUnmounted = false | ||
| let refreshBillingOnFocus = false | ||
|
|
||
| const currentButton = computed(() => | ||
| canRunWorkflows.value ? ComfyQueueButton : SubscribeToRunButton | ||
| onUnmounted(() => { | ||
| isUnmounted = true | ||
| }) | ||
|
|
||
| useEventListener(window, 'focus', () => { | ||
| if (!refreshBillingOnFocus) return | ||
| refreshBillingOnFocus = false | ||
| void Promise.allSettled([fetchStatus(), fetchBalance()]) | ||
| }) | ||
|
|
||
| const paymentRecoveryLock = computed<'owner' | 'member' | null>(() => | ||
| flags.v1PaymentRecovery && billingStatus.value === 'paused' | ||
| ? permissions.value.canManageSubscription | ||
| ? 'owner' | ||
| : 'member' | ||
| : null | ||
| ) | ||
|
|
||
| function closePaymentRecoveryDialog() { | ||
| dialogStore.closeDialog({ key: DIALOG_KEY }) | ||
| } | ||
|
|
||
| function updatePayment(): Promise<void> { | ||
| if (paymentPortalRequest) return paymentPortalRequest | ||
|
|
||
| paymentPortalRequest = (async () => { | ||
| isUpdatingPayment.value = true | ||
| dialogStore.updateDialog({ | ||
| key: DIALOG_KEY, | ||
| contentProps: { isUpdatingPayment: true } | ||
| }) | ||
| try { | ||
| await manageSubscription() | ||
|
dante01yoon marked this conversation as resolved.
Resolved
|
||
| if (!isUnmounted) { | ||
| refreshBillingOnFocus = true | ||
| closePaymentRecoveryDialog() | ||
| } | ||
| } catch (error) { | ||
| if (!isUnmounted) toastErrorHandler(error) | ||
| } finally { | ||
| isUpdatingPayment.value = false | ||
| paymentPortalRequest = null | ||
| if (!isUnmounted) { | ||
| dialogStore.updateDialog({ | ||
| key: DIALOG_KEY, | ||
| contentProps: { isUpdatingPayment: false } | ||
| }) | ||
| } | ||
| } | ||
| })() | ||
|
|
||
| return paymentPortalRequest | ||
| } | ||
|
|
||
| function showPaymentRecoveryDialog() { | ||
| dialogService.showLayoutDialog({ | ||
| key: DIALOG_KEY, | ||
| component: SubscriptionPausedDialog, | ||
| props: { | ||
| canManage: paymentRecoveryLock.value === 'owner', | ||
| isUpdatingPayment: isUpdatingPayment.value, | ||
| onClose: closePaymentRecoveryDialog, | ||
| onUpdatePayment: updatePayment | ||
| }, | ||
| dialogComponentProps: { | ||
| renderer: 'reka', | ||
| headless: true, | ||
| contentClass: | ||
| 'w-[min(360px,95vw)] max-w-[min(360px,95vw)] sm:max-w-[min(360px,95vw)] border-0 bg-transparent shadow-none' | ||
| } | ||
| }) | ||
| } | ||
| </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.
Uh oh!
There was an error while loading. Please reload this page.