@antelopejs/dms-saas 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/dist/billing-state/recovery.js +2 -2
- package/dist/billing-state/recovery.js.map +1 -1
- package/dist/pages/platform/credit-notes.js +1 -1
- package/dist/pages/platform/credit-notes.js.map +1 -1
- package/dist/pages/platform/features.js +3 -1
- package/dist/pages/platform/features.js.map +1 -1
- package/dist/pages/platform/invoices.js +2 -2
- package/dist/pages/platform/invoices.js.map +1 -1
- package/dist/pages/platform/plans/index.js +15 -9
- package/dist/pages/platform/plans/index.js.map +1 -1
- package/dist/pages/platform/plans/migrations.js +2 -2
- package/dist/pages/platform/plans/migrations.js.map +1 -1
- package/dist/pages/platform/segments/index.js +1 -1
- package/dist/pages/platform/segments/index.js.map +1 -1
- package/dist/pages/platform/users/detail.js +11 -3
- package/dist/pages/platform/users/detail.js.map +1 -1
- package/dist/pages/platform/users/index.js +1 -1
- package/dist/pages/platform/users/index.js.map +1 -1
- package/dist/pages/platform/workspaces/detail.js +1 -1
- package/dist/pages/platform/workspaces/detail.js.map +1 -1
- package/dist/pages/platform/workspaces/index.js +2 -2
- package/dist/pages/platform/workspaces/index.js.map +1 -1
- package/dist/pages/tenant/billing.js +2 -2
- package/dist/pages/tenant/billing.js.map +1 -1
- package/dist/stripe/client.d.ts +3 -0
- package/dist/stripe/client.js +16 -1
- package/dist/stripe/client.js.map +1 -1
- package/dist/stripe/customer-billing.js +1 -1
- package/dist/stripe/customer-billing.js.map +1 -1
- package/dist/stripe/subscription-cancellation.js +1 -1
- package/dist/stripe/subscription-cancellation.js.map +1 -1
- package/dist/stripe/upcoming-invoice.js +3 -3
- package/dist/stripe/upcoming-invoice.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.js.map +1 -1
- package/frontend-vue/app/build/PayInvoicePanel.vue +4 -8
- package/frontend-vue/app/build/PlanChangeReview.vue +3 -6
- package/frontend-vue/app/build/public/RegistrationCardField.vue +6 -3
- package/frontend-vue/app/build/segments/useSegmentCatalog.ts +7 -12
- package/frontend-vue/app/build/useWorkspaceName.ts +1 -2
- package/frontend-vue/app/build/users/useUserDetail.ts +8 -10
- package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +14 -7
- package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +11 -10
- package/frontend-vue/app/build/workspace-detail/useWorkspaceOverview.ts +16 -30
- package/frontend-vue/app/components/CustomerPortalButton.vue +6 -4
- package/frontend-vue/app/components/DataExport.vue +34 -54
- package/frontend-vue/app/components/DataExportHistory.vue +2 -7
- package/frontend-vue/app/components/IssueCreditNoteModal.vue +5 -4
- package/frontend-vue/app/components/MigrationStripeCheck.vue +11 -8
- package/frontend-vue/app/components/PastDueAlert.vue +8 -6
- package/frontend-vue/app/components/PastDueBanner.vue +4 -4
- package/frontend-vue/app/components/PaymentMethodCard.vue +7 -12
- package/frontend-vue/app/components/PlanAccessEditor.vue +31 -30
- package/frontend-vue/app/components/PlanCard.vue +2 -3
- package/frontend-vue/app/components/PlanEditorPreview.vue +27 -36
- package/frontend-vue/app/components/PlanUpgradeModal.vue +1 -1
- package/frontend-vue/app/components/PlatformNotes.vue +27 -28
- package/frontend-vue/app/components/Pricing.vue +16 -23
- package/frontend-vue/app/components/RefundButton.vue +62 -46
- package/frontend-vue/app/components/RetirePlanModal.vue +13 -7
- package/frontend-vue/app/components/SeatQuotaBanner.vue +9 -10
- package/frontend-vue/app/components/SegmentConditionsBuilder.vue +0 -1
- package/frontend-vue/app/components/SegmentRulesText.vue +1 -3
- package/frontend-vue/app/components/TenantBillingForm.vue +14 -19
- package/frontend-vue/app/components/TenantPlanCard.vue +19 -22
- package/frontend-vue/app/components/TrialEndingBanner.vue +5 -10
- package/frontend-vue/app/components/UserPlatformRoleCard.vue +8 -9
- package/frontend-vue/app/components/UserSegmentMatches.vue +8 -16
- package/frontend-vue/app/components/UserSummaryCard.vue +2 -4
- package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +13 -5
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +5 -1
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +8 -7
- package/frontend-vue/app/components/WorkspaceDetailHeader.vue +14 -4
- package/frontend-vue/app/components/WorkspaceSuspended.vue +27 -32
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +5 -16
- package/frontend-vue/app/composables/useBillingIdentity.ts +9 -5
- package/frontend-vue/app/composables/useBillingStatus.ts +8 -7
- package/frontend-vue/app/composables/useCurrentWorkspace.ts +6 -8
- package/frontend-vue/app/composables/useExportHistory.ts +67 -78
- package/frontend-vue/app/composables/useMountedData.ts +27 -0
- package/frontend-vue/app/composables/useMyWorkspaces.ts +24 -27
- package/frontend-vue/app/composables/useNextInvoice.ts +7 -6
- package/frontend-vue/app/composables/useOnDemandRead.ts +49 -0
- package/frontend-vue/app/composables/usePendingCheckout.ts +2 -1
- package/frontend-vue/app/composables/usePlanCatalog.ts +3 -9
- package/frontend-vue/app/composables/usePublicPricing.ts +24 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +2 -0
- package/frontend-vue/app/composables/useSeatQuota.ts +2 -6
- package/frontend-vue/app/composables/useTenantPlan.ts +26 -9
- package/frontend-vue/app/composables/useWorkspaceOverview.ts +2 -6
- package/frontend-vue/i18n/locales/saas-public-en-GB.json +1 -0
- package/frontend-vue/i18n/locales/saas-public-fr-FR.json +1 -0
- package/frontend-vue/package.json +1 -1
- package/package.json +4 -4
- package/frontend-vue/app/composables/useServerConfirm.ts +0 -44
- package/frontend-vue/app/composables/useSharedRequest.ts +0 -54
- package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +0 -52
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
3
3
|
import { SENTENCE_DAY_FORMAT } from '../build/day-formats'
|
|
4
4
|
|
|
5
5
|
/** Query parameter a delivered export link carries, set by the DMS. */
|
|
@@ -20,19 +20,34 @@ const { resolveApiError } = useApiErrorMessage()
|
|
|
20
20
|
const route = useDmsRoute()
|
|
21
21
|
const router = useDmsRouter()
|
|
22
22
|
const toast = useToast()
|
|
23
|
-
const { state, running, load,
|
|
24
|
-
useExportHistory()
|
|
23
|
+
const { state, running, load, start, download } = useExportHistory()
|
|
25
24
|
|
|
26
25
|
/** The export this visit watched finish, shown until the page is left. */
|
|
27
26
|
const finished = ref<ExportHistoryEntry | null>(null)
|
|
28
27
|
/** The e-mailed link this visit came from, once the server said it is gone. */
|
|
29
28
|
const expiredLinkJobId = ref<string | null>(null)
|
|
30
29
|
const isDownloading = ref(false)
|
|
31
|
-
|
|
30
|
+
// The export being built is read again every interval, in the browser, until
|
|
31
|
+
// it is done; a tick waits for a slow answer instead of piling up requests.
|
|
32
|
+
const runningStatus = useApiData<ExportJobStatus>(
|
|
33
|
+
() =>
|
|
34
|
+
running.value
|
|
35
|
+
? `${EXPORT_STATUS_ENDPOINT}/${encodeURIComponent(running.value.jobId)}`
|
|
36
|
+
: null,
|
|
37
|
+
{ server: false, refreshInterval: POLL_INTERVAL_MS, refreshOnPageRefresh: false },
|
|
38
|
+
)
|
|
32
39
|
|
|
33
40
|
const email = computed(() => user.value?.email ?? '')
|
|
34
41
|
const progress = computed(() =>
|
|
35
|
-
Math.min(
|
|
42
|
+
Math.min(
|
|
43
|
+
FULL_PROGRESS,
|
|
44
|
+
Math.round(
|
|
45
|
+
(runningStatus.placeholder.value ? null : runningStatus.data.value)
|
|
46
|
+
?.progress ??
|
|
47
|
+
running.value?.progress ??
|
|
48
|
+
0,
|
|
49
|
+
),
|
|
50
|
+
),
|
|
36
51
|
)
|
|
37
52
|
const isFinishedPartial = computed(() => !!finished.value?.result?.partial)
|
|
38
53
|
|
|
@@ -79,48 +94,17 @@ async function downloadFinished(): Promise<void> {
|
|
|
79
94
|
})
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return await readStatus(jobId).catch(() => null)
|
|
94
|
-
} finally {
|
|
95
|
-
isReadingStatus = false
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function pollRunning(): Promise<void> {
|
|
100
|
-
const entry = running.value
|
|
101
|
-
if (!entry) return
|
|
102
|
-
const status = await readRunningStatus(entry.jobId)
|
|
103
|
-
if (!status) return
|
|
104
|
-
if (status.status === EXPORT_STATUS.pending) {
|
|
105
|
-
entry.progress = status.progress
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
finished.value = { ...entry, ...status }
|
|
109
|
-
await load()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function stopPolling(): void {
|
|
113
|
-
if (pollTimer) clearInterval(pollTimer)
|
|
114
|
-
pollTimer = null
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** One timer at most, following the export being built, if any. */
|
|
118
|
-
function syncPolling(): void {
|
|
119
|
-
stopPolling()
|
|
120
|
-
if (running.value) pollTimer = setInterval(pollRunning, POLL_INTERVAL_MS)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
watch(() => running.value?.jobId, syncPolling)
|
|
97
|
+
watch(
|
|
98
|
+
() => runningStatus.data.value,
|
|
99
|
+
async (status) => {
|
|
100
|
+
const entry = running.value
|
|
101
|
+
if (!status || !entry || runningStatus.placeholder.value) return
|
|
102
|
+
if (status.status === EXPORT_STATUS.pending) return
|
|
103
|
+
if (finished.value?.jobId === entry.jobId) return
|
|
104
|
+
finished.value = { ...entry, ...status }
|
|
105
|
+
await load()
|
|
106
|
+
},
|
|
107
|
+
)
|
|
124
108
|
|
|
125
109
|
async function clearDeliveredLink(): Promise<void> {
|
|
126
110
|
const { [EXPORT_JOB_QUERY_PARAM]: _consumed, ...query } = route.query
|
|
@@ -149,13 +133,9 @@ async function consumeDeliveredLink(): Promise<void> {
|
|
|
149
133
|
}
|
|
150
134
|
}
|
|
151
135
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
await consumeDeliveredLink()
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
onBeforeUnmount(stopPolling)
|
|
136
|
+
// The history is read with the page, on the server too: the browser polls
|
|
137
|
+
// the export it shows running, and downloads the archive a link names.
|
|
138
|
+
onMounted(consumeDeliveredLink)
|
|
159
139
|
</script>
|
|
160
140
|
|
|
161
141
|
<template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
const KEYS = 'saas.workspace.data_export.history'
|
|
5
5
|
const SKELETON_ROWS = 3
|
|
@@ -30,8 +30,7 @@ const ROW_TONES: Record<ExportRowState, Tone> = {
|
|
|
30
30
|
const { t, locale } = useI18n()
|
|
31
31
|
const { resolveApiError } = useApiErrorMessage()
|
|
32
32
|
const toast = useToast()
|
|
33
|
-
const { state, running, load,
|
|
34
|
-
useExportHistory()
|
|
33
|
+
const { state, running, load, goToPage, start, download } = useExportHistory()
|
|
35
34
|
|
|
36
35
|
const downloadingJobId = ref<string | null>(null)
|
|
37
36
|
|
|
@@ -106,10 +105,6 @@ function requestAnother(): Promise<void> {
|
|
|
106
105
|
notifyError(error, 'saas.workspace.data_export.error.start'),
|
|
107
106
|
)
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
onMounted(() => {
|
|
111
|
-
void refresh()
|
|
112
|
-
})
|
|
113
108
|
</script>
|
|
114
109
|
|
|
115
110
|
<template>
|
|
@@ -50,14 +50,15 @@ const texts = useCreditNoteTexts({
|
|
|
50
50
|
creditedAfter: draft.creditedAfter,
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
+
const previewRead = useOnDemandRead<CreditNotePreview>(
|
|
54
|
+
() => `${PREVIEW_ENDPOINT}/${encodeURIComponent(props.rowData?._id ?? '')}`,
|
|
55
|
+
)
|
|
56
|
+
|
|
53
57
|
async function load(): Promise<void> {
|
|
54
|
-
const invoiceId = props.rowData?._id
|
|
55
58
|
isLoading.value = true
|
|
56
59
|
loadError.value = null
|
|
57
60
|
try {
|
|
58
|
-
preview.value = await
|
|
59
|
-
`${PREVIEW_ENDPOINT}/${encodeURIComponent(invoiceId ?? '')}`,
|
|
60
|
-
)
|
|
61
|
+
preview.value = await previewRead.read()
|
|
61
62
|
draft.reset(preview.value)
|
|
62
63
|
} catch (error) {
|
|
63
64
|
loadError.value = resolveApiError(error, `${TEXT}.load_failed`)
|
|
@@ -34,7 +34,7 @@ const props = defineProps<{ rowData?: MigrationWorkspaceRow }>()
|
|
|
34
34
|
const KeyValueListBlock = resolveDmsComponent('dms-key-value-list-block')
|
|
35
35
|
const { $authFetch } = useAuthFetch()
|
|
36
36
|
const { t } = useI18n()
|
|
37
|
-
const { confirmFrom } =
|
|
37
|
+
const { confirmFrom } = useConfirmFrom()
|
|
38
38
|
const toast = useToast()
|
|
39
39
|
const { resolveApiError } = useApiErrorMessage()
|
|
40
40
|
|
|
@@ -52,13 +52,15 @@ const resolution = computed(() =>
|
|
|
52
52
|
isSettled.value ? null : (reading.value?.resolution ?? null),
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
const stripeRead = useOnDemandRead<StripeReading>(() =>
|
|
56
|
+
workspaceApi.value ? `${workspaceApi.value}/stripe` : null,
|
|
57
|
+
)
|
|
58
|
+
|
|
55
59
|
async function load(): Promise<void> {
|
|
56
60
|
if (!workspaceApi.value) return
|
|
57
61
|
loadFailed.value = false
|
|
58
62
|
try {
|
|
59
|
-
reading.value = await
|
|
60
|
-
`${workspaceApi.value}/stripe`,
|
|
61
|
-
)
|
|
63
|
+
reading.value = await stripeRead.read()
|
|
62
64
|
} catch {
|
|
63
65
|
loadFailed.value = true
|
|
64
66
|
}
|
|
@@ -71,14 +73,15 @@ async function settle(kind: UncertainResolution): Promise<void> {
|
|
|
71
73
|
})
|
|
72
74
|
isSettled.value = true
|
|
73
75
|
toast.add({ color: 'success', title: t(`${DETAIL}.${kind}_done`) })
|
|
74
|
-
|
|
76
|
+
// The dialog closes once the page shows the settlement.
|
|
77
|
+
await refreshPageBlocks()
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
async function openSettlement(kind: UncertainResolution): Promise<void> {
|
|
78
81
|
try {
|
|
79
|
-
await confirmFrom(`${workspaceApi.value}/dialogs/${kind}`,
|
|
80
|
-
settle(kind),
|
|
81
|
-
)
|
|
82
|
+
await confirmFrom(`${workspaceApi.value}/dialogs/${kind}`, {
|
|
83
|
+
onConfirm: () => settle(kind),
|
|
84
|
+
})
|
|
82
85
|
} catch (error) {
|
|
83
86
|
toast.add({
|
|
84
87
|
color: 'error',
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
import PayInvoiceDialog from '../build/PayInvoiceDialog.vue'
|
|
4
4
|
import { LABEL_DAY_FORMAT, SENTENCE_DAY_FORMAT } from '../build/day-formats'
|
|
5
5
|
|
|
6
|
+
// Drawn as two roots (the alert, then the payment dialog): the page's block
|
|
7
|
+
// attributes have no single element to land on.
|
|
8
|
+
defineOptions({ inheritAttrs: false })
|
|
9
|
+
|
|
6
10
|
interface TimelineStep {
|
|
7
11
|
key: string
|
|
8
12
|
date: string
|
|
@@ -14,7 +18,7 @@ const SUSPENDED_STATUS = 'suspended'
|
|
|
14
18
|
const UNPAID_STATUSES = new Set(['past_due', SUSPENDED_STATUS])
|
|
15
19
|
const KEY_PREFIX = 'saas.tenant_billing.past_due'
|
|
16
20
|
|
|
17
|
-
const { data,
|
|
21
|
+
const { data, status: readStatus, refresh } = useBillingStatus()
|
|
18
22
|
const { formatMinorUnits } = useMoneyFormat()
|
|
19
23
|
const { open: openPayment } = usePayInvoice()
|
|
20
24
|
const { t, locale } = useI18n()
|
|
@@ -126,15 +130,13 @@ const DOT_CLASSES: Record<TimelineStep['tone'], string> = {
|
|
|
126
130
|
function payInvoice(): void {
|
|
127
131
|
if (invoice.value) openPayment(invoice.value)
|
|
128
132
|
}
|
|
129
|
-
|
|
130
|
-
onMounted(load)
|
|
131
133
|
</script>
|
|
132
134
|
|
|
133
135
|
<template>
|
|
134
136
|
<DmsSaasLoadFailure
|
|
135
|
-
v-if="error && !data"
|
|
137
|
+
v-if="readStatus === 'error' && !data"
|
|
136
138
|
:title="$t(`${KEY_PREFIX}.load_failed`)"
|
|
137
|
-
@retry="refresh"
|
|
139
|
+
@retry="refresh()"
|
|
138
140
|
/>
|
|
139
141
|
|
|
140
142
|
<DmsBanner
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
import PayInvoiceDialog from '../build/PayInvoiceDialog.vue'
|
|
4
4
|
import { useWorkspaceName } from '../build/useWorkspaceName'
|
|
5
5
|
|
|
@@ -17,7 +17,8 @@ const DEADLINE_FORMAT: Intl.DateTimeFormatOptions = {
|
|
|
17
17
|
month: 'long',
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const { data
|
|
20
|
+
const { data: billingStatus } = useBillingStatus({ server: false })
|
|
21
|
+
const data = useMountedData(billingStatus)
|
|
21
22
|
const workspaceName = useWorkspaceName()
|
|
22
23
|
const { formatMinorUnits } = useMoneyFormat()
|
|
23
24
|
const { open: openPayment } = usePayInvoice()
|
|
@@ -63,8 +64,6 @@ const ownerMailto = computed(() =>
|
|
|
63
64
|
function payInvoice(): void {
|
|
64
65
|
if (invoice.value) openPayment(invoice.value)
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
onMounted(load)
|
|
68
67
|
</script>
|
|
69
68
|
|
|
70
69
|
<template>
|
|
@@ -78,6 +77,7 @@ onMounted(load)
|
|
|
78
77
|
<template v-if="isOwnerStrip">
|
|
79
78
|
<DmsSaasCustomerPortalButton
|
|
80
79
|
label-key="saas.tenant_billing.past_due.update_card"
|
|
80
|
+
is-deferred
|
|
81
81
|
icon="i-ph-credit-card"
|
|
82
82
|
variant="ghost"
|
|
83
83
|
size="xs"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
|
|
4
4
|
const UNPAID_STATUSES = new Set(['past_due', 'suspended'])
|
|
5
5
|
const KEY_PREFIX = 'saas.tenant_billing.payment_method'
|
|
@@ -8,8 +8,8 @@ const DAY_FORMAT: Intl.DateTimeFormatOptions = {
|
|
|
8
8
|
month: 'short',
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const { data,
|
|
12
|
-
const { data: plan
|
|
11
|
+
const { data, status: readStatus, refresh } = useBillingStatus()
|
|
12
|
+
const { data: plan } = useTenantPlan()
|
|
13
13
|
const { open: openPlanComparison } = usePlanComparison()
|
|
14
14
|
const { open: openPayment } = usePayInvoice()
|
|
15
15
|
const { locale } = useI18n()
|
|
@@ -46,15 +46,10 @@ function payWithAnotherCard(): void {
|
|
|
46
46
|
hostedInvoiceUrl: unpaid.hostedInvoiceUrl,
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
onMounted(() => {
|
|
51
|
-
void loadPlan()
|
|
52
|
-
return load()
|
|
53
|
-
})
|
|
54
49
|
</script>
|
|
55
50
|
|
|
56
51
|
<template>
|
|
57
|
-
<DmsCard :title="$t(`${KEY_PREFIX}.title`)">
|
|
52
|
+
<DmsCard class="grow" :title="$t(`${KEY_PREFIX}.title`)">
|
|
58
53
|
<template v-if="data && isTenantOwner && card" #actions>
|
|
59
54
|
<DmsStatusPill
|
|
60
55
|
:tone="needsUpdate ? 'warning' : 'success'"
|
|
@@ -66,15 +61,15 @@ onMounted(() => {
|
|
|
66
61
|
/>
|
|
67
62
|
</template>
|
|
68
63
|
|
|
69
|
-
<div v-if="!data &&
|
|
64
|
+
<div v-if="!data && readStatus !== 'error'" class="flex flex-col gap-3">
|
|
70
65
|
<USkeleton class="h-14 w-full" />
|
|
71
66
|
<USkeleton class="h-4 w-2/3" />
|
|
72
67
|
</div>
|
|
73
68
|
|
|
74
69
|
<DmsSaasLoadFailure
|
|
75
|
-
v-else-if="error && !data"
|
|
70
|
+
v-else-if="readStatus === 'error' && !data"
|
|
76
71
|
:title="$t(`${KEY_PREFIX}.load_failed`)"
|
|
77
|
-
@retry="refresh"
|
|
72
|
+
@retry="refresh()"
|
|
78
73
|
/>
|
|
79
74
|
|
|
80
75
|
<p v-else-if="!isTenantOwner" class="text-muted text-sm">
|
|
@@ -28,21 +28,26 @@ const props = defineProps<{
|
|
|
28
28
|
|
|
29
29
|
const emit = defineEmits<{ 'update:modelValue': [value: PlanAccess] }>()
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const EMPTY_CATALOG: PlanCatalog = {
|
|
32
|
+
plans: [],
|
|
33
|
+
features: [],
|
|
34
|
+
newPlanPermissions: [],
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
const planCatalog = usePlanCatalog()
|
|
38
|
+
const permissionsTree = useApiData<PermissionNode[]>(
|
|
39
|
+
props.permissionsTreeUrl ?? '/api/saas/plans/permissions-tree',
|
|
40
|
+
)
|
|
33
41
|
const route = useDmsRoute()
|
|
34
42
|
const { t } = useI18n()
|
|
35
43
|
const { processI18n } = useTranslation()
|
|
36
44
|
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
37
45
|
|
|
38
|
-
const catalog =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const tree = ref<PermissionNode[]>([])
|
|
44
|
-
const isLoading = ref(true)
|
|
45
|
-
const hasError = ref(false)
|
|
46
|
+
const catalog = computed(() => planCatalog.data.value ?? EMPTY_CATALOG)
|
|
47
|
+
const tree = computed(() => permissionsTree.data.value ?? [])
|
|
48
|
+
const hasError = computed(() =>
|
|
49
|
+
[planCatalog, permissionsTree].some((read) => read.status.value === 'error'),
|
|
50
|
+
)
|
|
46
51
|
const isPickerOpen = ref(false)
|
|
47
52
|
|
|
48
53
|
// A new plan starts with no value: no parent, nothing of its own.
|
|
@@ -184,34 +189,30 @@ function isBlank(value: PlanAccess): boolean {
|
|
|
184
189
|
|
|
185
190
|
// A new plan starts with every permission checked, as the seeded plans hold
|
|
186
191
|
// them, for the operator to uncheck; a duplicate keeps the plan it copies.
|
|
192
|
+
// The form's value changes from the browser: until then a new plan shows the
|
|
193
|
+
// placeholder, on the server as in the browser's first render.
|
|
194
|
+
const isNewBlankPlan = !currentPlanId.value && !route.query.duplicate
|
|
195
|
+
const isSeeding = ref(isNewBlankPlan)
|
|
196
|
+
const isLoading = computed(
|
|
197
|
+
() =>
|
|
198
|
+
!hasError.value &&
|
|
199
|
+
(isSeeding.value || !planCatalog.data.value || !permissionsTree.data.value),
|
|
200
|
+
)
|
|
201
|
+
|
|
187
202
|
function startNewPlanWithEveryPermission(): void {
|
|
188
|
-
if (
|
|
189
|
-
if (!isBlank(access.value)) return
|
|
203
|
+
if (!isNewBlankPlan || !isBlank(access.value)) return
|
|
190
204
|
update({ extraPermissions: catalog.value.newPlanPermissions })
|
|
191
205
|
}
|
|
192
206
|
|
|
193
207
|
async function load(): Promise<void> {
|
|
194
|
-
|
|
195
|
-
hasError.value = false
|
|
196
|
-
try {
|
|
197
|
-
const [loadedCatalog, loadedTree] = await Promise.all([
|
|
198
|
-
planCatalog.refresh(),
|
|
199
|
-
$authFetch<PermissionNode[]>(
|
|
200
|
-
props.permissionsTreeUrl ?? '/api/saas/plans/permissions-tree',
|
|
201
|
-
),
|
|
202
|
-
])
|
|
203
|
-
if (!loadedCatalog) throw new Error('catalog unavailable')
|
|
204
|
-
catalog.value = loadedCatalog
|
|
205
|
-
tree.value = loadedTree
|
|
206
|
-
startNewPlanWithEveryPermission()
|
|
207
|
-
} catch {
|
|
208
|
-
hasError.value = true
|
|
209
|
-
} finally {
|
|
210
|
-
isLoading.value = false
|
|
211
|
-
}
|
|
208
|
+
await Promise.all([planCatalog.refresh(), permissionsTree.refresh()])
|
|
212
209
|
}
|
|
213
210
|
|
|
214
|
-
onMounted(
|
|
211
|
+
onMounted(async () => {
|
|
212
|
+
await Promise.all([planCatalog, permissionsTree])
|
|
213
|
+
if (planCatalog.data.value) startNewPlanWithEveryPermission()
|
|
214
|
+
isSeeding.value = false
|
|
215
|
+
})
|
|
215
216
|
</script>
|
|
216
217
|
|
|
217
218
|
<template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
import {
|
|
4
4
|
type CatalogFeature,
|
|
5
5
|
type CatalogPlanRow,
|
|
@@ -199,7 +199,6 @@ function toggleSale(): void {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
// Every card asks as it mounts: the cards of a page share the one request.
|
|
202
|
-
onMounted(catalog.refresh)
|
|
203
202
|
</script>
|
|
204
203
|
|
|
205
204
|
<template>
|
|
@@ -321,7 +320,7 @@ onMounted(catalog.refresh)
|
|
|
321
320
|
</div>
|
|
322
321
|
|
|
323
322
|
<p
|
|
324
|
-
v-if="catalog.
|
|
323
|
+
v-if="catalog.status.value === 'error'"
|
|
325
324
|
class="text-muted flex items-center gap-1.5 text-xs"
|
|
326
325
|
>
|
|
327
326
|
<UIcon name="i-ph-warning" class="text-warning size-4" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, type Ref } from 'vue'
|
|
3
3
|
import { useLiveFormValues } from '../build/composables/useLiveFormValues'
|
|
4
4
|
import {
|
|
5
5
|
cardFeatures,
|
|
@@ -60,22 +60,26 @@ const props = defineProps<{
|
|
|
60
60
|
formKey?: string
|
|
61
61
|
}>()
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
const { t, locale } = useI18n()
|
|
65
|
-
const planDescription = usePlanDescription()
|
|
66
|
-
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
67
|
-
|
|
68
|
-
const saved = ref<PlanDraft | null>(null)
|
|
69
|
-
const context = ref<EditorContext | null>(null)
|
|
70
|
-
const catalog = ref<PlanCatalog>({
|
|
63
|
+
const EMPTY_CATALOG: PlanCatalog = {
|
|
71
64
|
plans: [],
|
|
72
65
|
features: [],
|
|
73
66
|
newPlanPermissions: [],
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { t, locale } = useI18n()
|
|
70
|
+
const planDescription = usePlanDescription()
|
|
71
|
+
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
77
72
|
|
|
78
73
|
const planId = computed(() => props.routeParams?.id)
|
|
74
|
+
// A new plan has nothing saved and no Stripe context yet.
|
|
75
|
+
const savedPlan = useApiData<PlanDraft>(() =>
|
|
76
|
+
planId.value ? `${PLANS_ENDPOINT}/${planId.value}` : null,
|
|
77
|
+
)
|
|
78
|
+
const editorContext = useApiData<EditorContext>(() =>
|
|
79
|
+
planId.value ? `${PLANS_ENDPOINT}/${planId.value}/editor-context` : null,
|
|
80
|
+
)
|
|
81
|
+
const saved = savedPlan.data
|
|
82
|
+
const context = editorContext.data
|
|
79
83
|
// The form declared beside the preview, in the same grid row.
|
|
80
84
|
const formComponentId = computed(() =>
|
|
81
85
|
props.componentId
|
|
@@ -84,6 +88,16 @@ const formComponentId = computed(() =>
|
|
|
84
88
|
)
|
|
85
89
|
const live = useLiveFormValues(() => formComponentId.value) as Ref<PlanDraft | null>
|
|
86
90
|
const planCatalog = usePlanCatalog()
|
|
91
|
+
const catalog = computed(() => planCatalog.data.value ?? EMPTY_CATALOG)
|
|
92
|
+
const reads = [planCatalog, savedPlan, editorContext]
|
|
93
|
+
const hasError = computed(() =>
|
|
94
|
+
reads.some((read) => read.status.value === 'error'),
|
|
95
|
+
)
|
|
96
|
+
const isLoading = computed(
|
|
97
|
+
() =>
|
|
98
|
+
!hasError.value &&
|
|
99
|
+
(!planCatalog.data.value || reads.some((read) => read.pending.value)),
|
|
100
|
+
)
|
|
87
101
|
const draft = computed<PlanDraft>(() => live.value ?? saved.value ?? {})
|
|
88
102
|
const currency = computed(() => draft.value.currency ?? 'EUR')
|
|
89
103
|
const price = computed(() => Number(draft.value.price ?? 0))
|
|
@@ -187,31 +201,8 @@ const isPriceChanged = computed(() => {
|
|
|
187
201
|
const productUrl = computed(() => context.value?.stripeProductUrl ?? undefined)
|
|
188
202
|
|
|
189
203
|
async function load(): Promise<void> {
|
|
190
|
-
|
|
191
|
-
hasError.value = false
|
|
192
|
-
try {
|
|
193
|
-
const [loadedCatalog, plan, editor] = await Promise.all([
|
|
194
|
-
planCatalog.refresh(),
|
|
195
|
-
planId.value
|
|
196
|
-
? $authFetch<PlanDraft>(`${PLANS_ENDPOINT}/${planId.value}`)
|
|
197
|
-
: null,
|
|
198
|
-
planId.value
|
|
199
|
-
? $authFetch<EditorContext>(
|
|
200
|
-
`${PLANS_ENDPOINT}/${planId.value}/editor-context`,
|
|
201
|
-
)
|
|
202
|
-
: null,
|
|
203
|
-
])
|
|
204
|
-
if (loadedCatalog) catalog.value = loadedCatalog
|
|
205
|
-
saved.value = plan
|
|
206
|
-
context.value = editor
|
|
207
|
-
} catch {
|
|
208
|
-
hasError.value = true
|
|
209
|
-
} finally {
|
|
210
|
-
isLoading.value = false
|
|
211
|
-
}
|
|
204
|
+
await Promise.all(reads.map((read) => read.refresh()))
|
|
212
205
|
}
|
|
213
|
-
|
|
214
|
-
onMounted(() => void load())
|
|
215
206
|
</script>
|
|
216
207
|
|
|
217
208
|
<template>
|
|
@@ -21,7 +21,7 @@ const toast = useToast()
|
|
|
21
21
|
const { t, locale } = useI18n()
|
|
22
22
|
const { resolveApiError } = useApiErrorMessage()
|
|
23
23
|
const identity = useBillingIdentity()
|
|
24
|
-
const { changePlan, previewChange } =
|
|
24
|
+
const { changePlan, previewChange } = useTenantPlanChanges()
|
|
25
25
|
const { offerFor: offerPendingCheckout } = usePendingCheckout()
|
|
26
26
|
const { formatMajorUnits, formatMinorUnits } = useMoneyFormat()
|
|
27
27
|
const planIntervalLabel = usePlanIntervalLabel('saas.workspace.plan.interval')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Internal notes operators keep on a workspace or a user (`targetType`),
|
|
@@ -44,11 +44,28 @@ const baseUrl = computed(
|
|
|
44
44
|
() => `/api/saas/platform-notes/${props.targetType}/${targetId.value}`,
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
const notes = ref<PlatformNote[]>([])
|
|
48
|
-
const total = ref(0)
|
|
49
47
|
const isExpanded = ref(false)
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// The newest notes, or all of them once expanded: the previous ones stay on
|
|
49
|
+
// screen while the longer page loads.
|
|
50
|
+
const page = useApiData<NotesPage>(
|
|
51
|
+
() => (targetId.value ? baseUrl.value : null),
|
|
52
|
+
{
|
|
53
|
+
query: () => ({
|
|
54
|
+
page: 1,
|
|
55
|
+
pageSize: isExpanded.value ? ALL_COUNT : PREVIEW_COUNT,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
const notes = computed(() => page.data.value?.items ?? [])
|
|
60
|
+
const total = computed(() => page.data.value?.total ?? 0)
|
|
61
|
+
const isLoading = computed(
|
|
62
|
+
() => page.status.value === 'pending' || page.status.value === 'idle',
|
|
63
|
+
)
|
|
64
|
+
const loadError = computed(() =>
|
|
65
|
+
page.error.value
|
|
66
|
+
? resolveApiError(page.error.value, `${N}.error.load`)
|
|
67
|
+
: null,
|
|
68
|
+
)
|
|
52
69
|
const isSubmitting = ref(false)
|
|
53
70
|
const draft = ref('')
|
|
54
71
|
|
|
@@ -83,29 +100,12 @@ function when(note: PlatformNote): string {
|
|
|
83
100
|
)
|
|
84
101
|
}
|
|
85
102
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
isLoading.value = true
|
|
89
|
-
loadError.value = null
|
|
90
|
-
try {
|
|
91
|
-
const page = await $authFetch<NotesPage>(baseUrl.value, {
|
|
92
|
-
query: {
|
|
93
|
-
page: 1,
|
|
94
|
-
pageSize: isExpanded.value ? ALL_COUNT : PREVIEW_COUNT,
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
notes.value = page.items
|
|
98
|
-
total.value = page.total
|
|
99
|
-
} catch (error) {
|
|
100
|
-
loadError.value = resolveApiError(error, `${N}.error.load`)
|
|
101
|
-
} finally {
|
|
102
|
-
isLoading.value = false
|
|
103
|
-
}
|
|
103
|
+
function load(): Promise<void> {
|
|
104
|
+
return page.refresh()
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
function showAll(): void {
|
|
107
108
|
isExpanded.value = true
|
|
108
|
-
void load()
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
async function submit(): Promise<void> {
|
|
@@ -117,7 +117,8 @@ async function submit(): Promise<void> {
|
|
|
117
117
|
body: { content: trimmed.value },
|
|
118
118
|
})
|
|
119
119
|
draft.value = ''
|
|
120
|
-
|
|
120
|
+
// The note is listed before the button comes back.
|
|
121
|
+
await refreshPageBlocks()
|
|
121
122
|
} catch (error) {
|
|
122
123
|
toast.add({
|
|
123
124
|
color: 'error',
|
|
@@ -142,10 +143,8 @@ async function remove(note: PlatformNote): Promise<void> {
|
|
|
142
143
|
})
|
|
143
144
|
},
|
|
144
145
|
})
|
|
145
|
-
if (isConfirmed)
|
|
146
|
+
if (isConfirmed) refreshPageBlocks()
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
-
onMounted(load)
|
|
149
148
|
</script>
|
|
150
149
|
|
|
151
150
|
<template>
|