Skip to content

Commit

Permalink
Show only the size limit for the bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
ernstmul committed Jan 20, 2025
1 parent 7f9c5d4 commit 860cc5e
Showing 1 changed file with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
<script lang="ts">
import { Alert, CustomId } from '$lib/components';
import { BillingPlan } from '$lib/constants';
import { page } from '$app/stores';
import { Pill } from '$lib/elements';
import { Button, FormList, InputFile } from '$lib/elements/forms';
import { FormList, InputFile } from '$lib/elements/forms';
import { humanFileSize, sizeToBytes } from '$lib/helpers/sizeConvertion';
import WizardStep from '$lib/layout/wizardStep.svelte';
import { tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization, currentPlan } from '$lib/stores/organization';
import { currentPlan } from '$lib/stores/organization';
import { isCloud } from '$lib/system';
import { bucket } from '../store';
import { createFile } from './store';
import { base } from '$app/paths';
let showCustomId = false;
let fileError: string = null;
const service = $currentPlan['fileSize'];
const projectId = $page.params.project;
</script>

<WizardStep>
<svelte:fragment slot="title">File</svelte:fragment>
<svelte:fragment slot="subtitle">Upload a file to add it to your bucket.</svelte:fragment>

{#if isCloud}
{@const size = humanFileSize(sizeToBytes(service, 'MB', 1000))}
{@const plan = tierToPlan($organization?.billingPlan)}
{#if isCloud && fileError === 'File size exceeds the limit'}
{@const size = humanFileSize($bucket.maximumFileSize ?? sizeToBytes(service, 'MB', 1000))}
<Alert type="info">
<p class="text">
The {plan.name} plan has a maximum upload file size limit of {Math.floor(
parseInt(size.value)
)}{size.unit}.
{#if $organization?.billingPlan === BillingPlan.FREE}
Upgrade to allow files of a larger size.
{/if}
The maximum file upload size for this bucket is {parseInt(size.value)}{size.unit}.
Edit this number in your
<a
href={`${base}/project-${projectId}/storage/bucket-${$bucket.$id}/settings`}
style:text-decoration="underline">bucket settings</a
>.
</p>
<svelte:fragment slot="action">
{#if $organization?.billingPlan === BillingPlan.FREE}
<div class="alert-buttons u-flex">
<Button text href={$upgradeURL}>Upgrade plan</Button>
</div>
{/if}
</svelte:fragment>
</Alert>
{/if}

Expand All @@ -47,6 +41,7 @@
required
bind:files={$createFile.files}
allowedFileExtensions={$bucket.allowedFileExtensions}
bind:error={fileError}
maxSize={isCloud
? $bucket.maximumFileSize
: ($bucket.maximumFileSize ?? sizeToBytes(service, 'MB', 1000))} />
Expand Down

0 comments on commit 860cc5e

Please sign in to comment.