Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(cloud): show quota notice in modal and hide create trigger when blocked

Timothy Yine163bfccc250
diff --git a/apps/cloud/app/components/CloudSiteCreate.vue b/apps/cloud/app/components/CloudSiteCreate.vue
index 5f5c6bd1..9c4e8589 100644
--- a/apps/cloud/app/components/CloudSiteCreate.vue
+++ b/apps/cloud/app/components/CloudSiteCreate.vue
@@ -8,6 +8,7 @@ const quota = useCloudQuota(() => props.workspaceId)
const admission = computed(() => quota.gate('sites'))
const checking = ref(false)
const open = ref(false)
+const quotaOpen = ref(false)
const name = ref('')
const slug = ref('')
const busy = ref(false)
@@ -24,7 +25,11 @@ async function show() {
checking.value = true
await quota.refresh()
checking.value = false
- if (!admission.value.allowed || quota.error.value) return
+ if (!admission.value.allowed || quota.error.value) {
+ quotaOpen.value = true
+ return
+ }
+ quotaOpen.value = false
open.value = true
await nextTick()
document.getElementById('site-name')?.focus()
@@ -71,17 +76,32 @@ async function create() {
v-if="!open"
id="create-site-trigger"
size="sm"
- :disabled="!admission.allowed || !!quota.error.value || checking"
+ :disabled="checking"
:loading="checking"
@click="show"
><Plus :size="15" />{{ $t('cloud.messages.createSite') }}</CloudButton
>
</div>
- <CloudQuotaNotice
- :reason="admission.reason"
- :error="!!quota.error.value"
- @retry="quota.refresh()"
- />
+ <UModal
+ v-model:open="quotaOpen"
+ :title="$t('cloud.messages.createASite')"
+ >
+ <template #body>
+ <CloudQuotaNotice
+ :reason="admission.reason"
+ :error="!!quota.error.value"
+ @retry="show"
+ />
+ </template>
+ <template #footer>
+ <CloudButton
+ variant="secondary"
+ @click="quotaOpen = false"
+ >
+ {{ $t('cloud.messages.cancel') }}
+ </CloudButton>
+ </template>
+ </UModal>
<CloudCard
v-if="open"
class="cf-create-panel"
diff --git a/apps/cloud/app/pages/workspace.vue b/apps/cloud/app/pages/workspace.vue
index cbb91d62..72b5f845 100644
--- a/apps/cloud/app/pages/workspace.vue
+++ b/apps/cloud/app/pages/workspace.vue
@@ -2,6 +2,7 @@
import { ArrowUpRight, Images, SlidersHorizontal } from 'lucide-vue-next'
import type { EntrySiteCatalog } from '@chronoframe/contracts/entry'
import { allowance } from '../utils/billing-format'
+import { quotaGate } from '../utils/quota-gate'
definePageMeta({ layout: 'portal' })
const { t, locale } = useI18n(),
billing = useWorkspaceBilling()
@@ -147,7 +148,11 @@ useSeoMeta({
class="h-28 w-full"
/>
<CloudSiteCreate
- v-if="data && billing.workspaces.value[0]?.owned"
+ v-if="
+ data &&
+ billing.workspaces.value[0]?.owned &&
+ quotaGate(data, 'sites').allowed
+ "
:workspace-id="data.workspace.id"
:workspace-name="data.workspace.name"
/>