Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@5aca249",
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@67c988c",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
"@stripe/stripe-js": "^3.5.0",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/lib/helpers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export function removeFile(file: File, files: FileList) {
return dataTransfer.files;
}

export enum InvalidFileType {
SIZE = 'invalid_size',
EXTENSION = 'invalid_extension'
}

export const defaultIgnore = `
### Node ###
# Logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Icon, Layout, Tooltip, Typography, Upload } from '@appwrite.io/pink-svelte';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';
import { page } from '$app/state';
import { sdk } from '$lib/stores/sdk';
import { invalidate } from '$app/navigation';
Expand Down Expand Up @@ -36,6 +36,17 @@
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .txt files allowed';
} else if (reason === InvalidFileType.SIZE) {
error = 'File size exceeds 5MB';
} else {
error = 'Invalid file';
}
}

$: filesList = files?.length
? Array.from(files).map((f) => {
return {
Expand All @@ -61,7 +72,12 @@
<Typography.Text color="--fgcolor-neutral-primary">
Upload a .txt file with your DNS records
</Typography.Text>
<Upload.Dropzone bind:files extensions={['txt']}>
<Upload.Dropzone
bind:files
extensions={['txt']}
maxSize={5000000}
required
on:invalid={handleInvalid}>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack
Expand All @@ -80,7 +96,7 @@
>Only .txt files allowed</svelte:fragment>
</Tooltip>
</Layout.Stack>
<Typography.Caption variant="400">Max file size 10MB</Typography.Caption>
<Typography.Caption variant="400">Max file size 5MB</Typography.Caption>
</Layout.Stack>
</Layout.Stack>
</Upload.Dropzone>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import Configuration from './configuration.svelte';
import { getIconFromRuntime } from '$lib/stores/runtimes';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';

export let data;

Expand Down Expand Up @@ -122,6 +122,26 @@
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
message: 'Only .tar.gz files allowed'
});
} else if (reason === InvalidFileType.SIZE) {
addNotification({
type: 'error',
message: 'File size exceeds 10MB'
});
} else {
addNotification({
type: 'error',
message: 'Invalid file'
});
}
}

$: filesList = files?.length
? Array.from(files).map((f) => {
return {
Expand Down Expand Up @@ -157,7 +177,8 @@
title="Upload function"
extensions={['gz', 'tar']}
maxSize={10000000}
required>
required
on:invalid={handleInvalid}>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
Expand Down Expand Up @@ -36,6 +36,17 @@
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .tar.gz files allowed';
} else if (reason === InvalidFileType.SIZE) {
error = 'File size exceeds 10MB';
} else {
error = 'Invalid file';
}
}

$: filesList = files?.length
? Array.from(files).map((f) => {
return {
Expand All @@ -55,7 +66,12 @@
<Typography.Text color="--fgcolor-neutral-primary">
Upload a tar.gz file containing your function source code
</Typography.Text>
<Upload.Dropzone extensions={['gz', 'tar']} bind:files maxSize={10000000} required>
<Upload.Dropzone
extensions={['gz', 'tar']}
bind:files
maxSize={10000000}
required
on:invalid={handleInvalid}>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import TooltipPopover from './tooltipPopover.svelte';
import { Icon, Tooltip, Upload, Layout, Typography } from '@appwrite.io/pink-svelte';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';
import { addNotification } from '$lib/stores/notifications';

export let files: Record<string, FileList>;

Expand Down Expand Up @@ -55,6 +56,22 @@
image: input.popoverImage
};
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;

if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
message: 'Only .json files allowed'
});
} else {
addNotification({
type: 'error',
message: 'Invalid file'
});
}
}
</script>

{#if input.type === 'text'}
Expand Down Expand Up @@ -104,6 +121,7 @@
</InputPhone>
{:else if input.type === 'file'}
<Upload.Dropzone
on:invalid={handleInvalid}
extensions={['json']}
bind:files={files[input.name]}
required={!input.optional}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { organization } from '$lib/stores/organization';
import { consoleVariables } from '$routes/(console)/store';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';

export let data;
let showExitModal = false;
Expand Down Expand Up @@ -116,6 +116,26 @@
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
message: 'Only .tar.gz files allowed'
});
} else if (reason === InvalidFileType.SIZE) {
addNotification({
type: 'error',
message: 'File size exceeds 10MB'
});
} else {
addNotification({
type: 'error',
message: 'Invalid file'
});
}
}

$: filesList = files?.length
? Array.from(files).map((f) => {
return {
Expand Down Expand Up @@ -144,7 +164,12 @@
<Typography.Text color="--fgcolor-neutral-primary">
Upload a tar.gz containing your site source code
</Typography.Text>
<Upload.Dropzone extensions={['gz', 'tar']} bind:files maxSize={10000000} required>
<Upload.Dropzone
extensions={['gz', 'tar']}
bind:files
maxSize={10000000}
required
on:invalid={handleInvalid}>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';
import { addNotification } from '$lib/stores/notifications';
import { uploader } from '$lib/stores/uploader';
import type { Models } from '@appwrite.io/console';
Expand All @@ -25,11 +25,19 @@
message: 'Deployment upload started',
type: 'success'
});
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
} catch (e) {
error = e.message;
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .tar.gz files allowed';
} else if (reason === InvalidFileType.SIZE) {
error = 'File size exceeds 10MB';
} else {
error = 'Invalid file';
}
}

Expand All @@ -52,7 +60,12 @@
<Typography.Text color="--fgcolor-neutral-primary">
Upload a tar.gz file containing your site source code
</Typography.Text>
<Upload.Dropzone extensions={['gz', 'tar']} bind:files maxSize={10000000} required>
<Upload.Dropzone
extensions={['gz', 'tar']}
bind:files
maxSize={10000000}
required
on:invalid={handleInvalid}>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { removeFile } from '$lib/helpers/files';
import { InvalidFileType, removeFile } from '$lib/helpers/files';

export let data: PageData;

Expand Down Expand Up @@ -74,6 +74,21 @@
trackError(e, Submit.FileCreate);
}
}

function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
message: `Only ${data.bucket.allowedFileExtensions.join(', ')} files allowed`
});
} else {
addNotification({
type: 'error',
message: 'Invalid file'
});
}
}
</script>

<Wizard
Expand Down Expand Up @@ -103,7 +118,8 @@
<Upload.Dropzone
bind:files
required
extensions={data.bucket.allowedFileExtensions}>
extensions={data.bucket.allowedFileExtensions}
on:invalid={handleInvalid}>
<Typography.Text variant="l-500"
>Drag and drop files here or click to upload</Typography.Text>
</Upload.Dropzone>
Expand Down
Loading