-
Notifications
You must be signed in to change notification settings - Fork 439
refactor: rename isSubscribed for better expressiveness and avoid initializing cloud modules on local
#7127
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
Changes from all commits
9d88919
afaceb5
cd15c27
5fd6aa6
6fb677f
1ebdab9
8ce0c9e
b8f563d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,37 +23,49 @@ | |
| </div> | ||
| </div> | ||
|
|
||
| <div v-if="isActiveSubscription" class="flex items-center justify-between"> | ||
| <div class="flex flex-col gap-1"> | ||
| <UserCredit text-class="text-2xl" /> | ||
| <component | ||
| :is="SubscriptionSection" | ||
| v-if="SubscriptionSection" | ||
| @top-up="handleTopUp" | ||
| @open-partner-info="handleOpenPartnerNodesInfo" | ||
| @open-plan-settings="handleOpenPlanAndCreditsSettings" | ||
| /> | ||
| <template v-else> | ||
| <div class="flex items-center justify-between"> | ||
| <div class="flex flex-col gap-1"> | ||
| <UserCredit text-class="text-2xl" /> | ||
| <Button | ||
| :label="$t('subscription.partnerNodesCredits')" | ||
| severity="secondary" | ||
| text | ||
| size="small" | ||
| class="pl-6 p-0 h-auto justify-start" | ||
| :pt="{ | ||
| root: { | ||
| class: 'hover:bg-transparent active:bg-transparent' | ||
| } | ||
| }" | ||
| @click="handleOpenPartnerNodesInfo" | ||
| /> | ||
| </div> | ||
| <Button | ||
| :label="$t('subscription.partnerNodesCredits')" | ||
| :label="$t('credits.topUp.topUp')" | ||
| severity="secondary" | ||
| text | ||
| size="small" | ||
| class="pl-6 p-0 h-auto justify-start" | ||
| :pt="{ | ||
| root: { | ||
| class: 'hover:bg-transparent active:bg-transparent' | ||
| } | ||
| }" | ||
| @click="handleOpenPartnerNodesInfo" | ||
| @click="handleTopUp" | ||
| /> | ||
| </div> | ||
|
|
||
| <Button | ||
| :label="$t('credits.topUp.topUp')" | ||
| class="justify-start" | ||
| :label="$t(planSettingsLabel)" | ||
| icon="pi pi-receipt" | ||
| text | ||
| fluid | ||
| severity="secondary" | ||
| size="small" | ||
| @click="handleTopUp" | ||
| @click="handleOpenPlanAndCreditsSettings" | ||
| /> | ||
| </div> | ||
| <SubscribeButton | ||
| v-else | ||
| :label="$t('subscription.subscribeToComfyCloud')" | ||
| size="small" | ||
| variant="gradient" | ||
| @subscribed="handleSubscribed" | ||
| /> | ||
| </template> | ||
|
|
||
| <Divider class="my-2" /> | ||
|
|
||
|
|
@@ -67,17 +79,6 @@ | |
| @click="handleOpenUserSettings" | ||
| /> | ||
|
|
||
| <Button | ||
| v-if="isActiveSubscription" | ||
| class="justify-start" | ||
| :label="$t(planSettingsLabel)" | ||
| icon="pi pi-receipt" | ||
| text | ||
| fluid | ||
| severity="secondary" | ||
| @click="handleOpenPlanAndCreditsSettings" | ||
| /> | ||
|
|
||
| <Divider class="my-2" /> | ||
|
|
||
| <Button | ||
|
|
@@ -95,15 +96,13 @@ | |
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
| import Divider from 'primevue/divider' | ||
| import { onMounted } from 'vue' | ||
| import { defineAsyncComponent, onMounted } from 'vue' | ||
|
|
||
| import UserAvatar from '@/components/common/UserAvatar.vue' | ||
| import UserCredit from '@/components/common/UserCredit.vue' | ||
| import { useCurrentUser } from '@/composables/auth/useCurrentUser' | ||
| import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions' | ||
| import { useExternalLink } from '@/composables/useExternalLink' | ||
| import SubscribeButton from '@/platform/cloud/subscription/components/SubscribeButton.vue' | ||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
| import { isCloud } from '@/platform/distribution/types' | ||
| import { useTelemetry } from '@/platform/telemetry' | ||
| import { useDialogService } from '@/services/dialogService' | ||
|
|
@@ -114,15 +113,18 @@ const emit = defineEmits<{ | |
|
|
||
| const { buildDocsUrl } = useExternalLink() | ||
|
|
||
| const planSettingsLabel = isCloud | ||
| ? 'settingsCategories.PlanCredits' | ||
| : 'settingsCategories.Credits' | ||
| const planSettingsLabel = 'settingsCategories.Credits' | ||
|
|
||
| const SubscriptionSection = isCloud | ||
| ? defineAsyncComponent( | ||
| () => import('./CurrentUserPopoverSubscriptionSection.vue') | ||
| ) | ||
| : null | ||
|
Comment on lines
+116
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider inlining the constant to simplify. The -const planSettingsLabel = 'settingsCategories.Credits'
-
const SubscriptionSection = isCloud
? defineAsyncComponent(
() => import('./CurrentUserPopoverSubscriptionSection.vue')
)
: nullAnd at line 61: - :label="$t(planSettingsLabel)"
+ :label="$t('settingsCategories.Credits')"
🤖 Prompt for AI Agents |
||
|
|
||
| const { userDisplayName, userEmail, userPhotoUrl, handleSignOut } = | ||
| useCurrentUser() | ||
| const authActions = useFirebaseAuthActions() | ||
| const dialogService = useDialogService() | ||
| const { isActiveSubscription, fetchStatus } = useSubscription() | ||
|
|
||
| const handleOpenUserSettings = () => { | ||
| dialogService.showSettingsDialog('user') | ||
|
|
@@ -161,10 +163,6 @@ const handleLogout = async () => { | |
| emit('close') | ||
| } | ||
|
|
||
| const handleSubscribed = async () => { | ||
| await fetchStatus() | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| void authActions.fetchBalance() | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| <template> | ||
| <div v-if="isSubscriptionRequirementMet" class="flex flex-col gap-2"> | ||
| <div class="flex items-center justify-between"> | ||
| <div class="flex flex-col gap-1"> | ||
| <UserCredit text-class="text-2xl" /> | ||
| <Button | ||
| :label="$t('subscription.partnerNodesCredits')" | ||
| severity="secondary" | ||
| text | ||
| size="small" | ||
| class="pl-6 p-0 h-auto justify-start" | ||
| :pt="{ | ||
| root: { | ||
| class: 'hover:bg-transparent active:bg-transparent' | ||
| } | ||
| }" | ||
| @click="handleOpenPartnerInfo" | ||
| /> | ||
| </div> | ||
| <Button | ||
| :label="$t('credits.topUp.topUp')" | ||
| severity="secondary" | ||
| size="small" | ||
| @click="handleTopUp" | ||
| /> | ||
| </div> | ||
|
|
||
| <Button | ||
| class="justify-start" | ||
| :label="$t('settingsCategories.PlanCredits')" | ||
| icon="pi pi-receipt" | ||
| text | ||
| fluid | ||
| severity="secondary" | ||
| @click="handleOpenPlanSettings" | ||
| /> | ||
| </div> | ||
| <SubscribeButton | ||
| v-else | ||
| :label="$t('subscription.subscribeToComfyCloud')" | ||
| size="small" | ||
| variant="gradient" | ||
| class="w-full" | ||
| @subscribed="handleSubscribed" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
|
|
||
| import UserCredit from '@/components/common/UserCredit.vue' | ||
| import SubscribeButton from '@/platform/cloud/subscription/components/SubscribeButton.vue' | ||
| import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription' | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'top-up': [] | ||
| 'open-partner-info': [] | ||
| 'open-plan-settings': [] | ||
| }>() | ||
|
|
||
| const { isSubscriptionRequirementMet, fetchStatus } = useSubscription() | ||
|
|
||
| const handleSubscribed = async () => { | ||
| await fetchStatus() | ||
| } | ||
|
|
||
| const handleTopUp = () => { | ||
| emit('top-up') | ||
| } | ||
|
|
||
| const handleOpenPartnerInfo = () => { | ||
| emit('open-partner-info') | ||
| } | ||
|
|
||
| const handleOpenPlanSettings = () => { | ||
| emit('open-plan-settings') | ||
| } | ||
| </script> |
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.
🧹 Nitpick | 🔵 Trivial
Consider adding a guard for missing buttons to improve test failure messages.
The non-null assertion
!will throw an unhelpful error if the button isn't found. A small guard would make test failures more debuggable:📝 Committable suggestion
🤖 Prompt for AI Agents