Skip to content

Commit 99f5b36

Browse files
[backport cloud/1.36] feat: local/legacy settings dialog fix (#8004)
Backport of #7990 to `cloud/1.36` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8004-backport-cloud-1-36-feat-local-legacy-settings-dialog-fix-2e76d73d3650814398aff135890ee1cb) by [Unito](https://www.unito.io) Co-authored-by: Simula_r <18093452+simula-r@users.noreply.github.com>
1 parent 2da8338 commit 99f5b36

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/components/dialog/content/TopUpCreditsDialogContent.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ import Button from '@/components/ui/button/Button.vue'
158158
import FormattedNumberStepper from '@/components/ui/stepper/FormattedNumberStepper.vue'
159159
import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions'
160160
import { useExternalLink } from '@/composables/useExternalLink'
161+
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
161162
import { useTelemetry } from '@/platform/telemetry'
162163
import { clearTopupTracking } from '@/platform/telemetry/topupTracker'
163164
import { useDialogService } from '@/services/dialogService'
@@ -175,6 +176,7 @@ const dialogService = useDialogService()
175176
const telemetry = useTelemetry()
176177
const toast = useToast()
177178
const { buildDocsUrl, docsPaths } = useExternalLink()
179+
const { isSubscriptionEnabled } = useSubscription()
178180
179181
// Constants
180182
const PRESET_AMOUNTS = [10, 25, 50, 100]
@@ -252,9 +254,11 @@ async function handleBuy() {
252254
telemetry?.trackApiCreditTopupButtonPurchaseClicked(payAmount.value)
253255
await authActions.purchaseCredits(payAmount.value)
254256
255-
// Close top-up dialog (keep tracking) and open subscription panel to show updated credits
257+
// Close top-up dialog (keep tracking) and open credits panel to show updated balance
256258
handleClose(false)
257-
dialogService.showSettingsDialog('subscription')
259+
dialogService.showSettingsDialog(
260+
isSubscriptionEnabled() ? 'subscription' : 'credits'
261+
)
258262
} catch (error) {
259263
console.error('Purchase failed:', error)
260264

src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ import PricingTable from '@/platform/cloud/subscription/components/PricingTable.
128128
import SubscribeButton from '@/platform/cloud/subscription/components/SubscribeButton.vue'
129129
import SubscriptionBenefits from '@/platform/cloud/subscription/components/SubscriptionBenefits.vue'
130130
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
131-
import { isCloud } from '@/platform/distribution/types'
132131
import { useTelemetry } from '@/platform/telemetry'
133132
import { useCommandStore } from '@/stores/commandStore'
134133
@@ -140,7 +139,8 @@ const emit = defineEmits<{
140139
close: [subscribed: boolean]
141140
}>()
142141
143-
const { fetchStatus, isActiveSubscription } = useSubscription()
142+
const { fetchStatus, isActiveSubscription, isSubscriptionEnabled } =
143+
useSubscription()
144144
145145
// Legacy price for non-tier flow with locale-aware formatting
146146
const formattedMonthlyPrice = new Intl.NumberFormat(
@@ -156,9 +156,7 @@ const commandStore = useCommandStore()
156156
const telemetry = useTelemetry()
157157
158158
// Always show custom pricing table for cloud subscriptions
159-
const showCustomPricingTable = computed(
160-
() => isCloud && window.__CONFIG__?.subscription_required
161-
)
159+
const showCustomPricingTable = computed(() => isSubscriptionEnabled())
162160
163161
const POLL_INTERVAL_MS = 3000
164162
const MAX_POLL_ATTEMPTS = 3

src/platform/cloud/subscription/composables/useSubscription.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ function useSubscriptionInternal() {
121121
void showSubscriptionRequiredDialog()
122122
}
123123

124-
const shouldWatchCancellation = (): boolean =>
124+
/**
125+
* Whether cloud subscription mode is enabled (cloud distribution with subscription_required config).
126+
* Use to determine which UI to show (SubscriptionPanel vs LegacyCreditsPanel).
127+
*/
128+
const isSubscriptionEnabled = (): boolean =>
125129
Boolean(isCloud && window.__CONFIG__?.subscription_required)
126130

127131
const { startCancellationWatcher, stopCancellationWatcher } =
@@ -130,7 +134,7 @@ function useSubscriptionInternal() {
130134
isActiveSubscription: isSubscribedOrIsNotCloud,
131135
subscriptionStatus,
132136
telemetry,
133-
shouldWatchCancellation
137+
shouldWatchCancellation: isSubscriptionEnabled
134138
})
135139

136140
const manageSubscription = async () => {
@@ -249,6 +253,9 @@ function useSubscriptionInternal() {
249253
subscriptionTierName,
250254
subscriptionStatus,
251255

256+
// Utilities
257+
isSubscriptionEnabled,
258+
252259
// Actions
253260
subscribe,
254261
fetchStatus,

0 commit comments

Comments
 (0)